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

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Chat
     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 new resource.
    29  	FriendlyName *string `json:"FriendlyName,omitempty"`
    30  }
    31  
    32  func (params *CreateServiceParams) SetFriendlyName(FriendlyName string) *CreateServiceParams {
    33  	params.FriendlyName = &FriendlyName
    34  	return params
    35  }
    36  
    37  //
    38  func (c *ApiService) CreateService(params *CreateServiceParams) (*ChatV2Service, error) {
    39  	path := "/v2/Services"
    40  
    41  	data := url.Values{}
    42  	headers := make(map[string]interface{})
    43  
    44  	if params != nil && params.FriendlyName != nil {
    45  		data.Set("FriendlyName", *params.FriendlyName)
    46  	}
    47  
    48  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    49  	if err != nil {
    50  		return nil, err
    51  	}
    52  
    53  	defer resp.Body.Close()
    54  
    55  	ps := &ChatV2Service{}
    56  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    57  		return nil, err
    58  	}
    59  
    60  	return ps, err
    61  }
    62  
    63  //
    64  func (c *ApiService) DeleteService(Sid string) error {
    65  	path := "/v2/Services/{Sid}"
    66  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    67  
    68  	data := url.Values{}
    69  	headers := make(map[string]interface{})
    70  
    71  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
    72  	if err != nil {
    73  		return err
    74  	}
    75  
    76  	defer resp.Body.Close()
    77  
    78  	return nil
    79  }
    80  
    81  //
    82  func (c *ApiService) FetchService(Sid string) (*ChatV2Service, error) {
    83  	path := "/v2/Services/{Sid}"
    84  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    85  
    86  	data := url.Values{}
    87  	headers := make(map[string]interface{})
    88  
    89  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    90  	if err != nil {
    91  		return nil, err
    92  	}
    93  
    94  	defer resp.Body.Close()
    95  
    96  	ps := &ChatV2Service{}
    97  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    98  		return nil, err
    99  	}
   100  
   101  	return ps, err
   102  }
   103  
   104  // Optional parameters for the method 'ListService'
   105  type ListServiceParams struct {
   106  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
   107  	PageSize *int `json:"PageSize,omitempty"`
   108  	// Max number of records to return.
   109  	Limit *int `json:"limit,omitempty"`
   110  }
   111  
   112  func (params *ListServiceParams) SetPageSize(PageSize int) *ListServiceParams {
   113  	params.PageSize = &PageSize
   114  	return params
   115  }
   116  func (params *ListServiceParams) SetLimit(Limit int) *ListServiceParams {
   117  	params.Limit = &Limit
   118  	return params
   119  }
   120  
   121  // Retrieve a single page of Service records from the API. Request is executed immediately.
   122  func (c *ApiService) PageService(params *ListServiceParams, pageToken, pageNumber string) (*ListServiceResponse, error) {
   123  	path := "/v2/Services"
   124  
   125  	data := url.Values{}
   126  	headers := make(map[string]interface{})
   127  
   128  	if params != nil && params.PageSize != nil {
   129  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
   130  	}
   131  
   132  	if pageToken != "" {
   133  		data.Set("PageToken", pageToken)
   134  	}
   135  	if pageNumber != "" {
   136  		data.Set("Page", pageNumber)
   137  	}
   138  
   139  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   140  	if err != nil {
   141  		return nil, err
   142  	}
   143  
   144  	defer resp.Body.Close()
   145  
   146  	ps := &ListServiceResponse{}
   147  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   148  		return nil, err
   149  	}
   150  
   151  	return ps, err
   152  }
   153  
   154  // Lists Service records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   155  func (c *ApiService) ListService(params *ListServiceParams) ([]ChatV2Service, error) {
   156  	response, errors := c.StreamService(params)
   157  
   158  	records := make([]ChatV2Service, 0)
   159  	for record := range response {
   160  		records = append(records, record)
   161  	}
   162  
   163  	if err := <-errors; err != nil {
   164  		return nil, err
   165  	}
   166  
   167  	return records, nil
   168  }
   169  
   170  // Streams Service records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   171  func (c *ApiService) StreamService(params *ListServiceParams) (chan ChatV2Service, chan error) {
   172  	if params == nil {
   173  		params = &ListServiceParams{}
   174  	}
   175  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   176  
   177  	recordChannel := make(chan ChatV2Service, 1)
   178  	errorChannel := make(chan error, 1)
   179  
   180  	response, err := c.PageService(params, "", "")
   181  	if err != nil {
   182  		errorChannel <- err
   183  		close(recordChannel)
   184  		close(errorChannel)
   185  	} else {
   186  		go c.streamService(response, params, recordChannel, errorChannel)
   187  	}
   188  
   189  	return recordChannel, errorChannel
   190  }
   191  
   192  func (c *ApiService) streamService(response *ListServiceResponse, params *ListServiceParams, recordChannel chan ChatV2Service, errorChannel chan error) {
   193  	curRecord := 1
   194  
   195  	for response != nil {
   196  		responseRecords := response.Services
   197  		for item := range responseRecords {
   198  			recordChannel <- responseRecords[item]
   199  			curRecord += 1
   200  			if params.Limit != nil && *params.Limit < curRecord {
   201  				close(recordChannel)
   202  				close(errorChannel)
   203  				return
   204  			}
   205  		}
   206  
   207  		record, err := client.GetNext(c.baseURL, response, c.getNextListServiceResponse)
   208  		if err != nil {
   209  			errorChannel <- err
   210  			break
   211  		} else if record == nil {
   212  			break
   213  		}
   214  
   215  		response = record.(*ListServiceResponse)
   216  	}
   217  
   218  	close(recordChannel)
   219  	close(errorChannel)
   220  }
   221  
   222  func (c *ApiService) getNextListServiceResponse(nextPageUrl string) (interface{}, error) {
   223  	if nextPageUrl == "" {
   224  		return nil, nil
   225  	}
   226  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   227  	if err != nil {
   228  		return nil, err
   229  	}
   230  
   231  	defer resp.Body.Close()
   232  
   233  	ps := &ListServiceResponse{}
   234  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   235  		return nil, err
   236  	}
   237  	return ps, nil
   238  }
   239  
   240  // Optional parameters for the method 'UpdateService'
   241  type UpdateServiceParams struct {
   242  	// A descriptive string that you create to describe the resource.
   243  	FriendlyName *string `json:"FriendlyName,omitempty"`
   244  	// The service role assigned to users when they are added to the service. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
   245  	DefaultServiceRoleSid *string `json:"DefaultServiceRoleSid,omitempty"`
   246  	// The channel role assigned to users when they are added to a channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
   247  	DefaultChannelRoleSid *string `json:"DefaultChannelRoleSid,omitempty"`
   248  	// The channel role assigned to a channel creator when they join a new channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
   249  	DefaultChannelCreatorRoleSid *string `json:"DefaultChannelCreatorRoleSid,omitempty"`
   250  	// Whether to enable the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature. The default is `true`.
   251  	ReadStatusEnabled *bool `json:"ReadStatusEnabled,omitempty"`
   252  	// Whether to enable the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) for this Service instance. The default is `false`.
   253  	ReachabilityEnabled *bool `json:"ReachabilityEnabled,omitempty"`
   254  	// How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received.  The default is 5 seconds.
   255  	TypingIndicatorTimeout *int `json:"TypingIndicatorTimeout,omitempty"`
   256  	// DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.
   257  	ConsumptionReportInterval *int `json:"ConsumptionReportInterval,omitempty"`
   258  	// Whether to send a notification when a new message is added to a channel. The default is `false`.
   259  	NotificationsNewMessageEnabled *bool `json:"Notifications.NewMessage.Enabled,omitempty"`
   260  	// The template to use to create the notification text displayed when a new message is added to a channel and `notifications.new_message.enabled` is `true`.
   261  	NotificationsNewMessageTemplate *string `json:"Notifications.NewMessage.Template,omitempty"`
   262  	// The name of the sound to play when a new message is added to a channel and `notifications.new_message.enabled` is `true`.
   263  	NotificationsNewMessageSound *string `json:"Notifications.NewMessage.Sound,omitempty"`
   264  	// Whether the new message badge is enabled. The default is `false`.
   265  	NotificationsNewMessageBadgeCountEnabled *bool `json:"Notifications.NewMessage.BadgeCountEnabled,omitempty"`
   266  	// Whether to send a notification when a member is added to a channel. The default is `false`.
   267  	NotificationsAddedToChannelEnabled *bool `json:"Notifications.AddedToChannel.Enabled,omitempty"`
   268  	// The template to use to create the notification text displayed when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`.
   269  	NotificationsAddedToChannelTemplate *string `json:"Notifications.AddedToChannel.Template,omitempty"`
   270  	// The name of the sound to play when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`.
   271  	NotificationsAddedToChannelSound *string `json:"Notifications.AddedToChannel.Sound,omitempty"`
   272  	// Whether to send a notification to a user when they are removed from a channel. The default is `false`.
   273  	NotificationsRemovedFromChannelEnabled *bool `json:"Notifications.RemovedFromChannel.Enabled,omitempty"`
   274  	// The template to use to create the notification text displayed to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`.
   275  	NotificationsRemovedFromChannelTemplate *string `json:"Notifications.RemovedFromChannel.Template,omitempty"`
   276  	// The name of the sound to play to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`.
   277  	NotificationsRemovedFromChannelSound *string `json:"Notifications.RemovedFromChannel.Sound,omitempty"`
   278  	// Whether to send a notification when a user is invited to a channel. The default is `false`.
   279  	NotificationsInvitedToChannelEnabled *bool `json:"Notifications.InvitedToChannel.Enabled,omitempty"`
   280  	// The template to use to create the notification text displayed when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`.
   281  	NotificationsInvitedToChannelTemplate *string `json:"Notifications.InvitedToChannel.Template,omitempty"`
   282  	// The name of the sound to play when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`.
   283  	NotificationsInvitedToChannelSound *string `json:"Notifications.InvitedToChannel.Sound,omitempty"`
   284  	// The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
   285  	PreWebhookUrl *string `json:"PreWebhookUrl,omitempty"`
   286  	// The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
   287  	PostWebhookUrl *string `json:"PostWebhookUrl,omitempty"`
   288  	// The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks.  Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
   289  	WebhookMethod *string `json:"WebhookMethod,omitempty"`
   290  	// The list of webhook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
   291  	WebhookFilters *[]string `json:"WebhookFilters,omitempty"`
   292  	// The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000.
   293  	LimitsChannelMembers *int `json:"Limits.ChannelMembers,omitempty"`
   294  	// The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000.
   295  	LimitsUserChannels *int `json:"Limits.UserChannels,omitempty"`
   296  	// The message to send when a media message has no text. Can be used as placeholder message.
   297  	MediaCompatibilityMessage *string `json:"Media.CompatibilityMessage,omitempty"`
   298  	// The number of times to retry a call to the `pre_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won't be retried.
   299  	PreWebhookRetryCount *int `json:"PreWebhookRetryCount,omitempty"`
   300  	// The number of times to retry a call to the `post_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won't be retried.
   301  	PostWebhookRetryCount *int `json:"PostWebhookRetryCount,omitempty"`
   302  	// Whether to log notifications. The default is `false`.
   303  	NotificationsLogEnabled *bool `json:"Notifications.LogEnabled,omitempty"`
   304  }
   305  
   306  func (params *UpdateServiceParams) SetFriendlyName(FriendlyName string) *UpdateServiceParams {
   307  	params.FriendlyName = &FriendlyName
   308  	return params
   309  }
   310  func (params *UpdateServiceParams) SetDefaultServiceRoleSid(DefaultServiceRoleSid string) *UpdateServiceParams {
   311  	params.DefaultServiceRoleSid = &DefaultServiceRoleSid
   312  	return params
   313  }
   314  func (params *UpdateServiceParams) SetDefaultChannelRoleSid(DefaultChannelRoleSid string) *UpdateServiceParams {
   315  	params.DefaultChannelRoleSid = &DefaultChannelRoleSid
   316  	return params
   317  }
   318  func (params *UpdateServiceParams) SetDefaultChannelCreatorRoleSid(DefaultChannelCreatorRoleSid string) *UpdateServiceParams {
   319  	params.DefaultChannelCreatorRoleSid = &DefaultChannelCreatorRoleSid
   320  	return params
   321  }
   322  func (params *UpdateServiceParams) SetReadStatusEnabled(ReadStatusEnabled bool) *UpdateServiceParams {
   323  	params.ReadStatusEnabled = &ReadStatusEnabled
   324  	return params
   325  }
   326  func (params *UpdateServiceParams) SetReachabilityEnabled(ReachabilityEnabled bool) *UpdateServiceParams {
   327  	params.ReachabilityEnabled = &ReachabilityEnabled
   328  	return params
   329  }
   330  func (params *UpdateServiceParams) SetTypingIndicatorTimeout(TypingIndicatorTimeout int) *UpdateServiceParams {
   331  	params.TypingIndicatorTimeout = &TypingIndicatorTimeout
   332  	return params
   333  }
   334  func (params *UpdateServiceParams) SetConsumptionReportInterval(ConsumptionReportInterval int) *UpdateServiceParams {
   335  	params.ConsumptionReportInterval = &ConsumptionReportInterval
   336  	return params
   337  }
   338  func (params *UpdateServiceParams) SetNotificationsNewMessageEnabled(NotificationsNewMessageEnabled bool) *UpdateServiceParams {
   339  	params.NotificationsNewMessageEnabled = &NotificationsNewMessageEnabled
   340  	return params
   341  }
   342  func (params *UpdateServiceParams) SetNotificationsNewMessageTemplate(NotificationsNewMessageTemplate string) *UpdateServiceParams {
   343  	params.NotificationsNewMessageTemplate = &NotificationsNewMessageTemplate
   344  	return params
   345  }
   346  func (params *UpdateServiceParams) SetNotificationsNewMessageSound(NotificationsNewMessageSound string) *UpdateServiceParams {
   347  	params.NotificationsNewMessageSound = &NotificationsNewMessageSound
   348  	return params
   349  }
   350  func (params *UpdateServiceParams) SetNotificationsNewMessageBadgeCountEnabled(NotificationsNewMessageBadgeCountEnabled bool) *UpdateServiceParams {
   351  	params.NotificationsNewMessageBadgeCountEnabled = &NotificationsNewMessageBadgeCountEnabled
   352  	return params
   353  }
   354  func (params *UpdateServiceParams) SetNotificationsAddedToChannelEnabled(NotificationsAddedToChannelEnabled bool) *UpdateServiceParams {
   355  	params.NotificationsAddedToChannelEnabled = &NotificationsAddedToChannelEnabled
   356  	return params
   357  }
   358  func (params *UpdateServiceParams) SetNotificationsAddedToChannelTemplate(NotificationsAddedToChannelTemplate string) *UpdateServiceParams {
   359  	params.NotificationsAddedToChannelTemplate = &NotificationsAddedToChannelTemplate
   360  	return params
   361  }
   362  func (params *UpdateServiceParams) SetNotificationsAddedToChannelSound(NotificationsAddedToChannelSound string) *UpdateServiceParams {
   363  	params.NotificationsAddedToChannelSound = &NotificationsAddedToChannelSound
   364  	return params
   365  }
   366  func (params *UpdateServiceParams) SetNotificationsRemovedFromChannelEnabled(NotificationsRemovedFromChannelEnabled bool) *UpdateServiceParams {
   367  	params.NotificationsRemovedFromChannelEnabled = &NotificationsRemovedFromChannelEnabled
   368  	return params
   369  }
   370  func (params *UpdateServiceParams) SetNotificationsRemovedFromChannelTemplate(NotificationsRemovedFromChannelTemplate string) *UpdateServiceParams {
   371  	params.NotificationsRemovedFromChannelTemplate = &NotificationsRemovedFromChannelTemplate
   372  	return params
   373  }
   374  func (params *UpdateServiceParams) SetNotificationsRemovedFromChannelSound(NotificationsRemovedFromChannelSound string) *UpdateServiceParams {
   375  	params.NotificationsRemovedFromChannelSound = &NotificationsRemovedFromChannelSound
   376  	return params
   377  }
   378  func (params *UpdateServiceParams) SetNotificationsInvitedToChannelEnabled(NotificationsInvitedToChannelEnabled bool) *UpdateServiceParams {
   379  	params.NotificationsInvitedToChannelEnabled = &NotificationsInvitedToChannelEnabled
   380  	return params
   381  }
   382  func (params *UpdateServiceParams) SetNotificationsInvitedToChannelTemplate(NotificationsInvitedToChannelTemplate string) *UpdateServiceParams {
   383  	params.NotificationsInvitedToChannelTemplate = &NotificationsInvitedToChannelTemplate
   384  	return params
   385  }
   386  func (params *UpdateServiceParams) SetNotificationsInvitedToChannelSound(NotificationsInvitedToChannelSound string) *UpdateServiceParams {
   387  	params.NotificationsInvitedToChannelSound = &NotificationsInvitedToChannelSound
   388  	return params
   389  }
   390  func (params *UpdateServiceParams) SetPreWebhookUrl(PreWebhookUrl string) *UpdateServiceParams {
   391  	params.PreWebhookUrl = &PreWebhookUrl
   392  	return params
   393  }
   394  func (params *UpdateServiceParams) SetPostWebhookUrl(PostWebhookUrl string) *UpdateServiceParams {
   395  	params.PostWebhookUrl = &PostWebhookUrl
   396  	return params
   397  }
   398  func (params *UpdateServiceParams) SetWebhookMethod(WebhookMethod string) *UpdateServiceParams {
   399  	params.WebhookMethod = &WebhookMethod
   400  	return params
   401  }
   402  func (params *UpdateServiceParams) SetWebhookFilters(WebhookFilters []string) *UpdateServiceParams {
   403  	params.WebhookFilters = &WebhookFilters
   404  	return params
   405  }
   406  func (params *UpdateServiceParams) SetLimitsChannelMembers(LimitsChannelMembers int) *UpdateServiceParams {
   407  	params.LimitsChannelMembers = &LimitsChannelMembers
   408  	return params
   409  }
   410  func (params *UpdateServiceParams) SetLimitsUserChannels(LimitsUserChannels int) *UpdateServiceParams {
   411  	params.LimitsUserChannels = &LimitsUserChannels
   412  	return params
   413  }
   414  func (params *UpdateServiceParams) SetMediaCompatibilityMessage(MediaCompatibilityMessage string) *UpdateServiceParams {
   415  	params.MediaCompatibilityMessage = &MediaCompatibilityMessage
   416  	return params
   417  }
   418  func (params *UpdateServiceParams) SetPreWebhookRetryCount(PreWebhookRetryCount int) *UpdateServiceParams {
   419  	params.PreWebhookRetryCount = &PreWebhookRetryCount
   420  	return params
   421  }
   422  func (params *UpdateServiceParams) SetPostWebhookRetryCount(PostWebhookRetryCount int) *UpdateServiceParams {
   423  	params.PostWebhookRetryCount = &PostWebhookRetryCount
   424  	return params
   425  }
   426  func (params *UpdateServiceParams) SetNotificationsLogEnabled(NotificationsLogEnabled bool) *UpdateServiceParams {
   427  	params.NotificationsLogEnabled = &NotificationsLogEnabled
   428  	return params
   429  }
   430  
   431  //
   432  func (c *ApiService) UpdateService(Sid string, params *UpdateServiceParams) (*ChatV2Service, error) {
   433  	path := "/v2/Services/{Sid}"
   434  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   435  
   436  	data := url.Values{}
   437  	headers := make(map[string]interface{})
   438  
   439  	if params != nil && params.FriendlyName != nil {
   440  		data.Set("FriendlyName", *params.FriendlyName)
   441  	}
   442  	if params != nil && params.DefaultServiceRoleSid != nil {
   443  		data.Set("DefaultServiceRoleSid", *params.DefaultServiceRoleSid)
   444  	}
   445  	if params != nil && params.DefaultChannelRoleSid != nil {
   446  		data.Set("DefaultChannelRoleSid", *params.DefaultChannelRoleSid)
   447  	}
   448  	if params != nil && params.DefaultChannelCreatorRoleSid != nil {
   449  		data.Set("DefaultChannelCreatorRoleSid", *params.DefaultChannelCreatorRoleSid)
   450  	}
   451  	if params != nil && params.ReadStatusEnabled != nil {
   452  		data.Set("ReadStatusEnabled", fmt.Sprint(*params.ReadStatusEnabled))
   453  	}
   454  	if params != nil && params.ReachabilityEnabled != nil {
   455  		data.Set("ReachabilityEnabled", fmt.Sprint(*params.ReachabilityEnabled))
   456  	}
   457  	if params != nil && params.TypingIndicatorTimeout != nil {
   458  		data.Set("TypingIndicatorTimeout", fmt.Sprint(*params.TypingIndicatorTimeout))
   459  	}
   460  	if params != nil && params.ConsumptionReportInterval != nil {
   461  		data.Set("ConsumptionReportInterval", fmt.Sprint(*params.ConsumptionReportInterval))
   462  	}
   463  	if params != nil && params.NotificationsNewMessageEnabled != nil {
   464  		data.Set("Notifications.NewMessage.Enabled", fmt.Sprint(*params.NotificationsNewMessageEnabled))
   465  	}
   466  	if params != nil && params.NotificationsNewMessageTemplate != nil {
   467  		data.Set("Notifications.NewMessage.Template", *params.NotificationsNewMessageTemplate)
   468  	}
   469  	if params != nil && params.NotificationsNewMessageSound != nil {
   470  		data.Set("Notifications.NewMessage.Sound", *params.NotificationsNewMessageSound)
   471  	}
   472  	if params != nil && params.NotificationsNewMessageBadgeCountEnabled != nil {
   473  		data.Set("Notifications.NewMessage.BadgeCountEnabled", fmt.Sprint(*params.NotificationsNewMessageBadgeCountEnabled))
   474  	}
   475  	if params != nil && params.NotificationsAddedToChannelEnabled != nil {
   476  		data.Set("Notifications.AddedToChannel.Enabled", fmt.Sprint(*params.NotificationsAddedToChannelEnabled))
   477  	}
   478  	if params != nil && params.NotificationsAddedToChannelTemplate != nil {
   479  		data.Set("Notifications.AddedToChannel.Template", *params.NotificationsAddedToChannelTemplate)
   480  	}
   481  	if params != nil && params.NotificationsAddedToChannelSound != nil {
   482  		data.Set("Notifications.AddedToChannel.Sound", *params.NotificationsAddedToChannelSound)
   483  	}
   484  	if params != nil && params.NotificationsRemovedFromChannelEnabled != nil {
   485  		data.Set("Notifications.RemovedFromChannel.Enabled", fmt.Sprint(*params.NotificationsRemovedFromChannelEnabled))
   486  	}
   487  	if params != nil && params.NotificationsRemovedFromChannelTemplate != nil {
   488  		data.Set("Notifications.RemovedFromChannel.Template", *params.NotificationsRemovedFromChannelTemplate)
   489  	}
   490  	if params != nil && params.NotificationsRemovedFromChannelSound != nil {
   491  		data.Set("Notifications.RemovedFromChannel.Sound", *params.NotificationsRemovedFromChannelSound)
   492  	}
   493  	if params != nil && params.NotificationsInvitedToChannelEnabled != nil {
   494  		data.Set("Notifications.InvitedToChannel.Enabled", fmt.Sprint(*params.NotificationsInvitedToChannelEnabled))
   495  	}
   496  	if params != nil && params.NotificationsInvitedToChannelTemplate != nil {
   497  		data.Set("Notifications.InvitedToChannel.Template", *params.NotificationsInvitedToChannelTemplate)
   498  	}
   499  	if params != nil && params.NotificationsInvitedToChannelSound != nil {
   500  		data.Set("Notifications.InvitedToChannel.Sound", *params.NotificationsInvitedToChannelSound)
   501  	}
   502  	if params != nil && params.PreWebhookUrl != nil {
   503  		data.Set("PreWebhookUrl", *params.PreWebhookUrl)
   504  	}
   505  	if params != nil && params.PostWebhookUrl != nil {
   506  		data.Set("PostWebhookUrl", *params.PostWebhookUrl)
   507  	}
   508  	if params != nil && params.WebhookMethod != nil {
   509  		data.Set("WebhookMethod", *params.WebhookMethod)
   510  	}
   511  	if params != nil && params.WebhookFilters != nil {
   512  		for _, item := range *params.WebhookFilters {
   513  			data.Add("WebhookFilters", item)
   514  		}
   515  	}
   516  	if params != nil && params.LimitsChannelMembers != nil {
   517  		data.Set("Limits.ChannelMembers", fmt.Sprint(*params.LimitsChannelMembers))
   518  	}
   519  	if params != nil && params.LimitsUserChannels != nil {
   520  		data.Set("Limits.UserChannels", fmt.Sprint(*params.LimitsUserChannels))
   521  	}
   522  	if params != nil && params.MediaCompatibilityMessage != nil {
   523  		data.Set("Media.CompatibilityMessage", *params.MediaCompatibilityMessage)
   524  	}
   525  	if params != nil && params.PreWebhookRetryCount != nil {
   526  		data.Set("PreWebhookRetryCount", fmt.Sprint(*params.PreWebhookRetryCount))
   527  	}
   528  	if params != nil && params.PostWebhookRetryCount != nil {
   529  		data.Set("PostWebhookRetryCount", fmt.Sprint(*params.PostWebhookRetryCount))
   530  	}
   531  	if params != nil && params.NotificationsLogEnabled != nil {
   532  		data.Set("Notifications.LogEnabled", fmt.Sprint(*params.NotificationsLogEnabled))
   533  	}
   534  
   535  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   536  	if err != nil {
   537  		return nil, err
   538  	}
   539  
   540  	defer resp.Body.Close()
   541  
   542  	ps := &ChatV2Service{}
   543  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   544  		return nil, err
   545  	}
   546  
   547  	return ps, err
   548  }