github.com/twilio/twilio-go@v1.20.1/rest/api/v2010/accounts_applications.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  
    23  	"github.com/twilio/twilio-go/client"
    24  )
    25  
    26  // Optional parameters for the method 'CreateApplication'
    27  type CreateApplicationParams struct {
    28  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource.
    29  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
    30  	// The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
    31  	ApiVersion *string `json:"ApiVersion,omitempty"`
    32  	// The URL we should call when the phone number assigned to this application receives a call.
    33  	VoiceUrl *string `json:"VoiceUrl,omitempty"`
    34  	// The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
    35  	VoiceMethod *string `json:"VoiceMethod,omitempty"`
    36  	// The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
    37  	VoiceFallbackUrl *string `json:"VoiceFallbackUrl,omitempty"`
    38  	// The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
    39  	VoiceFallbackMethod *string `json:"VoiceFallbackMethod,omitempty"`
    40  	// The URL we should call using the `status_callback_method` to send status information to your application.
    41  	StatusCallback *string `json:"StatusCallback,omitempty"`
    42  	// The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
    43  	StatusCallbackMethod *string `json:"StatusCallbackMethod,omitempty"`
    44  	// Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
    45  	VoiceCallerIdLookup *bool `json:"VoiceCallerIdLookup,omitempty"`
    46  	// The URL we should call when the phone number receives an incoming SMS message.
    47  	SmsUrl *string `json:"SmsUrl,omitempty"`
    48  	// The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
    49  	SmsMethod *string `json:"SmsMethod,omitempty"`
    50  	// The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
    51  	SmsFallbackUrl *string `json:"SmsFallbackUrl,omitempty"`
    52  	// The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
    53  	SmsFallbackMethod *string `json:"SmsFallbackMethod,omitempty"`
    54  	// The URL we should call using a POST method to send status information about SMS messages sent by the application.
    55  	SmsStatusCallback *string `json:"SmsStatusCallback,omitempty"`
    56  	// The URL we should call using a POST method to send message status information to your application.
    57  	MessageStatusCallback *string `json:"MessageStatusCallback,omitempty"`
    58  	// A descriptive string that you create to describe the new application. It can be up to 64 characters long.
    59  	FriendlyName *string `json:"FriendlyName,omitempty"`
    60  	// Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
    61  	PublicApplicationConnectEnabled *bool `json:"PublicApplicationConnectEnabled,omitempty"`
    62  }
    63  
    64  func (params *CreateApplicationParams) SetPathAccountSid(PathAccountSid string) *CreateApplicationParams {
    65  	params.PathAccountSid = &PathAccountSid
    66  	return params
    67  }
    68  func (params *CreateApplicationParams) SetApiVersion(ApiVersion string) *CreateApplicationParams {
    69  	params.ApiVersion = &ApiVersion
    70  	return params
    71  }
    72  func (params *CreateApplicationParams) SetVoiceUrl(VoiceUrl string) *CreateApplicationParams {
    73  	params.VoiceUrl = &VoiceUrl
    74  	return params
    75  }
    76  func (params *CreateApplicationParams) SetVoiceMethod(VoiceMethod string) *CreateApplicationParams {
    77  	params.VoiceMethod = &VoiceMethod
    78  	return params
    79  }
    80  func (params *CreateApplicationParams) SetVoiceFallbackUrl(VoiceFallbackUrl string) *CreateApplicationParams {
    81  	params.VoiceFallbackUrl = &VoiceFallbackUrl
    82  	return params
    83  }
    84  func (params *CreateApplicationParams) SetVoiceFallbackMethod(VoiceFallbackMethod string) *CreateApplicationParams {
    85  	params.VoiceFallbackMethod = &VoiceFallbackMethod
    86  	return params
    87  }
    88  func (params *CreateApplicationParams) SetStatusCallback(StatusCallback string) *CreateApplicationParams {
    89  	params.StatusCallback = &StatusCallback
    90  	return params
    91  }
    92  func (params *CreateApplicationParams) SetStatusCallbackMethod(StatusCallbackMethod string) *CreateApplicationParams {
    93  	params.StatusCallbackMethod = &StatusCallbackMethod
    94  	return params
    95  }
    96  func (params *CreateApplicationParams) SetVoiceCallerIdLookup(VoiceCallerIdLookup bool) *CreateApplicationParams {
    97  	params.VoiceCallerIdLookup = &VoiceCallerIdLookup
    98  	return params
    99  }
   100  func (params *CreateApplicationParams) SetSmsUrl(SmsUrl string) *CreateApplicationParams {
   101  	params.SmsUrl = &SmsUrl
   102  	return params
   103  }
   104  func (params *CreateApplicationParams) SetSmsMethod(SmsMethod string) *CreateApplicationParams {
   105  	params.SmsMethod = &SmsMethod
   106  	return params
   107  }
   108  func (params *CreateApplicationParams) SetSmsFallbackUrl(SmsFallbackUrl string) *CreateApplicationParams {
   109  	params.SmsFallbackUrl = &SmsFallbackUrl
   110  	return params
   111  }
   112  func (params *CreateApplicationParams) SetSmsFallbackMethod(SmsFallbackMethod string) *CreateApplicationParams {
   113  	params.SmsFallbackMethod = &SmsFallbackMethod
   114  	return params
   115  }
   116  func (params *CreateApplicationParams) SetSmsStatusCallback(SmsStatusCallback string) *CreateApplicationParams {
   117  	params.SmsStatusCallback = &SmsStatusCallback
   118  	return params
   119  }
   120  func (params *CreateApplicationParams) SetMessageStatusCallback(MessageStatusCallback string) *CreateApplicationParams {
   121  	params.MessageStatusCallback = &MessageStatusCallback
   122  	return params
   123  }
   124  func (params *CreateApplicationParams) SetFriendlyName(FriendlyName string) *CreateApplicationParams {
   125  	params.FriendlyName = &FriendlyName
   126  	return params
   127  }
   128  func (params *CreateApplicationParams) SetPublicApplicationConnectEnabled(PublicApplicationConnectEnabled bool) *CreateApplicationParams {
   129  	params.PublicApplicationConnectEnabled = &PublicApplicationConnectEnabled
   130  	return params
   131  }
   132  
   133  // Create a new application within your account
   134  func (c *ApiService) CreateApplication(params *CreateApplicationParams) (*ApiV2010Application, error) {
   135  	path := "/2010-04-01/Accounts/{AccountSid}/Applications.json"
   136  	if params != nil && params.PathAccountSid != nil {
   137  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   138  	} else {
   139  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   140  	}
   141  
   142  	data := url.Values{}
   143  	headers := make(map[string]interface{})
   144  
   145  	if params != nil && params.ApiVersion != nil {
   146  		data.Set("ApiVersion", *params.ApiVersion)
   147  	}
   148  	if params != nil && params.VoiceUrl != nil {
   149  		data.Set("VoiceUrl", *params.VoiceUrl)
   150  	}
   151  	if params != nil && params.VoiceMethod != nil {
   152  		data.Set("VoiceMethod", *params.VoiceMethod)
   153  	}
   154  	if params != nil && params.VoiceFallbackUrl != nil {
   155  		data.Set("VoiceFallbackUrl", *params.VoiceFallbackUrl)
   156  	}
   157  	if params != nil && params.VoiceFallbackMethod != nil {
   158  		data.Set("VoiceFallbackMethod", *params.VoiceFallbackMethod)
   159  	}
   160  	if params != nil && params.StatusCallback != nil {
   161  		data.Set("StatusCallback", *params.StatusCallback)
   162  	}
   163  	if params != nil && params.StatusCallbackMethod != nil {
   164  		data.Set("StatusCallbackMethod", *params.StatusCallbackMethod)
   165  	}
   166  	if params != nil && params.VoiceCallerIdLookup != nil {
   167  		data.Set("VoiceCallerIdLookup", fmt.Sprint(*params.VoiceCallerIdLookup))
   168  	}
   169  	if params != nil && params.SmsUrl != nil {
   170  		data.Set("SmsUrl", *params.SmsUrl)
   171  	}
   172  	if params != nil && params.SmsMethod != nil {
   173  		data.Set("SmsMethod", *params.SmsMethod)
   174  	}
   175  	if params != nil && params.SmsFallbackUrl != nil {
   176  		data.Set("SmsFallbackUrl", *params.SmsFallbackUrl)
   177  	}
   178  	if params != nil && params.SmsFallbackMethod != nil {
   179  		data.Set("SmsFallbackMethod", *params.SmsFallbackMethod)
   180  	}
   181  	if params != nil && params.SmsStatusCallback != nil {
   182  		data.Set("SmsStatusCallback", *params.SmsStatusCallback)
   183  	}
   184  	if params != nil && params.MessageStatusCallback != nil {
   185  		data.Set("MessageStatusCallback", *params.MessageStatusCallback)
   186  	}
   187  	if params != nil && params.FriendlyName != nil {
   188  		data.Set("FriendlyName", *params.FriendlyName)
   189  	}
   190  	if params != nil && params.PublicApplicationConnectEnabled != nil {
   191  		data.Set("PublicApplicationConnectEnabled", fmt.Sprint(*params.PublicApplicationConnectEnabled))
   192  	}
   193  
   194  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   195  	if err != nil {
   196  		return nil, err
   197  	}
   198  
   199  	defer resp.Body.Close()
   200  
   201  	ps := &ApiV2010Application{}
   202  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   203  		return nil, err
   204  	}
   205  
   206  	return ps, err
   207  }
   208  
   209  // Optional parameters for the method 'DeleteApplication'
   210  type DeleteApplicationParams struct {
   211  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to delete.
   212  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   213  }
   214  
   215  func (params *DeleteApplicationParams) SetPathAccountSid(PathAccountSid string) *DeleteApplicationParams {
   216  	params.PathAccountSid = &PathAccountSid
   217  	return params
   218  }
   219  
   220  // Delete the application by the specified application sid
   221  func (c *ApiService) DeleteApplication(Sid string, params *DeleteApplicationParams) error {
   222  	path := "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json"
   223  	if params != nil && params.PathAccountSid != nil {
   224  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   225  	} else {
   226  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   227  	}
   228  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   229  
   230  	data := url.Values{}
   231  	headers := make(map[string]interface{})
   232  
   233  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
   234  	if err != nil {
   235  		return err
   236  	}
   237  
   238  	defer resp.Body.Close()
   239  
   240  	return nil
   241  }
   242  
   243  // Optional parameters for the method 'FetchApplication'
   244  type FetchApplicationParams struct {
   245  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resource to fetch.
   246  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   247  }
   248  
   249  func (params *FetchApplicationParams) SetPathAccountSid(PathAccountSid string) *FetchApplicationParams {
   250  	params.PathAccountSid = &PathAccountSid
   251  	return params
   252  }
   253  
   254  // Fetch the application specified by the provided sid
   255  func (c *ApiService) FetchApplication(Sid string, params *FetchApplicationParams) (*ApiV2010Application, error) {
   256  	path := "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json"
   257  	if params != nil && params.PathAccountSid != nil {
   258  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   259  	} else {
   260  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   261  	}
   262  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   263  
   264  	data := url.Values{}
   265  	headers := make(map[string]interface{})
   266  
   267  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   268  	if err != nil {
   269  		return nil, err
   270  	}
   271  
   272  	defer resp.Body.Close()
   273  
   274  	ps := &ApiV2010Application{}
   275  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   276  		return nil, err
   277  	}
   278  
   279  	return ps, err
   280  }
   281  
   282  // Optional parameters for the method 'ListApplication'
   283  type ListApplicationParams struct {
   284  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to read.
   285  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   286  	// The string that identifies the Application resources to read.
   287  	FriendlyName *string `json:"FriendlyName,omitempty"`
   288  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   289  	PageSize *int `json:"PageSize,omitempty"`
   290  	// Max number of records to return.
   291  	Limit *int `json:"limit,omitempty"`
   292  }
   293  
   294  func (params *ListApplicationParams) SetPathAccountSid(PathAccountSid string) *ListApplicationParams {
   295  	params.PathAccountSid = &PathAccountSid
   296  	return params
   297  }
   298  func (params *ListApplicationParams) SetFriendlyName(FriendlyName string) *ListApplicationParams {
   299  	params.FriendlyName = &FriendlyName
   300  	return params
   301  }
   302  func (params *ListApplicationParams) SetPageSize(PageSize int) *ListApplicationParams {
   303  	params.PageSize = &PageSize
   304  	return params
   305  }
   306  func (params *ListApplicationParams) SetLimit(Limit int) *ListApplicationParams {
   307  	params.Limit = &Limit
   308  	return params
   309  }
   310  
   311  // Retrieve a single page of Application records from the API. Request is executed immediately.
   312  func (c *ApiService) PageApplication(params *ListApplicationParams, pageToken, pageNumber string) (*ListApplicationResponse, error) {
   313  	path := "/2010-04-01/Accounts/{AccountSid}/Applications.json"
   314  
   315  	if params != nil && params.PathAccountSid != nil {
   316  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   317  	} else {
   318  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   319  	}
   320  
   321  	data := url.Values{}
   322  	headers := make(map[string]interface{})
   323  
   324  	if params != nil && params.FriendlyName != nil {
   325  		data.Set("FriendlyName", *params.FriendlyName)
   326  	}
   327  	if params != nil && params.PageSize != nil {
   328  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   329  	}
   330  
   331  	if pageToken != "" {
   332  		data.Set("PageToken", pageToken)
   333  	}
   334  	if pageNumber != "" {
   335  		data.Set("Page", pageNumber)
   336  	}
   337  
   338  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   339  	if err != nil {
   340  		return nil, err
   341  	}
   342  
   343  	defer resp.Body.Close()
   344  
   345  	ps := &ListApplicationResponse{}
   346  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   347  		return nil, err
   348  	}
   349  
   350  	return ps, err
   351  }
   352  
   353  // Lists Application records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   354  func (c *ApiService) ListApplication(params *ListApplicationParams) ([]ApiV2010Application, error) {
   355  	response, errors := c.StreamApplication(params)
   356  
   357  	records := make([]ApiV2010Application, 0)
   358  	for record := range response {
   359  		records = append(records, record)
   360  	}
   361  
   362  	if err := <-errors; err != nil {
   363  		return nil, err
   364  	}
   365  
   366  	return records, nil
   367  }
   368  
   369  // Streams Application records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   370  func (c *ApiService) StreamApplication(params *ListApplicationParams) (chan ApiV2010Application, chan error) {
   371  	if params == nil {
   372  		params = &ListApplicationParams{}
   373  	}
   374  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   375  
   376  	recordChannel := make(chan ApiV2010Application, 1)
   377  	errorChannel := make(chan error, 1)
   378  
   379  	response, err := c.PageApplication(params, "", "")
   380  	if err != nil {
   381  		errorChannel <- err
   382  		close(recordChannel)
   383  		close(errorChannel)
   384  	} else {
   385  		go c.streamApplication(response, params, recordChannel, errorChannel)
   386  	}
   387  
   388  	return recordChannel, errorChannel
   389  }
   390  
   391  func (c *ApiService) streamApplication(response *ListApplicationResponse, params *ListApplicationParams, recordChannel chan ApiV2010Application, errorChannel chan error) {
   392  	curRecord := 1
   393  
   394  	for response != nil {
   395  		responseRecords := response.Applications
   396  		for item := range responseRecords {
   397  			recordChannel <- responseRecords[item]
   398  			curRecord += 1
   399  			if params.Limit != nil && *params.Limit < curRecord {
   400  				close(recordChannel)
   401  				close(errorChannel)
   402  				return
   403  			}
   404  		}
   405  
   406  		record, err := client.GetNext(c.baseURL, response, c.getNextListApplicationResponse)
   407  		if err != nil {
   408  			errorChannel <- err
   409  			break
   410  		} else if record == nil {
   411  			break
   412  		}
   413  
   414  		response = record.(*ListApplicationResponse)
   415  	}
   416  
   417  	close(recordChannel)
   418  	close(errorChannel)
   419  }
   420  
   421  func (c *ApiService) getNextListApplicationResponse(nextPageUrl string) (interface{}, error) {
   422  	if nextPageUrl == "" {
   423  		return nil, nil
   424  	}
   425  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   426  	if err != nil {
   427  		return nil, err
   428  	}
   429  
   430  	defer resp.Body.Close()
   431  
   432  	ps := &ListApplicationResponse{}
   433  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   434  		return nil, err
   435  	}
   436  	return ps, nil
   437  }
   438  
   439  // Optional parameters for the method 'UpdateApplication'
   440  type UpdateApplicationParams struct {
   441  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to update.
   442  	PathAccountSid *string `json:"PathAccountSid,omitempty"`
   443  	// A descriptive string that you create to describe the resource. It can be up to 64 characters long.
   444  	FriendlyName *string `json:"FriendlyName,omitempty"`
   445  	// The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
   446  	ApiVersion *string `json:"ApiVersion,omitempty"`
   447  	// The URL we should call when the phone number assigned to this application receives a call.
   448  	VoiceUrl *string `json:"VoiceUrl,omitempty"`
   449  	// The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
   450  	VoiceMethod *string `json:"VoiceMethod,omitempty"`
   451  	// The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
   452  	VoiceFallbackUrl *string `json:"VoiceFallbackUrl,omitempty"`
   453  	// The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
   454  	VoiceFallbackMethod *string `json:"VoiceFallbackMethod,omitempty"`
   455  	// The URL we should call using the `status_callback_method` to send status information to your application.
   456  	StatusCallback *string `json:"StatusCallback,omitempty"`
   457  	// The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
   458  	StatusCallbackMethod *string `json:"StatusCallbackMethod,omitempty"`
   459  	// Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
   460  	VoiceCallerIdLookup *bool `json:"VoiceCallerIdLookup,omitempty"`
   461  	// The URL we should call when the phone number receives an incoming SMS message.
   462  	SmsUrl *string `json:"SmsUrl,omitempty"`
   463  	// The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
   464  	SmsMethod *string `json:"SmsMethod,omitempty"`
   465  	// The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
   466  	SmsFallbackUrl *string `json:"SmsFallbackUrl,omitempty"`
   467  	// The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
   468  	SmsFallbackMethod *string `json:"SmsFallbackMethod,omitempty"`
   469  	// Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
   470  	SmsStatusCallback *string `json:"SmsStatusCallback,omitempty"`
   471  	// The URL we should call using a POST method to send message status information to your application.
   472  	MessageStatusCallback *string `json:"MessageStatusCallback,omitempty"`
   473  	// Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
   474  	PublicApplicationConnectEnabled *bool `json:"PublicApplicationConnectEnabled,omitempty"`
   475  }
   476  
   477  func (params *UpdateApplicationParams) SetPathAccountSid(PathAccountSid string) *UpdateApplicationParams {
   478  	params.PathAccountSid = &PathAccountSid
   479  	return params
   480  }
   481  func (params *UpdateApplicationParams) SetFriendlyName(FriendlyName string) *UpdateApplicationParams {
   482  	params.FriendlyName = &FriendlyName
   483  	return params
   484  }
   485  func (params *UpdateApplicationParams) SetApiVersion(ApiVersion string) *UpdateApplicationParams {
   486  	params.ApiVersion = &ApiVersion
   487  	return params
   488  }
   489  func (params *UpdateApplicationParams) SetVoiceUrl(VoiceUrl string) *UpdateApplicationParams {
   490  	params.VoiceUrl = &VoiceUrl
   491  	return params
   492  }
   493  func (params *UpdateApplicationParams) SetVoiceMethod(VoiceMethod string) *UpdateApplicationParams {
   494  	params.VoiceMethod = &VoiceMethod
   495  	return params
   496  }
   497  func (params *UpdateApplicationParams) SetVoiceFallbackUrl(VoiceFallbackUrl string) *UpdateApplicationParams {
   498  	params.VoiceFallbackUrl = &VoiceFallbackUrl
   499  	return params
   500  }
   501  func (params *UpdateApplicationParams) SetVoiceFallbackMethod(VoiceFallbackMethod string) *UpdateApplicationParams {
   502  	params.VoiceFallbackMethod = &VoiceFallbackMethod
   503  	return params
   504  }
   505  func (params *UpdateApplicationParams) SetStatusCallback(StatusCallback string) *UpdateApplicationParams {
   506  	params.StatusCallback = &StatusCallback
   507  	return params
   508  }
   509  func (params *UpdateApplicationParams) SetStatusCallbackMethod(StatusCallbackMethod string) *UpdateApplicationParams {
   510  	params.StatusCallbackMethod = &StatusCallbackMethod
   511  	return params
   512  }
   513  func (params *UpdateApplicationParams) SetVoiceCallerIdLookup(VoiceCallerIdLookup bool) *UpdateApplicationParams {
   514  	params.VoiceCallerIdLookup = &VoiceCallerIdLookup
   515  	return params
   516  }
   517  func (params *UpdateApplicationParams) SetSmsUrl(SmsUrl string) *UpdateApplicationParams {
   518  	params.SmsUrl = &SmsUrl
   519  	return params
   520  }
   521  func (params *UpdateApplicationParams) SetSmsMethod(SmsMethod string) *UpdateApplicationParams {
   522  	params.SmsMethod = &SmsMethod
   523  	return params
   524  }
   525  func (params *UpdateApplicationParams) SetSmsFallbackUrl(SmsFallbackUrl string) *UpdateApplicationParams {
   526  	params.SmsFallbackUrl = &SmsFallbackUrl
   527  	return params
   528  }
   529  func (params *UpdateApplicationParams) SetSmsFallbackMethod(SmsFallbackMethod string) *UpdateApplicationParams {
   530  	params.SmsFallbackMethod = &SmsFallbackMethod
   531  	return params
   532  }
   533  func (params *UpdateApplicationParams) SetSmsStatusCallback(SmsStatusCallback string) *UpdateApplicationParams {
   534  	params.SmsStatusCallback = &SmsStatusCallback
   535  	return params
   536  }
   537  func (params *UpdateApplicationParams) SetMessageStatusCallback(MessageStatusCallback string) *UpdateApplicationParams {
   538  	params.MessageStatusCallback = &MessageStatusCallback
   539  	return params
   540  }
   541  func (params *UpdateApplicationParams) SetPublicApplicationConnectEnabled(PublicApplicationConnectEnabled bool) *UpdateApplicationParams {
   542  	params.PublicApplicationConnectEnabled = &PublicApplicationConnectEnabled
   543  	return params
   544  }
   545  
   546  // Updates the application's properties
   547  func (c *ApiService) UpdateApplication(Sid string, params *UpdateApplicationParams) (*ApiV2010Application, error) {
   548  	path := "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json"
   549  	if params != nil && params.PathAccountSid != nil {
   550  		path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
   551  	} else {
   552  		path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
   553  	}
   554  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   555  
   556  	data := url.Values{}
   557  	headers := make(map[string]interface{})
   558  
   559  	if params != nil && params.FriendlyName != nil {
   560  		data.Set("FriendlyName", *params.FriendlyName)
   561  	}
   562  	if params != nil && params.ApiVersion != nil {
   563  		data.Set("ApiVersion", *params.ApiVersion)
   564  	}
   565  	if params != nil && params.VoiceUrl != nil {
   566  		data.Set("VoiceUrl", *params.VoiceUrl)
   567  	}
   568  	if params != nil && params.VoiceMethod != nil {
   569  		data.Set("VoiceMethod", *params.VoiceMethod)
   570  	}
   571  	if params != nil && params.VoiceFallbackUrl != nil {
   572  		data.Set("VoiceFallbackUrl", *params.VoiceFallbackUrl)
   573  	}
   574  	if params != nil && params.VoiceFallbackMethod != nil {
   575  		data.Set("VoiceFallbackMethod", *params.VoiceFallbackMethod)
   576  	}
   577  	if params != nil && params.StatusCallback != nil {
   578  		data.Set("StatusCallback", *params.StatusCallback)
   579  	}
   580  	if params != nil && params.StatusCallbackMethod != nil {
   581  		data.Set("StatusCallbackMethod", *params.StatusCallbackMethod)
   582  	}
   583  	if params != nil && params.VoiceCallerIdLookup != nil {
   584  		data.Set("VoiceCallerIdLookup", fmt.Sprint(*params.VoiceCallerIdLookup))
   585  	}
   586  	if params != nil && params.SmsUrl != nil {
   587  		data.Set("SmsUrl", *params.SmsUrl)
   588  	}
   589  	if params != nil && params.SmsMethod != nil {
   590  		data.Set("SmsMethod", *params.SmsMethod)
   591  	}
   592  	if params != nil && params.SmsFallbackUrl != nil {
   593  		data.Set("SmsFallbackUrl", *params.SmsFallbackUrl)
   594  	}
   595  	if params != nil && params.SmsFallbackMethod != nil {
   596  		data.Set("SmsFallbackMethod", *params.SmsFallbackMethod)
   597  	}
   598  	if params != nil && params.SmsStatusCallback != nil {
   599  		data.Set("SmsStatusCallback", *params.SmsStatusCallback)
   600  	}
   601  	if params != nil && params.MessageStatusCallback != nil {
   602  		data.Set("MessageStatusCallback", *params.MessageStatusCallback)
   603  	}
   604  	if params != nil && params.PublicApplicationConnectEnabled != nil {
   605  		data.Set("PublicApplicationConnectEnabled", fmt.Sprint(*params.PublicApplicationConnectEnabled))
   606  	}
   607  
   608  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   609  	if err != nil {
   610  		return nil, err
   611  	}
   612  
   613  	defer resp.Body.Close()
   614  
   615  	ps := &ApiV2010Application{}
   616  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   617  		return nil, err
   618  	}
   619  
   620  	return ps, err
   621  }