-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into natebrennand/add-context-methods-to-base-client
- Loading branch information
Showing
67 changed files
with
573 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
rest/api/v2010/accounts_calls_user_defined_message_subscriptions.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* This code was generated by | ||
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ | ||
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | ||
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ | ||
* | ||
* Twilio - Api | ||
* This is the public Twilio REST API. | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator. | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
package openapi | ||
|
||
import ( | ||
"encoding/json" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
// Optional parameters for the method 'CreateUserDefinedMessageSubscription' | ||
type CreateUserDefinedMessageSubscriptionParams struct { | ||
// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages. | ||
PathAccountSid *string `json:"PathAccountSid,omitempty"` | ||
// The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted). | ||
Callback *string `json:"Callback,omitempty"` | ||
// The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. | ||
Method *string `json:"Method,omitempty"` | ||
// A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. | ||
IdempotencyKey *string `json:"IdempotencyKey,omitempty"` | ||
} | ||
|
||
func (params *CreateUserDefinedMessageSubscriptionParams) SetPathAccountSid(PathAccountSid string) *CreateUserDefinedMessageSubscriptionParams { | ||
params.PathAccountSid = &PathAccountSid | ||
return params | ||
} | ||
func (params *CreateUserDefinedMessageSubscriptionParams) SetCallback(Callback string) *CreateUserDefinedMessageSubscriptionParams { | ||
params.Callback = &Callback | ||
return params | ||
} | ||
func (params *CreateUserDefinedMessageSubscriptionParams) SetMethod(Method string) *CreateUserDefinedMessageSubscriptionParams { | ||
params.Method = &Method | ||
return params | ||
} | ||
func (params *CreateUserDefinedMessageSubscriptionParams) SetIdempotencyKey(IdempotencyKey string) *CreateUserDefinedMessageSubscriptionParams { | ||
params.IdempotencyKey = &IdempotencyKey | ||
return params | ||
} | ||
|
||
// Subscribe to User Defined Messages for a given call sid. | ||
func (c *ApiService) CreateUserDefinedMessageSubscription(CallSid string, params *CreateUserDefinedMessageSubscriptionParams) (*ApiV2010UserDefinedMessageSubscription, error) { | ||
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/UserDefinedMessageSubscriptions.json" | ||
if params != nil && params.PathAccountSid != nil { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) | ||
} else { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) | ||
} | ||
path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) | ||
|
||
data := url.Values{} | ||
headers := make(map[string]interface{}) | ||
|
||
if params != nil && params.Callback != nil { | ||
data.Set("Callback", *params.Callback) | ||
} | ||
if params != nil && params.Method != nil { | ||
data.Set("Method", *params.Method) | ||
} | ||
if params != nil && params.IdempotencyKey != nil { | ||
data.Set("IdempotencyKey", *params.IdempotencyKey) | ||
} | ||
|
||
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
ps := &ApiV2010UserDefinedMessageSubscription{} | ||
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { | ||
return nil, err | ||
} | ||
|
||
return ps, err | ||
} | ||
|
||
// Optional parameters for the method 'DeleteUserDefinedMessageSubscription' | ||
type DeleteUserDefinedMessageSubscriptionParams struct { | ||
// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages. | ||
PathAccountSid *string `json:"PathAccountSid,omitempty"` | ||
} | ||
|
||
func (params *DeleteUserDefinedMessageSubscriptionParams) SetPathAccountSid(PathAccountSid string) *DeleteUserDefinedMessageSubscriptionParams { | ||
params.PathAccountSid = &PathAccountSid | ||
return params | ||
} | ||
|
||
// Delete a specific User Defined Message Subscription. | ||
func (c *ApiService) DeleteUserDefinedMessageSubscription(CallSid string, Sid string, params *DeleteUserDefinedMessageSubscriptionParams) error { | ||
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/UserDefinedMessageSubscriptions/{Sid}.json" | ||
if params != nil && params.PathAccountSid != nil { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) | ||
} else { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) | ||
} | ||
path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) | ||
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) | ||
|
||
data := url.Values{} | ||
headers := make(map[string]interface{}) | ||
|
||
resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* This code was generated by | ||
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ | ||
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | ||
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ | ||
* | ||
* Twilio - Api | ||
* This is the public Twilio REST API. | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator. | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
package openapi | ||
|
||
import ( | ||
"encoding/json" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
// Optional parameters for the method 'CreateUserDefinedMessage' | ||
type CreateUserDefinedMessageParams struct { | ||
// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message. | ||
PathAccountSid *string `json:"PathAccountSid,omitempty"` | ||
// A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. | ||
Content *string `json:"Content,omitempty"` | ||
// A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. | ||
IdempotencyKey *string `json:"IdempotencyKey,omitempty"` | ||
} | ||
|
||
func (params *CreateUserDefinedMessageParams) SetPathAccountSid(PathAccountSid string) *CreateUserDefinedMessageParams { | ||
params.PathAccountSid = &PathAccountSid | ||
return params | ||
} | ||
func (params *CreateUserDefinedMessageParams) SetContent(Content string) *CreateUserDefinedMessageParams { | ||
params.Content = &Content | ||
return params | ||
} | ||
func (params *CreateUserDefinedMessageParams) SetIdempotencyKey(IdempotencyKey string) *CreateUserDefinedMessageParams { | ||
params.IdempotencyKey = &IdempotencyKey | ||
return params | ||
} | ||
|
||
// Create a new User Defined Message for the given call sid. | ||
func (c *ApiService) CreateUserDefinedMessage(CallSid string, params *CreateUserDefinedMessageParams) (*ApiV2010UserDefinedMessage, error) { | ||
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/UserDefinedMessages.json" | ||
if params != nil && params.PathAccountSid != nil { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) | ||
} else { | ||
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) | ||
} | ||
path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) | ||
|
||
data := url.Values{} | ||
headers := make(map[string]interface{}) | ||
|
||
if params != nil && params.Content != nil { | ||
data.Set("Content", *params.Content) | ||
} | ||
if params != nil && params.IdempotencyKey != nil { | ||
data.Set("IdempotencyKey", *params.IdempotencyKey) | ||
} | ||
|
||
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
ps := &ApiV2010UserDefinedMessage{} | ||
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { | ||
return nil, err | ||
} | ||
|
||
return ps, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.