github.com/twilio/twilio-go@v1.20.1/rest/api/v2010/accounts_messages.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Api
     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  	"fmt"
    20  	"net/url"
    21  	"strings"
    22  	"time"
    23  
    24  	"github.com/twilio/twilio-go/client"
    25  )
    26  
    27  // Optional parameters for the method 'CreateMessage'
    28  type CreateMessageParams struct {
    29  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) creating the Message resource.
    30  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
    31  	// The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
    32  	To *string `json:"To,omitempty"`
    33  	// The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource).
    34  	StatusCallback *string `json:"StatusCallback,omitempty"`
    35  	// The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored.
    36  	ApplicationSid *string `json:"ApplicationSid,omitempty"`
    37  	// [DEPRECATED] This parameter will no longer have any effect as of 2024-06-03.
    38  	MaxPrice *float32 `json:"MaxPrice,omitempty"`
    39  	// Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`.
    40  	ProvideFeedback *bool `json:"ProvideFeedback,omitempty"`
    41  	// Total number of attempts made (including this request) to send the message regardless of the provider used
    42  	Attempt *int `json:"Attempt,omitempty"`
    43  	// The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `14400`. Default value is `14400`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html)
    44  	ValidityPeriod *int `json:"ValidityPeriod,omitempty"`
    45  	// Reserved
    46  	ForceDelivery *bool `json:"ForceDelivery,omitempty"`
    47  	//
    48  	ContentRetention *string `json:"ContentRetention,omitempty"`
    49  	//
    50  	AddressRetention *string `json:"AddressRetention,omitempty"`
    51  	// Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`.
    52  	SmartEncoded *bool `json:"SmartEncoded,omitempty"`
    53  	// Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp).
    54  	PersistentAction *[]string `json:"PersistentAction,omitempty"`
    55  	// For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided.
    56  	ShortenUrls *bool `json:"ShortenUrls,omitempty"`
    57  	//
    58  	ScheduleType *string `json:"ScheduleType,omitempty"`
    59  	// The time that Twilio will send the message. Must be in ISO 8601 format.
    60  	SendAt *time.Time `json:"SendAt,omitempty"`
    61  	// If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media.
    62  	SendAsMms *bool `json:"SendAsMms,omitempty"`
    63  	// For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used.
    64  	ContentVariables *string `json:"ContentVariables,omitempty"`
    65  	//
    66  	RiskCheck *string `json:"RiskCheck,omitempty"`
    67  	// The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool.
    68  	From *string `json:"From,omitempty"`
    69  	// The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool.
    70  	MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"`
    71  	// The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages).
    72  	Body *string `json:"Body,omitempty"`
    73  	// The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply.
    74  	MediaUrl *[]string `json:"MediaUrl,omitempty"`
    75  	// For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources).
    76  	ContentSid *string `json:"ContentSid,omitempty"`
    77  }
    78  
    79  func (params *CreateMessageParams) SetPathAccountSid(PathAccountSid string) *CreateMessageParams {
    80  	params.PathAccountSid = &PathAccountSid
    81  	return params
    82  }
    83  func (params *CreateMessageParams) SetTo(To string) *CreateMessageParams {
    84  	params.To = &To
    85  	return params
    86  }
    87  func (params *CreateMessageParams) SetStatusCallback(StatusCallback string) *CreateMessageParams {
    88  	params.StatusCallback = &StatusCallback
    89  	return params
    90  }
    91  func (params *CreateMessageParams) SetApplicationSid(ApplicationSid string) *CreateMessageParams {
    92  	params.ApplicationSid = &ApplicationSid
    93  	return params
    94  }
    95  func (params *CreateMessageParams) SetMaxPrice(MaxPrice float32) *CreateMessageParams {
    96  	params.MaxPrice = &MaxPrice
    97  	return params
    98  }
    99  func (params *CreateMessageParams) SetProvideFeedback(ProvideFeedback bool) *CreateMessageParams {
   100  	params.ProvideFeedback = &ProvideFeedback
   101  	return params
   102  }
   103  func (params *CreateMessageParams) SetAttempt(Attempt int) *CreateMessageParams {
   104  	params.Attempt = &Attempt
   105  	return params
   106  }
   107  func (params *CreateMessageParams) SetValidityPeriod(ValidityPeriod int) *CreateMessageParams {
   108  	params.ValidityPeriod = &ValidityPeriod
   109  	return params
   110  }
   111  func (params *CreateMessageParams) SetForceDelivery(ForceDelivery bool) *CreateMessageParams {
   112  	params.ForceDelivery = &ForceDelivery
   113  	return params
   114  }
   115  func (params *CreateMessageParams) SetContentRetention(ContentRetention string) *CreateMessageParams {
   116  	params.ContentRetention = &ContentRetention
   117  	return params
   118  }
   119  func (params *CreateMessageParams) SetAddressRetention(AddressRetention string) *CreateMessageParams {
   120  	params.AddressRetention = &AddressRetention
   121  	return params
   122  }
   123  func (params *CreateMessageParams) SetSmartEncoded(SmartEncoded bool) *CreateMessageParams {
   124  	params.SmartEncoded = &SmartEncoded
   125  	return params
   126  }
   127  func (params *CreateMessageParams) SetPersistentAction(PersistentAction []string) *CreateMessageParams {
   128  	params.PersistentAction = &PersistentAction
   129  	return params
   130  }
   131  func (params *CreateMessageParams) SetShortenUrls(ShortenUrls bool) *CreateMessageParams {
   132  	params.ShortenUrls = &ShortenUrls
   133  	return params
   134  }
   135  func (params *CreateMessageParams) SetScheduleType(ScheduleType string) *CreateMessageParams {
   136  	params.ScheduleType = &ScheduleType
   137  	return params
   138  }
   139  func (params *CreateMessageParams) SetSendAt(SendAt time.Time) *CreateMessageParams {
   140  	params.SendAt = &SendAt
   141  	return params
   142  }
   143  func (params *CreateMessageParams) SetSendAsMms(SendAsMms bool) *CreateMessageParams {
   144  	params.SendAsMms = &SendAsMms
   145  	return params
   146  }
   147  func (params *CreateMessageParams) SetContentVariables(ContentVariables string) *CreateMessageParams {
   148  	params.ContentVariables = &ContentVariables
   149  	return params
   150  }
   151  func (params *CreateMessageParams) SetRiskCheck(RiskCheck string) *CreateMessageParams {
   152  	params.RiskCheck = &RiskCheck
   153  	return params
   154  }
   155  func (params *CreateMessageParams) SetFrom(From string) *CreateMessageParams {
   156  	params.From = &From
   157  	return params
   158  }
   159  func (params *CreateMessageParams) SetMessagingServiceSid(MessagingServiceSid string) *CreateMessageParams {
   160  	params.MessagingServiceSid = &MessagingServiceSid
   161  	return params
   162  }
   163  func (params *CreateMessageParams) SetBody(Body string) *CreateMessageParams {
   164  	params.Body = &Body
   165  	return params
   166  }
   167  func (params *CreateMessageParams) SetMediaUrl(MediaUrl []string) *CreateMessageParams {
   168  	params.MediaUrl = &MediaUrl
   169  	return params
   170  }
   171  func (params *CreateMessageParams) SetContentSid(ContentSid string) *CreateMessageParams {
   172  	params.ContentSid = &ContentSid
   173  	return params
   174  }
   175  
   176  // Send a message
   177  func (c *ApiService) CreateMessage(params *CreateMessageParams) (*ApiV2010Message, error) {
   178  	path := "/2010-04-01/Accounts/{AccountSid}/Messages.json"
   179  	if params != nil && params.PathAccountSid != nil {
   180  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   181  	} else {
   182  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   183  	}
   184  
   185  	data := url.Values{}
   186  	headers := make(map[string]interface{})
   187  
   188  	if params != nil && params.To != nil {
   189  		data.Set("To", *params.To)
   190  	}
   191  	if params != nil && params.StatusCallback != nil {
   192  		data.Set("StatusCallback", *params.StatusCallback)
   193  	}
   194  	if params != nil && params.ApplicationSid != nil {
   195  		data.Set("ApplicationSid", *params.ApplicationSid)
   196  	}
   197  	if params != nil && params.MaxPrice != nil {
   198  		data.Set("MaxPrice", fmt.Sprint(*params.MaxPrice))
   199  	}
   200  	if params != nil && params.ProvideFeedback != nil {
   201  		data.Set("ProvideFeedback", fmt.Sprint(*params.ProvideFeedback))
   202  	}
   203  	if params != nil && params.Attempt != nil {
   204  		data.Set("Attempt", fmt.Sprint(*params.Attempt))
   205  	}
   206  	if params != nil && params.ValidityPeriod != nil {
   207  		data.Set("ValidityPeriod", fmt.Sprint(*params.ValidityPeriod))
   208  	}
   209  	if params != nil && params.ForceDelivery != nil {
   210  		data.Set("ForceDelivery", fmt.Sprint(*params.ForceDelivery))
   211  	}
   212  	if params != nil && params.ContentRetention != nil {
   213  		data.Set("ContentRetention", *params.ContentRetention)
   214  	}
   215  	if params != nil && params.AddressRetention != nil {
   216  		data.Set("AddressRetention", *params.AddressRetention)
   217  	}
   218  	if params != nil && params.SmartEncoded != nil {
   219  		data.Set("SmartEncoded", fmt.Sprint(*params.SmartEncoded))
   220  	}
   221  	if params != nil && params.PersistentAction != nil {
   222  		for _, item := range *params.PersistentAction {
   223  			data.Add("PersistentAction", item)
   224  		}
   225  	}
   226  	if params != nil && params.ShortenUrls != nil {
   227  		data.Set("ShortenUrls", fmt.Sprint(*params.ShortenUrls))
   228  	}
   229  	if params != nil && params.ScheduleType != nil {
   230  		data.Set("ScheduleType", *params.ScheduleType)
   231  	}
   232  	if params != nil && params.SendAt != nil {
   233  		data.Set("SendAt", fmt.Sprint((*params.SendAt).Format(time.RFC3339)))
   234  	}
   235  	if params != nil && params.SendAsMms != nil {
   236  		data.Set("SendAsMms", fmt.Sprint(*params.SendAsMms))
   237  	}
   238  	if params != nil && params.ContentVariables != nil {
   239  		data.Set("ContentVariables", *params.ContentVariables)
   240  	}
   241  	if params != nil && params.RiskCheck != nil {
   242  		data.Set("RiskCheck", *params.RiskCheck)
   243  	}
   244  	if params != nil && params.From != nil {
   245  		data.Set("From", *params.From)
   246  	}
   247  	if params != nil && params.MessagingServiceSid != nil {
   248  		data.Set("MessagingServiceSid", *params.MessagingServiceSid)
   249  	}
   250  	if params != nil && params.Body != nil {
   251  		data.Set("Body", *params.Body)
   252  	}
   253  	if params != nil && params.MediaUrl != nil {
   254  		for _, item := range *params.MediaUrl {
   255  			data.Add("MediaUrl", item)
   256  		}
   257  	}
   258  	if params != nil && params.ContentSid != nil {
   259  		data.Set("ContentSid", *params.ContentSid)
   260  	}
   261  
   262  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   263  	if err != nil {
   264  		return nil, err
   265  	}
   266  
   267  	defer resp.Body.Close()
   268  
   269  	ps := &ApiV2010Message{}
   270  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   271  		return nil, err
   272  	}
   273  
   274  	return ps, err
   275  }
   276  
   277  // Optional parameters for the method 'DeleteMessage'
   278  type DeleteMessageParams struct {
   279  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource
   280  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   281  }
   282  
   283  func (params *DeleteMessageParams) SetPathAccountSid(PathAccountSid string) *DeleteMessageParams {
   284  	params.PathAccountSid = &PathAccountSid
   285  	return params
   286  }
   287  
   288  // Deletes a Message resource from your account
   289  func (c *ApiService) DeleteMessage(Sid string, params *DeleteMessageParams) error {
   290  	path := "/2010-04-01/Accounts/{AccountSid}/Messages/{Sid}.json"
   291  	if params != nil && params.PathAccountSid != nil {
   292  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   293  	} else {
   294  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   295  	}
   296  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   297  
   298  	data := url.Values{}
   299  	headers := make(map[string]interface{})
   300  
   301  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
   302  	if err != nil {
   303  		return err
   304  	}
   305  
   306  	defer resp.Body.Close()
   307  
   308  	return nil
   309  }
   310  
   311  // Optional parameters for the method 'FetchMessage'
   312  type FetchMessageParams struct {
   313  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource
   314  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   315  }
   316  
   317  func (params *FetchMessageParams) SetPathAccountSid(PathAccountSid string) *FetchMessageParams {
   318  	params.PathAccountSid = &PathAccountSid
   319  	return params
   320  }
   321  
   322  // Fetch a specific Message
   323  func (c *ApiService) FetchMessage(Sid string, params *FetchMessageParams) (*ApiV2010Message, error) {
   324  	path := "/2010-04-01/Accounts/{AccountSid}/Messages/{Sid}.json"
   325  	if params != nil && params.PathAccountSid != nil {
   326  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   327  	} else {
   328  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   329  	}
   330  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   331  
   332  	data := url.Values{}
   333  	headers := make(map[string]interface{})
   334  
   335  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   336  	if err != nil {
   337  		return nil, err
   338  	}
   339  
   340  	defer resp.Body.Close()
   341  
   342  	ps := &ApiV2010Message{}
   343  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   344  		return nil, err
   345  	}
   346  
   347  	return ps, err
   348  }
   349  
   350  // Optional parameters for the method 'ListMessage'
   351  type ListMessageParams struct {
   352  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resources.
   353  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   354  	// Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
   355  	To *string `json:"To,omitempty"`
   356  	// Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
   357  	From *string `json:"From,omitempty"`
   358  	// Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
   359  	DateSent *time.Time `json:"DateSent,omitempty"`
   360  	// Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
   361  	DateSentBefore *time.Time `json:"DateSent&lt;,omitempty"`
   362  	// Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
   363  	DateSentAfter *time.Time `json:"DateSent&gt;,omitempty"`
   364  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   365  	PageSize *int `json:"PageSize,omitempty"`
   366  	// Max number of records to return.
   367  	Limit *int `json:"limit,omitempty"`
   368  }
   369  
   370  func (params *ListMessageParams) SetPathAccountSid(PathAccountSid string) *ListMessageParams {
   371  	params.PathAccountSid = &PathAccountSid
   372  	return params
   373  }
   374  func (params *ListMessageParams) SetTo(To string) *ListMessageParams {
   375  	params.To = &To
   376  	return params
   377  }
   378  func (params *ListMessageParams) SetFrom(From string) *ListMessageParams {
   379  	params.From = &From
   380  	return params
   381  }
   382  func (params *ListMessageParams) SetDateSent(DateSent time.Time) *ListMessageParams {
   383  	params.DateSent = &DateSent
   384  	return params
   385  }
   386  func (params *ListMessageParams) SetDateSentBefore(DateSentBefore time.Time) *ListMessageParams {
   387  	params.DateSentBefore = &DateSentBefore
   388  	return params
   389  }
   390  func (params *ListMessageParams) SetDateSentAfter(DateSentAfter time.Time) *ListMessageParams {
   391  	params.DateSentAfter = &DateSentAfter
   392  	return params
   393  }
   394  func (params *ListMessageParams) SetPageSize(PageSize int) *ListMessageParams {
   395  	params.PageSize = &PageSize
   396  	return params
   397  }
   398  func (params *ListMessageParams) SetLimit(Limit int) *ListMessageParams {
   399  	params.Limit = &Limit
   400  	return params
   401  }
   402  
   403  // Retrieve a single page of Message records from the API. Request is executed immediately.
   404  func (c *ApiService) PageMessage(params *ListMessageParams, pageToken, pageNumber string) (*ListMessageResponse, error) {
   405  	path := "/2010-04-01/Accounts/{AccountSid}/Messages.json"
   406  
   407  	if params != nil && params.PathAccountSid != nil {
   408  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   409  	} else {
   410  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   411  	}
   412  
   413  	data := url.Values{}
   414  	headers := make(map[string]interface{})
   415  
   416  	if params != nil && params.To != nil {
   417  		data.Set("To", *params.To)
   418  	}
   419  	if params != nil && params.From != nil {
   420  		data.Set("From", *params.From)
   421  	}
   422  	if params != nil && params.DateSent != nil {
   423  		data.Set("DateSent", fmt.Sprint((*params.DateSent).Format(time.RFC3339)))
   424  	}
   425  	if params != nil && params.DateSentBefore != nil {
   426  		data.Set("DateSent<", fmt.Sprint((*params.DateSentBefore).Format(time.RFC3339)))
   427  	}
   428  	if params != nil && params.DateSentAfter != nil {
   429  		data.Set("DateSent>", fmt.Sprint((*params.DateSentAfter).Format(time.RFC3339)))
   430  	}
   431  	if params != nil && params.PageSize != nil {
   432  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   433  	}
   434  
   435  	if pageToken != "" {
   436  		data.Set("PageToken", pageToken)
   437  	}
   438  	if pageNumber != "" {
   439  		data.Set("Page", pageNumber)
   440  	}
   441  
   442  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   443  	if err != nil {
   444  		return nil, err
   445  	}
   446  
   447  	defer resp.Body.Close()
   448  
   449  	ps := &ListMessageResponse{}
   450  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   451  		return nil, err
   452  	}
   453  
   454  	return ps, err
   455  }
   456  
   457  // Lists Message records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   458  func (c *ApiService) ListMessage(params *ListMessageParams) ([]ApiV2010Message, error) {
   459  	response, errors := c.StreamMessage(params)
   460  
   461  	records := make([]ApiV2010Message, 0)
   462  	for record := range response {
   463  		records = append(records, record)
   464  	}
   465  
   466  	if err := <-errors; err != nil {
   467  		return nil, err
   468  	}
   469  
   470  	return records, nil
   471  }
   472  
   473  // Streams Message records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   474  func (c *ApiService) StreamMessage(params *ListMessageParams) (chan ApiV2010Message, chan error) {
   475  	if params == nil {
   476  		params = &ListMessageParams{}
   477  	}
   478  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   479  
   480  	recordChannel := make(chan ApiV2010Message, 1)
   481  	errorChannel := make(chan error, 1)
   482  
   483  	response, err := c.PageMessage(params, "", "")
   484  	if err != nil {
   485  		errorChannel <- err
   486  		close(recordChannel)
   487  		close(errorChannel)
   488  	} else {
   489  		go c.streamMessage(response, params, recordChannel, errorChannel)
   490  	}
   491  
   492  	return recordChannel, errorChannel
   493  }
   494  
   495  func (c *ApiService) streamMessage(response *ListMessageResponse, params *ListMessageParams, recordChannel chan ApiV2010Message, errorChannel chan error) {
   496  	curRecord := 1
   497  
   498  	for response != nil {
   499  		responseRecords := response.Messages
   500  		for item := range responseRecords {
   501  			recordChannel <- responseRecords[item]
   502  			curRecord += 1
   503  			if params.Limit != nil && *params.Limit < curRecord {
   504  				close(recordChannel)
   505  				close(errorChannel)
   506  				return
   507  			}
   508  		}
   509  
   510  		record, err := client.GetNext(c.baseURL, response, c.getNextListMessageResponse)
   511  		if err != nil {
   512  			errorChannel <- err
   513  			break
   514  		} else if record == nil {
   515  			break
   516  		}
   517  
   518  		response = record.(*ListMessageResponse)
   519  	}
   520  
   521  	close(recordChannel)
   522  	close(errorChannel)
   523  }
   524  
   525  func (c *ApiService) getNextListMessageResponse(nextPageUrl string) (interface{}, error) {
   526  	if nextPageUrl == "" {
   527  		return nil, nil
   528  	}
   529  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   530  	if err != nil {
   531  		return nil, err
   532  	}
   533  
   534  	defer resp.Body.Close()
   535  
   536  	ps := &ListMessageResponse{}
   537  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   538  		return nil, err
   539  	}
   540  	return ps, nil
   541  }
   542  
   543  // Optional parameters for the method 'UpdateMessage'
   544  type UpdateMessageParams struct {
   545  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resources to update.
   546  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   547  	// The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
   548  	Body *string `json:"Body,omitempty"`
   549  	//
   550  	Status *string `json:"Status,omitempty"`
   551  }
   552  
   553  func (params *UpdateMessageParams) SetPathAccountSid(PathAccountSid string) *UpdateMessageParams {
   554  	params.PathAccountSid = &PathAccountSid
   555  	return params
   556  }
   557  func (params *UpdateMessageParams) SetBody(Body string) *UpdateMessageParams {
   558  	params.Body = &Body
   559  	return params
   560  }
   561  func (params *UpdateMessageParams) SetStatus(Status string) *UpdateMessageParams {
   562  	params.Status = &Status
   563  	return params
   564  }
   565  
   566  // Update a Message resource (used to redact Message `body` text and to cancel not-yet-sent messages)
   567  func (c *ApiService) UpdateMessage(Sid string, params *UpdateMessageParams) (*ApiV2010Message, error) {
   568  	path := "/2010-04-01/Accounts/{AccountSid}/Messages/{Sid}.json"
   569  	if params != nil && params.PathAccountSid != nil {
   570  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   571  	} else {
   572  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   573  	}
   574  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   575  
   576  	data := url.Values{}
   577  	headers := make(map[string]interface{})
   578  
   579  	if params != nil && params.Body != nil {
   580  		data.Set("Body", *params.Body)
   581  	}
   582  	if params != nil && params.Status != nil {
   583  		data.Set("Status", *params.Status)
   584  	}
   585  
   586  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   587  	if err != nil {
   588  		return nil, err
   589  	}
   590  
   591  	defer resp.Body.Close()
   592  
   593  	ps := &ApiV2010Message{}
   594  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   595  		return nil, err
   596  	}
   597  
   598  	return ps, err
   599  }