github.com/twilio/twilio-go@v1.20.1/rest/verify/v2/services.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Verify
     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 verification service. It can be up to 32 characters long. **This value should not contain PII.**
    29  	FriendlyName *string `json:"FriendlyName,omitempty"`
    30  	// The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.
    31  	CodeLength *int `json:"CodeLength,omitempty"`
    32  	// Whether to perform a lookup with each verification started and return info about the phone number.
    33  	LookupEnabled *bool `json:"LookupEnabled,omitempty"`
    34  	// Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
    35  	SkipSmsToLandlines *bool `json:"SkipSmsToLandlines,omitempty"`
    36  	// Whether to ask the user to press a number before delivering the verify code in a phone call.
    37  	DtmfInputRequired *bool `json:"DtmfInputRequired,omitempty"`
    38  	// The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
    39  	TtsName *string `json:"TtsName,omitempty"`
    40  	// Whether to pass PSD2 transaction parameters when starting a verification.
    41  	Psd2Enabled *bool `json:"Psd2Enabled,omitempty"`
    42  	// Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code`
    43  	DoNotShareWarningEnabled *bool `json:"DoNotShareWarningEnabled,omitempty"`
    44  	// Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers.
    45  	CustomCodeEnabled *bool `json:"CustomCodeEnabled,omitempty"`
    46  	// Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead.
    47  	PushIncludeDate *bool `json:"Push.IncludeDate,omitempty"`
    48  	// Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
    49  	PushApnCredentialSid *string `json:"Push.ApnCredentialSid,omitempty"`
    50  	// Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
    51  	PushFcmCredentialSid *string `json:"Push.FcmCredentialSid,omitempty"`
    52  	// Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. Defaults to the service friendly name if not provided.
    53  	TotpIssuer *string `json:"Totp.Issuer,omitempty"`
    54  	// Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds
    55  	TotpTimeStep *int `json:"Totp.TimeStep,omitempty"`
    56  	// Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6
    57  	TotpCodeLength *int `json:"Totp.CodeLength,omitempty"`
    58  	// Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1
    59  	TotpSkew *int `json:"Totp.Skew,omitempty"`
    60  	// The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only.
    61  	DefaultTemplateSid *string `json:"DefaultTemplateSid,omitempty"`
    62  	// The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users.
    63  	WhatsappMsgServiceSid *string `json:"Whatsapp.MsgServiceSid,omitempty"`
    64  	// The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID.
    65  	WhatsappFrom *string `json:"Whatsapp.From,omitempty"`
    66  	// Whether to allow verifications from the service to reach the stream-events sinks if configured
    67  	VerifyEventSubscriptionEnabled *bool `json:"VerifyEventSubscriptionEnabled,omitempty"`
    68  }
    69  
    70  func (params *CreateServiceParams) SetFriendlyName(FriendlyName string) *CreateServiceParams {
    71  	params.FriendlyName = &FriendlyName
    72  	return params
    73  }
    74  func (params *CreateServiceParams) SetCodeLength(CodeLength int) *CreateServiceParams {
    75  	params.CodeLength = &CodeLength
    76  	return params
    77  }
    78  func (params *CreateServiceParams) SetLookupEnabled(LookupEnabled bool) *CreateServiceParams {
    79  	params.LookupEnabled = &LookupEnabled
    80  	return params
    81  }
    82  func (params *CreateServiceParams) SetSkipSmsToLandlines(SkipSmsToLandlines bool) *CreateServiceParams {
    83  	params.SkipSmsToLandlines = &SkipSmsToLandlines
    84  	return params
    85  }
    86  func (params *CreateServiceParams) SetDtmfInputRequired(DtmfInputRequired bool) *CreateServiceParams {
    87  	params.DtmfInputRequired = &DtmfInputRequired
    88  	return params
    89  }
    90  func (params *CreateServiceParams) SetTtsName(TtsName string) *CreateServiceParams {
    91  	params.TtsName = &TtsName
    92  	return params
    93  }
    94  func (params *CreateServiceParams) SetPsd2Enabled(Psd2Enabled bool) *CreateServiceParams {
    95  	params.Psd2Enabled = &Psd2Enabled
    96  	return params
    97  }
    98  func (params *CreateServiceParams) SetDoNotShareWarningEnabled(DoNotShareWarningEnabled bool) *CreateServiceParams {
    99  	params.DoNotShareWarningEnabled = &DoNotShareWarningEnabled
   100  	return params
   101  }
   102  func (params *CreateServiceParams) SetCustomCodeEnabled(CustomCodeEnabled bool) *CreateServiceParams {
   103  	params.CustomCodeEnabled = &CustomCodeEnabled
   104  	return params
   105  }
   106  func (params *CreateServiceParams) SetPushIncludeDate(PushIncludeDate bool) *CreateServiceParams {
   107  	params.PushIncludeDate = &PushIncludeDate
   108  	return params
   109  }
   110  func (params *CreateServiceParams) SetPushApnCredentialSid(PushApnCredentialSid string) *CreateServiceParams {
   111  	params.PushApnCredentialSid = &PushApnCredentialSid
   112  	return params
   113  }
   114  func (params *CreateServiceParams) SetPushFcmCredentialSid(PushFcmCredentialSid string) *CreateServiceParams {
   115  	params.PushFcmCredentialSid = &PushFcmCredentialSid
   116  	return params
   117  }
   118  func (params *CreateServiceParams) SetTotpIssuer(TotpIssuer string) *CreateServiceParams {
   119  	params.TotpIssuer = &TotpIssuer
   120  	return params
   121  }
   122  func (params *CreateServiceParams) SetTotpTimeStep(TotpTimeStep int) *CreateServiceParams {
   123  	params.TotpTimeStep = &TotpTimeStep
   124  	return params
   125  }
   126  func (params *CreateServiceParams) SetTotpCodeLength(TotpCodeLength int) *CreateServiceParams {
   127  	params.TotpCodeLength = &TotpCodeLength
   128  	return params
   129  }
   130  func (params *CreateServiceParams) SetTotpSkew(TotpSkew int) *CreateServiceParams {
   131  	params.TotpSkew = &TotpSkew
   132  	return params
   133  }
   134  func (params *CreateServiceParams) SetDefaultTemplateSid(DefaultTemplateSid string) *CreateServiceParams {
   135  	params.DefaultTemplateSid = &DefaultTemplateSid
   136  	return params
   137  }
   138  func (params *CreateServiceParams) SetWhatsappMsgServiceSid(WhatsappMsgServiceSid string) *CreateServiceParams {
   139  	params.WhatsappMsgServiceSid = &WhatsappMsgServiceSid
   140  	return params
   141  }
   142  func (params *CreateServiceParams) SetWhatsappFrom(WhatsappFrom string) *CreateServiceParams {
   143  	params.WhatsappFrom = &WhatsappFrom
   144  	return params
   145  }
   146  func (params *CreateServiceParams) SetVerifyEventSubscriptionEnabled(VerifyEventSubscriptionEnabled bool) *CreateServiceParams {
   147  	params.VerifyEventSubscriptionEnabled = &VerifyEventSubscriptionEnabled
   148  	return params
   149  }
   150  
   151  // Create a new Verification Service.
   152  func (c *ApiService) CreateService(params *CreateServiceParams) (*VerifyV2Service, error) {
   153  	path := "/v2/Services"
   154  
   155  	data := url.Values{}
   156  	headers := make(map[string]interface{})
   157  
   158  	if params != nil && params.FriendlyName != nil {
   159  		data.Set("FriendlyName", *params.FriendlyName)
   160  	}
   161  	if params != nil && params.CodeLength != nil {
   162  		data.Set("CodeLength", fmt.Sprint(*params.CodeLength))
   163  	}
   164  	if params != nil && params.LookupEnabled != nil {
   165  		data.Set("LookupEnabled", fmt.Sprint(*params.LookupEnabled))
   166  	}
   167  	if params != nil && params.SkipSmsToLandlines != nil {
   168  		data.Set("SkipSmsToLandlines", fmt.Sprint(*params.SkipSmsToLandlines))
   169  	}
   170  	if params != nil && params.DtmfInputRequired != nil {
   171  		data.Set("DtmfInputRequired", fmt.Sprint(*params.DtmfInputRequired))
   172  	}
   173  	if params != nil && params.TtsName != nil {
   174  		data.Set("TtsName", *params.TtsName)
   175  	}
   176  	if params != nil && params.Psd2Enabled != nil {
   177  		data.Set("Psd2Enabled", fmt.Sprint(*params.Psd2Enabled))
   178  	}
   179  	if params != nil && params.DoNotShareWarningEnabled != nil {
   180  		data.Set("DoNotShareWarningEnabled", fmt.Sprint(*params.DoNotShareWarningEnabled))
   181  	}
   182  	if params != nil && params.CustomCodeEnabled != nil {
   183  		data.Set("CustomCodeEnabled", fmt.Sprint(*params.CustomCodeEnabled))
   184  	}
   185  	if params != nil && params.PushIncludeDate != nil {
   186  		data.Set("Push.IncludeDate", fmt.Sprint(*params.PushIncludeDate))
   187  	}
   188  	if params != nil && params.PushApnCredentialSid != nil {
   189  		data.Set("Push.ApnCredentialSid", *params.PushApnCredentialSid)
   190  	}
   191  	if params != nil && params.PushFcmCredentialSid != nil {
   192  		data.Set("Push.FcmCredentialSid", *params.PushFcmCredentialSid)
   193  	}
   194  	if params != nil && params.TotpIssuer != nil {
   195  		data.Set("Totp.Issuer", *params.TotpIssuer)
   196  	}
   197  	if params != nil && params.TotpTimeStep != nil {
   198  		data.Set("Totp.TimeStep", fmt.Sprint(*params.TotpTimeStep))
   199  	}
   200  	if params != nil && params.TotpCodeLength != nil {
   201  		data.Set("Totp.CodeLength", fmt.Sprint(*params.TotpCodeLength))
   202  	}
   203  	if params != nil && params.TotpSkew != nil {
   204  		data.Set("Totp.Skew", fmt.Sprint(*params.TotpSkew))
   205  	}
   206  	if params != nil && params.DefaultTemplateSid != nil {
   207  		data.Set("DefaultTemplateSid", *params.DefaultTemplateSid)
   208  	}
   209  	if params != nil && params.WhatsappMsgServiceSid != nil {
   210  		data.Set("Whatsapp.MsgServiceSid", *params.WhatsappMsgServiceSid)
   211  	}
   212  	if params != nil && params.WhatsappFrom != nil {
   213  		data.Set("Whatsapp.From", *params.WhatsappFrom)
   214  	}
   215  	if params != nil && params.VerifyEventSubscriptionEnabled != nil {
   216  		data.Set("VerifyEventSubscriptionEnabled", fmt.Sprint(*params.VerifyEventSubscriptionEnabled))
   217  	}
   218  
   219  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   220  	if err != nil {
   221  		return nil, err
   222  	}
   223  
   224  	defer resp.Body.Close()
   225  
   226  	ps := &VerifyV2Service{}
   227  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   228  		return nil, err
   229  	}
   230  
   231  	return ps, err
   232  }
   233  
   234  // Delete a specific Verification Service Instance.
   235  func (c *ApiService) DeleteService(Sid string) error {
   236  	path := "/v2/Services/{Sid}"
   237  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   238  
   239  	data := url.Values{}
   240  	headers := make(map[string]interface{})
   241  
   242  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
   243  	if err != nil {
   244  		return err
   245  	}
   246  
   247  	defer resp.Body.Close()
   248  
   249  	return nil
   250  }
   251  
   252  // Fetch specific Verification Service Instance.
   253  func (c *ApiService) FetchService(Sid string) (*VerifyV2Service, error) {
   254  	path := "/v2/Services/{Sid}"
   255  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   256  
   257  	data := url.Values{}
   258  	headers := make(map[string]interface{})
   259  
   260  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   261  	if err != nil {
   262  		return nil, err
   263  	}
   264  
   265  	defer resp.Body.Close()
   266  
   267  	ps := &VerifyV2Service{}
   268  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   269  		return nil, err
   270  	}
   271  
   272  	return ps, err
   273  }
   274  
   275  // Optional parameters for the method 'ListService'
   276  type ListServiceParams struct {
   277  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   278  	PageSize *int `json:"PageSize,omitempty"`
   279  	// Max number of records to return.
   280  	Limit *int `json:"limit,omitempty"`
   281  }
   282  
   283  func (params *ListServiceParams) SetPageSize(PageSize int) *ListServiceParams {
   284  	params.PageSize = &PageSize
   285  	return params
   286  }
   287  func (params *ListServiceParams) SetLimit(Limit int) *ListServiceParams {
   288  	params.Limit = &Limit
   289  	return params
   290  }
   291  
   292  // Retrieve a single page of Service records from the API. Request is executed immediately.
   293  func (c *ApiService) PageService(params *ListServiceParams, pageToken, pageNumber string) (*ListServiceResponse, error) {
   294  	path := "/v2/Services"
   295  
   296  	data := url.Values{}
   297  	headers := make(map[string]interface{})
   298  
   299  	if params != nil && params.PageSize != nil {
   300  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   301  	}
   302  
   303  	if pageToken != "" {
   304  		data.Set("PageToken", pageToken)
   305  	}
   306  	if pageNumber != "" {
   307  		data.Set("Page", pageNumber)
   308  	}
   309  
   310  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   311  	if err != nil {
   312  		return nil, err
   313  	}
   314  
   315  	defer resp.Body.Close()
   316  
   317  	ps := &ListServiceResponse{}
   318  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   319  		return nil, err
   320  	}
   321  
   322  	return ps, err
   323  }
   324  
   325  // Lists Service records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   326  func (c *ApiService) ListService(params *ListServiceParams) ([]VerifyV2Service, error) {
   327  	response, errors := c.StreamService(params)
   328  
   329  	records := make([]VerifyV2Service, 0)
   330  	for record := range response {
   331  		records = append(records, record)
   332  	}
   333  
   334  	if err := <-errors; err != nil {
   335  		return nil, err
   336  	}
   337  
   338  	return records, nil
   339  }
   340  
   341  // Streams Service records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   342  func (c *ApiService) StreamService(params *ListServiceParams) (chan VerifyV2Service, chan error) {
   343  	if params == nil {
   344  		params = &ListServiceParams{}
   345  	}
   346  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   347  
   348  	recordChannel := make(chan VerifyV2Service, 1)
   349  	errorChannel := make(chan error, 1)
   350  
   351  	response, err := c.PageService(params, "", "")
   352  	if err != nil {
   353  		errorChannel <- err
   354  		close(recordChannel)
   355  		close(errorChannel)
   356  	} else {
   357  		go c.streamService(response, params, recordChannel, errorChannel)
   358  	}
   359  
   360  	return recordChannel, errorChannel
   361  }
   362  
   363  func (c *ApiService) streamService(response *ListServiceResponse, params *ListServiceParams, recordChannel chan VerifyV2Service, errorChannel chan error) {
   364  	curRecord := 1
   365  
   366  	for response != nil {
   367  		responseRecords := response.Services
   368  		for item := range responseRecords {
   369  			recordChannel <- responseRecords[item]
   370  			curRecord += 1
   371  			if params.Limit != nil && *params.Limit < curRecord {
   372  				close(recordChannel)
   373  				close(errorChannel)
   374  				return
   375  			}
   376  		}
   377  
   378  		record, err := client.GetNext(c.baseURL, response, c.getNextListServiceResponse)
   379  		if err != nil {
   380  			errorChannel <- err
   381  			break
   382  		} else if record == nil {
   383  			break
   384  		}
   385  
   386  		response = record.(*ListServiceResponse)
   387  	}
   388  
   389  	close(recordChannel)
   390  	close(errorChannel)
   391  }
   392  
   393  func (c *ApiService) getNextListServiceResponse(nextPageUrl string) (interface{}, error) {
   394  	if nextPageUrl == "" {
   395  		return nil, nil
   396  	}
   397  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   398  	if err != nil {
   399  		return nil, err
   400  	}
   401  
   402  	defer resp.Body.Close()
   403  
   404  	ps := &ListServiceResponse{}
   405  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   406  		return nil, err
   407  	}
   408  	return ps, nil
   409  }
   410  
   411  // Optional parameters for the method 'UpdateService'
   412  type UpdateServiceParams struct {
   413  	// A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.**
   414  	FriendlyName *string `json:"FriendlyName,omitempty"`
   415  	// The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.
   416  	CodeLength *int `json:"CodeLength,omitempty"`
   417  	// Whether to perform a lookup with each verification started and return info about the phone number.
   418  	LookupEnabled *bool `json:"LookupEnabled,omitempty"`
   419  	// Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
   420  	SkipSmsToLandlines *bool `json:"SkipSmsToLandlines,omitempty"`
   421  	// Whether to ask the user to press a number before delivering the verify code in a phone call.
   422  	DtmfInputRequired *bool `json:"DtmfInputRequired,omitempty"`
   423  	// The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
   424  	TtsName *string `json:"TtsName,omitempty"`
   425  	// Whether to pass PSD2 transaction parameters when starting a verification.
   426  	Psd2Enabled *bool `json:"Psd2Enabled,omitempty"`
   427  	// Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.**
   428  	DoNotShareWarningEnabled *bool `json:"DoNotShareWarningEnabled,omitempty"`
   429  	// Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers.
   430  	CustomCodeEnabled *bool `json:"CustomCodeEnabled,omitempty"`
   431  	// Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter.
   432  	PushIncludeDate *bool `json:"Push.IncludeDate,omitempty"`
   433  	// Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
   434  	PushApnCredentialSid *string `json:"Push.ApnCredentialSid,omitempty"`
   435  	// Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
   436  	PushFcmCredentialSid *string `json:"Push.FcmCredentialSid,omitempty"`
   437  	// Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI.
   438  	TotpIssuer *string `json:"Totp.Issuer,omitempty"`
   439  	// Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds
   440  	TotpTimeStep *int `json:"Totp.TimeStep,omitempty"`
   441  	// Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6
   442  	TotpCodeLength *int `json:"Totp.CodeLength,omitempty"`
   443  	// Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1
   444  	TotpSkew *int `json:"Totp.Skew,omitempty"`
   445  	// The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only.
   446  	DefaultTemplateSid *string `json:"DefaultTemplateSid,omitempty"`
   447  	// The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service.
   448  	WhatsappMsgServiceSid *string `json:"Whatsapp.MsgServiceSid,omitempty"`
   449  	// The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service.
   450  	WhatsappFrom *string `json:"Whatsapp.From,omitempty"`
   451  	// Whether to allow verifications from the service to reach the stream-events sinks if configured
   452  	VerifyEventSubscriptionEnabled *bool `json:"VerifyEventSubscriptionEnabled,omitempty"`
   453  }
   454  
   455  func (params *UpdateServiceParams) SetFriendlyName(FriendlyName string) *UpdateServiceParams {
   456  	params.FriendlyName = &FriendlyName
   457  	return params
   458  }
   459  func (params *UpdateServiceParams) SetCodeLength(CodeLength int) *UpdateServiceParams {
   460  	params.CodeLength = &CodeLength
   461  	return params
   462  }
   463  func (params *UpdateServiceParams) SetLookupEnabled(LookupEnabled bool) *UpdateServiceParams {
   464  	params.LookupEnabled = &LookupEnabled
   465  	return params
   466  }
   467  func (params *UpdateServiceParams) SetSkipSmsToLandlines(SkipSmsToLandlines bool) *UpdateServiceParams {
   468  	params.SkipSmsToLandlines = &SkipSmsToLandlines
   469  	return params
   470  }
   471  func (params *UpdateServiceParams) SetDtmfInputRequired(DtmfInputRequired bool) *UpdateServiceParams {
   472  	params.DtmfInputRequired = &DtmfInputRequired
   473  	return params
   474  }
   475  func (params *UpdateServiceParams) SetTtsName(TtsName string) *UpdateServiceParams {
   476  	params.TtsName = &TtsName
   477  	return params
   478  }
   479  func (params *UpdateServiceParams) SetPsd2Enabled(Psd2Enabled bool) *UpdateServiceParams {
   480  	params.Psd2Enabled = &Psd2Enabled
   481  	return params
   482  }
   483  func (params *UpdateServiceParams) SetDoNotShareWarningEnabled(DoNotShareWarningEnabled bool) *UpdateServiceParams {
   484  	params.DoNotShareWarningEnabled = &DoNotShareWarningEnabled
   485  	return params
   486  }
   487  func (params *UpdateServiceParams) SetCustomCodeEnabled(CustomCodeEnabled bool) *UpdateServiceParams {
   488  	params.CustomCodeEnabled = &CustomCodeEnabled
   489  	return params
   490  }
   491  func (params *UpdateServiceParams) SetPushIncludeDate(PushIncludeDate bool) *UpdateServiceParams {
   492  	params.PushIncludeDate = &PushIncludeDate
   493  	return params
   494  }
   495  func (params *UpdateServiceParams) SetPushApnCredentialSid(PushApnCredentialSid string) *UpdateServiceParams {
   496  	params.PushApnCredentialSid = &PushApnCredentialSid
   497  	return params
   498  }
   499  func (params *UpdateServiceParams) SetPushFcmCredentialSid(PushFcmCredentialSid string) *UpdateServiceParams {
   500  	params.PushFcmCredentialSid = &PushFcmCredentialSid
   501  	return params
   502  }
   503  func (params *UpdateServiceParams) SetTotpIssuer(TotpIssuer string) *UpdateServiceParams {
   504  	params.TotpIssuer = &TotpIssuer
   505  	return params
   506  }
   507  func (params *UpdateServiceParams) SetTotpTimeStep(TotpTimeStep int) *UpdateServiceParams {
   508  	params.TotpTimeStep = &TotpTimeStep
   509  	return params
   510  }
   511  func (params *UpdateServiceParams) SetTotpCodeLength(TotpCodeLength int) *UpdateServiceParams {
   512  	params.TotpCodeLength = &TotpCodeLength
   513  	return params
   514  }
   515  func (params *UpdateServiceParams) SetTotpSkew(TotpSkew int) *UpdateServiceParams {
   516  	params.TotpSkew = &TotpSkew
   517  	return params
   518  }
   519  func (params *UpdateServiceParams) SetDefaultTemplateSid(DefaultTemplateSid string) *UpdateServiceParams {
   520  	params.DefaultTemplateSid = &DefaultTemplateSid
   521  	return params
   522  }
   523  func (params *UpdateServiceParams) SetWhatsappMsgServiceSid(WhatsappMsgServiceSid string) *UpdateServiceParams {
   524  	params.WhatsappMsgServiceSid = &WhatsappMsgServiceSid
   525  	return params
   526  }
   527  func (params *UpdateServiceParams) SetWhatsappFrom(WhatsappFrom string) *UpdateServiceParams {
   528  	params.WhatsappFrom = &WhatsappFrom
   529  	return params
   530  }
   531  func (params *UpdateServiceParams) SetVerifyEventSubscriptionEnabled(VerifyEventSubscriptionEnabled bool) *UpdateServiceParams {
   532  	params.VerifyEventSubscriptionEnabled = &VerifyEventSubscriptionEnabled
   533  	return params
   534  }
   535  
   536  // Update a specific Verification Service.
   537  func (c *ApiService) UpdateService(Sid string, params *UpdateServiceParams) (*VerifyV2Service, error) {
   538  	path := "/v2/Services/{Sid}"
   539  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   540  
   541  	data := url.Values{}
   542  	headers := make(map[string]interface{})
   543  
   544  	if params != nil && params.FriendlyName != nil {
   545  		data.Set("FriendlyName", *params.FriendlyName)
   546  	}
   547  	if params != nil && params.CodeLength != nil {
   548  		data.Set("CodeLength", fmt.Sprint(*params.CodeLength))
   549  	}
   550  	if params != nil && params.LookupEnabled != nil {
   551  		data.Set("LookupEnabled", fmt.Sprint(*params.LookupEnabled))
   552  	}
   553  	if params != nil && params.SkipSmsToLandlines != nil {
   554  		data.Set("SkipSmsToLandlines", fmt.Sprint(*params.SkipSmsToLandlines))
   555  	}
   556  	if params != nil && params.DtmfInputRequired != nil {
   557  		data.Set("DtmfInputRequired", fmt.Sprint(*params.DtmfInputRequired))
   558  	}
   559  	if params != nil && params.TtsName != nil {
   560  		data.Set("TtsName", *params.TtsName)
   561  	}
   562  	if params != nil && params.Psd2Enabled != nil {
   563  		data.Set("Psd2Enabled", fmt.Sprint(*params.Psd2Enabled))
   564  	}
   565  	if params != nil && params.DoNotShareWarningEnabled != nil {
   566  		data.Set("DoNotShareWarningEnabled", fmt.Sprint(*params.DoNotShareWarningEnabled))
   567  	}
   568  	if params != nil && params.CustomCodeEnabled != nil {
   569  		data.Set("CustomCodeEnabled", fmt.Sprint(*params.CustomCodeEnabled))
   570  	}
   571  	if params != nil && params.PushIncludeDate != nil {
   572  		data.Set("Push.IncludeDate", fmt.Sprint(*params.PushIncludeDate))
   573  	}
   574  	if params != nil && params.PushApnCredentialSid != nil {
   575  		data.Set("Push.ApnCredentialSid", *params.PushApnCredentialSid)
   576  	}
   577  	if params != nil && params.PushFcmCredentialSid != nil {
   578  		data.Set("Push.FcmCredentialSid", *params.PushFcmCredentialSid)
   579  	}
   580  	if params != nil && params.TotpIssuer != nil {
   581  		data.Set("Totp.Issuer", *params.TotpIssuer)
   582  	}
   583  	if params != nil && params.TotpTimeStep != nil {
   584  		data.Set("Totp.TimeStep", fmt.Sprint(*params.TotpTimeStep))
   585  	}
   586  	if params != nil && params.TotpCodeLength != nil {
   587  		data.Set("Totp.CodeLength", fmt.Sprint(*params.TotpCodeLength))
   588  	}
   589  	if params != nil && params.TotpSkew != nil {
   590  		data.Set("Totp.Skew", fmt.Sprint(*params.TotpSkew))
   591  	}
   592  	if params != nil && params.DefaultTemplateSid != nil {
   593  		data.Set("DefaultTemplateSid", *params.DefaultTemplateSid)
   594  	}
   595  	if params != nil && params.WhatsappMsgServiceSid != nil {
   596  		data.Set("Whatsapp.MsgServiceSid", *params.WhatsappMsgServiceSid)
   597  	}
   598  	if params != nil && params.WhatsappFrom != nil {
   599  		data.Set("Whatsapp.From", *params.WhatsappFrom)
   600  	}
   601  	if params != nil && params.VerifyEventSubscriptionEnabled != nil {
   602  		data.Set("VerifyEventSubscriptionEnabled", fmt.Sprint(*params.VerifyEventSubscriptionEnabled))
   603  	}
   604  
   605  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   606  	if err != nil {
   607  		return nil, err
   608  	}
   609  
   610  	defer resp.Body.Close()
   611  
   612  	ps := &VerifyV2Service{}
   613  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   614  		return nil, err
   615  	}
   616  
   617  	return ps, err
   618  }