github.com/twilio/twilio-go@v1.20.1/rest/messaging/v1/services.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  	"fmt"
    20  	"net/url"
    21  	"strings"
    22  
    23  	"github.com/twilio/twilio-go/client"
    24  )
    25  
    26  // Optional parameters for the method 'CreateService'
    27  type CreateServiceParams struct {
    28  	// A descriptive string that you create to describe the resource. It can be up to 64 characters long.
    29  	FriendlyName *string `json:"FriendlyName,omitempty"`
    30  	// The URL we call using `inbound_method` when a message is received by any phone number or short code in the Service. When this property is `null`, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `inbound_request_url` defined for the Messaging Service.
    31  	InboundRequestUrl *string `json:"InboundRequestUrl,omitempty"`
    32  	// The HTTP method we should use to call `inbound_request_url`. Can be `GET` or `POST` and the default is `POST`.
    33  	InboundMethod *string `json:"InboundMethod,omitempty"`
    34  	// The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service.
    35  	FallbackUrl *string `json:"FallbackUrl,omitempty"`
    36  	// The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`.
    37  	FallbackMethod *string `json:"FallbackMethod,omitempty"`
    38  	// The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery.
    39  	StatusCallback *string `json:"StatusCallback,omitempty"`
    40  	// Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance.
    41  	StickySender *bool `json:"StickySender,omitempty"`
    42  	// Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance.
    43  	MmsConverter *bool `json:"MmsConverter,omitempty"`
    44  	// Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance.
    45  	SmartEncoding *bool `json:"SmartEncoding,omitempty"`
    46  	//
    47  	ScanMessageContent *string `json:"ScanMessageContent,omitempty"`
    48  	// [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.
    49  	FallbackToLongCode *bool `json:"FallbackToLongCode,omitempty"`
    50  	// Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance.
    51  	AreaCodeGeomatch *bool `json:"AreaCodeGeomatch,omitempty"`
    52  	// How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`.
    53  	ValidityPeriod *int `json:"ValidityPeriod,omitempty"`
    54  	// Reserved.
    55  	SynchronousValidation *bool `json:"SynchronousValidation,omitempty"`
    56  	// A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`.
    57  	Usecase *string `json:"Usecase,omitempty"`
    58  	// A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service.
    59  	UseInboundWebhookOnNumber *bool `json:"UseInboundWebhookOnNumber,omitempty"`
    60  }
    61  
    62  func (params *CreateServiceParams) SetFriendlyName(FriendlyName string) *CreateServiceParams {
    63  	params.FriendlyName = &FriendlyName
    64  	return params
    65  }
    66  func (params *CreateServiceParams) SetInboundRequestUrl(InboundRequestUrl string) *CreateServiceParams {
    67  	params.InboundRequestUrl = &InboundRequestUrl
    68  	return params
    69  }
    70  func (params *CreateServiceParams) SetInboundMethod(InboundMethod string) *CreateServiceParams {
    71  	params.InboundMethod = &InboundMethod
    72  	return params
    73  }
    74  func (params *CreateServiceParams) SetFallbackUrl(FallbackUrl string) *CreateServiceParams {
    75  	params.FallbackUrl = &FallbackUrl
    76  	return params
    77  }
    78  func (params *CreateServiceParams) SetFallbackMethod(FallbackMethod string) *CreateServiceParams {
    79  	params.FallbackMethod = &FallbackMethod
    80  	return params
    81  }
    82  func (params *CreateServiceParams) SetStatusCallback(StatusCallback string) *CreateServiceParams {
    83  	params.StatusCallback = &StatusCallback
    84  	return params
    85  }
    86  func (params *CreateServiceParams) SetStickySender(StickySender bool) *CreateServiceParams {
    87  	params.StickySender = &StickySender
    88  	return params
    89  }
    90  func (params *CreateServiceParams) SetMmsConverter(MmsConverter bool) *CreateServiceParams {
    91  	params.MmsConverter = &MmsConverter
    92  	return params
    93  }
    94  func (params *CreateServiceParams) SetSmartEncoding(SmartEncoding bool) *CreateServiceParams {
    95  	params.SmartEncoding = &SmartEncoding
    96  	return params
    97  }
    98  func (params *CreateServiceParams) SetScanMessageContent(ScanMessageContent string) *CreateServiceParams {
    99  	params.ScanMessageContent = &ScanMessageContent
   100  	return params
   101  }
   102  func (params *CreateServiceParams) SetFallbackToLongCode(FallbackToLongCode bool) *CreateServiceParams {
   103  	params.FallbackToLongCode = &FallbackToLongCode
   104  	return params
   105  }
   106  func (params *CreateServiceParams) SetAreaCodeGeomatch(AreaCodeGeomatch bool) *CreateServiceParams {
   107  	params.AreaCodeGeomatch = &AreaCodeGeomatch
   108  	return params
   109  }
   110  func (params *CreateServiceParams) SetValidityPeriod(ValidityPeriod int) *CreateServiceParams {
   111  	params.ValidityPeriod = &ValidityPeriod
   112  	return params
   113  }
   114  func (params *CreateServiceParams) SetSynchronousValidation(SynchronousValidation bool) *CreateServiceParams {
   115  	params.SynchronousValidation = &SynchronousValidation
   116  	return params
   117  }
   118  func (params *CreateServiceParams) SetUsecase(Usecase string) *CreateServiceParams {
   119  	params.Usecase = &Usecase
   120  	return params
   121  }
   122  func (params *CreateServiceParams) SetUseInboundWebhookOnNumber(UseInboundWebhookOnNumber bool) *CreateServiceParams {
   123  	params.UseInboundWebhookOnNumber = &UseInboundWebhookOnNumber
   124  	return params
   125  }
   126  
   127  //
   128  func (c *ApiService) CreateService(params *CreateServiceParams) (*MessagingV1Service, error) {
   129  	path := "/v1/Services"
   130  
   131  	data := url.Values{}
   132  	headers := make(map[string]interface{})
   133  
   134  	if params != nil && params.FriendlyName != nil {
   135  		data.Set("FriendlyName", *params.FriendlyName)
   136  	}
   137  	if params != nil && params.InboundRequestUrl != nil {
   138  		data.Set("InboundRequestUrl", *params.InboundRequestUrl)
   139  	}
   140  	if params != nil && params.InboundMethod != nil {
   141  		data.Set("InboundMethod", *params.InboundMethod)
   142  	}
   143  	if params != nil && params.FallbackUrl != nil {
   144  		data.Set("FallbackUrl", *params.FallbackUrl)
   145  	}
   146  	if params != nil && params.FallbackMethod != nil {
   147  		data.Set("FallbackMethod", *params.FallbackMethod)
   148  	}
   149  	if params != nil && params.StatusCallback != nil {
   150  		data.Set("StatusCallback", *params.StatusCallback)
   151  	}
   152  	if params != nil && params.StickySender != nil {
   153  		data.Set("StickySender", fmt.Sprint(*params.StickySender))
   154  	}
   155  	if params != nil && params.MmsConverter != nil {
   156  		data.Set("MmsConverter", fmt.Sprint(*params.MmsConverter))
   157  	}
   158  	if params != nil && params.SmartEncoding != nil {
   159  		data.Set("SmartEncoding", fmt.Sprint(*params.SmartEncoding))
   160  	}
   161  	if params != nil && params.ScanMessageContent != nil {
   162  		data.Set("ScanMessageContent", *params.ScanMessageContent)
   163  	}
   164  	if params != nil && params.FallbackToLongCode != nil {
   165  		data.Set("FallbackToLongCode", fmt.Sprint(*params.FallbackToLongCode))
   166  	}
   167  	if params != nil && params.AreaCodeGeomatch != nil {
   168  		data.Set("AreaCodeGeomatch", fmt.Sprint(*params.AreaCodeGeomatch))
   169  	}
   170  	if params != nil && params.ValidityPeriod != nil {
   171  		data.Set("ValidityPeriod", fmt.Sprint(*params.ValidityPeriod))
   172  	}
   173  	if params != nil && params.SynchronousValidation != nil {
   174  		data.Set("SynchronousValidation", fmt.Sprint(*params.SynchronousValidation))
   175  	}
   176  	if params != nil && params.Usecase != nil {
   177  		data.Set("Usecase", *params.Usecase)
   178  	}
   179  	if params != nil && params.UseInboundWebhookOnNumber != nil {
   180  		data.Set("UseInboundWebhookOnNumber", fmt.Sprint(*params.UseInboundWebhookOnNumber))
   181  	}
   182  
   183  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   184  	if err != nil {
   185  		return nil, err
   186  	}
   187  
   188  	defer resp.Body.Close()
   189  
   190  	ps := &MessagingV1Service{}
   191  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   192  		return nil, err
   193  	}
   194  
   195  	return ps, err
   196  }
   197  
   198  //
   199  func (c *ApiService) DeleteService(Sid string) error {
   200  	path := "/v1/Services/{Sid}"
   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.Delete(c.baseURL+path, data, headers)
   207  	if err != nil {
   208  		return err
   209  	}
   210  
   211  	defer resp.Body.Close()
   212  
   213  	return nil
   214  }
   215  
   216  //
   217  func (c *ApiService) FetchService(Sid string) (*MessagingV1Service, error) {
   218  	path := "/v1/Services/{Sid}"
   219  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   220  
   221  	data := url.Values{}
   222  	headers := make(map[string]interface{})
   223  
   224  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   225  	if err != nil {
   226  		return nil, err
   227  	}
   228  
   229  	defer resp.Body.Close()
   230  
   231  	ps := &MessagingV1Service{}
   232  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   233  		return nil, err
   234  	}
   235  
   236  	return ps, err
   237  }
   238  
   239  // Optional parameters for the method 'ListService'
   240  type ListServiceParams struct {
   241  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   242  	PageSize *int `json:"PageSize,omitempty"`
   243  	// Max number of records to return.
   244  	Limit *int `json:"limit,omitempty"`
   245  }
   246  
   247  func (params *ListServiceParams) SetPageSize(PageSize int) *ListServiceParams {
   248  	params.PageSize = &PageSize
   249  	return params
   250  }
   251  func (params *ListServiceParams) SetLimit(Limit int) *ListServiceParams {
   252  	params.Limit = &Limit
   253  	return params
   254  }
   255  
   256  // Retrieve a single page of Service records from the API. Request is executed immediately.
   257  func (c *ApiService) PageService(params *ListServiceParams, pageToken, pageNumber string) (*ListServiceResponse, error) {
   258  	path := "/v1/Services"
   259  
   260  	data := url.Values{}
   261  	headers := make(map[string]interface{})
   262  
   263  	if params != nil && params.PageSize != nil {
   264  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   265  	}
   266  
   267  	if pageToken != "" {
   268  		data.Set("PageToken", pageToken)
   269  	}
   270  	if pageNumber != "" {
   271  		data.Set("Page", pageNumber)
   272  	}
   273  
   274  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   275  	if err != nil {
   276  		return nil, err
   277  	}
   278  
   279  	defer resp.Body.Close()
   280  
   281  	ps := &ListServiceResponse{}
   282  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   283  		return nil, err
   284  	}
   285  
   286  	return ps, err
   287  }
   288  
   289  // Lists Service records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   290  func (c *ApiService) ListService(params *ListServiceParams) ([]MessagingV1Service, error) {
   291  	response, errors := c.StreamService(params)
   292  
   293  	records := make([]MessagingV1Service, 0)
   294  	for record := range response {
   295  		records = append(records, record)
   296  	}
   297  
   298  	if err := <-errors; err != nil {
   299  		return nil, err
   300  	}
   301  
   302  	return records, nil
   303  }
   304  
   305  // Streams Service records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   306  func (c *ApiService) StreamService(params *ListServiceParams) (chan MessagingV1Service, chan error) {
   307  	if params == nil {
   308  		params = &ListServiceParams{}
   309  	}
   310  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   311  
   312  	recordChannel := make(chan MessagingV1Service, 1)
   313  	errorChannel := make(chan error, 1)
   314  
   315  	response, err := c.PageService(params, "", "")
   316  	if err != nil {
   317  		errorChannel <- err
   318  		close(recordChannel)
   319  		close(errorChannel)
   320  	} else {
   321  		go c.streamService(response, params, recordChannel, errorChannel)
   322  	}
   323  
   324  	return recordChannel, errorChannel
   325  }
   326  
   327  func (c *ApiService) streamService(response *ListServiceResponse, params *ListServiceParams, recordChannel chan MessagingV1Service, errorChannel chan error) {
   328  	curRecord := 1
   329  
   330  	for response != nil {
   331  		responseRecords := response.Services
   332  		for item := range responseRecords {
   333  			recordChannel <- responseRecords[item]
   334  			curRecord += 1
   335  			if params.Limit != nil && *params.Limit < curRecord {
   336  				close(recordChannel)
   337  				close(errorChannel)
   338  				return
   339  			}
   340  		}
   341  
   342  		record, err := client.GetNext(c.baseURL, response, c.getNextListServiceResponse)
   343  		if err != nil {
   344  			errorChannel <- err
   345  			break
   346  		} else if record == nil {
   347  			break
   348  		}
   349  
   350  		response = record.(*ListServiceResponse)
   351  	}
   352  
   353  	close(recordChannel)
   354  	close(errorChannel)
   355  }
   356  
   357  func (c *ApiService) getNextListServiceResponse(nextPageUrl string) (interface{}, error) {
   358  	if nextPageUrl == "" {
   359  		return nil, nil
   360  	}
   361  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   362  	if err != nil {
   363  		return nil, err
   364  	}
   365  
   366  	defer resp.Body.Close()
   367  
   368  	ps := &ListServiceResponse{}
   369  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   370  		return nil, err
   371  	}
   372  	return ps, nil
   373  }
   374  
   375  // Optional parameters for the method 'UpdateService'
   376  type UpdateServiceParams struct {
   377  	// A descriptive string that you create to describe the resource. It can be up to 64 characters long.
   378  	FriendlyName *string `json:"FriendlyName,omitempty"`
   379  	// The URL we call using `inbound_method` when a message is received by any phone number or short code in the Service. When this property is `null`, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `inbound_request_url` defined for the Messaging Service.
   380  	InboundRequestUrl *string `json:"InboundRequestUrl,omitempty"`
   381  	// The HTTP method we should use to call `inbound_request_url`. Can be `GET` or `POST` and the default is `POST`.
   382  	InboundMethod *string `json:"InboundMethod,omitempty"`
   383  	// The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service.
   384  	FallbackUrl *string `json:"FallbackUrl,omitempty"`
   385  	// The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`.
   386  	FallbackMethod *string `json:"FallbackMethod,omitempty"`
   387  	// The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery.
   388  	StatusCallback *string `json:"StatusCallback,omitempty"`
   389  	// Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance.
   390  	StickySender *bool `json:"StickySender,omitempty"`
   391  	// Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance.
   392  	MmsConverter *bool `json:"MmsConverter,omitempty"`
   393  	// Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance.
   394  	SmartEncoding *bool `json:"SmartEncoding,omitempty"`
   395  	//
   396  	ScanMessageContent *string `json:"ScanMessageContent,omitempty"`
   397  	// [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.
   398  	FallbackToLongCode *bool `json:"FallbackToLongCode,omitempty"`
   399  	// Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance.
   400  	AreaCodeGeomatch *bool `json:"AreaCodeGeomatch,omitempty"`
   401  	// How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`.
   402  	ValidityPeriod *int `json:"ValidityPeriod,omitempty"`
   403  	// Reserved.
   404  	SynchronousValidation *bool `json:"SynchronousValidation,omitempty"`
   405  	// A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`.
   406  	Usecase *string `json:"Usecase,omitempty"`
   407  	// A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service.
   408  	UseInboundWebhookOnNumber *bool `json:"UseInboundWebhookOnNumber,omitempty"`
   409  }
   410  
   411  func (params *UpdateServiceParams) SetFriendlyName(FriendlyName string) *UpdateServiceParams {
   412  	params.FriendlyName = &FriendlyName
   413  	return params
   414  }
   415  func (params *UpdateServiceParams) SetInboundRequestUrl(InboundRequestUrl string) *UpdateServiceParams {
   416  	params.InboundRequestUrl = &InboundRequestUrl
   417  	return params
   418  }
   419  func (params *UpdateServiceParams) SetInboundMethod(InboundMethod string) *UpdateServiceParams {
   420  	params.InboundMethod = &InboundMethod
   421  	return params
   422  }
   423  func (params *UpdateServiceParams) SetFallbackUrl(FallbackUrl string) *UpdateServiceParams {
   424  	params.FallbackUrl = &FallbackUrl
   425  	return params
   426  }
   427  func (params *UpdateServiceParams) SetFallbackMethod(FallbackMethod string) *UpdateServiceParams {
   428  	params.FallbackMethod = &FallbackMethod
   429  	return params
   430  }
   431  func (params *UpdateServiceParams) SetStatusCallback(StatusCallback string) *UpdateServiceParams {
   432  	params.StatusCallback = &StatusCallback
   433  	return params
   434  }
   435  func (params *UpdateServiceParams) SetStickySender(StickySender bool) *UpdateServiceParams {
   436  	params.StickySender = &StickySender
   437  	return params
   438  }
   439  func (params *UpdateServiceParams) SetMmsConverter(MmsConverter bool) *UpdateServiceParams {
   440  	params.MmsConverter = &MmsConverter
   441  	return params
   442  }
   443  func (params *UpdateServiceParams) SetSmartEncoding(SmartEncoding bool) *UpdateServiceParams {
   444  	params.SmartEncoding = &SmartEncoding
   445  	return params
   446  }
   447  func (params *UpdateServiceParams) SetScanMessageContent(ScanMessageContent string) *UpdateServiceParams {
   448  	params.ScanMessageContent = &ScanMessageContent
   449  	return params
   450  }
   451  func (params *UpdateServiceParams) SetFallbackToLongCode(FallbackToLongCode bool) *UpdateServiceParams {
   452  	params.FallbackToLongCode = &FallbackToLongCode
   453  	return params
   454  }
   455  func (params *UpdateServiceParams) SetAreaCodeGeomatch(AreaCodeGeomatch bool) *UpdateServiceParams {
   456  	params.AreaCodeGeomatch = &AreaCodeGeomatch
   457  	return params
   458  }
   459  func (params *UpdateServiceParams) SetValidityPeriod(ValidityPeriod int) *UpdateServiceParams {
   460  	params.ValidityPeriod = &ValidityPeriod
   461  	return params
   462  }
   463  func (params *UpdateServiceParams) SetSynchronousValidation(SynchronousValidation bool) *UpdateServiceParams {
   464  	params.SynchronousValidation = &SynchronousValidation
   465  	return params
   466  }
   467  func (params *UpdateServiceParams) SetUsecase(Usecase string) *UpdateServiceParams {
   468  	params.Usecase = &Usecase
   469  	return params
   470  }
   471  func (params *UpdateServiceParams) SetUseInboundWebhookOnNumber(UseInboundWebhookOnNumber bool) *UpdateServiceParams {
   472  	params.UseInboundWebhookOnNumber = &UseInboundWebhookOnNumber
   473  	return params
   474  }
   475  
   476  //
   477  func (c *ApiService) UpdateService(Sid string, params *UpdateServiceParams) (*MessagingV1Service, error) {
   478  	path := "/v1/Services/{Sid}"
   479  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   480  
   481  	data := url.Values{}
   482  	headers := make(map[string]interface{})
   483  
   484  	if params != nil && params.FriendlyName != nil {
   485  		data.Set("FriendlyName", *params.FriendlyName)
   486  	}
   487  	if params != nil && params.InboundRequestUrl != nil {
   488  		data.Set("InboundRequestUrl", *params.InboundRequestUrl)
   489  	}
   490  	if params != nil && params.InboundMethod != nil {
   491  		data.Set("InboundMethod", *params.InboundMethod)
   492  	}
   493  	if params != nil && params.FallbackUrl != nil {
   494  		data.Set("FallbackUrl", *params.FallbackUrl)
   495  	}
   496  	if params != nil && params.FallbackMethod != nil {
   497  		data.Set("FallbackMethod", *params.FallbackMethod)
   498  	}
   499  	if params != nil && params.StatusCallback != nil {
   500  		data.Set("StatusCallback", *params.StatusCallback)
   501  	}
   502  	if params != nil && params.StickySender != nil {
   503  		data.Set("StickySender", fmt.Sprint(*params.StickySender))
   504  	}
   505  	if params != nil && params.MmsConverter != nil {
   506  		data.Set("MmsConverter", fmt.Sprint(*params.MmsConverter))
   507  	}
   508  	if params != nil && params.SmartEncoding != nil {
   509  		data.Set("SmartEncoding", fmt.Sprint(*params.SmartEncoding))
   510  	}
   511  	if params != nil && params.ScanMessageContent != nil {
   512  		data.Set("ScanMessageContent", *params.ScanMessageContent)
   513  	}
   514  	if params != nil && params.FallbackToLongCode != nil {
   515  		data.Set("FallbackToLongCode", fmt.Sprint(*params.FallbackToLongCode))
   516  	}
   517  	if params != nil && params.AreaCodeGeomatch != nil {
   518  		data.Set("AreaCodeGeomatch", fmt.Sprint(*params.AreaCodeGeomatch))
   519  	}
   520  	if params != nil && params.ValidityPeriod != nil {
   521  		data.Set("ValidityPeriod", fmt.Sprint(*params.ValidityPeriod))
   522  	}
   523  	if params != nil && params.SynchronousValidation != nil {
   524  		data.Set("SynchronousValidation", fmt.Sprint(*params.SynchronousValidation))
   525  	}
   526  	if params != nil && params.Usecase != nil {
   527  		data.Set("Usecase", *params.Usecase)
   528  	}
   529  	if params != nil && params.UseInboundWebhookOnNumber != nil {
   530  		data.Set("UseInboundWebhookOnNumber", fmt.Sprint(*params.UseInboundWebhookOnNumber))
   531  	}
   532  
   533  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   534  	if err != nil {
   535  		return nil, err
   536  	}
   537  
   538  	defer resp.Body.Close()
   539  
   540  	ps := &MessagingV1Service{}
   541  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   542  		return nil, err
   543  	}
   544  
   545  	return ps, err
   546  }