From 98a880d91f63ccd01e98b628c801d65eb4f9836b Mon Sep 17 00:00:00 2001 From: "ACCOUNT-01\\d650261" Date: Wed, 27 Mar 2024 20:32:01 +1100 Subject: [PATCH] Fix api --- api_authentication.go | 14 ++++------ api_authentication_test.go | 5 ++-- api_free_trial_numbers.go | 14 ++++++---- api_free_trial_numbers_test.go | 8 ++---- api_health_check.go | 7 +++-- api_health_check_test.go | 4 +-- api_messages.go | 50 +++++++++++++++++++--------------- api_messages_test.go | 35 ++++++++++++------------ api_params.go | 4 +-- api_reports.go | 23 +++++++++------- api_reports_test.go | 12 ++------ api_virtual_numbers.go | 26 +++++++++++------- api_virtual_numbers_test.go | 24 ++++------------ 13 files changed, 109 insertions(+), 117 deletions(-) diff --git a/api_authentication.go b/api_authentication.go index b139b68..07c0052 100644 --- a/api_authentication.go +++ b/api_authentication.go @@ -69,18 +69,16 @@ An OAuth 2.0 access token is required to access the API features. To create a to @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiAuthTokenRequest */ -func (a *AuthenticationAPIService) AuthToken(ctx context.Context) ApiAuthTokenRequest { +func (a *AuthenticationAPIService) AuthToken(ctx context.Context, clientId string, clientSecret string) ApiAuthTokenRequest { return ApiAuthTokenRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + clientId: &clientId, + clientSecret: &clientSecret, } } -func (r ApiAuthTokenRequest) GetAuthToken(clientId string, clientSecret string) (*OAuth, *http.Response, error) { - r.clientId = new(string) - *r.clientId = clientId - r.clientSecret = new(string) - *r.clientSecret = clientSecret +func (r ApiAuthTokenRequest) AuthToken() (*OAuth, *http.Response, error) { return r.Execute() } diff --git a/api_authentication_test.go b/api_authentication_test.go index e0d1973..9b9f816 100644 --- a/api_authentication_test.go +++ b/api_authentication_test.go @@ -25,9 +25,8 @@ func Test_TelstraMessaging_AuthenticationAPIService(t *testing.T) { clientId := "YOUR CLIENT ID" clientSecret := "YOUR CLIENT SECRET" - authApi := apiClient.AuthenticationAPI.AuthToken(context.Background()) - - oauthResult, resp, err := authApi.GetAuthToken(clientId, clientSecret) + authApi := apiClient.AuthenticationAPI.AuthToken(context.Background(), clientId, clientSecret) + oauthResult, resp, err := authApi.AuthToken() if err != nil { fmt.Println("Error:", err) diff --git a/api_free_trial_numbers.go b/api_free_trial_numbers.go index be0033d..d42102c 100644 --- a/api_free_trial_numbers.go +++ b/api_free_trial_numbers.go @@ -98,10 +98,11 @@ Note that you can only message mobile numbers that have been added to your Free @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiCreateTrialNumbersRequest */ -func (a *FreeTrialNumbersAPIService) CreateTrialNumbers(ctx context.Context) ApiCreateTrialNumbersRequest { +func (a *FreeTrialNumbersAPIService) CreateTrialNumbers(ctx context.Context, authorization string) ApiCreateTrialNumbersRequest { return ApiCreateTrialNumbersRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -382,10 +383,11 @@ If you're using a paid plan, there's no limit to the number of recipients that y @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiGetTrialNumbersRequest */ -func (a *FreeTrialNumbersAPIService) GetTrialNumbers(ctx context.Context) ApiGetTrialNumbersRequest { +func (a *FreeTrialNumbersAPIService) GetTrialNumbers(ctx context.Context, authorization string) ApiGetTrialNumbersRequest { return ApiGetTrialNumbersRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } diff --git a/api_free_trial_numbers_test.go b/api_free_trial_numbers_test.go index d095421..47ea7ac 100644 --- a/api_free_trial_numbers_test.go +++ b/api_free_trial_numbers_test.go @@ -32,9 +32,7 @@ func Test_TelstraMessaging_FreeTrialNumbersAPIService(t *testing.T) { createTrialNumbersRequestFreeTrialNumbers := ArrayOfStringAsCreateTrialNumbersRequestFreeTrialNumbers(&trialNumbers) createTrialNumbersRequest := NewCreateTrialNumbersRequest(createTrialNumbersRequestFreeTrialNumbers) - trialNumbersApi := apiClient.FreeTrialNumbersAPI.CreateTrialNumbers(context.Background()) - trialNumbersApi.authorization = &authorization - + trialNumbersApi := apiClient.FreeTrialNumbersAPI.CreateTrialNumbers(context.Background(), authorization) resp, httpRes, err := trialNumbersApi.CreateTrialNumbers(*createTrialNumbersRequest) if err != nil { @@ -54,9 +52,7 @@ func Test_TelstraMessaging_FreeTrialNumbersAPIService(t *testing.T) { t.Run("Test FreeTrialNumbersAPIService GetTrialNumbers", func(t *testing.T) { //t.Skip("skip test") - trialNumbersApi := apiClient.FreeTrialNumbersAPI.GetTrialNumbers(context.Background()) - trialNumbersApi.authorization = &authorization - + trialNumbersApi := apiClient.FreeTrialNumbersAPI.GetTrialNumbers(context.Background(), authorization) resp, httpRes, err := trialNumbersApi.GetTrialNumbers() if err != nil { diff --git a/api_health_check.go b/api_health_check.go index daf2b46..d913dd9 100644 --- a/api_health_check.go +++ b/api_health_check.go @@ -50,10 +50,11 @@ Use this endpoint to check the operational status of the messaging service. A 20 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiHealthCheckRequest */ -func (a *HealthCheckAPIService) HealthCheck(ctx context.Context) ApiHealthCheckRequest { +func (a *HealthCheckAPIService) HealthCheck(ctx context.Context, authorization string) ApiHealthCheckRequest { return ApiHealthCheckRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } diff --git a/api_health_check_test.go b/api_health_check_test.go index af41e5a..9835bf8 100644 --- a/api_health_check_test.go +++ b/api_health_check_test.go @@ -29,9 +29,7 @@ func Test_TelstraMessaging_HealthCheckAPIService(t *testing.T) { //t.Skip("skip test") // remove to run test - healthCheckApi := apiClient.HealthCheckAPI.HealthCheck(context.Background()) - healthCheckApi.authorization = &authorization - + healthCheckApi := apiClient.HealthCheckAPI.HealthCheck(context.Background(), authorization) resp, httpRes, err := healthCheckApi.HealthCheck() if err != nil { diff --git a/api_messages.go b/api_messages.go index 54e957e..0192fec 100644 --- a/api_messages.go +++ b/api_messages.go @@ -87,11 +87,12 @@ Use this endpoint to delete a message that's been scheduled for sending, but has @param messageId When you sent the original message, this is the UUID that was returned in the call response. Use this ID to fetch, update or delete a message with the appropriate endpoints. @return ApiDeleteMessageByIdRequest */ -func (a *MessagesAPIService) DeleteMessageById(ctx context.Context, messageId string) ApiDeleteMessageByIdRequest { +func (a *MessagesAPIService) DeleteMessageById(ctx context.Context, messageId string, authorization string) ApiDeleteMessageByIdRequest { return ApiDeleteMessageByIdRequest{ - ApiService: a, - ctx: ctx, - messageId: messageId, + ApiService: a, + ctx: ctx, + messageId: messageId, + authorization: &authorization, } } @@ -356,11 +357,12 @@ Use the **messageId** to fetch a message that's been sent from/to your account w @param messageId When you sent the original message, this is the UUID that was returned in the response. Use this ID to fetch, update or delete a message with the appropriate endpoints. Incoming messages are also assigned a messageId. Use this ID with GET/ messages/{messageId} to fetch the message later. @return ApiGetMessageByIdRequest */ -func (a *MessagesAPIService) GetMessageById(ctx context.Context, messageId string) ApiGetMessageByIdRequest { +func (a *MessagesAPIService) GetMessageById(ctx context.Context, messageId string, authorization string) ApiGetMessageByIdRequest { return ApiGetMessageByIdRequest{ - ApiService: a, - ctx: ctx, - messageId: messageId, + ApiService: a, + ctx: ctx, + messageId: messageId, + authorization: &authorization, } } @@ -724,10 +726,11 @@ Fetch messages that have been sent from/to your account in the last 30 days. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiGetMessagesRequest */ -func (a *MessagesAPIService) GetMessages(ctx context.Context) ApiGetMessagesRequest { +func (a *MessagesAPIService) GetMessages(ctx context.Context, authorization string) ApiGetMessagesRequest { return ApiGetMessagesRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -1024,10 +1027,11 @@ Free Trial users can message to up to 10 unique recipient numbers for free. The @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiSendMessagesRequest */ -func (a *MessagesAPIService) SendMessages(ctx context.Context) ApiSendMessagesRequest { +func (a *MessagesAPIService) SendMessages(ctx context.Context, authorization string) ApiSendMessagesRequest { return ApiSendMessagesRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -1319,11 +1323,12 @@ Need to update a message that's scheduled for sending? You can change any of the @param messageId When you sent the original message, this is the UUID that was returned in the call response. Use this ID to fetch, update or delete a message with the appropriate endpoints. @return ApiUpdateMessageByIdRequest */ -func (a *MessagesAPIService) UpdateMessageById(ctx context.Context, messageId string) ApiUpdateMessageByIdRequest { +func (a *MessagesAPIService) UpdateMessageById(ctx context.Context, messageId string, authorization string) ApiUpdateMessageByIdRequest { return ApiUpdateMessageByIdRequest{ - ApiService: a, - ctx: ctx, - messageId: messageId, + ApiService: a, + ctx: ctx, + messageId: messageId, + authorization: &authorization, } } @@ -1622,11 +1627,12 @@ Use the **messageId** to update the tag(s) assigned to a message. You can use th @param messageId When you sent the original message, this is the UUID that was returned in the call response. Use this ID to fetch, update or delete a message with the appropriate endpoints. @return ApiUpdateMessageTagsRequest */ -func (a *MessagesAPIService) UpdateMessageTags(ctx context.Context, messageId string) ApiUpdateMessageTagsRequest { +func (a *MessagesAPIService) UpdateMessageTags(ctx context.Context, messageId string, authorization string) ApiUpdateMessageTagsRequest { return ApiUpdateMessageTagsRequest{ - ApiService: a, - ctx: ctx, - messageId: messageId, + ApiService: a, + ctx: ctx, + messageId: messageId, + authorization: &authorization, } } diff --git a/api_messages_test.go b/api_messages_test.go index 12e88a4..0996bb6 100644 --- a/api_messages_test.go +++ b/api_messages_test.go @@ -31,9 +31,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { t.Run("Test MessagesAPIService DeleteMessageById", func(t *testing.T) { //t.Skip("skip test") // remove to run test - messagesApi := apiClient.MessagesAPI.DeleteMessageById(context.Background(), messageId) - messagesApi.authorization = &authorization - + messagesApi := apiClient.MessagesAPI.DeleteMessageById(context.Background(), messageId, authorization) httpRes, err := messagesApi.DeleteMessageById() if err != nil { @@ -52,9 +50,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { //t.Skip("skip test") // remove to run test - messagesApi := apiClient.MessagesAPI.GetMessageById(context.Background(), messageId) - messagesApi.authorization = &authorization - + messagesApi := apiClient.MessagesAPI.GetMessageById(context.Background(), messageId, authorization) resp, httpRes, err := messagesApi.GetMessageById() if err != nil { @@ -73,8 +69,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { t.Run("Test MessagesAPIService GetMessages", func(t *testing.T) { - messagesApi := apiClient.MessagesAPI.GetMessages(context.Background()) - messagesApi.authorization = &authorization + messagesApi := apiClient.MessagesAPI.GetMessages(context.Background(), authorization) reverse := true messagesApi.reverse = &reverse startTime := time.Now().AddDate(0, 0, -5).UTC() @@ -116,6 +111,18 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { sendMessagesRequest.SetRetryTimeout(10) sendMessagesRequest.SetStatusCallbackUrl("http://www.example.com") + multimedia1 := Multimedia{ + Type: "image/jpeg", + FileName: "image/jpeg", + Payload: "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + } + multimedia2 := Multimedia{ + Type: "image/jpeg", + FileName: "image/jpeg", + Payload: "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + } + sendMessagesRequest.SetMultimedia([]Multimedia{multimedia1, multimedia2}) + tags := []string{ "ip", "deserunt exercitation", @@ -133,9 +140,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { sendMessagesRequest.SetTags(tags) - messagesApi := apiClient.MessagesAPI.SendMessages(context.Background()) - messagesApi.authorization = &authorization - + messagesApi := apiClient.MessagesAPI.SendMessages(context.Background(), authorization) resp, httpRes, err := messagesApi.SendMessages(*sendMessagesRequest) if err != nil { @@ -178,9 +183,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { } updateMessageByIdRequest.SetTags(tags) - messagesApi := apiClient.MessagesAPI.UpdateMessageById(context.Background(), messageId) - messagesApi.authorization = &authorization - + messagesApi := apiClient.MessagesAPI.UpdateMessageById(context.Background(), messageId, authorization) resp, httpRes, err := messagesApi.UpdateMessageById(*updateMessageByIdRequest) if err != nil { @@ -202,9 +205,7 @@ func Test_TelstraMessaging_MessagesAPIService(t *testing.T) { tags := []string{"marketing", "SMS"} updateMessageTagsRequest := NewUpdateMessageTagsRequest(tags) - messagesApi := apiClient.MessagesAPI.UpdateMessageTags(context.Background(), messageId) - messagesApi.authorization = &authorization - + messagesApi := apiClient.MessagesAPI.UpdateMessageTags(context.Background(), messageId, authorization) httpRes, err := messagesApi.UpdateMessageTags(*updateMessageTagsRequest) if err != nil { diff --git a/api_params.go b/api_params.go index 6b70d69..bcbdbd0 100644 --- a/api_params.go +++ b/api_params.go @@ -30,8 +30,8 @@ func SetRequestParams() *RequestParams { } func GetAuthorization(apiClient *APIClient, clientId string, clientSecret string) (string, error) { - authApi := apiClient.AuthenticationAPI.AuthToken(context.Background()) - oauthResult, _, err := authApi.GetAuthToken(clientId, clientSecret) + authApi := apiClient.AuthenticationAPI.AuthToken(context.Background(), clientId, clientSecret) + oauthResult, _, err := authApi.AuthToken() if err != nil { return "", err } diff --git a/api_reports.go b/api_reports.go index ebc1d27..5e4b241 100644 --- a/api_reports.go +++ b/api_reports.go @@ -86,11 +86,12 @@ Fetch a download link for a report generated with POST /reports/{reportId} using @param reportId Use the reportId returned in the POST /reports/{reportType} response. @return ApiGetReportRequest */ -func (a *ReportsAPIService) GetReport(ctx context.Context, reportId string) ApiGetReportRequest { +func (a *ReportsAPIService) GetReport(ctx context.Context, reportId string, authorization string) ApiGetReportRequest { return ApiGetReportRequest{ - ApiService: a, - ctx: ctx, - reportId: reportId, + ApiService: a, + ctx: ctx, + reportId: reportId, + authorization: &authorization, } } @@ -363,10 +364,11 @@ Fetch details of all reports recently generated for your account. Use it to chec @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiGetReportsRequest */ -func (a *ReportsAPIService) GetReports(ctx context.Context) ApiGetReportsRequest { +func (a *ReportsAPIService) GetReports(ctx context.Context, authorization string) ApiGetReportsRequest { return ApiGetReportsRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -631,10 +633,11 @@ Once your report is generated, it will be available for download for one week. T @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiMessagesReportRequest */ -func (a *ReportsAPIService) MessagesReport(ctx context.Context) ApiMessagesReportRequest { +func (a *ReportsAPIService) MessagesReport(ctx context.Context, authorization string) ApiMessagesReportRequest { return ApiMessagesReportRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } diff --git a/api_reports_test.go b/api_reports_test.go index ebfd739..43dbc48 100644 --- a/api_reports_test.go +++ b/api_reports_test.go @@ -33,9 +33,7 @@ func Test_TelstraMessaging_ReportsAPIService(t *testing.T) { //t.Skip("skip test") // remove to run test reportId := "c22d2050-eb37-11ee-ad5e-3d9263246ccb" - reportsApi := apiClient.ReportsAPI.GetReport(context.Background(), reportId) - reportsApi.authorization = &authorization - + reportsApi := apiClient.ReportsAPI.GetReport(context.Background(), reportId, authorization) resp, httpRes, err := reportsApi.GetReport() if err != nil { @@ -55,9 +53,7 @@ func Test_TelstraMessaging_ReportsAPIService(t *testing.T) { t.Run("Test ReportsAPIService GetReports", func(t *testing.T) { //t.Skip("skip test") // remove to run test - reportsApi := apiClient.ReportsAPI.GetReports(context.Background()) - reportsApi.authorization = &authorization - + reportsApi := apiClient.ReportsAPI.GetReports(context.Background(), authorization) resp, httpRes, err := reportsApi.GetReports() if err != nil { @@ -85,9 +81,7 @@ func Test_TelstraMessaging_ReportsAPIService(t *testing.T) { oneDayAgoFormatted := oneDayAgo.Format("2006-01-02") messageReportRequest := NewMessagesReportRequest(threeDaysAgoFormatted, oneDayAgoFormatted) - reportsApi := apiClient.ReportsAPI.MessagesReport(context.Background()) - reportsApi.authorization = &authorization - + reportsApi := apiClient.ReportsAPI.MessagesReport(context.Background(), authorization) resp, httpRes, err := reportsApi.MessagesReport(*messageReportRequest) if err != nil { diff --git a/api_virtual_numbers.go b/api_virtual_numbers.go index 2ff66ec..2a56d29 100644 --- a/api_virtual_numbers.go +++ b/api_virtual_numbers.go @@ -93,10 +93,11 @@ Note that Virtual Numbers used in v2 of the Messaging API cannot be used to send @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiAssignNumberRequest */ -func (a *VirtualNumbersAPIService) AssignNumber(ctx context.Context) ApiAssignNumberRequest { +func (a *VirtualNumbersAPIService) AssignNumber(ctx context.Context, authorization string) ApiAssignNumberRequest { return ApiAssignNumberRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -381,11 +382,12 @@ Use **virtual-number** to remove a Virtual Number that's been assigned to your a @param virtualNumber Write the Virtual Number here, using national format (e.g. 0412345678). @return ApiDeleteNumberRequest */ -func (a *VirtualNumbersAPIService) DeleteNumber(ctx context.Context, virtualNumber string) ApiDeleteNumberRequest { +func (a *VirtualNumbersAPIService) DeleteNumber(ctx context.Context, virtualNumber string, authorization string) ApiDeleteNumberRequest { return ApiDeleteNumberRequest{ ApiService: a, ctx: ctx, virtualNumber: virtualNumber, + authorization: &authorization, } } @@ -667,10 +669,11 @@ Use this endpoint to fetch all Virtual Numbers currently assigned to your accoun @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiGetNumbersRequest */ -func (a *VirtualNumbersAPIService) GetNumbers(ctx context.Context) ApiGetNumbersRequest { +func (a *VirtualNumbersAPIService) GetNumbers(ctx context.Context, authorization string) ApiGetNumbersRequest { return ApiGetNumbersRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, + authorization: &authorization, } } @@ -963,11 +966,12 @@ Recipients can opt out at any time by sending a message with industry standard k @param virtualNumber Write the Virtual Number here, using national format (e.g. 0412345678). @return ApiGetRecipientOptoutsRequest */ -func (a *VirtualNumbersAPIService) GetRecipientOptouts(ctx context.Context, virtualNumber string) ApiGetRecipientOptoutsRequest { +func (a *VirtualNumbersAPIService) GetRecipientOptouts(ctx context.Context, virtualNumber string, authorization string) ApiGetRecipientOptoutsRequest { return ApiGetRecipientOptoutsRequest{ ApiService: a, ctx: ctx, virtualNumber: virtualNumber, + authorization: &authorization, } } @@ -1248,11 +1252,12 @@ Fetch the tags, replyCallbackUrl and lastUse date for a Virtual Number. @param virtualNumber Write the Virtual Number here, using national format (e.g. 0412345678). @return ApiGetVirtualNumberRequest */ -func (a *VirtualNumbersAPIService) GetVirtualNumber(ctx context.Context, virtualNumber string) ApiGetVirtualNumberRequest { +func (a *VirtualNumbersAPIService) GetVirtualNumber(ctx context.Context, virtualNumber string, authorization string) ApiGetVirtualNumberRequest { return ApiGetVirtualNumberRequest{ ApiService: a, ctx: ctx, virtualNumber: virtualNumber, + authorization: &authorization, } } @@ -1535,11 +1540,12 @@ This request body will override the original POST/ virtual-numbers call. @param virtualNumber Write the Virtual Number here, using national format (e.g. 0412345678). @return ApiUpdateNumberRequest */ -func (a *VirtualNumbersAPIService) UpdateNumber(ctx context.Context, virtualNumber string) ApiUpdateNumberRequest { +func (a *VirtualNumbersAPIService) UpdateNumber(ctx context.Context, virtualNumber string, authorization string) ApiUpdateNumberRequest { return ApiUpdateNumberRequest{ ApiService: a, ctx: ctx, virtualNumber: virtualNumber, + authorization: &authorization, } } diff --git a/api_virtual_numbers_test.go b/api_virtual_numbers_test.go index e1e5e2f..3501d36 100644 --- a/api_virtual_numbers_test.go +++ b/api_virtual_numbers_test.go @@ -48,9 +48,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { assignNumberRequest.SetReplyCallbackUrl("http://www.example.com") assignNumberRequest.SetTags(tags) - vnApi := apiClient.VirtualNumbersAPI.AssignNumber(context.Background()) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.AssignNumber(context.Background(), authorization) resp, httpRes, err := vnApi.AssignNumber(*assignNumberRequest) if err != nil { @@ -69,9 +67,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { t.Run("Test VirtualNumbersAPIService DeleteNumber", func(t *testing.T) { - vnApi := apiClient.VirtualNumbersAPI.DeleteNumber(context.Background(), virtualNumber) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.DeleteNumber(context.Background(), virtualNumber, authorization) httpRes, err := vnApi.DeleteNumber() if err != nil { @@ -90,9 +86,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { //t.Skip("skip test") // remove to run test - vnApi := apiClient.VirtualNumbersAPI.GetNumbers(context.Background()) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.GetNumbers(context.Background(), authorization) resp, httpRes, err := vnApi.GetNumbers() if err != nil { @@ -112,9 +106,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { t.Run("Test VirtualNumbersAPIService GetRecipientOptouts", func(t *testing.T) { //t.Skip("skip test") // remove to run test - vnApi := apiClient.VirtualNumbersAPI.GetRecipientOptouts(context.Background(), virtualNumber) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.GetRecipientOptouts(context.Background(), virtualNumber, authorization) resp, httpRes, err := vnApi.GetRecipientOptouts() if err != nil { @@ -135,9 +127,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { //t.Skip("skip test") // remove to run test - vnApi := apiClient.VirtualNumbersAPI.GetVirtualNumber(context.Background(), virtualNumber) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.GetVirtualNumber(context.Background(), virtualNumber, authorization) resp, httpRes, err := vnApi.GetVirtualNumber() if err != nil { @@ -174,9 +164,7 @@ func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) { } updateNumberRequest.SetTags(tags) - vnApi := apiClient.VirtualNumbersAPI.UpdateNumber(context.Background(), virtualNumber) - vnApi.authorization = &authorization - + vnApi := apiClient.VirtualNumbersAPI.UpdateNumber(context.Background(), virtualNumber, authorization) resp, httpRes, err := vnApi.UpdateNumber(*updateNumberRequest) if err != nil {