github.com/twilio/twilio-go@v1.20.1/rest/chat/v3/services_channels.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  	"net/url"
    20  	"strings"
    21  )
    22  
    23  // Optional parameters for the method 'UpdateChannel'
    24  type UpdateChannelParams struct {
    25  	// The X-Twilio-Webhook-Enabled HTTP request header
    26  	XTwilioWebhookEnabled *string `json:"X-Twilio-Webhook-Enabled,omitempty"`
    27  	//
    28  	Type *string `json:"Type,omitempty"`
    29  	// The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to.
    30  	MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"`
    31  }
    32  
    33  func (params *UpdateChannelParams) SetXTwilioWebhookEnabled(XTwilioWebhookEnabled string) *UpdateChannelParams {
    34  	params.XTwilioWebhookEnabled = &XTwilioWebhookEnabled
    35  	return params
    36  }
    37  func (params *UpdateChannelParams) SetType(Type string) *UpdateChannelParams {
    38  	params.Type = &Type
    39  	return params
    40  }
    41  func (params *UpdateChannelParams) SetMessagingServiceSid(MessagingServiceSid string) *UpdateChannelParams {
    42  	params.MessagingServiceSid = &MessagingServiceSid
    43  	return params
    44  }
    45  
    46  // Update a specific Channel.
    47  func (c *ApiService) UpdateChannel(ServiceSid string, Sid string, params *UpdateChannelParams) (*ChatV3Channel, error) {
    48  	path := "/v3/Services/{ServiceSid}/Channels/{Sid}"
    49  	path = strings.Replace(path, "{"+"ServiceSid"+"}", ServiceSid, -1)
    50  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    51  
    52  	data := url.Values{}
    53  	headers := make(map[string]interface{})
    54  
    55  	if params != nil && params.Type != nil {
    56  		data.Set("Type", *params.Type)
    57  	}
    58  	if params != nil && params.MessagingServiceSid != nil {
    59  		data.Set("MessagingServiceSid", *params.MessagingServiceSid)
    60  	}
    61  
    62  	if params != nil && params.XTwilioWebhookEnabled != nil {
    63  		headers["X-Twilio-Webhook-Enabled"] = *params.XTwilioWebhookEnabled
    64  	}
    65  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    66  	if err != nil {
    67  		return nil, err
    68  	}
    69  
    70  	defer resp.Body.Close()
    71  
    72  	ps := &ChatV3Channel{}
    73  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    74  		return nil, err
    75  	}
    76  
    77  	return ps, err
    78  }