github.com/twilio/twilio-go@v1.20.1/rest/insights/v1/voice_settings.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Insights 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 ) 22 23 // Optional parameters for the method 'FetchAccountSettings' 24 type FetchAccountSettingsParams struct { 25 // The unique SID identifier of the Subaccount. 26 SubaccountSid *string `json:"SubaccountSid,omitempty"` 27 } 28 29 func (params *FetchAccountSettingsParams) SetSubaccountSid(SubaccountSid string) *FetchAccountSettingsParams { 30 params.SubaccountSid = &SubaccountSid 31 return params 32 } 33 34 // Get the Voice Insights Settings. 35 func (c *ApiService) FetchAccountSettings(params *FetchAccountSettingsParams) (*InsightsV1AccountSettings, error) { 36 path := "/v1/Voice/Settings" 37 38 data := url.Values{} 39 headers := make(map[string]interface{}) 40 41 if params != nil && params.SubaccountSid != nil { 42 data.Set("SubaccountSid", *params.SubaccountSid) 43 } 44 45 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 46 if err != nil { 47 return nil, err 48 } 49 50 defer resp.Body.Close() 51 52 ps := &InsightsV1AccountSettings{} 53 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 54 return nil, err 55 } 56 57 return ps, err 58 } 59 60 // Optional parameters for the method 'UpdateAccountSettings' 61 type UpdateAccountSettingsParams struct { 62 // A boolean flag to enable Advanced Features for Voice Insights. 63 AdvancedFeatures *bool `json:"AdvancedFeatures,omitempty"` 64 // A boolean flag to enable Voice Trace. 65 VoiceTrace *bool `json:"VoiceTrace,omitempty"` 66 // The unique SID identifier of the Subaccount. 67 SubaccountSid *string `json:"SubaccountSid,omitempty"` 68 } 69 70 func (params *UpdateAccountSettingsParams) SetAdvancedFeatures(AdvancedFeatures bool) *UpdateAccountSettingsParams { 71 params.AdvancedFeatures = &AdvancedFeatures 72 return params 73 } 74 func (params *UpdateAccountSettingsParams) SetVoiceTrace(VoiceTrace bool) *UpdateAccountSettingsParams { 75 params.VoiceTrace = &VoiceTrace 76 return params 77 } 78 func (params *UpdateAccountSettingsParams) SetSubaccountSid(SubaccountSid string) *UpdateAccountSettingsParams { 79 params.SubaccountSid = &SubaccountSid 80 return params 81 } 82 83 // Update a specific Voice Insights Setting. 84 func (c *ApiService) UpdateAccountSettings(params *UpdateAccountSettingsParams) (*InsightsV1AccountSettings, error) { 85 path := "/v1/Voice/Settings" 86 87 data := url.Values{} 88 headers := make(map[string]interface{}) 89 90 if params != nil && params.AdvancedFeatures != nil { 91 data.Set("AdvancedFeatures", fmt.Sprint(*params.AdvancedFeatures)) 92 } 93 if params != nil && params.VoiceTrace != nil { 94 data.Set("VoiceTrace", fmt.Sprint(*params.VoiceTrace)) 95 } 96 if params != nil && params.SubaccountSid != nil { 97 data.Set("SubaccountSid", *params.SubaccountSid) 98 } 99 100 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 101 if err != nil { 102 return nil, err 103 } 104 105 defer resp.Body.Close() 106 107 ps := &InsightsV1AccountSettings{} 108 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 109 return nil, err 110 } 111 112 return ps, err 113 }