github.com/twilio/twilio-go@v1.20.1/rest/messaging/v1/services_preregistered_usa2p.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Messaging 8 * This is the public Twilio REST API. 9 * 10 * NOTE: This class is auto generated by OpenAPI Generator. 11 * https://openapi-generator.tech 12 * Do not edit the class manually. 13 */ 14 15 package openapi 16 17 import ( 18 "encoding/json" 19 "net/url" 20 ) 21 22 // Optional parameters for the method 'CreateExternalCampaign' 23 type CreateExternalCampaignParams struct { 24 // ID of the preregistered campaign. 25 CampaignId *string `json:"CampaignId,omitempty"` 26 // The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with. 27 MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"` 28 } 29 30 func (params *CreateExternalCampaignParams) SetCampaignId(CampaignId string) *CreateExternalCampaignParams { 31 params.CampaignId = &CampaignId 32 return params 33 } 34 func (params *CreateExternalCampaignParams) SetMessagingServiceSid(MessagingServiceSid string) *CreateExternalCampaignParams { 35 params.MessagingServiceSid = &MessagingServiceSid 36 return params 37 } 38 39 // 40 func (c *ApiService) CreateExternalCampaign(params *CreateExternalCampaignParams) (*MessagingV1ExternalCampaign, error) { 41 path := "/v1/Services/PreregisteredUsa2p" 42 43 data := url.Values{} 44 headers := make(map[string]interface{}) 45 46 if params != nil && params.CampaignId != nil { 47 data.Set("CampaignId", *params.CampaignId) 48 } 49 if params != nil && params.MessagingServiceSid != nil { 50 data.Set("MessagingServiceSid", *params.MessagingServiceSid) 51 } 52 53 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 54 if err != nil { 55 return nil, err 56 } 57 58 defer resp.Body.Close() 59 60 ps := &MessagingV1ExternalCampaign{} 61 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 62 return nil, err 63 } 64 65 return ps, err 66 }