github.com/twilio/twilio-go@v1.20.1/rest/flex/v2/web_chats.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Flex
     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  )
    21  
    22  // Optional parameters for the method 'CreateWebChannel'
    23  type CreateWebChannelParams struct {
    24  	// The Ui-Version HTTP request header
    25  	UiVersion *string `json:"Ui-Version,omitempty"`
    26  	// The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration.
    27  	AddressSid *string `json:"AddressSid,omitempty"`
    28  	// The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example.
    29  	ChatFriendlyName *string `json:"ChatFriendlyName,omitempty"`
    30  	// The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example.
    31  	CustomerFriendlyName *string `json:"CustomerFriendlyName,omitempty"`
    32  	// The pre-engagement data.
    33  	PreEngagementData *string `json:"PreEngagementData,omitempty"`
    34  }
    35  
    36  func (params *CreateWebChannelParams) SetUiVersion(UiVersion string) *CreateWebChannelParams {
    37  	params.UiVersion = &UiVersion
    38  	return params
    39  }
    40  func (params *CreateWebChannelParams) SetAddressSid(AddressSid string) *CreateWebChannelParams {
    41  	params.AddressSid = &AddressSid
    42  	return params
    43  }
    44  func (params *CreateWebChannelParams) SetChatFriendlyName(ChatFriendlyName string) *CreateWebChannelParams {
    45  	params.ChatFriendlyName = &ChatFriendlyName
    46  	return params
    47  }
    48  func (params *CreateWebChannelParams) SetCustomerFriendlyName(CustomerFriendlyName string) *CreateWebChannelParams {
    49  	params.CustomerFriendlyName = &CustomerFriendlyName
    50  	return params
    51  }
    52  func (params *CreateWebChannelParams) SetPreEngagementData(PreEngagementData string) *CreateWebChannelParams {
    53  	params.PreEngagementData = &PreEngagementData
    54  	return params
    55  }
    56  
    57  //
    58  func (c *ApiService) CreateWebChannel(params *CreateWebChannelParams) (*FlexV2WebChannel, error) {
    59  	path := "/v2/WebChats"
    60  
    61  	data := url.Values{}
    62  	headers := make(map[string]interface{})
    63  
    64  	if params != nil && params.AddressSid != nil {
    65  		data.Set("AddressSid", *params.AddressSid)
    66  	}
    67  	if params != nil && params.ChatFriendlyName != nil {
    68  		data.Set("ChatFriendlyName", *params.ChatFriendlyName)
    69  	}
    70  	if params != nil && params.CustomerFriendlyName != nil {
    71  		data.Set("CustomerFriendlyName", *params.CustomerFriendlyName)
    72  	}
    73  	if params != nil && params.PreEngagementData != nil {
    74  		data.Set("PreEngagementData", *params.PreEngagementData)
    75  	}
    76  
    77  	if params != nil && params.UiVersion != nil {
    78  		headers["Ui-Version"] = *params.UiVersion
    79  	}
    80  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  
    85  	defer resp.Body.Close()
    86  
    87  	ps := &FlexV2WebChannel{}
    88  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    89  		return nil, err
    90  	}
    91  
    92  	return ps, err
    93  }