diff --git a/sendpulse/automation360_service.go b/sendpulse/automation360_service.go index a244c99..bca9ece 100644 --- a/sendpulse/automation360_service.go +++ b/sendpulse/automation360_service.go @@ -29,7 +29,7 @@ type Autoresponder struct { MainID int `json:"main_id"` AfType string `json:"af_type"` Created DateTimeType `json:"created"` - LastSend DateTimeType `json:"created"` + LastSend DateTimeType `json:"last_send"` Task map[string]interface{} `json:"task"` } `json:"flows"` Starts int `json:"starts"` @@ -44,7 +44,7 @@ func (service *Automation360Service) GetAutoresponderStatistics(id int) (*Autore path := fmt.Sprintf("/a360/autoresponders/%d", id) var respData *Autoresponder - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -55,7 +55,7 @@ func (service *Automation360Service) StartEvent(eventName string, variables map[ var respData struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), variables, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, variables, &respData, true) return err } @@ -73,7 +73,7 @@ func (service *Automation360Service) GetStartBlockStatistics(id int) (*MainTrigg var respData struct { Data *MainTriggerBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -105,7 +105,7 @@ func (service *Automation360Service) GetEmailBlockStatistics(id int) (*EmailBloc var respData struct { Data *EmailBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -126,7 +126,7 @@ func (service *Automation360Service) GetPushBlockStatistics(id int) (*PushBlockS var respData struct { Data *PushBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -149,7 +149,7 @@ func (service *Automation360Service) GetSmsBlockStatistics(id int) (*SmsBlockSta var respData struct { Data *SmsBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -168,7 +168,7 @@ func (service *Automation360Service) GetMessengerBlockStatistics(id int) (*Messe var respData struct { Data *MessengerBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -186,7 +186,7 @@ func (service *Automation360Service) GetFilterBlockStatistics(id int) (*FilterBl var respData struct { Data *FilterBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -204,7 +204,7 @@ func (service *Automation360Service) GetTriggerBlockStatistics(id int) (*Trigger var respData struct { Data *TriggerBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -227,7 +227,7 @@ func (service *Automation360Service) GetGoalBlockStatistics(id int) (*GoalBlockS var respData struct { Data *GoalBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -245,7 +245,7 @@ func (service *Automation360Service) GetActionBlockStatistics(id int) (*ActionBl var respData struct { Data *ActionBlockStat `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -279,7 +279,7 @@ func (service *Automation360Service) GetAutoresponderConversions(id int) (*Autor var respData struct { Data *AutoresponderConversion `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -301,6 +301,6 @@ func (service *Automation360Service) GetAutoresponderContacts(id int) ([]*Autore var respData struct { Items []*AutoresponderContact `json:"items"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Items, err } diff --git a/sendpulse/balance_service.go b/sendpulse/balance_service.go index 727b7fb..709440f 100644 --- a/sendpulse/balance_service.go +++ b/sendpulse/balance_service.go @@ -1,7 +1,6 @@ package sendpulse import ( - "fmt" "net/http" "strings" ) @@ -56,7 +55,7 @@ func (service *BalanceService) GetBalance(currency string) (*Balance, error) { } var respData Balance - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return &respData, err } @@ -65,6 +64,6 @@ func (service *BalanceService) GetDetailedBalance() (*BalanceDetailed, error) { path := "/user/balance/detail" var respData BalanceDetailed - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return &respData, err } diff --git a/sendpulse/emails_address_service.go b/sendpulse/emails_address_service.go index d1e8a18..d0d2ff1 100644 --- a/sendpulse/emails_address_service.go +++ b/sendpulse/emails_address_service.go @@ -33,7 +33,7 @@ type EmailInfo struct { func (service *AddressService) GetEmailInfo(email string) ([]*EmailInfo, error) { path := fmt.Sprintf("/emails/%s", email) var response []*EmailInfo - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response, err } @@ -46,7 +46,7 @@ func (service *AddressService) GetEmailsInfo(emails []string) (map[string][]*Ema params := data{Emails: emails} respData := make(map[string][]*EmailInfo) - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return respData, err } @@ -62,7 +62,7 @@ type EmailInfoList struct { func (service *AddressService) GetDetails(email string) ([]*EmailInfoList, error) { path := fmt.Sprintf("/emails/%s/details", email) var response []*EmailInfoList - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response, err } @@ -70,7 +70,7 @@ func (service *AddressService) GetDetails(email string) ([]*EmailInfoList, error func (service *AddressService) GetStatisticsByCampaign(campaignID int, email string) (*CampaignEmailStatistics, error) { path := fmt.Sprintf("/campaigns/%d/email/%s", campaignID, email) var respData *CampaignEmailStatistics - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -96,7 +96,7 @@ type CampaignEmailStatistics struct { func (service *AddressService) GetStatisticsByAddressBook(addressBookID int, email string) (*AddressBookEmailStatistics, error) { path := fmt.Sprintf("/addressbooks/%d/emails/%s", addressBookID, email) var respData AddressBookEmailStatistics - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return &respData, err } @@ -106,7 +106,7 @@ func (service *AddressService) DeleteFromAllAddressBooks(email string) error { var respData struct { Result bool } - _, err := service.client.newRequest(http.MethodDelete, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodDelete, path, nil, &respData, true) return err } @@ -128,7 +128,7 @@ type CampaignsEmailStatistics struct { func (service *AddressService) GetEmailStatisticsByCampaignsAndAddressBooks(email string) (*CampaignsEmailStatistics, error) { path := fmt.Sprintf("/emails/%s/campaigns", email) var respData *CampaignsEmailStatistics - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -154,7 +154,7 @@ func (service *AddressService) GetEmailsStatisticsByCampaignsAndAddressBooks(ema } params := data{Emails: emails} - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return respData, err } @@ -171,6 +171,6 @@ func (service *AddressService) ChangeVariables(addressBookID int, email string, var respData struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return err } diff --git a/sendpulse/emails_addressbooks_service.go b/sendpulse/emails_addressbooks_service.go index 077bd94..fe129c5 100644 --- a/sendpulse/emails_addressbooks_service.go +++ b/sendpulse/emails_addressbooks_service.go @@ -27,7 +27,7 @@ func (service *MailingListsService) CreateMailingList(name string) (int, error) ID int `json:"id"` } params := data{Name: name} - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return response.ID, err } diff --git a/sendpulse/emails_blacklist_service.go b/sendpulse/emails_blacklist_service.go index 3e60005..bcccea8 100644 --- a/sendpulse/emails_blacklist_service.go +++ b/sendpulse/emails_blacklist_service.go @@ -2,7 +2,6 @@ package sendpulse import ( b64 "encoding/base64" - "fmt" "net/http" "strings" ) @@ -39,7 +38,7 @@ func (service *BlacklistService) AddToBlacklist(emails []string, comment string) } var respData response - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return err } @@ -60,7 +59,7 @@ func (service *BlacklistService) RemoveFromBlacklist(emails []string) error { } var respData response - _, err := service.client.newRequest(http.MethodDelete, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodDelete, path, params, &respData, true) return err } @@ -69,6 +68,6 @@ func (service *BlacklistService) GetEmails() ([]string, error) { path := "/blacklist" var respData []string - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } diff --git a/sendpulse/emails_mailings_service.go b/sendpulse/emails_mailings_service.go index 58deb3e..b68a53e 100644 --- a/sendpulse/emails_mailings_service.go +++ b/sendpulse/emails_mailings_service.go @@ -71,7 +71,7 @@ func (service *CampaignsService) CreateCampaign(data CampaignParams) (*Campaign, data.BodyAMP = b64.StdEncoding.EncodeToString([]byte(data.BodyAMP)) } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), data, &innerMailing, true) + _, err := service.client.newRequest(http.MethodPost, path, data, &innerMailing, true) if err != nil { return nil, err } @@ -99,7 +99,7 @@ func (service *CampaignsService) UpdateCampaign(id int, data CampaignParams) err data.BodyAMP = b64.StdEncoding.EncodeToString([]byte(data.BodyAMP)) } - _, err := service.client.newRequest(http.MethodPatch, fmt.Sprintf(path), data, &respData, true) + _, err := service.client.newRequest(http.MethodPatch, path, data, &respData, true) return err } @@ -107,7 +107,7 @@ func (service *CampaignsService) UpdateCampaign(id int, data CampaignParams) err func (service *CampaignsService) GetCampaign(id int) (*Campaign, error) { path := fmt.Sprintf("/campaigns/%d", id) var respData Campaign - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return &respData, err } diff --git a/sendpulse/emails_senders_service.go b/sendpulse/emails_senders_service.go index 74adb5c..cd2e67f 100644 --- a/sendpulse/emails_senders_service.go +++ b/sendpulse/emails_senders_service.go @@ -30,7 +30,7 @@ func (service *SendersService) CreateSender(name string, email string) error { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return err } @@ -40,7 +40,7 @@ func (service *SendersService) GetSenderActivationCode(email string) error { var response struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return err } @@ -58,7 +58,7 @@ func (service *SendersService) ActivateSender(email, code string) error { var response struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return err } @@ -72,7 +72,7 @@ func (service *SendersService) GetSenders() ([]*Sender, error) { path := "/senders" var respData []*Sender - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -90,6 +90,6 @@ func (service *SendersService) DeleteSender(email string) error { var response struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodDelete, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodDelete, path, params, &response, true) return err } diff --git a/sendpulse/emails_templates_service.go b/sendpulse/emails_templates_service.go index c321c4a..87bdfef 100644 --- a/sendpulse/emails_templates_service.go +++ b/sendpulse/emails_templates_service.go @@ -38,7 +38,7 @@ func (service *TemplatesService) CreateTemplate(name string, body string, lang s Result bool `json:"result"` RealID int `json:"real_id"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return response.RealID, err } @@ -58,7 +58,7 @@ func (service *TemplatesService) UpdateTemplate(templateID int, body string, lan var response struct { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return err } @@ -105,7 +105,7 @@ func (t *Template) UnmarshalJSON(data []byte) error { func (service *TemplatesService) GetTemplate(templateID int) (*Template, error) { path := fmt.Sprintf("/template/%d", templateID) var respData Template - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return &respData, err } @@ -116,6 +116,6 @@ func (service *TemplatesService) GetTemplates(limit, offset int, owner string) ( } var respData []*Template - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } diff --git a/sendpulse/emails_validator_service.go b/sendpulse/emails_validator_service.go index 9bc1d99..0fc8d85 100644 --- a/sendpulse/emails_validator_service.go +++ b/sendpulse/emails_validator_service.go @@ -27,7 +27,7 @@ func (service *ValidatorService) ValidateMailingList(mailingListID int) error { ID int `json:"id"` } body := bodyFormat{ID: mailingListID} - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), body, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, body, &response, true) return err } @@ -44,7 +44,7 @@ func (service *ValidatorService) GetMailingListValidationProgress(mailingListID Result bool `json:"result"` Data *ValidationProgress `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response.Data, err } @@ -83,7 +83,7 @@ type MailingListValidationResultDetailed struct { func (service *ValidatorService) GetMailingListValidationResult(mailingListID int) (*MailingListValidationResultDetailed, error) { path := fmt.Sprintf("/verifier-service/check/?id=%d", mailingListID) var response *MailingListValidationResultDetailed - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response, err } @@ -94,7 +94,7 @@ func (service *ValidatorService) GetValidatedMailingLists(limit, offset int) ([] Total int `json:"total"` List []*MailingListValidationResult `json:"list"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response.List, err } @@ -108,7 +108,7 @@ func (service *ValidatorService) ValidateEmail(email string) error { Email string `json:"email"` } body := bodyFormat{Email: email} - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), body, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, body, &response, true) return err } @@ -132,7 +132,7 @@ func (service *ValidatorService) GetEmailValidationResult(email string) (*EmailV Result bool `json:"result"` Data *EmailValidationResult `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response.Data, err } @@ -146,7 +146,7 @@ func (service *ValidatorService) DeleteEmailValidationResult(email string) error Email string `json:"email"` } body := bodyFormat{Email: email} - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), body, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, body, &response, true) return err } @@ -186,7 +186,7 @@ func (service *ValidatorService) CreateMailingListValidationReport(params Mailin body.Statuses = "[" + strings.Join(strStatuses, ",") + "]" } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &response, true) return err } @@ -194,6 +194,6 @@ func (service *ValidatorService) CreateMailingListValidationReport(params Mailin func (service *ValidatorService) GetMailingListValidationReport(mailingListID int) (*MailingListValidationResultDetailed, error) { path := fmt.Sprintf("/verifier-service/check-report?id=%d", mailingListID) var response *MailingListValidationResultDetailed - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &response, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &response, true) return response, err } diff --git a/sendpulse/emails_webhooks_service.go b/sendpulse/emails_webhooks_service.go index 2c83124..fd3365e 100644 --- a/sendpulse/emails_webhooks_service.go +++ b/sendpulse/emails_webhooks_service.go @@ -32,7 +32,7 @@ func (service *WebhooksService) GetWebhooks() ([]*Webhook, error) { Data []*Webhook `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } @@ -45,7 +45,7 @@ func (service *WebhooksService) GetWebhook(id int) (*Webhook, error) { Data *Webhook `json:"data"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Data, err } diff --git a/sendpulse/push_service.go b/sendpulse/push_service.go index 42c77f0..71fcb10 100644 --- a/sendpulse/push_service.go +++ b/sendpulse/push_service.go @@ -70,7 +70,7 @@ func (service *PushService) CountWebsites() (int, error) { var respData struct { Total int `json:"total"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Total, err } @@ -85,7 +85,7 @@ type PushWebsite struct { func (service *PushService) GetWebsites(limit, offset int) ([]*PushWebsite, error) { path := fmt.Sprintf("/push/websites/?limit=%d&offset=%d", limit, offset) var respData []*PushWebsite - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -100,7 +100,7 @@ type PushWebsiteVariable struct { func (service *PushService) GetWebsiteVariables(websiteID int) ([]*PushWebsiteVariable, error) { path := fmt.Sprintf("/push/websites/%d/variables", websiteID) var respData []*PushWebsiteVariable - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -146,7 +146,7 @@ func (service *PushService) GetWebsiteSubscriptions(websiteID int, params Websit } var respData []*WebsiteSubscription - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -156,7 +156,7 @@ func (service *PushService) CountWebsiteSubscriptions(websiteID int) (int, error var respData struct { Total int `json:"total"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Total, err } @@ -177,7 +177,7 @@ type WebsiteInfo struct { func (service *PushService) GetWebsiteInfo(websiteID int) (*WebsiteInfo, error) { path := fmt.Sprintf("/push/websites/info/%d", websiteID) var respData *WebsiteInfo - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -194,7 +194,7 @@ func (service *PushService) ActivateSubscription(subscriptionID int) error { var respData struct { Result bool `json:"true"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), data, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, data, &respData, true) return err } @@ -211,7 +211,7 @@ func (service *PushService) DeactivateSubscription(subscriptionID int) error { var respData struct { Result bool `json:"true"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), data, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, data, &respData, true) return err } @@ -260,7 +260,7 @@ func (service *PushService) CreatePushCampaign(params PushMessageParams) (int, e ID int `json:"id"` Result bool `json:"true"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return respData.ID, err } @@ -285,6 +285,6 @@ func (service *PushService) GetPushMessagesStatistics(taskID int) (*PushMessages path := fmt.Sprintf("/push/tasks/%d", taskID) var respData *PushMessagesStatistics - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } diff --git a/sendpulse/smtp_service.go b/sendpulse/smtp_service.go index c6e39f9..bf191b7 100644 --- a/sendpulse/smtp_service.go +++ b/sendpulse/smtp_service.go @@ -54,7 +54,7 @@ func (service *SmtpService) SendMessage(params SendEmailParams) (string, error) Result bool `json:"result"` ID string `json:"id"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), data, &response, true) + _, err := service.client.newRequest(http.MethodPost, path, data, &response, true) return response.ID, err } @@ -70,7 +70,7 @@ type SmtpMessage struct { UsedIP string `json:"used_ip"` Recipient string `json:"recipient"` Subject string `json:"subject"` - SendDate DateTimeType `json:"subject"` + SendDate DateTimeType `json:"send_date"` Tracking struct { Click int `json:"click"` Open int `json:"open"` @@ -125,7 +125,7 @@ func (service *SmtpService) GetMessages(params SmtpListParams) ([]*SmtpMessage, } var respData []*SmtpMessage - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -134,14 +134,14 @@ func (service *SmtpService) CountMessages() (int, error) { var respData struct { Total int `json:"total"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Total, err } func (service *SmtpService) GetMessage(id int) (*SmtpMessage, error) { path := fmt.Sprintf("/smtp/emails/%d", id) var respData *SmtpMessage - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -167,7 +167,7 @@ func (service *SmtpService) GetDailyBounces(limit, offset int, date time.Time) ( } var respData *BouncesList - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -177,7 +177,7 @@ func (service *SmtpService) CountBounces() (int, error) { var respData struct { Total int `json:"total"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData.Total, err } @@ -198,7 +198,7 @@ func (service *SmtpService) UnsubscribeEmails(emails []*SmtpUnsubscribeEmail) er var respData struct { Result bool `json:"true"` } - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), data, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, data, &respData, true) return err } @@ -214,7 +214,7 @@ func (service *SmtpService) DeleteUnsubscribedEmails(emails []string) error { var respData struct { Result bool `json:"true"` } - _, err := service.client.newRequest(http.MethodDelete, fmt.Sprintf(path), data, &respData, true) + _, err := service.client.newRequest(http.MethodDelete, path, data, &respData, true) return err } @@ -244,7 +244,7 @@ func (service *SmtpService) GetUnsubscribedEmails(params UnsubscribedListParams) var respData []Unsubscribed - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -252,7 +252,7 @@ func (service *SmtpService) GetSendersIPs() ([]string, error) { path := "/smtp/ips" var respData []string - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -260,7 +260,7 @@ func (service *SmtpService) GetSendersEmails() ([]string, error) { path := "/smtp/senders" var respData []string - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -268,7 +268,7 @@ func (service *SmtpService) GetAllowedDomains() ([]string, error) { path := "/smtp/domains" var respData []string - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return respData, err } @@ -284,7 +284,7 @@ func (service *SmtpService) AddDomain(email string) error { } params := data{Email: email} - _, err := service.client.newRequest(http.MethodPost, fmt.Sprintf(path), params, &respData, true) + _, err := service.client.newRequest(http.MethodPost, path, params, &respData, true) return err } @@ -295,6 +295,6 @@ func (service *SmtpService) VerifyDomain(email string) error { Result bool `json:"result"` } - _, err := service.client.newRequest(http.MethodGet, fmt.Sprintf(path), nil, &respData, true) + _, err := service.client.newRequest(http.MethodGet, path, nil, &respData, true) return err } diff --git a/sendpulse/vk_ok_service_test.go b/sendpulse/vk_ok_service_test.go index 8726553..0a5615e 100644 --- a/sendpulse/vk_ok_service_test.go +++ b/sendpulse/vk_ok_service_test.go @@ -25,13 +25,19 @@ func (suite *SendpulseTestSuite) TestVkOkService_CreateSender() { b64 := "/9j/4AAQSkZJRgABAQEBLAEsAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/4gKwSUNDX1BST0ZJTEUAAQEAAAKgbGNtcwQwAABtbnRyUkdCIFhZWiAH5QAHAAMADQA1ACxhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1kZXNjAAABIAAAAEBjcHJ0AAABYAAAADZ3dHB0AAABmAAAABRjaGFkAAABrAAAACxyWFlaAAAB2AAAABRiWFlaAAAB7AAAABRnWFlaAAACAAAAABRyVFJDAAACFAAAACBnVFJDAAACFAAAACBiVFJDAAACFAAAACBjaHJtAAACNAAAACRkbW5kAAACWAAAACRkbWRkAAACfAAAACRtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACQAAAAcAEcASQBNAFAAIABiAHUAaQBsAHQALQBpAG4AIABzAFIARwBCbWx1YwAAAAAAAAABAAAADGVuVVMAAAAaAAAAHABQAHUAYgBsAGkAYwAgAEQAbwBtAGEAaQBuAABYWVogAAAAAAAA9tYAAQAAAADTLXNmMzIAAAAAAAEMQgAABd7///MlAAAHkwAA/ZD///uh///9ogAAA9wAAMBuWFlaIAAAAAAAAG+gAAA49QAAA5BYWVogAAAAAAAAJJ8AAA+EAAC2xFhZWiAAAAAAAABilwAAt4cAABjZcGFyYQAAAAAAAwAAAAJmZgAA8qcAAA1ZAAAT0AAACltjaHJtAAAAAAADAAAAAKPXAABUfAAATM0AAJmaAAAmZwAAD1xtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAEcASQBNAFBtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEL/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wgARCAAFAAUDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAX8P/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwF//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPwF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oADAMBAAIAAwAAABAf/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxB//9k=" dec, err := base64.StdEncoding.DecodeString(b64) + if err != nil { + panic(err) + } f, err := os.Create("/tmp/img.jpg") if err != nil { panic(err) } defer f.Close() - f.Write(dec) + _, err = f.Write(dec) + if err != nil { + panic(err) + } id, err := suite.client.VkOk.CreateSender(CreateVkOkSenderParams{ Name: "Test",