github.com/twilio/twilio-go@v1.20.1/rest/studio/v2/flows_test_users.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Studio
     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  // Fetch flow test users
    24  func (c *ApiService) FetchTestUser(Sid string) (*StudioV2TestUser, error) {
    25  	path := "/v2/Flows/{Sid}/TestUsers"
    26  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    27  
    28  	data := url.Values{}
    29  	headers := make(map[string]interface{})
    30  
    31  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    32  	if err != nil {
    33  		return nil, err
    34  	}
    35  
    36  	defer resp.Body.Close()
    37  
    38  	ps := &StudioV2TestUser{}
    39  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    40  		return nil, err
    41  	}
    42  
    43  	return ps, err
    44  }
    45  
    46  // Optional parameters for the method 'UpdateTestUser'
    47  type UpdateTestUserParams struct {
    48  	// List of test user identities that can test draft versions of the flow.
    49  	TestUsers *[]string `json:"TestUsers,omitempty"`
    50  }
    51  
    52  func (params *UpdateTestUserParams) SetTestUsers(TestUsers []string) *UpdateTestUserParams {
    53  	params.TestUsers = &TestUsers
    54  	return params
    55  }
    56  
    57  // Update flow test users
    58  func (c *ApiService) UpdateTestUser(Sid string, params *UpdateTestUserParams) (*StudioV2TestUser, error) {
    59  	path := "/v2/Flows/{Sid}/TestUsers"
    60  	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
    61  
    62  	data := url.Values{}
    63  	headers := make(map[string]interface{})
    64  
    65  	if params != nil && params.TestUsers != nil {
    66  		for _, item := range *params.TestUsers {
    67  			data.Add("TestUsers", item)
    68  		}
    69  	}
    70  
    71  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    72  	if err != nil {
    73  		return nil, err
    74  	}
    75  
    76  	defer resp.Body.Close()
    77  
    78  	ps := &StudioV2TestUser{}
    79  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    80  		return nil, err
    81  	}
    82  
    83  	return ps, err
    84  }