github.com/twilio/twilio-go@v1.20.1/rest/taskrouter/v1/workspaces_workers_reservations.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Taskrouter
     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  //
    27  func (c *ApiService) FetchWorkerReservation(WorkspaceSid string, WorkerSid string, Sid string) (*TaskrouterV1WorkerReservation, error) {
    28  	path := "/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Reservations/{Sid}"
    29  	path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1)
    30  	path = strings.Replace(path, "{"+"WorkerSid"+"}", WorkerSid, -1)
    31  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    32  
    33  	data := url.Values{}
    34  	headers := make(map[string]interface{})
    35  
    36  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  
    41  	defer resp.Body.Close()
    42  
    43  	ps := &TaskrouterV1WorkerReservation{}
    44  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    45  		return nil, err
    46  	}
    47  
    48  	return ps, err
    49  }
    50  
    51  // Optional parameters for the method 'ListWorkerReservation'
    52  type ListWorkerReservationParams struct {
    53  	// Returns the list of reservations for a worker with a specified ReservationStatus. Can be: `pending`, `accepted`, `rejected`, `timeout`, `canceled`, or `rescinded`.
    54  	ReservationStatus *string `json:"ReservationStatus,omitempty"`
    55  	// How many resources to return in each list page. The default is 50, and the maximum is 1000.
    56  	PageSize *int `json:"PageSize,omitempty"`
    57  	// Max number of records to return.
    58  	Limit *int `json:"limit,omitempty"`
    59  }
    60  
    61  func (params *ListWorkerReservationParams) SetReservationStatus(ReservationStatus string) *ListWorkerReservationParams {
    62  	params.ReservationStatus = &ReservationStatus
    63  	return params
    64  }
    65  func (params *ListWorkerReservationParams) SetPageSize(PageSize int) *ListWorkerReservationParams {
    66  	params.PageSize = &PageSize
    67  	return params
    68  }
    69  func (params *ListWorkerReservationParams) SetLimit(Limit int) *ListWorkerReservationParams {
    70  	params.Limit = &Limit
    71  	return params
    72  }
    73  
    74  // Retrieve a single page of WorkerReservation records from the API. Request is executed immediately.
    75  func (c *ApiService) PageWorkerReservation(WorkspaceSid string, WorkerSid string, params *ListWorkerReservationParams, pageToken, pageNumber string) (*ListWorkerReservationResponse, error) {
    76  	path := "/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Reservations"
    77  
    78  	path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1)
    79  	path = strings.Replace(path, "{"+"WorkerSid"+"}", WorkerSid, -1)
    80  
    81  	data := url.Values{}
    82  	headers := make(map[string]interface{})
    83  
    84  	if params != nil && params.ReservationStatus != nil {
    85  		data.Set("ReservationStatus", *params.ReservationStatus)
    86  	}
    87  	if params != nil && params.PageSize != nil {
    88  		data.Set("PageSize", fmt.Sprint(*params.PageSize))
    89  	}
    90  
    91  	if pageToken != "" {
    92  		data.Set("PageToken", pageToken)
    93  	}
    94  	if pageNumber != "" {
    95  		data.Set("Page", pageNumber)
    96  	}
    97  
    98  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    99  	if err != nil {
   100  		return nil, err
   101  	}
   102  
   103  	defer resp.Body.Close()
   104  
   105  	ps := &ListWorkerReservationResponse{}
   106  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   107  		return nil, err
   108  	}
   109  
   110  	return ps, err
   111  }
   112  
   113  // Lists WorkerReservation records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
   114  func (c *ApiService) ListWorkerReservation(WorkspaceSid string, WorkerSid string, params *ListWorkerReservationParams) ([]TaskrouterV1WorkerReservation, error) {
   115  	response, errors := c.StreamWorkerReservation(WorkspaceSid, WorkerSid, params)
   116  
   117  	records := make([]TaskrouterV1WorkerReservation, 0)
   118  	for record := range response {
   119  		records = append(records, record)
   120  	}
   121  
   122  	if err := <-errors; err != nil {
   123  		return nil, err
   124  	}
   125  
   126  	return records, nil
   127  }
   128  
   129  // Streams WorkerReservation records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
   130  func (c *ApiService) StreamWorkerReservation(WorkspaceSid string, WorkerSid string, params *ListWorkerReservationParams) (chan TaskrouterV1WorkerReservation, chan error) {
   131  	if params == nil {
   132  		params = &ListWorkerReservationParams{}
   133  	}
   134  	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
   135  
   136  	recordChannel := make(chan TaskrouterV1WorkerReservation, 1)
   137  	errorChannel := make(chan error, 1)
   138  
   139  	response, err := c.PageWorkerReservation(WorkspaceSid, WorkerSid, params, "", "")
   140  	if err != nil {
   141  		errorChannel <- err
   142  		close(recordChannel)
   143  		close(errorChannel)
   144  	} else {
   145  		go c.streamWorkerReservation(response, params, recordChannel, errorChannel)
   146  	}
   147  
   148  	return recordChannel, errorChannel
   149  }
   150  
   151  func (c *ApiService) streamWorkerReservation(response *ListWorkerReservationResponse, params *ListWorkerReservationParams, recordChannel chan TaskrouterV1WorkerReservation, errorChannel chan error) {
   152  	curRecord := 1
   153  
   154  	for response != nil {
   155  		responseRecords := response.Reservations
   156  		for item := range responseRecords {
   157  			recordChannel <- responseRecords[item]
   158  			curRecord += 1
   159  			if params.Limit != nil && *params.Limit < curRecord {
   160  				close(recordChannel)
   161  				close(errorChannel)
   162  				return
   163  			}
   164  		}
   165  
   166  		record, err := client.GetNext(c.baseURL, response, c.getNextListWorkerReservationResponse)
   167  		if err != nil {
   168  			errorChannel <- err
   169  			break
   170  		} else if record == nil {
   171  			break
   172  		}
   173  
   174  		response = record.(*ListWorkerReservationResponse)
   175  	}
   176  
   177  	close(recordChannel)
   178  	close(errorChannel)
   179  }
   180  
   181  func (c *ApiService) getNextListWorkerReservationResponse(nextPageUrl string) (interface{}, error) {
   182  	if nextPageUrl == "" {
   183  		return nil, nil
   184  	}
   185  	resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
   186  	if err != nil {
   187  		return nil, err
   188  	}
   189  
   190  	defer resp.Body.Close()
   191  
   192  	ps := &ListWorkerReservationResponse{}
   193  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   194  		return nil, err
   195  	}
   196  	return ps, nil
   197  }
   198  
   199  // Optional parameters for the method 'UpdateWorkerReservation'
   200  type UpdateWorkerReservationParams struct {
   201  	// The If-Match HTTP request header
   202  	IfMatch *string `json:"If-Match,omitempty"`
   203  	//
   204  	ReservationStatus *string `json:"ReservationStatus,omitempty"`
   205  	// The new worker activity SID if rejecting a reservation.
   206  	WorkerActivitySid *string `json:"WorkerActivitySid,omitempty"`
   207  	// The assignment instruction for the reservation.
   208  	Instruction *string `json:"Instruction,omitempty"`
   209  	// The SID of the Activity resource to start after executing a Dequeue instruction.
   210  	DequeuePostWorkActivitySid *string `json:"DequeuePostWorkActivitySid,omitempty"`
   211  	// The caller ID of the call to the worker when executing a Dequeue instruction.
   212  	DequeueFrom *string `json:"DequeueFrom,omitempty"`
   213  	// Whether to record both legs of a call when executing a Dequeue instruction or which leg to record.
   214  	DequeueRecord *string `json:"DequeueRecord,omitempty"`
   215  	// The timeout for call when executing a Dequeue instruction.
   216  	DequeueTimeout *int `json:"DequeueTimeout,omitempty"`
   217  	// The contact URI of the worker when executing a Dequeue instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination.
   218  	DequeueTo *string `json:"DequeueTo,omitempty"`
   219  	// The callback URL for completed call event when executing a Dequeue instruction.
   220  	DequeueStatusCallbackUrl *string `json:"DequeueStatusCallbackUrl,omitempty"`
   221  	// The Caller ID of the outbound call when executing a Call instruction.
   222  	CallFrom *string `json:"CallFrom,omitempty"`
   223  	// Whether to record both legs of a call when executing a Call instruction.
   224  	CallRecord *string `json:"CallRecord,omitempty"`
   225  	// The timeout for a call when executing a Call instruction.
   226  	CallTimeout *int `json:"CallTimeout,omitempty"`
   227  	// The contact URI of the worker when executing a Call instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination.
   228  	CallTo *string `json:"CallTo,omitempty"`
   229  	// TwiML URI executed on answering the worker's leg as a result of the Call instruction.
   230  	CallUrl *string `json:"CallUrl,omitempty"`
   231  	// The URL to call for the completed call event when executing a Call instruction.
   232  	CallStatusCallbackUrl *string `json:"CallStatusCallbackUrl,omitempty"`
   233  	// Whether to accept a reservation when executing a Call instruction.
   234  	CallAccept *bool `json:"CallAccept,omitempty"`
   235  	// The Call SID of the call parked in the queue when executing a Redirect instruction.
   236  	RedirectCallSid *string `json:"RedirectCallSid,omitempty"`
   237  	// Whether the reservation should be accepted when executing a Redirect instruction.
   238  	RedirectAccept *bool `json:"RedirectAccept,omitempty"`
   239  	// TwiML URI to redirect the call to when executing the Redirect instruction.
   240  	RedirectUrl *string `json:"RedirectUrl,omitempty"`
   241  	// The Contact URI of the worker when executing a Conference instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination.
   242  	To *string `json:"To,omitempty"`
   243  	// The caller ID of the call to the worker when executing a Conference instruction.
   244  	From *string `json:"From,omitempty"`
   245  	// The URL we should call using the `status_callback_method` to send status information to your application.
   246  	StatusCallback *string `json:"StatusCallback,omitempty"`
   247  	// The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
   248  	StatusCallbackMethod *string `json:"StatusCallbackMethod,omitempty"`
   249  	// The call progress events that we will send to `status_callback`. Can be: `initiated`, `ringing`, `answered`, or `completed`.
   250  	StatusCallbackEvent *[]string `json:"StatusCallbackEvent,omitempty"`
   251  	// The timeout for a call when executing a Conference instruction.
   252  	Timeout *int `json:"Timeout,omitempty"`
   253  	// Whether to record the participant and their conferences, including the time between conferences. Can be `true` or `false` and the default is `false`.
   254  	Record *bool `json:"Record,omitempty"`
   255  	// Whether the agent is muted in the conference. Defaults to `false`.
   256  	Muted *bool `json:"Muted,omitempty"`
   257  	// Whether to play a notification beep when the participant joins or when to play a beep. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`.
   258  	Beep *string `json:"Beep,omitempty"`
   259  	// Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference.
   260  	StartConferenceOnEnter *bool `json:"StartConferenceOnEnter,omitempty"`
   261  	// Whether to end the conference when the agent leaves.
   262  	EndConferenceOnExit *bool `json:"EndConferenceOnExit,omitempty"`
   263  	// The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic).
   264  	WaitUrl *string `json:"WaitUrl,omitempty"`
   265  	// The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file.
   266  	WaitMethod *string `json:"WaitMethod,omitempty"`
   267  	// Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. The default is `true`.
   268  	EarlyMedia *bool `json:"EarlyMedia,omitempty"`
   269  	// The maximum number of participants allowed in the conference. Can be a positive integer from `2` to `250`. The default value is `250`.
   270  	MaxParticipants *int `json:"MaxParticipants,omitempty"`
   271  	// The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored.
   272  	ConferenceStatusCallback *string `json:"ConferenceStatusCallback,omitempty"`
   273  	// The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
   274  	ConferenceStatusCallbackMethod *string `json:"ConferenceStatusCallbackMethod,omitempty"`
   275  	// The conference status events that we will send to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `speaker`.
   276  	ConferenceStatusCallbackEvent *[]string `json:"ConferenceStatusCallbackEvent,omitempty"`
   277  	// Whether to record the conference the participant is joining or when to record the conference. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`.
   278  	ConferenceRecord *string `json:"ConferenceRecord,omitempty"`
   279  	// Whether to trim leading and trailing silence from your recorded conference audio files. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`.
   280  	ConferenceTrim *string `json:"ConferenceTrim,omitempty"`
   281  	// The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`.
   282  	RecordingChannels *string `json:"RecordingChannels,omitempty"`
   283  	// The URL that we should call using the `recording_status_callback_method` when the recording status changes.
   284  	RecordingStatusCallback *string `json:"RecordingStatusCallback,omitempty"`
   285  	// The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
   286  	RecordingStatusCallbackMethod *string `json:"RecordingStatusCallbackMethod,omitempty"`
   287  	// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available.
   288  	ConferenceRecordingStatusCallback *string `json:"ConferenceRecordingStatusCallback,omitempty"`
   289  	// The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
   290  	ConferenceRecordingStatusCallbackMethod *string `json:"ConferenceRecordingStatusCallbackMethod,omitempty"`
   291  	// The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`.
   292  	Region *string `json:"Region,omitempty"`
   293  	// The SIP username used for authentication.
   294  	SipAuthUsername *string `json:"SipAuthUsername,omitempty"`
   295  	// The SIP password for authentication.
   296  	SipAuthPassword *string `json:"SipAuthPassword,omitempty"`
   297  	// The call progress events sent via webhooks as a result of a Dequeue instruction.
   298  	DequeueStatusCallbackEvent *[]string `json:"DequeueStatusCallbackEvent,omitempty"`
   299  	// The new worker activity SID after executing a Conference instruction.
   300  	PostWorkActivitySid *string `json:"PostWorkActivitySid,omitempty"`
   301  	// Whether to end the conference when the customer leaves.
   302  	EndConferenceOnCustomerExit *bool `json:"EndConferenceOnCustomerExit,omitempty"`
   303  	// Whether to play a notification beep when the customer joins.
   304  	BeepOnCustomerEntrance *bool `json:"BeepOnCustomerEntrance,omitempty"`
   305  	// The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`.
   306  	JitterBufferSize *string `json:"JitterBufferSize,omitempty"`
   307  }
   308  
   309  func (params *UpdateWorkerReservationParams) SetIfMatch(IfMatch string) *UpdateWorkerReservationParams {
   310  	params.IfMatch = &IfMatch
   311  	return params
   312  }
   313  func (params *UpdateWorkerReservationParams) SetReservationStatus(ReservationStatus string) *UpdateWorkerReservationParams {
   314  	params.ReservationStatus = &ReservationStatus
   315  	return params
   316  }
   317  func (params *UpdateWorkerReservationParams) SetWorkerActivitySid(WorkerActivitySid string) *UpdateWorkerReservationParams {
   318  	params.WorkerActivitySid = &WorkerActivitySid
   319  	return params
   320  }
   321  func (params *UpdateWorkerReservationParams) SetInstruction(Instruction string) *UpdateWorkerReservationParams {
   322  	params.Instruction = &Instruction
   323  	return params
   324  }
   325  func (params *UpdateWorkerReservationParams) SetDequeuePostWorkActivitySid(DequeuePostWorkActivitySid string) *UpdateWorkerReservationParams {
   326  	params.DequeuePostWorkActivitySid = &DequeuePostWorkActivitySid
   327  	return params
   328  }
   329  func (params *UpdateWorkerReservationParams) SetDequeueFrom(DequeueFrom string) *UpdateWorkerReservationParams {
   330  	params.DequeueFrom = &DequeueFrom
   331  	return params
   332  }
   333  func (params *UpdateWorkerReservationParams) SetDequeueRecord(DequeueRecord string) *UpdateWorkerReservationParams {
   334  	params.DequeueRecord = &DequeueRecord
   335  	return params
   336  }
   337  func (params *UpdateWorkerReservationParams) SetDequeueTimeout(DequeueTimeout int) *UpdateWorkerReservationParams {
   338  	params.DequeueTimeout = &DequeueTimeout
   339  	return params
   340  }
   341  func (params *UpdateWorkerReservationParams) SetDequeueTo(DequeueTo string) *UpdateWorkerReservationParams {
   342  	params.DequeueTo = &DequeueTo
   343  	return params
   344  }
   345  func (params *UpdateWorkerReservationParams) SetDequeueStatusCallbackUrl(DequeueStatusCallbackUrl string) *UpdateWorkerReservationParams {
   346  	params.DequeueStatusCallbackUrl = &DequeueStatusCallbackUrl
   347  	return params
   348  }
   349  func (params *UpdateWorkerReservationParams) SetCallFrom(CallFrom string) *UpdateWorkerReservationParams {
   350  	params.CallFrom = &CallFrom
   351  	return params
   352  }
   353  func (params *UpdateWorkerReservationParams) SetCallRecord(CallRecord string) *UpdateWorkerReservationParams {
   354  	params.CallRecord = &CallRecord
   355  	return params
   356  }
   357  func (params *UpdateWorkerReservationParams) SetCallTimeout(CallTimeout int) *UpdateWorkerReservationParams {
   358  	params.CallTimeout = &CallTimeout
   359  	return params
   360  }
   361  func (params *UpdateWorkerReservationParams) SetCallTo(CallTo string) *UpdateWorkerReservationParams {
   362  	params.CallTo = &CallTo
   363  	return params
   364  }
   365  func (params *UpdateWorkerReservationParams) SetCallUrl(CallUrl string) *UpdateWorkerReservationParams {
   366  	params.CallUrl = &CallUrl
   367  	return params
   368  }
   369  func (params *UpdateWorkerReservationParams) SetCallStatusCallbackUrl(CallStatusCallbackUrl string) *UpdateWorkerReservationParams {
   370  	params.CallStatusCallbackUrl = &CallStatusCallbackUrl
   371  	return params
   372  }
   373  func (params *UpdateWorkerReservationParams) SetCallAccept(CallAccept bool) *UpdateWorkerReservationParams {
   374  	params.CallAccept = &CallAccept
   375  	return params
   376  }
   377  func (params *UpdateWorkerReservationParams) SetRedirectCallSid(RedirectCallSid string) *UpdateWorkerReservationParams {
   378  	params.RedirectCallSid = &RedirectCallSid
   379  	return params
   380  }
   381  func (params *UpdateWorkerReservationParams) SetRedirectAccept(RedirectAccept bool) *UpdateWorkerReservationParams {
   382  	params.RedirectAccept = &RedirectAccept
   383  	return params
   384  }
   385  func (params *UpdateWorkerReservationParams) SetRedirectUrl(RedirectUrl string) *UpdateWorkerReservationParams {
   386  	params.RedirectUrl = &RedirectUrl
   387  	return params
   388  }
   389  func (params *UpdateWorkerReservationParams) SetTo(To string) *UpdateWorkerReservationParams {
   390  	params.To = &To
   391  	return params
   392  }
   393  func (params *UpdateWorkerReservationParams) SetFrom(From string) *UpdateWorkerReservationParams {
   394  	params.From = &From
   395  	return params
   396  }
   397  func (params *UpdateWorkerReservationParams) SetStatusCallback(StatusCallback string) *UpdateWorkerReservationParams {
   398  	params.StatusCallback = &StatusCallback
   399  	return params
   400  }
   401  func (params *UpdateWorkerReservationParams) SetStatusCallbackMethod(StatusCallbackMethod string) *UpdateWorkerReservationParams {
   402  	params.StatusCallbackMethod = &StatusCallbackMethod
   403  	return params
   404  }
   405  func (params *UpdateWorkerReservationParams) SetStatusCallbackEvent(StatusCallbackEvent []string) *UpdateWorkerReservationParams {
   406  	params.StatusCallbackEvent = &StatusCallbackEvent
   407  	return params
   408  }
   409  func (params *UpdateWorkerReservationParams) SetTimeout(Timeout int) *UpdateWorkerReservationParams {
   410  	params.Timeout = &Timeout
   411  	return params
   412  }
   413  func (params *UpdateWorkerReservationParams) SetRecord(Record bool) *UpdateWorkerReservationParams {
   414  	params.Record = &Record
   415  	return params
   416  }
   417  func (params *UpdateWorkerReservationParams) SetMuted(Muted bool) *UpdateWorkerReservationParams {
   418  	params.Muted = &Muted
   419  	return params
   420  }
   421  func (params *UpdateWorkerReservationParams) SetBeep(Beep string) *UpdateWorkerReservationParams {
   422  	params.Beep = &Beep
   423  	return params
   424  }
   425  func (params *UpdateWorkerReservationParams) SetStartConferenceOnEnter(StartConferenceOnEnter bool) *UpdateWorkerReservationParams {
   426  	params.StartConferenceOnEnter = &StartConferenceOnEnter
   427  	return params
   428  }
   429  func (params *UpdateWorkerReservationParams) SetEndConferenceOnExit(EndConferenceOnExit bool) *UpdateWorkerReservationParams {
   430  	params.EndConferenceOnExit = &EndConferenceOnExit
   431  	return params
   432  }
   433  func (params *UpdateWorkerReservationParams) SetWaitUrl(WaitUrl string) *UpdateWorkerReservationParams {
   434  	params.WaitUrl = &WaitUrl
   435  	return params
   436  }
   437  func (params *UpdateWorkerReservationParams) SetWaitMethod(WaitMethod string) *UpdateWorkerReservationParams {
   438  	params.WaitMethod = &WaitMethod
   439  	return params
   440  }
   441  func (params *UpdateWorkerReservationParams) SetEarlyMedia(EarlyMedia bool) *UpdateWorkerReservationParams {
   442  	params.EarlyMedia = &EarlyMedia
   443  	return params
   444  }
   445  func (params *UpdateWorkerReservationParams) SetMaxParticipants(MaxParticipants int) *UpdateWorkerReservationParams {
   446  	params.MaxParticipants = &MaxParticipants
   447  	return params
   448  }
   449  func (params *UpdateWorkerReservationParams) SetConferenceStatusCallback(ConferenceStatusCallback string) *UpdateWorkerReservationParams {
   450  	params.ConferenceStatusCallback = &ConferenceStatusCallback
   451  	return params
   452  }
   453  func (params *UpdateWorkerReservationParams) SetConferenceStatusCallbackMethod(ConferenceStatusCallbackMethod string) *UpdateWorkerReservationParams {
   454  	params.ConferenceStatusCallbackMethod = &ConferenceStatusCallbackMethod
   455  	return params
   456  }
   457  func (params *UpdateWorkerReservationParams) SetConferenceStatusCallbackEvent(ConferenceStatusCallbackEvent []string) *UpdateWorkerReservationParams {
   458  	params.ConferenceStatusCallbackEvent = &ConferenceStatusCallbackEvent
   459  	return params
   460  }
   461  func (params *UpdateWorkerReservationParams) SetConferenceRecord(ConferenceRecord string) *UpdateWorkerReservationParams {
   462  	params.ConferenceRecord = &ConferenceRecord
   463  	return params
   464  }
   465  func (params *UpdateWorkerReservationParams) SetConferenceTrim(ConferenceTrim string) *UpdateWorkerReservationParams {
   466  	params.ConferenceTrim = &ConferenceTrim
   467  	return params
   468  }
   469  func (params *UpdateWorkerReservationParams) SetRecordingChannels(RecordingChannels string) *UpdateWorkerReservationParams {
   470  	params.RecordingChannels = &RecordingChannels
   471  	return params
   472  }
   473  func (params *UpdateWorkerReservationParams) SetRecordingStatusCallback(RecordingStatusCallback string) *UpdateWorkerReservationParams {
   474  	params.RecordingStatusCallback = &RecordingStatusCallback
   475  	return params
   476  }
   477  func (params *UpdateWorkerReservationParams) SetRecordingStatusCallbackMethod(RecordingStatusCallbackMethod string) *UpdateWorkerReservationParams {
   478  	params.RecordingStatusCallbackMethod = &RecordingStatusCallbackMethod
   479  	return params
   480  }
   481  func (params *UpdateWorkerReservationParams) SetConferenceRecordingStatusCallback(ConferenceRecordingStatusCallback string) *UpdateWorkerReservationParams {
   482  	params.ConferenceRecordingStatusCallback = &ConferenceRecordingStatusCallback
   483  	return params
   484  }
   485  func (params *UpdateWorkerReservationParams) SetConferenceRecordingStatusCallbackMethod(ConferenceRecordingStatusCallbackMethod string) *UpdateWorkerReservationParams {
   486  	params.ConferenceRecordingStatusCallbackMethod = &ConferenceRecordingStatusCallbackMethod
   487  	return params
   488  }
   489  func (params *UpdateWorkerReservationParams) SetRegion(Region string) *UpdateWorkerReservationParams {
   490  	params.Region = &Region
   491  	return params
   492  }
   493  func (params *UpdateWorkerReservationParams) SetSipAuthUsername(SipAuthUsername string) *UpdateWorkerReservationParams {
   494  	params.SipAuthUsername = &SipAuthUsername
   495  	return params
   496  }
   497  func (params *UpdateWorkerReservationParams) SetSipAuthPassword(SipAuthPassword string) *UpdateWorkerReservationParams {
   498  	params.SipAuthPassword = &SipAuthPassword
   499  	return params
   500  }
   501  func (params *UpdateWorkerReservationParams) SetDequeueStatusCallbackEvent(DequeueStatusCallbackEvent []string) *UpdateWorkerReservationParams {
   502  	params.DequeueStatusCallbackEvent = &DequeueStatusCallbackEvent
   503  	return params
   504  }
   505  func (params *UpdateWorkerReservationParams) SetPostWorkActivitySid(PostWorkActivitySid string) *UpdateWorkerReservationParams {
   506  	params.PostWorkActivitySid = &PostWorkActivitySid
   507  	return params
   508  }
   509  func (params *UpdateWorkerReservationParams) SetEndConferenceOnCustomerExit(EndConferenceOnCustomerExit bool) *UpdateWorkerReservationParams {
   510  	params.EndConferenceOnCustomerExit = &EndConferenceOnCustomerExit
   511  	return params
   512  }
   513  func (params *UpdateWorkerReservationParams) SetBeepOnCustomerEntrance(BeepOnCustomerEntrance bool) *UpdateWorkerReservationParams {
   514  	params.BeepOnCustomerEntrance = &BeepOnCustomerEntrance
   515  	return params
   516  }
   517  func (params *UpdateWorkerReservationParams) SetJitterBufferSize(JitterBufferSize string) *UpdateWorkerReservationParams {
   518  	params.JitterBufferSize = &JitterBufferSize
   519  	return params
   520  }
   521  
   522  //
   523  func (c *ApiService) UpdateWorkerReservation(WorkspaceSid string, WorkerSid string, Sid string, params *UpdateWorkerReservationParams) (*TaskrouterV1WorkerReservation, error) {
   524  	path := "/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Reservations/{Sid}"
   525  	path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1)
   526  	path = strings.Replace(path, "{"+"WorkerSid"+"}", WorkerSid, -1)
   527  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
   528  
   529  	data := url.Values{}
   530  	headers := make(map[string]interface{})
   531  
   532  	if params != nil && params.ReservationStatus != nil {
   533  		data.Set("ReservationStatus", *params.ReservationStatus)
   534  	}
   535  	if params != nil && params.WorkerActivitySid != nil {
   536  		data.Set("WorkerActivitySid", *params.WorkerActivitySid)
   537  	}
   538  	if params != nil && params.Instruction != nil {
   539  		data.Set("Instruction", *params.Instruction)
   540  	}
   541  	if params != nil && params.DequeuePostWorkActivitySid != nil {
   542  		data.Set("DequeuePostWorkActivitySid", *params.DequeuePostWorkActivitySid)
   543  	}
   544  	if params != nil && params.DequeueFrom != nil {
   545  		data.Set("DequeueFrom", *params.DequeueFrom)
   546  	}
   547  	if params != nil && params.DequeueRecord != nil {
   548  		data.Set("DequeueRecord", *params.DequeueRecord)
   549  	}
   550  	if params != nil && params.DequeueTimeout != nil {
   551  		data.Set("DequeueTimeout", fmt.Sprint(*params.DequeueTimeout))
   552  	}
   553  	if params != nil && params.DequeueTo != nil {
   554  		data.Set("DequeueTo", *params.DequeueTo)
   555  	}
   556  	if params != nil && params.DequeueStatusCallbackUrl != nil {
   557  		data.Set("DequeueStatusCallbackUrl", *params.DequeueStatusCallbackUrl)
   558  	}
   559  	if params != nil && params.CallFrom != nil {
   560  		data.Set("CallFrom", *params.CallFrom)
   561  	}
   562  	if params != nil && params.CallRecord != nil {
   563  		data.Set("CallRecord", *params.CallRecord)
   564  	}
   565  	if params != nil && params.CallTimeout != nil {
   566  		data.Set("CallTimeout", fmt.Sprint(*params.CallTimeout))
   567  	}
   568  	if params != nil && params.CallTo != nil {
   569  		data.Set("CallTo", *params.CallTo)
   570  	}
   571  	if params != nil && params.CallUrl != nil {
   572  		data.Set("CallUrl", *params.CallUrl)
   573  	}
   574  	if params != nil && params.CallStatusCallbackUrl != nil {
   575  		data.Set("CallStatusCallbackUrl", *params.CallStatusCallbackUrl)
   576  	}
   577  	if params != nil && params.CallAccept != nil {
   578  		data.Set("CallAccept", fmt.Sprint(*params.CallAccept))
   579  	}
   580  	if params != nil && params.RedirectCallSid != nil {
   581  		data.Set("RedirectCallSid", *params.RedirectCallSid)
   582  	}
   583  	if params != nil && params.RedirectAccept != nil {
   584  		data.Set("RedirectAccept", fmt.Sprint(*params.RedirectAccept))
   585  	}
   586  	if params != nil && params.RedirectUrl != nil {
   587  		data.Set("RedirectUrl", *params.RedirectUrl)
   588  	}
   589  	if params != nil && params.To != nil {
   590  		data.Set("To", *params.To)
   591  	}
   592  	if params != nil && params.From != nil {
   593  		data.Set("From", *params.From)
   594  	}
   595  	if params != nil && params.StatusCallback != nil {
   596  		data.Set("StatusCallback", *params.StatusCallback)
   597  	}
   598  	if params != nil && params.StatusCallbackMethod != nil {
   599  		data.Set("StatusCallbackMethod", *params.StatusCallbackMethod)
   600  	}
   601  	if params != nil && params.StatusCallbackEvent != nil {
   602  		for _, item := range *params.StatusCallbackEvent {
   603  			data.Add("StatusCallbackEvent", item)
   604  		}
   605  	}
   606  	if params != nil && params.Timeout != nil {
   607  		data.Set("Timeout", fmt.Sprint(*params.Timeout))
   608  	}
   609  	if params != nil && params.Record != nil {
   610  		data.Set("Record", fmt.Sprint(*params.Record))
   611  	}
   612  	if params != nil && params.Muted != nil {
   613  		data.Set("Muted", fmt.Sprint(*params.Muted))
   614  	}
   615  	if params != nil && params.Beep != nil {
   616  		data.Set("Beep", *params.Beep)
   617  	}
   618  	if params != nil && params.StartConferenceOnEnter != nil {
   619  		data.Set("StartConferenceOnEnter", fmt.Sprint(*params.StartConferenceOnEnter))
   620  	}
   621  	if params != nil && params.EndConferenceOnExit != nil {
   622  		data.Set("EndConferenceOnExit", fmt.Sprint(*params.EndConferenceOnExit))
   623  	}
   624  	if params != nil && params.WaitUrl != nil {
   625  		data.Set("WaitUrl", *params.WaitUrl)
   626  	}
   627  	if params != nil && params.WaitMethod != nil {
   628  		data.Set("WaitMethod", *params.WaitMethod)
   629  	}
   630  	if params != nil && params.EarlyMedia != nil {
   631  		data.Set("EarlyMedia", fmt.Sprint(*params.EarlyMedia))
   632  	}
   633  	if params != nil && params.MaxParticipants != nil {
   634  		data.Set("MaxParticipants", fmt.Sprint(*params.MaxParticipants))
   635  	}
   636  	if params != nil && params.ConferenceStatusCallback != nil {
   637  		data.Set("ConferenceStatusCallback", *params.ConferenceStatusCallback)
   638  	}
   639  	if params != nil && params.ConferenceStatusCallbackMethod != nil {
   640  		data.Set("ConferenceStatusCallbackMethod", *params.ConferenceStatusCallbackMethod)
   641  	}
   642  	if params != nil && params.ConferenceStatusCallbackEvent != nil {
   643  		for _, item := range *params.ConferenceStatusCallbackEvent {
   644  			data.Add("ConferenceStatusCallbackEvent", item)
   645  		}
   646  	}
   647  	if params != nil && params.ConferenceRecord != nil {
   648  		data.Set("ConferenceRecord", *params.ConferenceRecord)
   649  	}
   650  	if params != nil && params.ConferenceTrim != nil {
   651  		data.Set("ConferenceTrim", *params.ConferenceTrim)
   652  	}
   653  	if params != nil && params.RecordingChannels != nil {
   654  		data.Set("RecordingChannels", *params.RecordingChannels)
   655  	}
   656  	if params != nil && params.RecordingStatusCallback != nil {
   657  		data.Set("RecordingStatusCallback", *params.RecordingStatusCallback)
   658  	}
   659  	if params != nil && params.RecordingStatusCallbackMethod != nil {
   660  		data.Set("RecordingStatusCallbackMethod", *params.RecordingStatusCallbackMethod)
   661  	}
   662  	if params != nil && params.ConferenceRecordingStatusCallback != nil {
   663  		data.Set("ConferenceRecordingStatusCallback", *params.ConferenceRecordingStatusCallback)
   664  	}
   665  	if params != nil && params.ConferenceRecordingStatusCallbackMethod != nil {
   666  		data.Set("ConferenceRecordingStatusCallbackMethod", *params.ConferenceRecordingStatusCallbackMethod)
   667  	}
   668  	if params != nil && params.Region != nil {
   669  		data.Set("Region", *params.Region)
   670  	}
   671  	if params != nil && params.SipAuthUsername != nil {
   672  		data.Set("SipAuthUsername", *params.SipAuthUsername)
   673  	}
   674  	if params != nil && params.SipAuthPassword != nil {
   675  		data.Set("SipAuthPassword", *params.SipAuthPassword)
   676  	}
   677  	if params != nil && params.DequeueStatusCallbackEvent != nil {
   678  		for _, item := range *params.DequeueStatusCallbackEvent {
   679  			data.Add("DequeueStatusCallbackEvent", item)
   680  		}
   681  	}
   682  	if params != nil && params.PostWorkActivitySid != nil {
   683  		data.Set("PostWorkActivitySid", *params.PostWorkActivitySid)
   684  	}
   685  	if params != nil && params.EndConferenceOnCustomerExit != nil {
   686  		data.Set("EndConferenceOnCustomerExit", fmt.Sprint(*params.EndConferenceOnCustomerExit))
   687  	}
   688  	if params != nil && params.BeepOnCustomerEntrance != nil {
   689  		data.Set("BeepOnCustomerEntrance", fmt.Sprint(*params.BeepOnCustomerEntrance))
   690  	}
   691  	if params != nil && params.JitterBufferSize != nil {
   692  		data.Set("JitterBufferSize", *params.JitterBufferSize)
   693  	}
   694  
   695  	if params != nil && params.IfMatch != nil {
   696  		headers["If-Match"] = *params.IfMatch
   697  	}
   698  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   699  	if err != nil {
   700  		return nil, err
   701  	}
   702  
   703  	defer resp.Body.Close()
   704  
   705  	ps := &TaskrouterV1WorkerReservation{}
   706  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   707  		return nil, err
   708  	}
   709  
   710  	return ps, err
   711  }