github.com/twilio/twilio-go@v1.20.1/rest/conversations/v1/services_conversations.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Conversations
     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 'CreateServiceConversation'
    28  type CreateServiceConversationParams struct {
    29  	// The X-Twilio-Webhook-Enabled HTTP request header
    30  	XTwilioWebhookEnabled *string `json:"X-Twilio-Webhook-Enabled,omitempty"`
    31  	// The human-readable name of this conversation, limited to 256 characters. Optional.
    32  	FriendlyName *string `json:"FriendlyName,omitempty"`
    33  	// An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
    34  	UniqueName *string `json:"UniqueName,omitempty"`
    35  	// An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified.  **Note** that if the attributes are not set \\\"{}\\\" will be returned.
    36  	Attributes *string `json:"Attributes,omitempty"`
    37  	// The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
    38  	MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"`
    39  	// The date that this resource was created.
    40  	DateCreated *time.Time `json:"DateCreated,omitempty"`
    41  	// The date that this resource was last updated.
    42  	DateUpdated *time.Time `json:"DateUpdated,omitempty"`
    43  	//
    44  	State *string `json:"State,omitempty"`
    45  	// ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
    46  	TimersInactive *string `json:"Timers.Inactive,omitempty"`
    47  	// ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
    48  	TimersClosed *string `json:"Timers.Closed,omitempty"`
    49  	// The default email address that will be used when sending outbound emails in this conversation.
    50  	BindingsEmailAddress *string `json:"Bindings.Email.Address,omitempty"`
    51  	// The default name that will be used when sending outbound emails in this conversation.
    52  	BindingsEmailName *string `json:"Bindings.Email.Name,omitempty"`
    53  }
    54  
    55  func (params *CreateServiceConversationParams) SetXTwilioWebhookEnabled(XTwilioWebhookEnabled string) *CreateServiceConversationParams {
    56  	params.XTwilioWebhookEnabled = &XTwilioWebhookEnabled
    57  	return params
    58  }
    59  func (params *CreateServiceConversationParams) SetFriendlyName(FriendlyName string) *CreateServiceConversationParams {
    60  	params.FriendlyName = &FriendlyName
    61  	return params
    62  }
    63  func (params *CreateServiceConversationParams) SetUniqueName(UniqueName string) *CreateServiceConversationParams {
    64  	params.UniqueName = &UniqueName
    65  	return params
    66  }
    67  func (params *CreateServiceConversationParams) SetAttributes(Attributes string) *CreateServiceConversationParams {
    68  	params.Attributes = &Attributes
    69  	return params
    70  }
    71  func (params *CreateServiceConversationParams) SetMessagingServiceSid(MessagingServiceSid string) *CreateServiceConversationParams {
    72  	params.MessagingServiceSid = &MessagingServiceSid
    73  	return params
    74  }
    75  func (params *CreateServiceConversationParams) SetDateCreated(DateCreated time.Time) *CreateServiceConversationParams {
    76  	params.DateCreated = &DateCreated
    77  	return params
    78  }
    79  func (params *CreateServiceConversationParams) SetDateUpdated(DateUpdated time.Time) *CreateServiceConversationParams {
    80  	params.DateUpdated = &DateUpdated
    81  	return params
    82  }
    83  func (params *CreateServiceConversationParams) SetState(State string) *CreateServiceConversationParams {
    84  	params.State = &State
    85  	return params
    86  }
    87  func (params *CreateServiceConversationParams) SetTimersInactive(TimersInactive string) *CreateServiceConversationParams {
    88  	params.TimersInactive = &TimersInactive
    89  	return params
    90  }
    91  func (params *CreateServiceConversationParams) SetTimersClosed(TimersClosed string) *CreateServiceConversationParams {
    92  	params.TimersClosed = &TimersClosed
    93  	return params
    94  }
    95  func (params *CreateServiceConversationParams) SetBindingsEmailAddress(BindingsEmailAddress string) *CreateServiceConversationParams {
    96  	params.BindingsEmailAddress = &BindingsEmailAddress
    97  	return params
    98  }
    99  func (params *CreateServiceConversationParams) SetBindingsEmailName(BindingsEmailName string) *CreateServiceConversationParams {
   100  	params.BindingsEmailName = &BindingsEmailName
   101  	return params
   102  }
   103  
   104  // Create a new conversation in your service
   105  func (c *ApiService) CreateServiceConversation(ChatServiceSid string, params *CreateServiceConversationParams) (*ConversationsV1ServiceConversation, error) {
   106  	path := "/v1/Services/{ChatServiceSid}/Conversations"
   107  	path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
   108  
   109  	data := url.Values{}
   110  	headers := make(map[string]interface{})
   111  
   112  	if params != nil && params.FriendlyName != nil {
   113  		data.Set("FriendlyName", *params.FriendlyName)
   114  	}
   115  	if params != nil && params.UniqueName != nil {
   116  		data.Set("UniqueName", *params.UniqueName)
   117  	}
   118  	if params != nil && params.Attributes != nil {
   119  		data.Set("Attributes", *params.Attributes)
   120  	}
   121  	if params != nil && params.MessagingServiceSid != nil {
   122  		data.Set("MessagingServiceSid", *params.MessagingServiceSid)
   123  	}
   124  	if params != nil && params.DateCreated != nil {
   125  		data.Set("DateCreated", fmt.Sprint((*params.DateCreated).Format(time.RFC3339)))
   126  	}
   127  	if params != nil && params.DateUpdated != nil {
   128  		data.Set("DateUpdated", fmt.Sprint((*params.DateUpdated).Format(time.RFC3339)))
   129  	}
   130  	if params != nil && params.State != nil {
   131  		data.Set("State", *params.State)
   132  	}
   133  	if params != nil && params.TimersInactive != nil {
   134  		data.Set("Timers.Inactive", *params.TimersInactive)
   135  	}
   136  	if params != nil && params.TimersClosed != nil {
   137  		data.Set("Timers.Closed", *params.TimersClosed)
   138  	}
   139  	if params != nil && params.BindingsEmailAddress != nil {
   140  		data.Set("Bindings.Email.Address", *params.BindingsEmailAddress)
   141  	}
   142  	if params != nil && params.BindingsEmailName != nil {
   143  		data.Set("Bindings.Email.Name", *params.BindingsEmailName)
   144  	}
   145  
   146  	if params != nil && params.XTwilioWebhookEnabled != nil {
   147  		headers["X-Twilio-Webhook-Enabled"] = *params.XTwilioWebhookEnabled
   148  	}
   149  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   150  	if err != nil {
   151  		return nil, err
   152  	}
   153  
   154  	defer resp.Body.Close()
   155  
   156  	ps := &ConversationsV1ServiceConversation{}
   157  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   158  		return nil, err
   159  	}
   160  
   161  	return ps, err
   162  }
   163  
   164  // Optional parameters for the method 'DeleteServiceConversation'
   165  type DeleteServiceConversationParams struct {
   166  	// The X-Twilio-Webhook-Enabled HTTP request header
   167  	XTwilioWebhookEnabled *string `json:"X-Twilio-Webhook-Enabled,omitempty"`
   168  }
   169  
   170  func (params *DeleteServiceConversationParams) SetXTwilioWebhookEnabled(XTwilioWebhookEnabled string) *DeleteServiceConversationParams {
   171  	params.XTwilioWebhookEnabled = &XTwilioWebhookEnabled
   172  	return params
   173  }
   174  
   175  // Remove a conversation from your service
   176  func (c *ApiService) DeleteServiceConversation(ChatServiceSid string, Sid string, params *DeleteServiceConversationParams) error {
   177  	path := "/v1/Services/{ChatServiceSid}/Conversations/{Sid}"
   178  	path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
   179  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   180  
   181  	data := url.Values{}
   182  	headers := make(map[string]interface{})
   183  
   184  	if params != nil && params.XTwilioWebhookEnabled != nil {
   185  		headers["X-Twilio-Webhook-Enabled"] = *params.XTwilioWebhookEnabled
   186  	}
   187  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
   188  	if err != nil {
   189  		return err
   190  	}
   191  
   192  	defer resp.Body.Close()
   193  
   194  	return nil
   195  }
   196  
   197  // Fetch a conversation from your service
   198  func (c *ApiService) FetchServiceConversation(ChatServiceSid string, Sid string) (*ConversationsV1ServiceConversation, error) {
   199  	path := "/v1/Services/{ChatServiceSid}/Conversations/{Sid}"
   200  	path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
   201  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   202  
   203  	data := url.Values{}
   204  	headers := make(map[string]interface{})
   205  
   206  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   207  	if err != nil {
   208  		return nil, err
   209  	}
   210  
   211  	defer resp.Body.Close()
   212  
   213  	ps := &ConversationsV1ServiceConversation{}
   214  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   215  		return nil, err
   216  	}
   217  
   218  	return ps, err
   219  }
   220  
   221  // Optional parameters for the method 'ListServiceConversation'
   222  type ListServiceConversationParams struct {
   223  	// Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order.
   224  	StartDate *string `json:"StartDate,omitempty"`
   225  	// Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results.  The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order.
   226  	EndDate *string `json:"EndDate,omitempty"`
   227  	// State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed`
   228  	State *string `json:"State,omitempty"`
   229  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   230  	PageSize *int `json:"PageSize,omitempty"`
   231  	// Max number of records to return.
   232  	Limit *int `json:"limit,omitempty"`
   233  }
   234  
   235  func (params *ListServiceConversationParams) SetStartDate(StartDate string) *ListServiceConversationParams {
   236  	params.StartDate = &StartDate
   237  	return params
   238  }
   239  func (params *ListServiceConversationParams) SetEndDate(EndDate string) *ListServiceConversationParams {
   240  	params.EndDate = &EndDate
   241  	return params
   242  }
   243  func (params *ListServiceConversationParams) SetState(State string) *ListServiceConversationParams {
   244  	params.State = &State
   245  	return params
   246  }
   247  func (params *ListServiceConversationParams) SetPageSize(PageSize int) *ListServiceConversationParams {
   248  	params.PageSize = &PageSize
   249  	return params
   250  }
   251  func (params *ListServiceConversationParams) SetLimit(Limit int) *ListServiceConversationParams {
   252  	params.Limit = &Limit
   253  	return params
   254  }
   255  
   256  // Retrieve a single page of ServiceConversation records from the API. Request is executed immediately.
   257  func (c *ApiService) PageServiceConversation(ChatServiceSid string, params *ListServiceConversationParams, pageToken, pageNumber string) (*ListServiceConversationResponse, error) {
   258  	path := "/v1/Services/{ChatServiceSid}/Conversations"
   259  
   260  	path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
   261  
   262  	data := url.Values{}
   263  	headers := make(map[string]interface{})
   264  
   265  	if params != nil && params.StartDate != nil {
   266  		data.Set("StartDate", *params.StartDate)
   267  	}
   268  	if params != nil && params.EndDate != nil {
   269  		data.Set("EndDate", *params.EndDate)
   270  	}
   271  	if params != nil && params.State != nil {
   272  		data.Set("State", *params.State)
   273  	}
   274  	if params != nil && params.PageSize != nil {
   275  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   276  	}
   277  
   278  	if pageToken != "" {
   279  		data.Set("PageToken", pageToken)
   280  	}
   281  	if pageNumber != "" {
   282  		data.Set("Page", pageNumber)
   283  	}
   284  
   285  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   286  	if err != nil {
   287  		return nil, err
   288  	}
   289  
   290  	defer resp.Body.Close()
   291  
   292  	ps := &ListServiceConversationResponse{}
   293  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   294  		return nil, err
   295  	}
   296  
   297  	return ps, err
   298  }
   299  
   300  // Lists ServiceConversation records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   301  func (c *ApiService) ListServiceConversation(ChatServiceSid string, params *ListServiceConversationParams) ([]ConversationsV1ServiceConversation, error) {
   302  	response, errors := c.StreamServiceConversation(ChatServiceSid, params)
   303  
   304  	records := make([]ConversationsV1ServiceConversation, 0)
   305  	for record := range response {
   306  		records = append(records, record)
   307  	}
   308  
   309  	if err := <-errors; err != nil {
   310  		return nil, err
   311  	}
   312  
   313  	return records, nil
   314  }
   315  
   316  // Streams ServiceConversation records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   317  func (c *ApiService) StreamServiceConversation(ChatServiceSid string, params *ListServiceConversationParams) (chan ConversationsV1ServiceConversation, chan error) {
   318  	if params == nil {
   319  		params = &ListServiceConversationParams{}
   320  	}
   321  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   322  
   323  	recordChannel := make(chan ConversationsV1ServiceConversation, 1)
   324  	errorChannel := make(chan error, 1)
   325  
   326  	response, err := c.PageServiceConversation(ChatServiceSid, params, "", "")
   327  	if err != nil {
   328  		errorChannel <- err
   329  		close(recordChannel)
   330  		close(errorChannel)
   331  	} else {
   332  		go c.streamServiceConversation(response, params, recordChannel, errorChannel)
   333  	}
   334  
   335  	return recordChannel, errorChannel
   336  }
   337  
   338  func (c *ApiService) streamServiceConversation(response *ListServiceConversationResponse, params *ListServiceConversationParams, recordChannel chan ConversationsV1ServiceConversation, errorChannel chan error) {
   339  	curRecord := 1
   340  
   341  	for response != nil {
   342  		responseRecords := response.Conversations
   343  		for item := range responseRecords {
   344  			recordChannel <- responseRecords[item]
   345  			curRecord += 1
   346  			if params.Limit != nil && *params.Limit < curRecord {
   347  				close(recordChannel)
   348  				close(errorChannel)
   349  				return
   350  			}
   351  		}
   352  
   353  		record, err := client.GetNext(c.baseURL, response, c.getNextListServiceConversationResponse)
   354  		if err != nil {
   355  			errorChannel <- err
   356  			break
   357  		} else if record == nil {
   358  			break
   359  		}
   360  
   361  		response = record.(*ListServiceConversationResponse)
   362  	}
   363  
   364  	close(recordChannel)
   365  	close(errorChannel)
   366  }
   367  
   368  func (c *ApiService) getNextListServiceConversationResponse(nextPageUrl string) (interface{}, error) {
   369  	if nextPageUrl == "" {
   370  		return nil, nil
   371  	}
   372  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   373  	if err != nil {
   374  		return nil, err
   375  	}
   376  
   377  	defer resp.Body.Close()
   378  
   379  	ps := &ListServiceConversationResponse{}
   380  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   381  		return nil, err
   382  	}
   383  	return ps, nil
   384  }
   385  
   386  // Optional parameters for the method 'UpdateServiceConversation'
   387  type UpdateServiceConversationParams struct {
   388  	// The X-Twilio-Webhook-Enabled HTTP request header
   389  	XTwilioWebhookEnabled *string `json:"X-Twilio-Webhook-Enabled,omitempty"`
   390  	// The human-readable name of this conversation, limited to 256 characters. Optional.
   391  	FriendlyName *string `json:"FriendlyName,omitempty"`
   392  	// The date that this resource was created.
   393  	DateCreated *time.Time `json:"DateCreated,omitempty"`
   394  	// The date that this resource was last updated.
   395  	DateUpdated *time.Time `json:"DateUpdated,omitempty"`
   396  	// An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified.  **Note** that if the attributes are not set \\\"{}\\\" will be returned.
   397  	Attributes *string `json:"Attributes,omitempty"`
   398  	// The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.
   399  	MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"`
   400  	//
   401  	State *string `json:"State,omitempty"`
   402  	// ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute.
   403  	TimersInactive *string `json:"Timers.Inactive,omitempty"`
   404  	// ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes.
   405  	TimersClosed *string `json:"Timers.Closed,omitempty"`
   406  	// An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
   407  	UniqueName *string `json:"UniqueName,omitempty"`
   408  	// The default email address that will be used when sending outbound emails in this conversation.
   409  	BindingsEmailAddress *string `json:"Bindings.Email.Address,omitempty"`
   410  	// The default name that will be used when sending outbound emails in this conversation.
   411  	BindingsEmailName *string `json:"Bindings.Email.Name,omitempty"`
   412  }
   413  
   414  func (params *UpdateServiceConversationParams) SetXTwilioWebhookEnabled(XTwilioWebhookEnabled string) *UpdateServiceConversationParams {
   415  	params.XTwilioWebhookEnabled = &XTwilioWebhookEnabled
   416  	return params
   417  }
   418  func (params *UpdateServiceConversationParams) SetFriendlyName(FriendlyName string) *UpdateServiceConversationParams {
   419  	params.FriendlyName = &FriendlyName
   420  	return params
   421  }
   422  func (params *UpdateServiceConversationParams) SetDateCreated(DateCreated time.Time) *UpdateServiceConversationParams {
   423  	params.DateCreated = &DateCreated
   424  	return params
   425  }
   426  func (params *UpdateServiceConversationParams) SetDateUpdated(DateUpdated time.Time) *UpdateServiceConversationParams {
   427  	params.DateUpdated = &DateUpdated
   428  	return params
   429  }
   430  func (params *UpdateServiceConversationParams) SetAttributes(Attributes string) *UpdateServiceConversationParams {
   431  	params.Attributes = &Attributes
   432  	return params
   433  }
   434  func (params *UpdateServiceConversationParams) SetMessagingServiceSid(MessagingServiceSid string) *UpdateServiceConversationParams {
   435  	params.MessagingServiceSid = &MessagingServiceSid
   436  	return params
   437  }
   438  func (params *UpdateServiceConversationParams) SetState(State string) *UpdateServiceConversationParams {
   439  	params.State = &State
   440  	return params
   441  }
   442  func (params *UpdateServiceConversationParams) SetTimersInactive(TimersInactive string) *UpdateServiceConversationParams {
   443  	params.TimersInactive = &TimersInactive
   444  	return params
   445  }
   446  func (params *UpdateServiceConversationParams) SetTimersClosed(TimersClosed string) *UpdateServiceConversationParams {
   447  	params.TimersClosed = &TimersClosed
   448  	return params
   449  }
   450  func (params *UpdateServiceConversationParams) SetUniqueName(UniqueName string) *UpdateServiceConversationParams {
   451  	params.UniqueName = &UniqueName
   452  	return params
   453  }
   454  func (params *UpdateServiceConversationParams) SetBindingsEmailAddress(BindingsEmailAddress string) *UpdateServiceConversationParams {
   455  	params.BindingsEmailAddress = &BindingsEmailAddress
   456  	return params
   457  }
   458  func (params *UpdateServiceConversationParams) SetBindingsEmailName(BindingsEmailName string) *UpdateServiceConversationParams {
   459  	params.BindingsEmailName = &BindingsEmailName
   460  	return params
   461  }
   462  
   463  // Update an existing conversation in your service
   464  func (c *ApiService) UpdateServiceConversation(ChatServiceSid string, Sid string, params *UpdateServiceConversationParams) (*ConversationsV1ServiceConversation, error) {
   465  	path := "/v1/Services/{ChatServiceSid}/Conversations/{Sid}"
   466  	path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
   467  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   468  
   469  	data := url.Values{}
   470  	headers := make(map[string]interface{})
   471  
   472  	if params != nil && params.FriendlyName != nil {
   473  		data.Set("FriendlyName", *params.FriendlyName)
   474  	}
   475  	if params != nil && params.DateCreated != nil {
   476  		data.Set("DateCreated", fmt.Sprint((*params.DateCreated).Format(time.RFC3339)))
   477  	}
   478  	if params != nil && params.DateUpdated != nil {
   479  		data.Set("DateUpdated", fmt.Sprint((*params.DateUpdated).Format(time.RFC3339)))
   480  	}
   481  	if params != nil && params.Attributes != nil {
   482  		data.Set("Attributes", *params.Attributes)
   483  	}
   484  	if params != nil && params.MessagingServiceSid != nil {
   485  		data.Set("MessagingServiceSid", *params.MessagingServiceSid)
   486  	}
   487  	if params != nil && params.State != nil {
   488  		data.Set("State", *params.State)
   489  	}
   490  	if params != nil && params.TimersInactive != nil {
   491  		data.Set("Timers.Inactive", *params.TimersInactive)
   492  	}
   493  	if params != nil && params.TimersClosed != nil {
   494  		data.Set("Timers.Closed", *params.TimersClosed)
   495  	}
   496  	if params != nil && params.UniqueName != nil {
   497  		data.Set("UniqueName", *params.UniqueName)
   498  	}
   499  	if params != nil && params.BindingsEmailAddress != nil {
   500  		data.Set("Bindings.Email.Address", *params.BindingsEmailAddress)
   501  	}
   502  	if params != nil && params.BindingsEmailName != nil {
   503  		data.Set("Bindings.Email.Name", *params.BindingsEmailName)
   504  	}
   505  
   506  	if params != nil && params.XTwilioWebhookEnabled != nil {
   507  		headers["X-Twilio-Webhook-Enabled"] = *params.XTwilioWebhookEnabled
   508  	}
   509  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   510  	if err != nil {
   511  		return nil, err
   512  	}
   513  
   514  	defer resp.Body.Close()
   515  
   516  	ps := &ConversationsV1ServiceConversation{}
   517  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   518  		return nil, err
   519  	}
   520  
   521  	return ps, err
   522  }