From 224baa6cde79e086e3eed079ff437efbc7bea786 Mon Sep 17 00:00:00 2001 From: sburman Date: Tue, 4 Nov 2025 14:58:30 +0530 Subject: [PATCH] update to delete allowed status --- .../src/Twilio/Rest/Oauth/V2/TokenOptions.cs | 1 + .../src/Twilio/Rest/Oauth/V2/TokenResource.cs | 1 + .../go-client/helper/rest/api/v2010/README.md | 2 +- .../v2010/model_test_fetch_response_object.go | 46 +- .../api/v2010/model_test_response_object.go | 42 +- ...nse_object_test_array_of_objects_inner.go} | 8 +- .../com/twilio/rest/api/v2010/Account.java | 685 ++++++++------ .../twilio/rest/api/v2010/AccountCreator.java | 180 ++-- .../twilio/rest/api/v2010/AccountDeleter.java | 89 +- .../twilio/rest/api/v2010/AccountFetcher.java | 85 +- .../twilio/rest/api/v2010/AccountReader.java | 217 +++-- .../twilio/rest/api/v2010/AccountUpdater.java | 127 ++- .../twilio/rest/api/v2010/account/Call.java | 614 ++++++++----- .../rest/api/v2010/account/CallCreator.java | 189 ++-- .../rest/api/v2010/account/CallDeleter.java | 91 +- .../rest/api/v2010/account/CallFetcher.java | 87 +- .../account/call/FeedbackCallSummary.java | 572 +++++++----- .../call/FeedbackCallSummaryUpdater.java | 146 +-- .../java/com/twilio/rest/flexapi/v1/Call.java | 161 ++-- .../twilio/rest/flexapi/v1/CallUpdater.java | 90 +- .../rest/flexapi/v1/credential/Aws.java | 239 +++-- .../flexapi/v1/credential/AwsDeleter.java | 89 +- .../flexapi/v1/credential/AwsFetcher.java | 85 +- .../rest/flexapi/v1/credential/AwsReader.java | 135 +-- .../flexapi/v1/credential/AwsUpdater.java | 124 ++- .../flexapi/v1/credential/NewCredentials.java | 304 ++++--- .../v1/credential/NewCredentialsCreator.java | 451 ++++++---- .../flexapi/v1/credential/aws/History.java | 200 ++-- .../v1/credential/aws/HistoryFetcher.java | 107 ++- .../java/com/twilio/rest/oauth/v2/Token.java | 215 +++-- .../twilio/rest/oauth/v2/TokenCreator.java | 249 +++-- .../rest/previewiam/organizations/User.java | 385 -------- .../previewiam/organizations/UserCreator.java | 103 --- .../previewiam/organizations/UserDeleter.java | 85 -- .../previewiam/organizations/UserFetcher.java | 87 -- .../previewiam/organizations/UserReader.java | 143 --- .../previewiam/organizations/UserUpdater.java | 114 --- .../com/twilio/rest/previewiam/v1/Token.java | 193 ---- .../rest/previewiam/v1/TokenCreator.java | 166 ---- .../versionless/deployedDevices/Fleet.java | 215 +++-- .../deployedDevices/FleetCreator.java | 102 ++- .../deployedDevices/FleetFetcher.java | 85 +- .../versionless/understand/Assistant.java | 174 ++-- .../understand/AssistantReader.java | 135 +-- examples/node/src/rest/api/v2010/account.ts | 10 +- .../node/src/rest/api/v2010/account/call.ts | 10 +- .../v2010/account/call/feedbackCallSummary.ts | 10 +- examples/node/src/rest/previewIam/V1.ts | 46 - .../node/src/rest/previewIam/Versionless.ts | 37 - .../node/src/rest/previewIam/v1/authorize.ts | 174 ---- examples/node/src/rest/previewIam/v1/token.ts | 203 ----- .../previewIam/versionless/organization.ts | 138 --- .../versionless/organization/account.ts | 471 ---------- .../organization/roleAssignment.ts | 578 ------------ .../versionless/organization/user.ts | 851 ------------------ examples/php/src/Twilio/Rest/Api/V2010.php | 132 --- .../Call/FeedbackCallSummaryContext.php | 110 --- .../Call/FeedbackCallSummaryInstance.php | 159 ---- .../Account/Call/FeedbackCallSummaryList.php | 80 -- .../Call/FeedbackCallSummaryOptions.php | 83 -- .../Account/Call/FeedbackCallSummaryPage.php | 55 -- .../Rest/Api/V2010/Account/CallContext.php | 149 --- .../Rest/Api/V2010/Account/CallInstance.php | 169 ---- .../Rest/Api/V2010/Account/CallList.php | 174 ---- .../Rest/Api/V2010/Account/CallOptions.php | 104 --- .../Rest/Api/V2010/Account/CallPage.php | 55 -- .../Twilio/Rest/Api/V2010/AccountContext.php | 192 ---- .../Twilio/Rest/Api/V2010/AccountInstance.php | 195 ---- .../src/Twilio/Rest/Api/V2010/AccountList.php | 213 ----- .../Twilio/Rest/Api/V2010/AccountOptions.php | 284 ------ .../src/Twilio/Rest/Api/V2010/AccountPage.php | 55 -- .../php/src/Twilio/Rest/PreviewIam/V1.php | 105 --- .../Rest/PreviewIam/V1/AuthorizeInstance.php | 87 -- .../Rest/PreviewIam/V1/AuthorizeList.php | 95 -- .../Rest/PreviewIam/V1/AuthorizeOptions.php | 157 ---- .../Rest/PreviewIam/V1/AuthorizePage.php | 55 -- .../Rest/PreviewIam/V1/TokenInstance.php | 95 -- .../Twilio/Rest/PreviewIam/V1/TokenList.php | 103 --- .../Rest/PreviewIam/V1/TokenOptions.php | 175 ---- .../Twilio/Rest/PreviewIam/V1/TokenPage.php | 55 -- .../Twilio/Rest/PreviewIam/Versionless.php | 95 -- .../Organization/AccountContext.php | 96 -- .../Organization/AccountInstance.php | 132 --- .../Versionless/Organization/AccountList.php | 176 ---- .../Versionless/Organization/AccountPage.php | 55 -- .../Organization/RoleAssignmentContext.php | 89 -- .../Organization/RoleAssignmentInstance.php | 130 --- .../Organization/RoleAssignmentList.php | 206 ----- .../Organization/RoleAssignmentModels.php | 64 -- .../Organization/RoleAssignmentOptions.php | 103 --- .../Organization/RoleAssignmentPage.php | 55 -- .../Versionless/Organization/UserContext.php | 136 --- .../Versionless/Organization/UserInstance.php | 170 ---- .../Versionless/Organization/UserList.php | 204 ----- .../Versionless/Organization/UserModels.php | 268 ------ .../Versionless/Organization/UserOptions.php | 139 --- .../Versionless/Organization/UserPage.php | 55 -- .../Versionless/OrganizationContext.php | 203 ----- .../Versionless/OrganizationInstance.php | 155 ---- .../Versionless/OrganizationList.php | 78 -- .../Versionless/OrganizationPage.php | 55 -- .../twilio-java/common/imports.mustache | 4 +- .../deleter/operationMethod.mustache | 15 +- 103 files changed, 3962 insertions(+), 12003 deletions(-) rename examples/go/go-client/helper/rest/api/v2010/{model_test_response_object_test_array_of_objects.go => model_test_response_object_test_array_of_objects_inner.go} (76%) delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/User.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserDeleter.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserFetcher.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserReader.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java delete mode 100644 examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java delete mode 100644 examples/node/src/rest/previewIam/V1.ts delete mode 100644 examples/node/src/rest/previewIam/Versionless.ts delete mode 100644 examples/node/src/rest/previewIam/v1/authorize.ts delete mode 100644 examples/node/src/rest/previewIam/v1/token.ts delete mode 100644 examples/node/src/rest/previewIam/versionless/organization.ts delete mode 100644 examples/node/src/rest/previewIam/versionless/organization/account.ts delete mode 100644 examples/node/src/rest/previewIam/versionless/organization/roleAssignment.ts delete mode 100644 examples/node/src/rest/previewIam/versionless/organization/user.ts delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryContext.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryInstance.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryList.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryOptions.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryPage.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/CallContext.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/CallInstance.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/CallList.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/CallOptions.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/Account/CallPage.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/AccountContext.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/AccountInstance.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/AccountList.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/AccountOptions.php delete mode 100644 examples/php/src/Twilio/Rest/Api/V2010/AccountPage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeOptions.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizePage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/TokenInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/TokenList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/TokenOptions.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/V1/TokenPage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountContext.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountPage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentContext.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentModels.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentOptions.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentPage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserContext.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserModels.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserOptions.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserPage.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationContext.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationInstance.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationList.php delete mode 100644 examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationPage.php diff --git a/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenOptions.cs b/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenOptions.cs index b393b4186..05e507844 100644 --- a/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenOptions.cs +++ b/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenOptions.cs @@ -98,5 +98,6 @@ public List> GetParams() } + } diff --git a/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenResource.cs b/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenResource.cs index bdfe34d63..57bbb2d91 100644 --- a/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenResource.cs +++ b/examples/csharp/src/Twilio/Rest/Oauth/V2/TokenResource.cs @@ -127,6 +127,7 @@ public static async System.Threading.Tasks.Task CreateAsync( return await CreateAsync(options, client); } #endif + /// /// Converts a JSON string into a TokenResource object diff --git a/examples/go/go-client/helper/rest/api/v2010/README.md b/examples/go/go-client/helper/rest/api/v2010/README.md index 5fbc3509c..bbac26009 100644 --- a/examples/go/go-client/helper/rest/api/v2010/README.md +++ b/examples/go/go-client/helper/rest/api/v2010/README.md @@ -49,7 +49,7 @@ Class | Method | HTTP request | Description - [TestResponseObjectTestObject](docs/TestResponseObjectTestObject.md) - [TestFetchResponseObject](docs/TestFetchResponseObject.md) - [TestResponseObject](docs/TestResponseObject.md) - - [TestResponseObjectTestArrayOfObjects](docs/TestResponseObjectTestArrayOfObjects.md) + - [TestResponseObjectTestArrayOfObjectsInner](docs/TestResponseObjectTestArrayOfObjectsInner.md) ## Documentation For Authorization diff --git a/examples/go/go-client/helper/rest/api/v2010/model_test_fetch_response_object.go b/examples/go/go-client/helper/rest/api/v2010/model_test_fetch_response_object.go index 7d1da55b4..3c85a1375 100644 --- a/examples/go/go-client/helper/rest/api/v2010/model_test_fetch_response_object.go +++ b/examples/go/go-client/helper/rest/api/v2010/model_test_fetch_response_object.go @@ -35,10 +35,10 @@ type TestFetchResponseObject struct { TestNumberDecimal *float64 `json:"test_number_decimal,omitempty"` TestEnum *string `json:"test_enum,omitempty"` // A2P Messaging Profile Bundle BundleSid - A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid,omitempty"` - TestArrayOfIntegers []int `json:"test_array_of_integers,omitempty"` - TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers,omitempty"` - TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects,omitempty"` + A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid,omitempty"` + TestArrayOfIntegers []int `json:"test_array_of_integers,omitempty"` + TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers,omitempty"` + TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjectsInner `json:"test_array_of_objects,omitempty"` // Permissions authorized to the app TestArrayOfEnum *[]string `json:"test_array_of_enum,omitempty"` // The status of the user @@ -49,25 +49,25 @@ type TestFetchResponseObject struct { func (response *TestFetchResponseObject) UnmarshalJSON(bytes []byte) (err error) { raw := struct { - AccountSid *string `json:"account_sid"` - Sid *string `json:"sid"` - TestString *string `json:"test_string"` - TestInteger *int `json:"test_integer"` - TestObject *TestResponseObjectTestObject `json:"test_object"` - TestDateTime *string `json:"test_date_time"` - TestNumber *interface{} `json:"test_number"` - From *string `json:"from"` - PriceUnit *string `json:"price_unit"` - TestNumberFloat *interface{} `json:"test_number_float"` - TestNumberDecimal *float64 `json:"test_number_decimal"` - TestEnum *string `json:"test_enum"` - A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid"` - TestArrayOfIntegers []int `json:"test_array_of_integers"` - TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers"` - TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects"` - TestArrayOfEnum *[]string `json:"test_array_of_enum"` - Status string `json:"status"` - Message string `json:"message"` + AccountSid *string `json:"account_sid"` + Sid *string `json:"sid"` + TestString *string `json:"test_string"` + TestInteger *int `json:"test_integer"` + TestObject *TestResponseObjectTestObject `json:"test_object"` + TestDateTime *string `json:"test_date_time"` + TestNumber *interface{} `json:"test_number"` + From *string `json:"from"` + PriceUnit *string `json:"price_unit"` + TestNumberFloat *interface{} `json:"test_number_float"` + TestNumberDecimal *float64 `json:"test_number_decimal"` + TestEnum *string `json:"test_enum"` + A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid"` + TestArrayOfIntegers []int `json:"test_array_of_integers"` + TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers"` + TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjectsInner `json:"test_array_of_objects"` + TestArrayOfEnum *[]string `json:"test_array_of_enum"` + Status string `json:"status"` + Message string `json:"message"` }{} if err = json.Unmarshal(bytes, &raw); err != nil { diff --git a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go index ab294fc6c..d65d3c42d 100644 --- a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go +++ b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go @@ -35,33 +35,33 @@ type TestResponseObject struct { TestNumberDecimal *float64 `json:"test_number_decimal,omitempty"` TestEnum *string `json:"test_enum,omitempty"` // A2P Messaging Profile Bundle BundleSid - A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid,omitempty"` - TestArrayOfIntegers []int `json:"test_array_of_integers,omitempty"` - TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers,omitempty"` - TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects,omitempty"` + A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid,omitempty"` + TestArrayOfIntegers []int `json:"test_array_of_integers,omitempty"` + TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers,omitempty"` + TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjectsInner `json:"test_array_of_objects,omitempty"` // Permissions authorized to the app TestArrayOfEnum *[]string `json:"test_array_of_enum,omitempty"` } func (response *TestResponseObject) UnmarshalJSON(bytes []byte) (err error) { raw := struct { - AccountSid *string `json:"account_sid"` - Sid *string `json:"sid"` - TestString *string `json:"test_string"` - TestInteger *int `json:"test_integer"` - TestObject *TestResponseObjectTestObject `json:"test_object"` - TestDateTime *string `json:"test_date_time"` - TestNumber *interface{} `json:"test_number"` - From *string `json:"from"` - PriceUnit *string `json:"price_unit"` - TestNumberFloat *interface{} `json:"test_number_float"` - TestNumberDecimal *float64 `json:"test_number_decimal"` - TestEnum *string `json:"test_enum"` - A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid"` - TestArrayOfIntegers []int `json:"test_array_of_integers"` - TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers"` - TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects"` - TestArrayOfEnum *[]string `json:"test_array_of_enum"` + AccountSid *string `json:"account_sid"` + Sid *string `json:"sid"` + TestString *string `json:"test_string"` + TestInteger *int `json:"test_integer"` + TestObject *TestResponseObjectTestObject `json:"test_object"` + TestDateTime *string `json:"test_date_time"` + TestNumber *interface{} `json:"test_number"` + From *string `json:"from"` + PriceUnit *string `json:"price_unit"` + TestNumberFloat *interface{} `json:"test_number_float"` + TestNumberDecimal *float64 `json:"test_number_decimal"` + TestEnum *string `json:"test_enum"` + A2pProfileBundleSid *string `json:"a2p_profile_bundle_sid"` + TestArrayOfIntegers []int `json:"test_array_of_integers"` + TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers"` + TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjectsInner `json:"test_array_of_objects"` + TestArrayOfEnum *[]string `json:"test_array_of_enum"` }{} if err = json.Unmarshal(bytes, &raw); err != nil { diff --git a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects.go b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects_inner.go similarity index 76% rename from examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects.go rename to examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects_inner.go index dd4cf95b1..3eead6aad 100644 --- a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects.go +++ b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object_test_array_of_objects_inner.go @@ -20,13 +20,13 @@ import ( "github.com/twilio/twilio-go/client" ) -// TestResponseObjectTestArrayOfObjects struct for TestResponseObjectTestArrayOfObjects -type TestResponseObjectTestArrayOfObjects struct { +// TestResponseObjectTestArrayOfObjectsInner struct for TestResponseObjectTestArrayOfObjectsInner +type TestResponseObjectTestArrayOfObjectsInner struct { Count float32 `json:"count,omitempty"` Description string `json:"description,omitempty"` } -func (response *TestResponseObjectTestArrayOfObjects) UnmarshalJSON(bytes []byte) (err error) { +func (response *TestResponseObjectTestArrayOfObjectsInner) UnmarshalJSON(bytes []byte) (err error) { raw := struct { Count interface{} `json:"count"` Description string `json:"description"` @@ -36,7 +36,7 @@ func (response *TestResponseObjectTestArrayOfObjects) UnmarshalJSON(bytes []byte return err } - *response = TestResponseObjectTestArrayOfObjects{ + *response = TestResponseObjectTestArrayOfObjectsInner{ Description: raw.Description, } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java index de84fce8a..e51c1a15a 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,76 +39,286 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Account extends Resource { - private static final long serialVersionUID = 47015198707523L; + + + + public static AccountCreator creator() { + return new AccountCreator( + + ); + } + + + + + - public static AccountCreator creator(){ - return new AccountCreator(); + + + public static AccountDeleter deleter() { + return new AccountDeleter( + + ); } - public static AccountDeleter deleter(){ - return new AccountDeleter(); + + public static AccountDeleter deleter(final String pathSid) { + return new AccountDeleter( + pathSid + ); } - public static AccountDeleter deleter(final String pathSid){ - return new AccountDeleter(pathSid); + + + + + + + + + + public static AccountFetcher fetcher() { + return new AccountFetcher( + + ); } - public static AccountFetcher fetcher(){ - return new AccountFetcher(); + + public static AccountFetcher fetcher(final String pathSid) { + return new AccountFetcher( + pathSid + ); } - public static AccountFetcher fetcher(final String pathSid){ - return new AccountFetcher(pathSid); + + + + + + + + + + public static AccountReader reader() { + return new AccountReader( + + ); } - public static AccountReader reader(){ - return new AccountReader(); + + + + + + + + + public static AccountUpdater updater(final Account.Status status) { + return new AccountUpdater( + status + ); + } + + + public static AccountUpdater updater(final String pathSid, final Account.Status status) { + return new AccountUpdater( + pathSid, status + ); + } + + + +public enum Status { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private Status(final String value) { + this.value = value; } - public static AccountUpdater updater(final Account.Status status){ - return new AccountUpdater(status); + public String toString() { + return value; } - public static AccountUpdater updater(final String pathSid, final Account.Status status){ - return new AccountUpdater(pathSid, status); + + @JsonCreator + public static Status forValue(final String value) { + return Promoter.enumFromString(value, Status.values()); } +} +public enum AccountStatus { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private AccountStatus(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static AccountStatus forValue(final String value) { + return Promoter.enumFromString(value, AccountStatus.values()); + } +} +public enum XTwilioWebhookEnabled { + TRUE("true"), + FALSE("false"); + + private final String value; + + private XTwilioWebhookEnabled(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static XTwilioWebhookEnabled forValue(final String value) { + return Promoter.enumFromString(value, XTwilioWebhookEnabled.values()); + } +} + + + @JsonDeserialize(builder = TestResponseObjectTestArrayOfObjectsInner.Builder.class) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class TestResponseObjectTestArrayOfObjectsInner { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + @Getter private final BigDecimal count; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter private final String description; + + + private TestResponseObjectTestArrayOfObjectsInner(Builder builder) { + this.count = builder.count; + this.description = builder.description; + } + public static Builder builder() { + return new Builder(); + } + + public static TestResponseObjectTestArrayOfObjectsInner fromJson(String jsonString, ObjectMapper mapper) throws IOException { + return mapper.readValue(jsonString, TestResponseObjectTestArrayOfObjectsInner.class); + } + + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + @JsonProperty("count") + private BigDecimal count; + + @JsonProperty("description") + private String description; + + + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + public Builder count(BigDecimal count) { + this.count = count; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + public Builder description(String description) { + this.description = description; + return this; + } + + public TestResponseObjectTestArrayOfObjectsInner build() { + return new TestResponseObjectTestArrayOfObjectsInner(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestResponseObjectTestArrayOfObjectsInner other = (TestResponseObjectTestArrayOfObjectsInner) o; + return ( + Objects.equals(count, other.count) && + Objects.equals(description, other.description) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + count, + description + ); + } + + } + /** * Converts a JSON String into a Account object using the provided ObjectMapper. @@ -147,227 +357,182 @@ public static Account fromJson(final InputStream json, final ObjectMapper object } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter + private final String a2pProfileBundleSid; + @Getter private final String accountSid; - private final String sid; - private final String testString; - private final Integer testInteger; - private final PhoneNumberCapabilities testObject; - private final ZonedDateTime testDateTime; - private final BigDecimal testNumber; + @Getter private final com.twilio.type.PhoneNumber from; + @Getter + private final String message; + @Getter private final Currency priceUnit; - private final Float testNumberFloat; - private final BigDecimal testNumberDecimal; - private final Account.Status testEnum; - private final String a2pProfileBundleSid; - private final List testArrayOfIntegers; + @Getter + private final String sid; + @Getter + private final String status; + @Getter private final List> testArrayOfArrayOfIntegers; - private final List testArrayOfObjects; + @Getter private final List testArrayOfEnum; - private final String status; - private final String message; - - @JsonCreator - private Account( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, - - @JsonProperty("test_integer") - final Integer testInteger, - - @JsonProperty("test_object") - final PhoneNumberCapabilities testObject, - - @JsonProperty("test_date_time") - final String testDateTime, - - @JsonProperty("test_number") - final BigDecimal testNumber, - - @JsonProperty("from") - final com.twilio.type.PhoneNumber from, - - @JsonProperty("price_unit") - @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) - final Currency priceUnit, - - @JsonProperty("test_number_float") - final Float testNumberFloat, - - @JsonProperty("test_number_decimal") - final BigDecimal testNumberDecimal, - - @JsonProperty("test_enum") - final Account.Status testEnum, - - @JsonProperty("a2p_profile_bundle_sid") - final String a2pProfileBundleSid, - - @JsonProperty("test_array_of_integers") - final List testArrayOfIntegers, - - @JsonProperty("test_array_of_array_of_integers") - final List> testArrayOfArrayOfIntegers, - - @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("test_array_of_enum") - final List testArrayOfEnum, - - @JsonProperty("status") - final String status, - - @JsonProperty("message") - final String message - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; - this.testObject = testObject; - this.testDateTime = DateConverter.rfc2822DateTimeFromString(testDateTime); - this.testNumber = testNumber; - this.from = from; - this.priceUnit = priceUnit; - this.testNumberFloat = testNumberFloat; - this.testNumberDecimal = testNumberDecimal; - this.testEnum = testEnum; - this.a2pProfileBundleSid = a2pProfileBundleSid; - this.testArrayOfIntegers = testArrayOfIntegers; - this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; - this.testArrayOfObjects = testArrayOfObjects; - this.testArrayOfEnum = testArrayOfEnum; - this.status = status; - this.message = message; - } - - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - public final PhoneNumberCapabilities getTestObject() { - return this.testObject; - } - public final ZonedDateTime getTestDateTime() { - return this.testDateTime; - } - public final BigDecimal getTestNumber() { - return this.testNumber; - } - public final com.twilio.type.PhoneNumber getFrom() { - return this.from; - } - public final Currency getPriceUnit() { - return this.priceUnit; - } - public final Float getTestNumberFloat() { - return this.testNumberFloat; - } - public final BigDecimal getTestNumberDecimal() { - return this.testNumberDecimal; - } - public final Account.Status getTestEnum() { - return this.testEnum; - } - public final String getA2pProfileBundleSid() { - return this.a2pProfileBundleSid; - } - public final List getTestArrayOfIntegers() { - return this.testArrayOfIntegers; - } - public final List> getTestArrayOfArrayOfIntegers() { - return this.testArrayOfArrayOfIntegers; - } - public final List getTestArrayOfObjects() { - return this.testArrayOfObjects; - } - public final List getTestArrayOfEnum() { - return this.testArrayOfEnum; - } - public final String getStatus() { - return this.status; - } - public final String getMessage() { - return this.message; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + @Getter + private final List testArrayOfIntegers; + @Getter + private final List testArrayOfObjects; + @Getter + private final ZonedDateTime testDateTime; + @Getter + private final Account.Status testEnum; + @Getter + private final Integer testInteger; + @Getter + private final BigDecimal testNumber; + @Getter + private final BigDecimal testNumberDecimal; + @Getter + private final Float testNumberFloat; + @Getter + private final PhoneNumberCapabilities testObject; + @Getter + private final String testString; - Account other = (Account) o; +@JsonCreator +private Account( + @JsonProperty("a2p_profile_bundle_sid") + final String a2pProfileBundleSid, + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("from") + final com.twilio.type.PhoneNumber from, + @JsonProperty("message") + final String message, + @JsonProperty("price_unit") + @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) + final Currency priceUnit, + @JsonProperty("sid") + final String sid, + @JsonProperty("status") + final String status, + @JsonProperty("test_array_of_array_of_integers") + final List> testArrayOfArrayOfIntegers, + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum, + @JsonProperty("test_array_of_integers") + final List testArrayOfIntegers, + @JsonProperty("test_array_of_objects") + final List testArrayOfObjects, + @JsonProperty("test_date_time") + @JsonDeserialize(using = com.twilio.converter.RFC2822Deserializer.class) + final ZonedDateTime testDateTime, + @JsonProperty("test_enum") + final Account.Status testEnum, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_number") + final BigDecimal testNumber, + @JsonProperty("test_number_decimal") + final BigDecimal testNumberDecimal, + @JsonProperty("test_number_float") + final Float testNumberFloat, + @JsonProperty("test_object") + final PhoneNumberCapabilities testObject, + @JsonProperty("test_string") + final String testString +){ + this.a2pProfileBundleSid = a2pProfileBundleSid; + this.accountSid = accountSid; + this.from = from; + this.message = message; + this.priceUnit = priceUnit; + this.sid = sid; + this.status = status; + this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; + this.testArrayOfEnum = testArrayOfEnum; + this.testArrayOfIntegers = testArrayOfIntegers; + this.testArrayOfObjects = testArrayOfObjects; + this.testDateTime = testDateTime; + this.testEnum = testEnum; + this.testInteger = testInteger; + this.testNumber = testNumber; + this.testNumberDecimal = testNumberDecimal; + this.testNumberFloat = testNumberFloat; + this.testObject = testObject; + this.testString = testString; +} - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(from, other.from) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testNumberDecimal, other.testNumberDecimal) && Objects.equals(testEnum, other.testEnum) && Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && Objects.equals(testArrayOfEnum, other.testArrayOfEnum) && Objects.equals(status, other.status) && Objects.equals(message, other.message) ; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, from, priceUnit, testNumberFloat, testNumberDecimal, testEnum, a2pProfileBundleSid, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum, status, message); + if (o == null || getClass() != o.getClass()) { + return false; } - public enum XTwilioWebhookEnabled { - TRUE("true"), - FALSE("false"); - - private final String value; - - private XTwilioWebhookEnabled(final String value) { - this.value = value; - } - - public String toString() { - return value; - } - - @JsonCreator - public static XTwilioWebhookEnabled forValue(final String value) { - return Promoter.enumFromString(value, XTwilioWebhookEnabled.values()); - } - } - public enum Status { - IN_PROGRESS("in-progress"), - PAUSED("paused"), - STOPPED("stopped"), - PROCESSING("processing"), - COMPLETED("completed"), - ABSENT("absent"); - - private final String value; + Account other = (Account) o; + return ( + Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(from, other.from) && + Objects.equals(message, other.message) && + Objects.equals(priceUnit, other.priceUnit) && + Objects.equals(sid, other.sid) && + Objects.equals(status, other.status) && + Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && + Objects.equals(testArrayOfEnum, other.testArrayOfEnum) && + Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && + Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && + Objects.equals(testDateTime, other.testDateTime) && + Objects.equals(testEnum, other.testEnum) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testNumber, other.testNumber) && + Objects.equals(testNumberDecimal, other.testNumberDecimal) && + Objects.equals(testNumberFloat, other.testNumberFloat) && + Objects.equals(testObject, other.testObject) && + Objects.equals(testString, other.testString) + ); +} - private Status(final String value) { - this.value = value; - } +@Override +public int hashCode() { + return Objects.hash( + a2pProfileBundleSid, + accountSid, + from, + message, + priceUnit, + sid, + status, + testArrayOfArrayOfIntegers, + testArrayOfEnum, + testArrayOfIntegers, + testArrayOfObjects, + testDateTime, + testEnum, + testInteger, + testNumber, + testNumberDecimal, + testNumberFloat, + testObject, + testString + ); +} - public String toString() { - return value; - } - @JsonCreator - public static Status forValue(final String value) { - return Promoter.enumFromString(value, Status.values()); - } - } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java index 328c1fc60..00e32da6f 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java @@ -14,46 +14,70 @@ package com.twilio.rest.api.v2010; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; -import java.util.UUID; - -import lombok.ToString; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import java.net.URI; -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; +public class AccountCreator extends Creator { -public class AccountCreator extends Creator{ private Account.XTwilioWebhookEnabled xTwilioWebhookEnabled; private URI recordingStatusCallback; private List recordingStatusCallbackEvent; @@ -62,80 +86,100 @@ public class AccountCreator extends Creator{ public AccountCreator() { } - public AccountCreator setXTwilioWebhookEnabled(final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled){ - this.xTwilioWebhookEnabled = xTwilioWebhookEnabled; - return this; - } - public AccountCreator setRecordingStatusCallback(final URI recordingStatusCallback){ - this.recordingStatusCallback = recordingStatusCallback; - return this; - } - public AccountCreator setRecordingStatusCallback(final String recordingStatusCallback){ - return setRecordingStatusCallback(Promoter.uriFromString(recordingStatusCallback)); - } - public AccountCreator setRecordingStatusCallbackEvent(final List recordingStatusCallbackEvent){ - this.recordingStatusCallbackEvent = recordingStatusCallbackEvent; - return this; - } - public AccountCreator setRecordingStatusCallbackEvent(final String recordingStatusCallbackEvent){ - return setRecordingStatusCallbackEvent(Promoter.listOfOne(recordingStatusCallbackEvent)); - } - public AccountCreator setTwiml(final com.twilio.type.Twiml twiml){ - this.twiml = twiml; - return this; - } +public AccountCreator setRecordingStatusCallback(final URI recordingStatusCallback){ + this.recordingStatusCallback = recordingStatusCallback; + return this; +} + +public AccountCreator setRecordingStatusCallback(final String recordingStatusCallback){ + return setRecordingStatusCallback(Promoter.uriFromString(recordingStatusCallback)); +} + +public AccountCreator setRecordingStatusCallbackEvent(final List recordingStatusCallbackEvent){ + this.recordingStatusCallbackEvent = recordingStatusCallbackEvent; + return this; +} + +public AccountCreator setRecordingStatusCallbackEvent(final String recordingStatusCallbackEvent){ + return setRecordingStatusCallbackEvent(Promoter.listOfOne(recordingStatusCallbackEvent)); +} + +public AccountCreator setTwiml(final com.twilio.type.Twiml twiml){ + this.twiml = twiml; + return this; +} + +public AccountCreator setTwiml(final String twiml){ + return setTwiml(Promoter.twimlFromString(twiml)); +} + +public AccountCreator setXTwilioWebhookEnabled(final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled){ + this.xTwilioWebhookEnabled = xTwilioWebhookEnabled; + return this; +} - public AccountCreator setTwiml(final String twiml){ - return setTwiml(Promoter.twimlFromString(twiml)); - } @Override - public Account create(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts.json"; + public Account create(final TwilioRestClient client) { + + String path = "/2010-04-01/Accounts.json"; + Request request = new Request( HttpMethod.POST, Domains.API.toString(), path ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); - addPostParams(request); addHeaderParams(request); + addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Account creation failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Account.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (recordingStatusCallback != null) { - request.addPostParam("RecordingStatusCallback", recordingStatusCallback.toString()); - - } - if (recordingStatusCallbackEvent != null) { - for (String prop : recordingStatusCallbackEvent) { - request.addPostParam("RecordingStatusCallbackEvent", prop); - } - - } - if (twiml != null) { - request.addPostParam("Twiml", twiml.toString()); - + + if (recordingStatusCallback != null) { + Serializer.toString(request, "RecordingStatusCallback", recordingStatusCallback, ParameterType.URLENCODED); + } + + + + + if (recordingStatusCallbackEvent != null) { + for (String param: recordingStatusCallbackEvent) { + Serializer.toString(request, "RecordingStatusCallbackEvent", param, ParameterType.URLENCODED); } } + + if (twiml != null) { + Serializer.toString(request, "Twiml", twiml, ParameterType.URLENCODED); + } + + +} private void addHeaderParams(final Request request) { - if (xTwilioWebhookEnabled != null) { - request.addHeaderParam("X-Twilio-Webhook-Enabled", xTwilioWebhookEnabled.toString()); - } + + if (xTwilioWebhookEnabled != null) { + Serializer.toString(request, "X-Twilio-Webhook-Enabled", xTwilioWebhookEnabled, ParameterType.HEADER); } + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java index 7f83d6681..e6245bd3a 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java @@ -13,73 +13,110 @@ */ package com.twilio.rest.api.v2010; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.converter.Promoter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; import com.twilio.exception.ApiException; -import com.twilio.converter.Converter; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class AccountDeleter extends Deleter { -public class AccountDeleter extends Deleter { - private String pathSid; + private String pathSid; - public AccountDeleter(){ + public AccountDeleter() { } - public AccountDeleter(final String pathSid){ + public AccountDeleter(final String pathSid) { this.pathSid = pathSid; } - - @Override + + @Override public boolean delete(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{Sid}.json"; + + String path = "/2010-04-01/Accounts/{Sid}.json"; this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + + Predicate deleteStatues = i -> i != null && i >= 200 && i < 300; Request request = new Request( HttpMethod.DELETE, Domains.API.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); if (response == null) { throw new ApiConnectionException("Account delete failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return response.getStatusCode() == 204; + return deleteStatues.test(response.getStatusCode()); } -} + + } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java index 74241f27d..212c8d739 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java @@ -13,75 +13,108 @@ */ package com.twilio.rest.api.v2010; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class AccountFetcher extends Fetcher { -public class AccountFetcher extends Fetcher { - private String pathSid; + private String pathSid; - public AccountFetcher(){ + public AccountFetcher() { } - public AccountFetcher(final String pathSid){ + public AccountFetcher(final String pathSid) { this.pathSid = pathSid; } - - @Override + + @Override public Account fetch(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{Sid}.json"; + + String path = "/2010-04-01/Accounts/{Sid}.json"; this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.GET, Domains.API.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("Account fetch failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return Account.fromJson(response.getStream(), client.getObjectMapper()); } -} + } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java index 01c7c8c5a..7d70d0c1b 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java @@ -13,158 +13,211 @@ */ package com.twilio.rest.api.v2010; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; import com.twilio.base.Page; -import com.twilio.base.Reader; import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; public class AccountReader extends Reader { - private ZonedDateTime dateCreated; + + private ZonedDateTime dateCreated; private LocalDate dateTest; private ZonedDateTime dateCreatedBefore; private ZonedDateTime dateCreatedAfter; private Integer pageSize; - public AccountReader(){ + public AccountReader() { } - public AccountReader setDateCreated(final ZonedDateTime dateCreated){ - this.dateCreated = dateCreated; - return this; - } - public AccountReader setDateTest(final LocalDate dateTest){ - this.dateTest = dateTest; - return this; - } - public AccountReader setDateCreatedBefore(final ZonedDateTime dateCreatedBefore){ - this.dateCreatedBefore = dateCreatedBefore; - return this; - } - public AccountReader setDateCreatedAfter(final ZonedDateTime dateCreatedAfter){ - this.dateCreatedAfter = dateCreatedAfter; - return this; - } - public AccountReader setPageSize(final Integer pageSize){ - this.pageSize = pageSize; - return this; - } + +public AccountReader setDateCreated(final ZonedDateTime dateCreated){ + this.dateCreated = dateCreated; + return this; +} - @Override + +public AccountReader setDateTest(final LocalDate dateTest){ + this.dateTest = dateTest; + return this; +} + + +public AccountReader setDateCreatedBefore(final ZonedDateTime dateCreatedBefore){ + this.dateCreatedBefore = dateCreatedBefore; + return this; +} + + +public AccountReader setDateCreatedAfter(final ZonedDateTime dateCreatedAfter){ + this.dateCreatedAfter = dateCreatedAfter; + return this; +} + + +public AccountReader setPageSize(final Integer pageSize){ + this.pageSize = pageSize; + return this; +} + + + @Override public ResourceSet read(final TwilioRestClient client) { return new ResourceSet<>(this, client, firstPage(client)); } - + public Page firstPage(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts.json"; + + String path = "/2010-04-01/Accounts.json"; + Request request = new Request( HttpMethod.GET, Domains.API.toString(), path ); - addQueryParams(request); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); } private Page pageForRequest(final TwilioRestClient client, final Request request) { Response response = client.request(request); - if (response == null) { throw new ApiConnectionException("Account read failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper()); + if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); - } + } return Page.fromJson( "accounts", response.getContent(), Account.class, - client.getObjectMapper() - ); + client.getObjectMapper()); } @Override - public Page previousPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getPreviousPageUrl(Domains.API.toString()) - ); + public Page previousPage(final Page page, final TwilioRestClient client ) { + Request request = new Request(HttpMethod.GET, page.getPreviousPageUrl(Domains.API.toString())); return pageForRequest(client, request); } - @Override public Page nextPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getNextPageUrl(Domains.API.toString()) - ); - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, page.getNextPageUrl(Domains.API.toString())); + return pageForRequest(client, request); } @Override public Page getPage(final String targetUrl, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - targetUrl - ); - - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, targetUrl); + return pageForRequest(client, request); } private void addQueryParams(final Request request) { - if (dateCreated != null) { - request.addQueryParam("DateCreated", dateCreated.format(DateTimeFormatter.ofPattern(Request.QUERY_STRING_DATE_TIME_FORMAT))); - } - else if (dateCreatedAfter != null || dateCreatedBefore != null) { - request.addQueryDateTimeRange("DateCreated", dateCreatedAfter, dateCreatedBefore); - } - if (dateTest != null) { - request.addQueryParam("Date.Test", DateConverter.dateStringFromLocalDate(dateTest)); - } - - if (pageSize != null) { - - request.addQueryParam("PageSize", pageSize.toString()); - } - if(getPageSize() != null) { - request.addQueryParam("PageSize", Integer.toString(getPageSize())); - } + + if (dateCreated != null) { + Serializer.toString(request, "DateCreated", dateCreated, ParameterType.QUERY); + } + + + + + + if (dateTest != null) { + Serializer.toString(request, "Date.Test", dateTest, ParameterType.QUERY); } + + + + + + if (dateCreatedBefore != null) { + Serializer.toString(request, "DateCreated<", dateCreatedBefore, ParameterType.QUERY); + } + + + + + + if (dateCreatedAfter != null) { + Serializer.toString(request, "DateCreated>", dateCreatedAfter, ParameterType.QUERY); + } + + + + + + if (pageSize != null) { + Serializer.toString(request, "PageSize", pageSize, ParameterType.QUERY); + } + + + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java index 6fd40fbb3..dc608c155 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java @@ -13,71 +13,103 @@ */ package com.twilio.rest.api.v2010; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -public class AccountUpdater extends Updater{ - private Account.Status status; - private String pathSid; + public class AccountUpdater extends Updater { + private String pathSid; private String pauseBehavior; + private Account.Status status; - public AccountUpdater(final Account.Status status){ + public AccountUpdater(final Account.Status status) { this.status = status; } - public AccountUpdater(final String pathSid, final Account.Status status){ + public AccountUpdater(final String pathSid, final Account.Status status) { this.pathSid = pathSid; this.status = status; } - public AccountUpdater setStatus(final Account.Status status){ - this.status = status; - return this; - } - public AccountUpdater setPauseBehavior(final String pauseBehavior){ - this.pauseBehavior = pauseBehavior; - return this; - } + +public AccountUpdater setPauseBehavior(final String pauseBehavior){ + this.pauseBehavior = pauseBehavior; + return this; +} + + +public AccountUpdater setStatus(final Account.Status status){ + this.status = status; + return this; +} + - @Override - public Account update(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{Sid}.json"; + @Override + public Account update(final TwilioRestClient client) { + + String path = "/2010-04-01/Accounts/{Sid}.json"; this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); - path = path.replace("{"+"Status"+"}", this.status.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -85,29 +117,36 @@ public Account update(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Account update failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Account.fromJson(response.getStream(), client.getObjectMapper()); } + private void addPostParams(final Request request) { - private void addPostParams(final Request request) { - if (pauseBehavior != null) { - request.addPostParam("PauseBehavior", pauseBehavior); - - } - if (status != null) { - request.addPostParam("Status", status.toString()); - - } + if (pauseBehavior != null) { + Serializer.toString(request, "PauseBehavior", pauseBehavior, ParameterType.URLENCODED); + } + + + + if (status != null) { + Serializer.toString(request, "Status", status, ParameterType.URLENCODED); } + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java index dfaddd34f..9fd1472bc 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,69 +39,265 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Call extends Resource { - private static final long serialVersionUID = 101860285032933L; + + + + public static CallCreator creator(final String requiredStringProperty, final HttpMethod testMethod) { + return new CallCreator( + requiredStringProperty, testMethod + ); + } + + + public static CallCreator creator(final String pathAccountSid, final String requiredStringProperty, final HttpMethod testMethod) { + return new CallCreator( + pathAccountSid, requiredStringProperty, testMethod + ); + } + + + + + - public static CallCreator creator(final String requiredStringProperty, final HttpMethod testMethod){ - return new CallCreator(requiredStringProperty, testMethod); + + + public static CallDeleter deleter(final Integer pathTestInteger) { + return new CallDeleter( + pathTestInteger + ); + } + + + public static CallDeleter deleter(final String pathAccountSid, final Integer pathTestInteger) { + return new CallDeleter( + pathAccountSid, pathTestInteger + ); + } + + + + + + + + + + public static CallFetcher fetcher(final Integer pathTestInteger) { + return new CallFetcher( + pathTestInteger + ); + } + + + public static CallFetcher fetcher(final String pathAccountSid, final Integer pathTestInteger) { + return new CallFetcher( + pathAccountSid, pathTestInteger + ); + } + + + + + +public enum Status { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private Status(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static Status forValue(final String value) { + return Promoter.enumFromString(value, Status.values()); + } +} +public enum AccountStatus { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private AccountStatus(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static AccountStatus forValue(final String value) { + return Promoter.enumFromString(value, AccountStatus.values()); + } +} +public enum CallAccountStatus { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private CallAccountStatus(final String value) { + this.value = value; + } + + public String toString() { + return value; } - public static CallCreator creator(final String pathAccountSid, final String requiredStringProperty, final HttpMethod testMethod){ - return new CallCreator(pathAccountSid, requiredStringProperty, testMethod); + + @JsonCreator + public static CallAccountStatus forValue(final String value) { + return Promoter.enumFromString(value, CallAccountStatus.values()); } +} + + + @JsonDeserialize(builder = TestResponseObjectTestArrayOfObjectsInner.Builder.class) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class TestResponseObjectTestArrayOfObjectsInner { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + @Getter private final BigDecimal count; - public static CallDeleter deleter(final Integer pathTestInteger){ - return new CallDeleter(pathTestInteger); + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter private final String description; + + + private TestResponseObjectTestArrayOfObjectsInner(Builder builder) { + this.count = builder.count; + this.description = builder.description; } - public static CallDeleter deleter(final String pathAccountSid, final Integer pathTestInteger){ - return new CallDeleter(pathAccountSid, pathTestInteger); + public static Builder builder() { + return new Builder(); + } + + public static TestResponseObjectTestArrayOfObjectsInner fromJson(String jsonString, ObjectMapper mapper) throws IOException { + return mapper.readValue(jsonString, TestResponseObjectTestArrayOfObjectsInner.class); } - public static CallFetcher fetcher(final Integer pathTestInteger){ - return new CallFetcher(pathTestInteger); + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + @JsonProperty("count") + private BigDecimal count; + + @JsonProperty("description") + private String description; + + + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + public Builder count(BigDecimal count) { + this.count = count; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + public Builder description(String description) { + this.description = description; + return this; + } + + public TestResponseObjectTestArrayOfObjectsInner build() { + return new TestResponseObjectTestArrayOfObjectsInner(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestResponseObjectTestArrayOfObjectsInner other = (TestResponseObjectTestArrayOfObjectsInner) o; + return ( + Objects.equals(count, other.count) && + Objects.equals(description, other.description) + ); } - public static CallFetcher fetcher(final String pathAccountSid, final Integer pathTestInteger){ - return new CallFetcher(pathAccountSid, pathTestInteger); + + @Override + public int hashCode() { + return Objects.hash( + count, + description + ); } + } + + /** * Converts a JSON String into a Call object using the provided ObjectMapper. * @@ -139,192 +335,168 @@ public static Call fromJson(final InputStream json, final ObjectMapper objectMap } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter + private final String a2pProfileBundleSid; + @Getter private final String accountSid; + @Getter + private final com.twilio.type.PhoneNumber from; + @Getter + private final Currency priceUnit; + @Getter private final String sid; - private final String testString; - private final Integer testInteger; - private final PhoneNumberCapabilities testObject; + @Getter + private final List> testArrayOfArrayOfIntegers; + @Getter + private final List testArrayOfEnum; + @Getter + private final List testArrayOfIntegers; + @Getter + private final List testArrayOfObjects; + @Getter private final ZonedDateTime testDateTime; + @Getter + private final Call.Status testEnum; + @Getter + private final Integer testInteger; + @Getter private final BigDecimal testNumber; - private final com.twilio.type.PhoneNumber from; - private final Currency priceUnit; - private final Float testNumberFloat; + @Getter private final BigDecimal testNumberDecimal; - private final Call.Status testEnum; - private final String a2pProfileBundleSid; - private final List testArrayOfIntegers; - private final List> testArrayOfArrayOfIntegers; - private final List testArrayOfObjects; - private final List testArrayOfEnum; - - @JsonCreator - private Call( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, - - @JsonProperty("test_integer") - final Integer testInteger, - - @JsonProperty("test_object") - final PhoneNumberCapabilities testObject, - - @JsonProperty("test_date_time") - final String testDateTime, - - @JsonProperty("test_number") - final BigDecimal testNumber, - - @JsonProperty("from") - final com.twilio.type.PhoneNumber from, - - @JsonProperty("price_unit") - @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) - final Currency priceUnit, - - @JsonProperty("test_number_float") - final Float testNumberFloat, - - @JsonProperty("test_number_decimal") - final BigDecimal testNumberDecimal, - - @JsonProperty("test_enum") - final Call.Status testEnum, - - @JsonProperty("a2p_profile_bundle_sid") - final String a2pProfileBundleSid, - - @JsonProperty("test_array_of_integers") - final List testArrayOfIntegers, - - @JsonProperty("test_array_of_array_of_integers") - final List> testArrayOfArrayOfIntegers, - - @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("test_array_of_enum") - final List testArrayOfEnum - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; - this.testObject = testObject; - this.testDateTime = DateConverter.rfc2822DateTimeFromString(testDateTime); - this.testNumber = testNumber; - this.from = from; - this.priceUnit = priceUnit; - this.testNumberFloat = testNumberFloat; - this.testNumberDecimal = testNumberDecimal; - this.testEnum = testEnum; - this.a2pProfileBundleSid = a2pProfileBundleSid; - this.testArrayOfIntegers = testArrayOfIntegers; - this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; - this.testArrayOfObjects = testArrayOfObjects; - this.testArrayOfEnum = testArrayOfEnum; - } - - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - public final PhoneNumberCapabilities getTestObject() { - return this.testObject; - } - public final ZonedDateTime getTestDateTime() { - return this.testDateTime; - } - public final BigDecimal getTestNumber() { - return this.testNumber; - } - public final com.twilio.type.PhoneNumber getFrom() { - return this.from; - } - public final Currency getPriceUnit() { - return this.priceUnit; - } - public final Float getTestNumberFloat() { - return this.testNumberFloat; - } - public final BigDecimal getTestNumberDecimal() { - return this.testNumberDecimal; - } - public final Call.Status getTestEnum() { - return this.testEnum; - } - public final String getA2pProfileBundleSid() { - return this.a2pProfileBundleSid; - } - public final List getTestArrayOfIntegers() { - return this.testArrayOfIntegers; - } - public final List> getTestArrayOfArrayOfIntegers() { - return this.testArrayOfArrayOfIntegers; - } - public final List getTestArrayOfObjects() { - return this.testArrayOfObjects; - } - public final List getTestArrayOfEnum() { - return this.testArrayOfEnum; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + @Getter + private final Float testNumberFloat; + @Getter + private final PhoneNumberCapabilities testObject; + @Getter + private final String testString; - Call other = (Call) o; +@JsonCreator +private Call( + @JsonProperty("a2p_profile_bundle_sid") + final String a2pProfileBundleSid, + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("from") + final com.twilio.type.PhoneNumber from, + @JsonProperty("price_unit") + @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) + final Currency priceUnit, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_array_of_array_of_integers") + final List> testArrayOfArrayOfIntegers, + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum, + @JsonProperty("test_array_of_integers") + final List testArrayOfIntegers, + @JsonProperty("test_array_of_objects") + final List testArrayOfObjects, + @JsonProperty("test_date_time") + @JsonDeserialize(using = com.twilio.converter.RFC2822Deserializer.class) + final ZonedDateTime testDateTime, + @JsonProperty("test_enum") + final Call.Status testEnum, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_number") + final BigDecimal testNumber, + @JsonProperty("test_number_decimal") + final BigDecimal testNumberDecimal, + @JsonProperty("test_number_float") + final Float testNumberFloat, + @JsonProperty("test_object") + final PhoneNumberCapabilities testObject, + @JsonProperty("test_string") + final String testString +){ + this.a2pProfileBundleSid = a2pProfileBundleSid; + this.accountSid = accountSid; + this.from = from; + this.priceUnit = priceUnit; + this.sid = sid; + this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; + this.testArrayOfEnum = testArrayOfEnum; + this.testArrayOfIntegers = testArrayOfIntegers; + this.testArrayOfObjects = testArrayOfObjects; + this.testDateTime = testDateTime; + this.testEnum = testEnum; + this.testInteger = testInteger; + this.testNumber = testNumber; + this.testNumberDecimal = testNumberDecimal; + this.testNumberFloat = testNumberFloat; + this.testObject = testObject; + this.testString = testString; +} - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(from, other.from) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testNumberDecimal, other.testNumberDecimal) && Objects.equals(testEnum, other.testEnum) && Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && Objects.equals(testArrayOfEnum, other.testArrayOfEnum) ; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, from, priceUnit, testNumberFloat, testNumberDecimal, testEnum, a2pProfileBundleSid, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); + if (o == null || getClass() != o.getClass()) { + return false; } - public enum Status { - IN_PROGRESS("in-progress"), - PAUSED("paused"), - STOPPED("stopped"), - PROCESSING("processing"), - COMPLETED("completed"), - ABSENT("absent"); - - private final String value; + Call other = (Call) o; + return ( + Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(from, other.from) && + Objects.equals(priceUnit, other.priceUnit) && + Objects.equals(sid, other.sid) && + Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && + Objects.equals(testArrayOfEnum, other.testArrayOfEnum) && + Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && + Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && + Objects.equals(testDateTime, other.testDateTime) && + Objects.equals(testEnum, other.testEnum) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testNumber, other.testNumber) && + Objects.equals(testNumberDecimal, other.testNumberDecimal) && + Objects.equals(testNumberFloat, other.testNumberFloat) && + Objects.equals(testObject, other.testObject) && + Objects.equals(testString, other.testString) + ); +} - private Status(final String value) { - this.value = value; - } +@Override +public int hashCode() { + return Objects.hash( + a2pProfileBundleSid, + accountSid, + from, + priceUnit, + sid, + testArrayOfArrayOfIntegers, + testArrayOfEnum, + testArrayOfIntegers, + testArrayOfObjects, + testDateTime, + testEnum, + testInteger, + testNumber, + testNumberDecimal, + testNumberFloat, + testObject, + testString + ); +} - public String toString() { - return value; - } - @JsonCreator - public static Status forValue(final String value) { - return Promoter.enumFromString(value, Status.values()); - } - } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java index c7220bc83..65750e46d 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java @@ -14,51 +14,75 @@ package com.twilio.rest.api.v2010.account; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; -import java.util.UUID; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import java.net.URI; +public class CallCreator extends Creator { -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - -public class CallCreator extends Creator{ - private String requiredStringProperty; - private HttpMethod testMethod; private String pathAccountSid; + private String requiredStringProperty; private List testArrayOfStrings; private List testArrayOfUri; + private HttpMethod testMethod; public CallCreator(final String requiredStringProperty, final HttpMethod testMethod) { this.requiredStringProperty = requiredStringProperty; @@ -70,42 +94,49 @@ public CallCreator(final String pathAccountSid, final String requiredStringPrope this.testMethod = testMethod; } - public CallCreator setRequiredStringProperty(final String requiredStringProperty){ - this.requiredStringProperty = requiredStringProperty; - return this; - } - public CallCreator setTestMethod(final HttpMethod testMethod){ - this.testMethod = testMethod; - return this; - } - public CallCreator setTestArrayOfStrings(final List testArrayOfStrings){ - this.testArrayOfStrings = testArrayOfStrings; - return this; - } - public CallCreator setTestArrayOfStrings(final String testArrayOfStrings){ - return setTestArrayOfStrings(Promoter.listOfOne(testArrayOfStrings)); - } - public CallCreator setTestArrayOfUri(final List testArrayOfUri){ - this.testArrayOfUri = testArrayOfUri; - return this; - } - public CallCreator setTestArrayOfUri(final URI testArrayOfUri){ - return setTestArrayOfUri(Promoter.listOfOne(testArrayOfUri)); - } - public CallCreator setTestArrayOfUri(final String testArrayOfUri){ - return setTestArrayOfUri(Promoter.uriFromString(testArrayOfUri)); - } +public CallCreator setRequiredStringProperty(final String requiredStringProperty){ + this.requiredStringProperty = requiredStringProperty; + return this; +} + + +public CallCreator setTestArrayOfStrings(final List testArrayOfStrings){ + this.testArrayOfStrings = testArrayOfStrings; + return this; +} + +public CallCreator setTestArrayOfStrings(final String testArrayOfStrings){ + return setTestArrayOfStrings(Promoter.listOfOne(testArrayOfStrings)); +} + +public CallCreator setTestArrayOfUri(final List testArrayOfUri){ + this.testArrayOfUri = testArrayOfUri; + return this; +} + +public CallCreator setTestArrayOfUri(final URI testArrayOfUri){ + return setTestArrayOfUri(Promoter.listOfOne(testArrayOfUri)); +} +public CallCreator setTestArrayOfUri(final String testArrayOfUri){ + return setTestArrayOfUri(Promoter.uriFromString(testArrayOfUri)); +} + +public CallCreator setTestMethod(final HttpMethod testMethod){ + this.testMethod = testMethod; + return this; +} + @Override - public Call create(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json"; + public Call create(final TwilioRestClient client) { + + String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json"; this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"RequiredStringProperty"+"}", this.requiredStringProperty.toString()); - path = path.replace("{"+"TestMethod"+"}", this.testMethod.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -113,40 +144,52 @@ public Call create(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Call creation failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Call.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (requiredStringProperty != null) { - request.addPostParam("RequiredStringProperty", requiredStringProperty); - - } - if (testArrayOfStrings != null) { - for (String prop : testArrayOfStrings) { - request.addPostParam("TestArrayOfStrings", prop); - } - - } - if (testArrayOfUri != null) { - for (URI prop : testArrayOfUri) { - request.addPostParam("TestArrayOfUri", prop.toString()); - } - + + if (requiredStringProperty != null) { + Serializer.toString(request, "RequiredStringProperty", requiredStringProperty, ParameterType.URLENCODED); + } + + + + + if (testArrayOfStrings != null) { + for (String param: testArrayOfStrings) { + Serializer.toString(request, "TestArrayOfStrings", param, ParameterType.URLENCODED); } - if (testMethod != null) { - request.addPostParam("TestMethod", testMethod.toString()); - + } + + + + if (testArrayOfUri != null) { + for (URI param: testArrayOfUri) { + Serializer.toString(request, "TestArrayOfUri", param, ParameterType.URLENCODED); } } + + if (testMethod != null) { + Serializer.toString(request, "TestMethod", testMethod, ParameterType.URLENCODED); + } + + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java index ff149c0be..c913330fb 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java @@ -13,77 +13,114 @@ */ package com.twilio.rest.api.v2010.account; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.converter.Promoter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; import com.twilio.exception.ApiException; -import com.twilio.converter.Converter; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class CallDeleter extends Deleter { -public class CallDeleter extends Deleter { + private String pathAccountSid; private Integer pathTestInteger; - private String pathAccountSid; - public CallDeleter(final Integer pathTestInteger){ + public CallDeleter(final Integer pathTestInteger) { this.pathTestInteger = pathTestInteger; } - public CallDeleter(final String pathAccountSid, final Integer pathTestInteger){ + public CallDeleter(final String pathAccountSid, final Integer pathTestInteger) { this.pathAccountSid = pathAccountSid; this.pathTestInteger = pathTestInteger; } - - @Override + + @Override public boolean delete(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; + + String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + + Predicate deleteStatues = i -> i != null && i >= 200 && i < 300; Request request = new Request( HttpMethod.DELETE, Domains.API.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); if (response == null) { throw new ApiConnectionException("Call delete failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return response.getStatusCode() == 204; + return deleteStatues.test(response.getStatusCode()); } -} + + } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java index ef9dbf245..b830385dc 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java @@ -13,79 +13,112 @@ */ package com.twilio.rest.api.v2010.account; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class CallFetcher extends Fetcher { -public class CallFetcher extends Fetcher { + private String pathAccountSid; private Integer pathTestInteger; - private String pathAccountSid; - public CallFetcher(final Integer pathTestInteger){ + public CallFetcher(final Integer pathTestInteger) { this.pathTestInteger = pathTestInteger; } - public CallFetcher(final String pathAccountSid, final Integer pathTestInteger){ + public CallFetcher(final String pathAccountSid, final Integer pathTestInteger) { this.pathAccountSid = pathAccountSid; this.pathTestInteger = pathTestInteger; } - - @Override + + @Override public Call fetch(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; + + String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + Request request = new Request( HttpMethod.GET, Domains.API.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("Call fetch failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return Call.fromJson(response.getStream(), client.getObjectMapper()); } -} + } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java index 7ca21c42f..f74a02ce0 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,55 +39,225 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class FeedbackCallSummary extends Resource { - private static final long serialVersionUID = 176825368696347L; + + + + + + + + public static FeedbackCallSummaryUpdater updater(final String pathSid, final LocalDate endDate, final LocalDate startDate) { + return new FeedbackCallSummaryUpdater( + pathSid, endDate, startDate + ); + } + + + public static FeedbackCallSummaryUpdater updater(final String pathAccountSid, final String pathSid, final LocalDate endDate, final LocalDate startDate) { + return new FeedbackCallSummaryUpdater( + pathAccountSid, pathSid, endDate, startDate + ); + } + + + +public enum Status { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private Status(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static Status forValue(final String value) { + return Promoter.enumFromString(value, Status.values()); + } +} +public enum FeedbackCallSummaryCallAccountStatus { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private FeedbackCallSummaryCallAccountStatus(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static FeedbackCallSummaryCallAccountStatus forValue(final String value) { + return Promoter.enumFromString(value, FeedbackCallSummaryCallAccountStatus.values()); + } +} +public enum CallAccountStatus { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private CallAccountStatus(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static CallAccountStatus forValue(final String value) { + return Promoter.enumFromString(value, CallAccountStatus.values()); + } +} + + + @JsonDeserialize(builder = TestResponseObjectTestArrayOfObjectsInner.Builder.class) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class TestResponseObjectTestArrayOfObjectsInner { + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + @Getter private final BigDecimal count; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter private final String description; + - public static FeedbackCallSummaryUpdater updater(final String pathSid, final LocalDate endDate, final LocalDate startDate){ - return new FeedbackCallSummaryUpdater(pathSid, endDate, startDate); + private TestResponseObjectTestArrayOfObjectsInner(Builder builder) { + this.count = builder.count; + this.description = builder.description; } - public static FeedbackCallSummaryUpdater updater(final String pathAccountSid, final String pathSid, final LocalDate endDate, final LocalDate startDate){ - return new FeedbackCallSummaryUpdater(pathAccountSid, pathSid, endDate, startDate); + public static Builder builder() { + return new Builder(); } + public static TestResponseObjectTestArrayOfObjectsInner fromJson(String jsonString, ObjectMapper mapper) throws IOException { + return mapper.readValue(jsonString, TestResponseObjectTestArrayOfObjectsInner.class); + } + + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + @JsonProperty("count") + private BigDecimal count; + + @JsonProperty("description") + private String description; + + + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("count") + public Builder count(BigDecimal count) { + this.count = count; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + public Builder description(String description) { + this.description = description; + return this; + } + + public TestResponseObjectTestArrayOfObjectsInner build() { + return new TestResponseObjectTestArrayOfObjectsInner(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestResponseObjectTestArrayOfObjectsInner other = (TestResponseObjectTestArrayOfObjectsInner) o; + return ( + Objects.equals(count, other.count) && + Objects.equals(description, other.description) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + count, + description + ); + } + + } + + /** * Converts a JSON String into a FeedbackCallSummary object using the provided ObjectMapper. * @@ -125,192 +295,168 @@ public static FeedbackCallSummary fromJson(final InputStream json, final ObjectM } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter + private final String a2pProfileBundleSid; + @Getter private final String accountSid; + @Getter + private final com.twilio.type.PhoneNumber from; + @Getter + private final Currency priceUnit; + @Getter private final String sid; - private final String testString; - private final Integer testInteger; - private final PhoneNumberCapabilities testObject; + @Getter + private final List> testArrayOfArrayOfIntegers; + @Getter + private final List testArrayOfEnum; + @Getter + private final List testArrayOfIntegers; + @Getter + private final List testArrayOfObjects; + @Getter private final ZonedDateTime testDateTime; + @Getter + private final FeedbackCallSummary.Status testEnum; + @Getter + private final Integer testInteger; + @Getter private final BigDecimal testNumber; - private final com.twilio.type.PhoneNumber from; - private final Currency priceUnit; - private final Float testNumberFloat; + @Getter private final BigDecimal testNumberDecimal; - private final FeedbackCallSummary.Status testEnum; - private final String a2pProfileBundleSid; - private final List testArrayOfIntegers; - private final List> testArrayOfArrayOfIntegers; - private final List testArrayOfObjects; - private final List testArrayOfEnum; - - @JsonCreator - private FeedbackCallSummary( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, - - @JsonProperty("test_integer") - final Integer testInteger, - - @JsonProperty("test_object") - final PhoneNumberCapabilities testObject, - - @JsonProperty("test_date_time") - final String testDateTime, - - @JsonProperty("test_number") - final BigDecimal testNumber, - - @JsonProperty("from") - final com.twilio.type.PhoneNumber from, - - @JsonProperty("price_unit") - @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) - final Currency priceUnit, - - @JsonProperty("test_number_float") - final Float testNumberFloat, - - @JsonProperty("test_number_decimal") - final BigDecimal testNumberDecimal, - - @JsonProperty("test_enum") - final FeedbackCallSummary.Status testEnum, - - @JsonProperty("a2p_profile_bundle_sid") - final String a2pProfileBundleSid, - - @JsonProperty("test_array_of_integers") - final List testArrayOfIntegers, - - @JsonProperty("test_array_of_array_of_integers") - final List> testArrayOfArrayOfIntegers, - - @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("test_array_of_enum") - final List testArrayOfEnum - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; - this.testObject = testObject; - this.testDateTime = DateConverter.rfc2822DateTimeFromString(testDateTime); - this.testNumber = testNumber; - this.from = from; - this.priceUnit = priceUnit; - this.testNumberFloat = testNumberFloat; - this.testNumberDecimal = testNumberDecimal; - this.testEnum = testEnum; - this.a2pProfileBundleSid = a2pProfileBundleSid; - this.testArrayOfIntegers = testArrayOfIntegers; - this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; - this.testArrayOfObjects = testArrayOfObjects; - this.testArrayOfEnum = testArrayOfEnum; - } - - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - public final PhoneNumberCapabilities getTestObject() { - return this.testObject; - } - public final ZonedDateTime getTestDateTime() { - return this.testDateTime; - } - public final BigDecimal getTestNumber() { - return this.testNumber; - } - public final com.twilio.type.PhoneNumber getFrom() { - return this.from; - } - public final Currency getPriceUnit() { - return this.priceUnit; - } - public final Float getTestNumberFloat() { - return this.testNumberFloat; - } - public final BigDecimal getTestNumberDecimal() { - return this.testNumberDecimal; - } - public final FeedbackCallSummary.Status getTestEnum() { - return this.testEnum; - } - public final String getA2pProfileBundleSid() { - return this.a2pProfileBundleSid; - } - public final List getTestArrayOfIntegers() { - return this.testArrayOfIntegers; - } - public final List> getTestArrayOfArrayOfIntegers() { - return this.testArrayOfArrayOfIntegers; - } - public final List getTestArrayOfObjects() { - return this.testArrayOfObjects; - } - public final List getTestArrayOfEnum() { - return this.testArrayOfEnum; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + @Getter + private final Float testNumberFloat; + @Getter + private final PhoneNumberCapabilities testObject; + @Getter + private final String testString; - FeedbackCallSummary other = (FeedbackCallSummary) o; +@JsonCreator +private FeedbackCallSummary( + @JsonProperty("a2p_profile_bundle_sid") + final String a2pProfileBundleSid, + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("from") + final com.twilio.type.PhoneNumber from, + @JsonProperty("price_unit") + @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class) + final Currency priceUnit, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_array_of_array_of_integers") + final List> testArrayOfArrayOfIntegers, + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum, + @JsonProperty("test_array_of_integers") + final List testArrayOfIntegers, + @JsonProperty("test_array_of_objects") + final List testArrayOfObjects, + @JsonProperty("test_date_time") + @JsonDeserialize(using = com.twilio.converter.RFC2822Deserializer.class) + final ZonedDateTime testDateTime, + @JsonProperty("test_enum") + final FeedbackCallSummary.Status testEnum, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_number") + final BigDecimal testNumber, + @JsonProperty("test_number_decimal") + final BigDecimal testNumberDecimal, + @JsonProperty("test_number_float") + final Float testNumberFloat, + @JsonProperty("test_object") + final PhoneNumberCapabilities testObject, + @JsonProperty("test_string") + final String testString +){ + this.a2pProfileBundleSid = a2pProfileBundleSid; + this.accountSid = accountSid; + this.from = from; + this.priceUnit = priceUnit; + this.sid = sid; + this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; + this.testArrayOfEnum = testArrayOfEnum; + this.testArrayOfIntegers = testArrayOfIntegers; + this.testArrayOfObjects = testArrayOfObjects; + this.testDateTime = testDateTime; + this.testEnum = testEnum; + this.testInteger = testInteger; + this.testNumber = testNumber; + this.testNumberDecimal = testNumberDecimal; + this.testNumberFloat = testNumberFloat; + this.testObject = testObject; + this.testString = testString; +} - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(from, other.from) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testNumberDecimal, other.testNumberDecimal) && Objects.equals(testEnum, other.testEnum) && Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && Objects.equals(testArrayOfEnum, other.testArrayOfEnum) ; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, from, priceUnit, testNumberFloat, testNumberDecimal, testEnum, a2pProfileBundleSid, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); + if (o == null || getClass() != o.getClass()) { + return false; } - public enum Status { - IN_PROGRESS("in-progress"), - PAUSED("paused"), - STOPPED("stopped"), - PROCESSING("processing"), - COMPLETED("completed"), - ABSENT("absent"); - - private final String value; + FeedbackCallSummary other = (FeedbackCallSummary) o; + return ( + Objects.equals(a2pProfileBundleSid, other.a2pProfileBundleSid) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(from, other.from) && + Objects.equals(priceUnit, other.priceUnit) && + Objects.equals(sid, other.sid) && + Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && + Objects.equals(testArrayOfEnum, other.testArrayOfEnum) && + Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && + Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && + Objects.equals(testDateTime, other.testDateTime) && + Objects.equals(testEnum, other.testEnum) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testNumber, other.testNumber) && + Objects.equals(testNumberDecimal, other.testNumberDecimal) && + Objects.equals(testNumberFloat, other.testNumberFloat) && + Objects.equals(testObject, other.testObject) && + Objects.equals(testString, other.testString) + ); +} - private Status(final String value) { - this.value = value; - } +@Override +public int hashCode() { + return Objects.hash( + a2pProfileBundleSid, + accountSid, + from, + priceUnit, + sid, + testArrayOfArrayOfIntegers, + testArrayOfEnum, + testArrayOfIntegers, + testArrayOfObjects, + testDateTime, + testEnum, + testInteger, + testNumber, + testNumberDecimal, + testNumberFloat, + testObject, + testString + ); +} - public String toString() { - return value; - } - @JsonCreator - public static Status forValue(final String value) { - return Promoter.enumFromString(value, Status.values()); - } - } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java index b25dddaa3..24ba9df50 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java @@ -13,83 +13,116 @@ */ package com.twilio.rest.api.v2010.account.call; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -public class FeedbackCallSummaryUpdater extends Updater{ + public class FeedbackCallSummaryUpdater extends Updater { + private String pathAccountSid; private String pathSid; + private String accountSid; private LocalDate endDate; private LocalDate startDate; - private String pathAccountSid; - private String accountSid; - public FeedbackCallSummaryUpdater(final String pathSid, final LocalDate endDate, final LocalDate startDate){ + public FeedbackCallSummaryUpdater(final String pathSid, final LocalDate endDate, final LocalDate startDate) { this.pathSid = pathSid; this.endDate = endDate; this.startDate = startDate; } - public FeedbackCallSummaryUpdater(final String pathAccountSid, final String pathSid, final LocalDate endDate, final LocalDate startDate){ + public FeedbackCallSummaryUpdater(final String pathAccountSid, final String pathSid, final LocalDate endDate, final LocalDate startDate) { this.pathAccountSid = pathAccountSid; this.pathSid = pathSid; this.endDate = endDate; this.startDate = startDate; } - public FeedbackCallSummaryUpdater setEndDate(final LocalDate endDate){ - this.endDate = endDate; - return this; - } - public FeedbackCallSummaryUpdater setStartDate(final LocalDate startDate){ - this.startDate = startDate; - return this; - } - public FeedbackCallSummaryUpdater setAccountSid(final String accountSid){ - this.accountSid = accountSid; - return this; - } + +public FeedbackCallSummaryUpdater setAccountSid(final String accountSid){ + this.accountSid = accountSid; + return this; +} - @Override - public FeedbackCallSummary update(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/Feedback/Summary/{Sid}.json"; + +public FeedbackCallSummaryUpdater setEndDate(final LocalDate endDate){ + this.endDate = endDate; + return this; +} + + +public FeedbackCallSummaryUpdater setStartDate(final LocalDate startDate){ + this.startDate = startDate; + return this; +} + + + @Override + public FeedbackCallSummary update(final TwilioRestClient client) { + + String path = "/2010-04-01/Accounts/{AccountSid}/Calls/Feedback/Summary/{Sid}.json"; this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); - path = path.replace("{"+"EndDate"+"}", this.endDate.toString()); - path = path.replace("{"+"StartDate"+"}", this.startDate.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -97,33 +130,42 @@ public FeedbackCallSummary update(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("FeedbackCallSummary update failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return FeedbackCallSummary.fromJson(response.getStream(), client.getObjectMapper()); } + private void addPostParams(final Request request) { - private void addPostParams(final Request request) { - if (accountSid != null) { - request.addPostParam("AccountSid", accountSid); - - } - if (endDate != null) { - request.addPostParam("EndDate", DateConverter.dateStringFromLocalDate(endDate)); + if (accountSid != null) { + Serializer.toString(request, "AccountSid", accountSid, ParameterType.URLENCODED); + } - } - if (startDate != null) { - request.addPostParam("StartDate", DateConverter.dateStringFromLocalDate(startDate)); - } + + if (endDate != null) { + Serializer.toString(request, "EndDate", endDate, ParameterType.URLENCODED); } + + + if (startDate != null) { + Serializer.toString(request, "StartDate", startDate, ParameterType.URLENCODED); + } + + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java index 71e9bf277..82ee4f67a 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,52 +39,67 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Call extends Resource { - private static final long serialVersionUID = 9929770204306L; - - public static CallUpdater updater(final String pathSid){ - return new CallUpdater(pathSid); + + + + + + + public static CallUpdater updater(final String pathSid) { + return new CallUpdater( + pathSid + ); } + + + + /** * Converts a JSON String into a Call object using the provided ObjectMapper. * @@ -122,40 +137,54 @@ public static Call fromJson(final InputStream json, final ObjectMapper objectMap } } - private final Integer sid; - - @JsonCreator - private Call( - @JsonProperty("sid") - final Integer sid - ) { - this.sid = sid; - } - - public final Integer getSid() { - return this.sid; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); } + } + - if (o == null || getClass() != o.getClass()) { - return false; - } + @Getter + private final Integer sid; - Call other = (Call) o; +@JsonCreator +private Call( + @JsonProperty("sid") + final Integer sid +){ + this.sid = sid; +} - return Objects.equals(sid, other.sid) ; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - @Override - public int hashCode() { - return Objects.hash(sid); + if (o == null || getClass() != o.getClass()) { + return false; } + Call other = (Call) o; + return ( + Objects.equals(sid, other.sid) + ); +} + +@Override +public int hashCode() { + return Objects.hash( + sid + ); +} + + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java index 0b7890712..7b93121c8 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java @@ -13,73 +13,105 @@ */ package com.twilio.rest.flexapi.v1; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -public class CallUpdater extends Updater{ - private String pathSid; + public class CallUpdater extends Updater { + private String pathSid; - public CallUpdater(final String pathSid){ + public CallUpdater(final String pathSid) { this.pathSid = pathSid; } + + @Override + public Call update(final TwilioRestClient client) { + + String path = "/v1/Voice/{Sid}"; - @Override - public Call update(final TwilioRestClient client){ - String path = "/v1/Voice/{Sid}"; - - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.POST, Domains.FLEXAPI.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Call update failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Call.fromJson(response.getStream(), client.getObjectMapper()); } - -} + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java index b5cf0affe..9554282d1 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,64 +39,106 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Aws extends Resource { - private static final long serialVersionUID = 234000032744450L; - - public static AwsDeleter deleter(final String pathSid){ - return new AwsDeleter(pathSid); + + + + public static AwsDeleter deleter(final String pathSid) { + return new AwsDeleter( + pathSid + ); } - public static AwsFetcher fetcher(final String pathSid){ - return new AwsFetcher(pathSid); + + + + + + + + + public static AwsFetcher fetcher(final String pathSid) { + return new AwsFetcher( + pathSid + ); } - public static AwsReader reader(){ - return new AwsReader(); + + + + + + + + + public static AwsReader reader() { + return new AwsReader( + + ); } - public static AwsUpdater updater(final String pathSid){ - return new AwsUpdater(pathSid); + + + + + + + + + public static AwsUpdater updater(final String pathSid) { + return new AwsUpdater( + pathSid + ); } + + + + /** * Converts a JSON String into a Aws object using the provided ObjectMapper. * @@ -134,63 +176,74 @@ public static Aws fromJson(final InputStream json, final ObjectMapper objectMapp } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter private final String accountSid; + @Getter private final String sid; - private final String testString; + @Getter private final Integer testInteger; + @Getter + private final String testString; - @JsonCreator - private Aws( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, +@JsonCreator +private Aws( + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_string") + final String testString +){ + this.accountSid = accountSid; + this.sid = sid; + this.testInteger = testInteger; + this.testString = testString; +} - @JsonProperty("test_integer") - final Integer testInteger - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + if (o == null || getClass() != o.getClass()) { + return false; + } - Aws other = (Aws) o; + Aws other = (Aws) o; + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(sid, other.sid) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testString, other.testString) + ); +} - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) ; - } +@Override +public int hashCode() { + return Objects.hash( + accountSid, + sid, + testInteger, + testString + ); +} - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger); - } } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java index 773fbe4ea..00e729c6b 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java @@ -13,70 +13,107 @@ */ package com.twilio.rest.flexapi.v1.credential; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.converter.Promoter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; import com.twilio.exception.ApiException; -import com.twilio.converter.Converter; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class AwsDeleter extends Deleter { -public class AwsDeleter extends Deleter { - private String pathSid; + private String pathSid; - public AwsDeleter(final String pathSid){ + public AwsDeleter(final String pathSid) { this.pathSid = pathSid; } - - @Override + + @Override public boolean delete(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + + String path = "/v1/Credentials/AWS/{Sid}"; + + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Predicate deleteStatues = i -> i != null && i >= 200 && i < 300; Request request = new Request( HttpMethod.DELETE, Domains.FLEXAPI.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); if (response == null) { throw new ApiConnectionException("Aws delete failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return response.getStatusCode() == 204; + return deleteStatues.test(response.getStatusCode()); } -} + + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java index 60b26432e..8ff33cd2b 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java @@ -13,72 +13,105 @@ */ package com.twilio.rest.flexapi.v1.credential; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class AwsFetcher extends Fetcher { -public class AwsFetcher extends Fetcher { - private String pathSid; + private String pathSid; - public AwsFetcher(final String pathSid){ + public AwsFetcher(final String pathSid) { this.pathSid = pathSid; } - - @Override + + @Override public Aws fetch(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + + String path = "/v1/Credentials/AWS/{Sid}"; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.GET, Domains.FLEXAPI.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("Aws fetch failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return Aws.fromJson(response.getStream(), client.getObjectMapper()); } -} + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java index 1f31f250f..df14f6b6c 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java @@ -13,128 +13,151 @@ */ package com.twilio.rest.flexapi.v1.credential; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; import com.twilio.base.Page; -import com.twilio.base.Reader; import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; public class AwsReader extends Reader { - private Integer pageSize; - public AwsReader(){ - } + private Integer pageSize; - public AwsReader setPageSize(final Integer pageSize){ - this.pageSize = pageSize; - return this; + public AwsReader() { } - @Override + +public AwsReader setPageSize(final Integer pageSize){ + this.pageSize = pageSize; + return this; +} + + + @Override public ResourceSet read(final TwilioRestClient client) { return new ResourceSet<>(this, client, firstPage(client)); } - + public Page firstPage(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS"; + + String path = "/v1/Credentials/AWS"; + Request request = new Request( HttpMethod.GET, Domains.FLEXAPI.toString(), path ); - addQueryParams(request); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); } private Page pageForRequest(final TwilioRestClient client, final Request request) { Response response = client.request(request); - if (response == null) { throw new ApiConnectionException("Aws read failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper()); + if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); - } + } return Page.fromJson( "credentials", response.getContent(), Aws.class, - client.getObjectMapper() - ); + client.getObjectMapper()); } @Override - public Page previousPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getPreviousPageUrl(Domains.FLEXAPI.toString()) - ); + public Page previousPage(final Page page, final TwilioRestClient client ) { + Request request = new Request(HttpMethod.GET, page.getPreviousPageUrl(Domains.API.toString())); return pageForRequest(client, request); } - @Override public Page nextPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getNextPageUrl(Domains.FLEXAPI.toString()) - ); - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, page.getNextPageUrl(Domains.API.toString())); + return pageForRequest(client, request); } @Override public Page getPage(final String targetUrl, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - targetUrl - ); - - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, targetUrl); + return pageForRequest(client, request); } private void addQueryParams(final Request request) { - if (pageSize != null) { - - request.addQueryParam("PageSize", pageSize.toString()); - } - if(getPageSize() != null) { - request.addQueryParam("PageSize", Integer.toString(getPageSize())); - } + + if (pageSize != null) { + Serializer.toString(request, "PageSize", pageSize, ParameterType.QUERY); } + + + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java index 705843b74..535027d1f 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java @@ -13,65 +13,98 @@ */ package com.twilio.rest.flexapi.v1.credential; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -public class AwsUpdater extends Updater{ - private String pathSid; + public class AwsUpdater extends Updater { + private String pathSid; private String testString; private Boolean testBoolean; - public AwsUpdater(final String pathSid){ + public AwsUpdater(final String pathSid) { this.pathSid = pathSid; } - public AwsUpdater setTestString(final String testString){ - this.testString = testString; - return this; - } - public AwsUpdater setTestBoolean(final Boolean testBoolean){ - this.testBoolean = testBoolean; - return this; - } + +public AwsUpdater setTestString(final String testString){ + this.testString = testString; + return this; +} - @Override - public Aws update(final TwilioRestClient client){ - String path = "/v1/Credentials/AWS/{Sid}"; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); +public AwsUpdater setTestBoolean(final Boolean testBoolean){ + this.testBoolean = testBoolean; + return this; +} + + + @Override + public Aws update(final TwilioRestClient client) { + + String path = "/v1/Credentials/AWS/{Sid}"; + + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.POST, Domains.FLEXAPI.toString(), @@ -79,29 +112,36 @@ public Aws update(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Aws update failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Aws.fromJson(response.getStream(), client.getObjectMapper()); } + private void addPostParams(final Request request) { - private void addPostParams(final Request request) { - if (testString != null) { - request.addPostParam("TestString", testString); - - } - if (testBoolean != null) { - request.addPostParam("TestBoolean", testBoolean.toString()); - - } + if (testString != null) { + Serializer.toString(request, "TestString", testString, ParameterType.URLENCODED); + } + + + + if (testBoolean != null) { + Serializer.toString(request, "TestBoolean", testBoolean, ParameterType.URLENCODED); } + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java index 6960b5343..1a5cd9dac 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,60 +39,129 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class NewCredentials extends Resource { - private static final long serialVersionUID = 234000032744450L; + + + + public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat) { + return new NewCredentialsCreator( + testString, testInteger, testNumberFloat + ); + } + + + public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Object testObject) { + return new NewCredentialsCreator( + testString, testInteger, testObject + ); + } + + + public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Float testNumberFloat) { + return new NewCredentialsCreator( + testString, testDate, testNumberFloat + ); + } + + + public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Object testObject) { + return new NewCredentialsCreator( + testString, testDate, testObject + ); + } + + + + + - public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat){ - return new NewCredentialsCreator(testString, testInteger, testNumberFloat); +public enum Status { + IN_PROGRESS("in-progress"), + PAUSED("paused"), + STOPPED("stopped"), + PROCESSING("processing"), + COMPLETED("completed"), + ABSENT("absent"); + + private final String value; + + private Status(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static Status forValue(final String value) { + return Promoter.enumFromString(value, Status.values()); } - public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Map testObject){ - return new NewCredentialsCreator(testString, testInteger, testObject); +} +public enum Permissions { + GET_ALL("get-all"), + POST_ALL("post-all"); + + private final String value; + + private Permissions(final String value) { + this.value = value; } - public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Float testNumberFloat){ - return new NewCredentialsCreator(testString, testDate, testNumberFloat); + + public String toString() { + return value; } - public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Map testObject){ - return new NewCredentialsCreator(testString, testDate, testObject); + + @JsonCreator + public static Permissions forValue(final String value) { + return Promoter.enumFromString(value, Permissions.values()); } +} + /** * Converts a JSON String into a NewCredentials object using the provided ObjectMapper. @@ -131,106 +200,75 @@ public static NewCredentials fromJson(final InputStream json, final ObjectMapper } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter private final String accountSid; + @Getter private final String sid; - private final String testString; + @Getter private final Integer testInteger; + @Getter + private final String testString; - @JsonCreator - private NewCredentials( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, - - @JsonProperty("test_integer") - final Integer testInteger - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; - } - - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - NewCredentials other = (NewCredentials) o; - - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) ; - } +@JsonCreator +private NewCredentials( + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_string") + final String testString +){ + this.accountSid = accountSid; + this.sid = sid; + this.testInteger = testInteger; + this.testString = testString; +} - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger); +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public enum Permissions { - GET_ALL("get-all"), - POST_ALL("post-all"); - - private final String value; - - private Permissions(final String value) { - this.value = value; - } - - public String toString() { - return value; - } - - @JsonCreator - public static Permissions forValue(final String value) { - return Promoter.enumFromString(value, Permissions.values()); - } + if (o == null || getClass() != o.getClass()) { + return false; } - public enum Status { - IN_PROGRESS("in-progress"), - PAUSED("paused"), - STOPPED("stopped"), - PROCESSING("processing"), - COMPLETED("completed"), - ABSENT("absent"); - private final String value; + NewCredentials other = (NewCredentials) o; + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(sid, other.sid) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testString, other.testString) + ); +} - private Status(final String value) { - this.value = value; - } +@Override +public int hashCode() { + return Objects.hash( + accountSid, + sid, + testInteger, + testString + ); +} - public String toString() { - return value; - } - @JsonCreator - public static Status forValue(final String value) { - return Promoter.enumFromString(value, Status.values()); - } - } } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java index 590525b66..1794462ac 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java @@ -14,46 +14,70 @@ package com.twilio.rest.flexapi.v1.credential; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; -import java.util.UUID; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import java.net.URI; +public class NewCredentialsCreator extends Creator { -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - -public class NewCredentialsCreator extends Creator{ private String testString; private Boolean testBoolean; private Integer testInteger; @@ -62,11 +86,11 @@ public class NewCredentialsCreator extends Creator{ private Double testNumberDouble; private BigDecimal testNumberInt32; private Long testNumberInt64; - private Map testObject; + private Object testObject; private ZonedDateTime testDateTime; private LocalDate testDate; private NewCredentials.Status testEnum; - private List> testObjectArray; + private List testObjectArray; private Object testAnyType; private List testAnyArray; private List permissions; @@ -77,7 +101,7 @@ public NewCredentialsCreator(final String testString, final Integer testInteger, this.testInteger = testInteger; this.testNumberFloat = testNumberFloat; } - public NewCredentialsCreator(final String testString, final Integer testInteger, final Map testObject) { + public NewCredentialsCreator(final String testString, final Integer testInteger, final Object testObject) { this.testString = testString; this.testInteger = testInteger; this.testObject = testObject; @@ -87,96 +111,131 @@ public NewCredentialsCreator(final String testString, final LocalDate testDate, this.testDate = testDate; this.testNumberFloat = testNumberFloat; } - public NewCredentialsCreator(final String testString, final LocalDate testDate, final Map testObject) { + public NewCredentialsCreator(final String testString, final LocalDate testDate, final Object testObject) { this.testString = testString; this.testDate = testDate; this.testObject = testObject; } - public NewCredentialsCreator setTestString(final String testString){ - this.testString = testString; - return this; - } - public NewCredentialsCreator setTestBoolean(final Boolean testBoolean){ - this.testBoolean = testBoolean; - return this; - } - public NewCredentialsCreator setTestInteger(final Integer testInteger){ - this.testInteger = testInteger; - return this; - } - public NewCredentialsCreator setTestNumber(final BigDecimal testNumber){ - this.testNumber = testNumber; - return this; - } - public NewCredentialsCreator setTestNumberFloat(final Float testNumberFloat){ - this.testNumberFloat = testNumberFloat; - return this; - } - public NewCredentialsCreator setTestNumberDouble(final Double testNumberDouble){ - this.testNumberDouble = testNumberDouble; - return this; - } - public NewCredentialsCreator setTestNumberInt32(final BigDecimal testNumberInt32){ - this.testNumberInt32 = testNumberInt32; - return this; - } - public NewCredentialsCreator setTestNumberInt64(final Long testNumberInt64){ - this.testNumberInt64 = testNumberInt64; - return this; - } - public NewCredentialsCreator setTestObject(final Map testObject){ - this.testObject = testObject; - return this; - } - public NewCredentialsCreator setTestDateTime(final ZonedDateTime testDateTime){ - this.testDateTime = testDateTime; - return this; - } - public NewCredentialsCreator setTestDate(final LocalDate testDate){ - this.testDate = testDate; - return this; - } - public NewCredentialsCreator setTestEnum(final NewCredentials.Status testEnum){ - this.testEnum = testEnum; - return this; - } - public NewCredentialsCreator setTestObjectArray(final List> testObjectArray){ - this.testObjectArray = testObjectArray; - return this; - } - public NewCredentialsCreator setTestObjectArray(final Map testObjectArray){ - return setTestObjectArray(Promoter.listOfOne(testObjectArray)); - } - public NewCredentialsCreator setTestAnyType(final Object testAnyType){ - this.testAnyType = testAnyType; - return this; - } - public NewCredentialsCreator setTestAnyArray(final List testAnyArray){ - this.testAnyArray = testAnyArray; - return this; - } - public NewCredentialsCreator setTestAnyArray(final Object testAnyArray){ - return setTestAnyArray(Promoter.listOfOne(testAnyArray)); - } - public NewCredentialsCreator setPermissions(final List permissions){ - this.permissions = permissions; - return this; - } - public NewCredentialsCreator setPermissions(final NewCredentials.Permissions permissions){ - return setPermissions(Promoter.listOfOne(permissions)); - } - public NewCredentialsCreator setSomeA2PThing(final String someA2PThing){ - this.someA2PThing = someA2PThing; - return this; - } + +public NewCredentialsCreator setTestString(final String testString){ + this.testString = testString; + return this; +} + + +public NewCredentialsCreator setTestBoolean(final Boolean testBoolean){ + this.testBoolean = testBoolean; + return this; +} + + +public NewCredentialsCreator setTestInteger(final Integer testInteger){ + this.testInteger = testInteger; + return this; +} + + +public NewCredentialsCreator setTestNumber(final BigDecimal testNumber){ + this.testNumber = testNumber; + return this; +} + + +public NewCredentialsCreator setTestNumberFloat(final Float testNumberFloat){ + this.testNumberFloat = testNumberFloat; + return this; +} + + +public NewCredentialsCreator setTestNumberDouble(final Double testNumberDouble){ + this.testNumberDouble = testNumberDouble; + return this; +} + + +public NewCredentialsCreator setTestNumberInt32(final BigDecimal testNumberInt32){ + this.testNumberInt32 = testNumberInt32; + return this; +} + + +public NewCredentialsCreator setTestNumberInt64(final Long testNumberInt64){ + this.testNumberInt64 = testNumberInt64; + return this; +} + + +public NewCredentialsCreator setTestObject(final Object testObject){ + this.testObject = testObject; + return this; +} + + +public NewCredentialsCreator setTestDateTime(final ZonedDateTime testDateTime){ + this.testDateTime = testDateTime; + return this; +} + + +public NewCredentialsCreator setTestDate(final LocalDate testDate){ + this.testDate = testDate; + return this; +} + + +public NewCredentialsCreator setTestEnum(final NewCredentials.Status testEnum){ + this.testEnum = testEnum; + return this; +} + + +public NewCredentialsCreator setTestObjectArray(final List testObjectArray){ + this.testObjectArray = testObjectArray; + return this; +} + +public NewCredentialsCreator setTestObjectArray(final Object testObjectArray){ + return setTestObjectArray(Promoter.listOfOne(testObjectArray)); +} + +public NewCredentialsCreator setTestAnyType(final Object testAnyType){ + this.testAnyType = testAnyType; + return this; +} + + +public NewCredentialsCreator setTestAnyArray(final List testAnyArray){ + this.testAnyArray = testAnyArray; + return this; +} + +public NewCredentialsCreator setTestAnyArray(final Object testAnyArray){ + return setTestAnyArray(Promoter.listOfOne(testAnyArray)); +} + +public NewCredentialsCreator setPermissions(final List permissions){ + this.permissions = permissions; + return this; +} + +public NewCredentialsCreator setPermissions(final NewCredentials.Permissions permissions){ + return setPermissions(Promoter.listOfOne(permissions)); +} + +public NewCredentialsCreator setSomeA2PThing(final String someA2PThing){ + this.someA2PThing = someA2PThing; + return this; +} + @Override - public NewCredentials create(final TwilioRestClient client){ - String path = "/v1/Credentials/AWS"; + public NewCredentials create(final TwilioRestClient client) { + + String path = "/v1/Credentials/AWS"; - path = path.replace("{"+"TestString"+"}", this.testString.toString()); + Request request = new Request( HttpMethod.POST, Domains.FLEXAPI.toString(), @@ -184,94 +243,132 @@ public NewCredentials create(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("NewCredentials creation failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return NewCredentials.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (testString != null) { - request.addPostParam("TestString", testString); - - } - if (testBoolean != null) { - request.addPostParam("TestBoolean", testBoolean.toString()); - - } - if (testInteger != null) { - request.addPostParam("TestInteger", testInteger.toString()); - - } - if (testNumber != null) { - request.addPostParam("TestNumber", testNumber.toString()); - - } - if (testNumberFloat != null) { - request.addPostParam("TestNumberFloat", testNumberFloat.toString()); - - } - if (testNumberDouble != null) { - request.addPostParam("TestNumberDouble", testNumberDouble.toString()); - - } - if (testNumberInt32 != null) { - request.addPostParam("TestNumberInt32", testNumberInt32.toString()); - - } - if (testNumberInt64 != null) { - request.addPostParam("TestNumberInt64", testNumberInt64.toString()); - - } - if (testObject != null) { - request.addPostParam("TestObject", Converter.mapToJson(testObject)); - - } - if (testDateTime != null) { - request.addPostParam("TestDateTime", testDateTime.toInstant().toString()); - } - if (testDate != null) { - request.addPostParam("TestDate", DateConverter.dateStringFromLocalDate(testDate)); + if (testString != null) { + Serializer.toString(request, "TestString", testString, ParameterType.URLENCODED); + } + + + if (testBoolean != null) { + Serializer.toString(request, "TestBoolean", testBoolean, ParameterType.URLENCODED); + } + + + + if (testInteger != null) { + Serializer.toString(request, "TestInteger", testInteger, ParameterType.URLENCODED); + } + + + + if (testNumber != null) { + Serializer.toString(request, "TestNumber", testNumber, ParameterType.URLENCODED); + } + + + + if (testNumberFloat != null) { + Serializer.toString(request, "TestNumberFloat", testNumberFloat, ParameterType.URLENCODED); + } + + + + if (testNumberDouble != null) { + Serializer.toString(request, "TestNumberDouble", testNumberDouble, ParameterType.URLENCODED); + } + + + + if (testNumberInt32 != null) { + Serializer.toString(request, "TestNumberInt32", testNumberInt32, ParameterType.URLENCODED); + } + + + + if (testNumberInt64 != null) { + Serializer.toString(request, "TestNumberInt64", testNumberInt64, ParameterType.URLENCODED); + } + + + + if (testObject != null) { + Serializer.toString(request, "TestObject", testObject, ParameterType.URLENCODED); + } + + + + if (testDateTime != null) { + Serializer.toString(request, "TestDateTime", testDateTime, ParameterType.URLENCODED); + } + + + + if (testDate != null) { + Serializer.toString(request, "TestDate", testDate, ParameterType.URLENCODED); + } + + + + if (testEnum != null) { + Serializer.toString(request, "TestEnum", testEnum, ParameterType.URLENCODED); + } + + + + + if (testObjectArray != null) { + for (Object param: testObjectArray) { + Serializer.toString(request, "TestObjectArray", param, ParameterType.URLENCODED); } - if (testEnum != null) { - request.addPostParam("TestEnum", testEnum.toString()); - - } - if (testObjectArray != null) { - for (Map prop : testObjectArray) { - request.addPostParam("TestObjectArray", Converter.mapToJson(prop)); - } - - } - if (testAnyType != null) { - request.addPostParam("TestAnyType", Converter.objectToJson(testAnyType)); - - } - if (testAnyArray != null) { - for (Object prop : testAnyArray) { - request.addPostParam("TestAnyArray", Converter.objectToJson(prop)); - } - - } - if (permissions != null) { - for (NewCredentials.Permissions prop : permissions) { - request.addPostParam("Permissions", prop.toString()); - } - + } + + + if (testAnyType != null) { + Serializer.toString(request, "TestAnyType", testAnyType, ParameterType.URLENCODED); + } + + + + + if (testAnyArray != null) { + for (Object param: testAnyArray) { + Serializer.toString(request, "TestAnyArray", param, ParameterType.URLENCODED); } - if (someA2PThing != null) { - request.addPostParam("SomeA2PThing", someA2PThing); - + } + + + + if (permissions != null) { + for (NewCredentials.Permissions param: permissions) { + Serializer.toString(request, "Permissions", param, ParameterType.URLENCODED); } } + + if (someA2PThing != null) { + Serializer.toString(request, "SomeA2PThing", someA2PThing, ParameterType.URLENCODED); + } + + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java index 53944a7a6..2947a05dc 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,52 +39,67 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class History extends Resource { - private static final long serialVersionUID = 234000032744450L; - - public static HistoryFetcher fetcher(final String pathSid){ - return new HistoryFetcher(pathSid); + + + + + public static HistoryFetcher fetcher(final String pathSid) { + return new HistoryFetcher( + pathSid + ); } + + + + + + /** * Converts a JSON String into a History object using the provided ObjectMapper. * @@ -122,63 +137,74 @@ public static History fromJson(final InputStream json, final ObjectMapper object } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter private final String accountSid; + @Getter private final String sid; - private final String testString; + @Getter private final Integer testInteger; + @Getter + private final String testString; - @JsonCreator - private History( - @JsonProperty("account_sid") - final String accountSid, - - @JsonProperty("sid") - final String sid, - - @JsonProperty("test_string") - final String testString, +@JsonCreator +private History( + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_integer") + final Integer testInteger, + @JsonProperty("test_string") + final String testString +){ + this.accountSid = accountSid; + this.sid = sid; + this.testInteger = testInteger; + this.testString = testString; +} - @JsonProperty("test_integer") - final Integer testInteger - ) { - this.accountSid = accountSid; - this.sid = sid; - this.testString = testString; - this.testInteger = testInteger; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public final String getAccountSid() { - return this.accountSid; - } - public final String getSid() { - return this.sid; - } - public final String getTestString() { - return this.testString; - } - public final Integer getTestInteger() { - return this.testInteger; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + if (o == null || getClass() != o.getClass()) { + return false; + } - History other = (History) o; + History other = (History) o; + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(sid, other.sid) && + Objects.equals(testInteger, other.testInteger) && + Objects.equals(testString, other.testString) + ); +} - return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) ; - } +@Override +public int hashCode() { + return Objects.hash( + accountSid, + sid, + testInteger, + testString + ); +} - @Override - public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger); - } } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java index da34ba156..285fa76c6 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java @@ -13,86 +13,123 @@ */ package com.twilio.rest.flexapi.v1.credential.aws; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class HistoryFetcher extends Fetcher { -public class HistoryFetcher extends Fetcher { - private String pathSid; + private String pathSid; private Map addOnsData; - public HistoryFetcher(final String pathSid){ + public HistoryFetcher(final String pathSid) { this.pathSid = pathSid; } - public HistoryFetcher setAddOnsData(final Map addOnsData){ - this.addOnsData = addOnsData; - return this; - } + +public HistoryFetcher setAddOnsData(final Map addOnsData){ + this.addOnsData = addOnsData; + return this; +} + - @Override + @Override public History fetch(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}/History"; + + String path = "/v1/Credentials/AWS/{Sid}/History"; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.GET, Domains.FLEXAPI.toString(), path ); addQueryParams(request); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("History fetch failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return History.fromJson(response.getStream(), client.getObjectMapper()); } - private void addQueryParams(final Request request) { - if (addOnsData != null) { - Map params = PrefixedCollapsibleMap.serialize(addOnsData, "AddOns"); - for (Map.Entry entry : params.entrySet()) { - request.addQueryParam(entry.getKey(), entry.getValue()); - } - } + private void addQueryParams(final Request request) { + + + if (addOnsData != null) { + Serializer.toString(request, "AddOnsData", addOnsData, ParameterType.QUERY); } + + + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/oauth/v2/Token.java b/examples/java/src/main/java/com/twilio/rest/oauth/v2/Token.java index d41b7cfb8..c78fbf7ab 100644 --- a/examples/java/src/main/java/com/twilio/rest/oauth/v2/Token.java +++ b/examples/java/src/main/java/com/twilio/rest/oauth/v2/Token.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.noauth.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,52 +39,67 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Token extends Resource { - private static final long serialVersionUID = 258139119277894L; - - public static TokenCreator creator(){ - return new TokenCreator(); + + public static TokenCreator creator() { + return new TokenCreator( + + ); } + + + + + + + + + /** * Converts a JSON String into a Token object using the provided ObjectMapper. * @@ -122,71 +137,81 @@ public static Token fromJson(final InputStream json, final ObjectMapper objectMa } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter private final String accessToken; - private final String refreshToken; + @Getter + private final Long expiresIn; + @Getter private final String idToken; + @Getter + private final String refreshToken; + @Getter private final String tokenType; - private final Long expiresIn; - @JsonCreator - private Token( - @JsonProperty("access_token") - final String accessToken, - - @JsonProperty("refresh_token") - final String refreshToken, - - @JsonProperty("id_token") - final String idToken, - - @JsonProperty("token_type") - final String tokenType, +@JsonCreator +private Token( + @JsonProperty("access_token") + final String accessToken, + @JsonProperty("expires_in") + final Long expiresIn, + @JsonProperty("id_token") + final String idToken, + @JsonProperty("refresh_token") + final String refreshToken, + @JsonProperty("token_type") + final String tokenType +){ + this.accessToken = accessToken; + this.expiresIn = expiresIn; + this.idToken = idToken; + this.refreshToken = refreshToken; + this.tokenType = tokenType; +} - @JsonProperty("expires_in") - final Long expiresIn - ) { - this.accessToken = accessToken; - this.refreshToken = refreshToken; - this.idToken = idToken; - this.tokenType = tokenType; - this.expiresIn = expiresIn; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public final String getAccessToken() { - return this.accessToken; - } - public final String getRefreshToken() { - return this.refreshToken; - } - public final String getIdToken() { - return this.idToken; - } - public final String getTokenType() { - return this.tokenType; - } - public final Long getExpiresIn() { - return this.expiresIn; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + if (o == null || getClass() != o.getClass()) { + return false; + } - Token other = (Token) o; + Token other = (Token) o; + return ( + Objects.equals(accessToken, other.accessToken) && + Objects.equals(expiresIn, other.expiresIn) && + Objects.equals(idToken, other.idToken) && + Objects.equals(refreshToken, other.refreshToken) && + Objects.equals(tokenType, other.tokenType) + ); +} - return Objects.equals(accessToken, other.accessToken) && Objects.equals(refreshToken, other.refreshToken) && Objects.equals(idToken, other.idToken) && Objects.equals(tokenType, other.tokenType) && Objects.equals(expiresIn, other.expiresIn) ; - } +@Override +public int hashCode() { + return Objects.hash( + accessToken, + expiresIn, + idToken, + refreshToken, + tokenType + ); +} - @Override - public int hashCode() { - return Objects.hash(accessToken, refreshToken, idToken, tokenType, expiresIn); - } } diff --git a/examples/java/src/main/java/com/twilio/rest/oauth/v2/TokenCreator.java b/examples/java/src/main/java/com/twilio/rest/oauth/v2/TokenCreator.java index 4e41d3edd..3184e0a8a 100644 --- a/examples/java/src/main/java/com/twilio/rest/oauth/v2/TokenCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/oauth/v2/TokenCreator.java @@ -14,46 +14,70 @@ package com.twilio.rest.oauth.v2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; -import java.util.UUID; - -import lombok.ToString; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import java.net.URI; -import com.twilio.base.noauth.Creator; -import com.twilio.http.noauth.NoAuthRequest; -import com.twilio.http.noauth.NoAuthTwilioRestClient; +public class TokenCreator extends Creator { -public class TokenCreator extends Creator{ private String grantType; private String clientId; private String clientSecret; @@ -66,97 +90,136 @@ public class TokenCreator extends Creator{ public TokenCreator() { } - public TokenCreator setGrantType(final String grantType){ - this.grantType = grantType; - return this; - } - public TokenCreator setClientId(final String clientId){ - this.clientId = clientId; - return this; - } - public TokenCreator setClientSecret(final String clientSecret){ - this.clientSecret = clientSecret; - return this; - } - public TokenCreator setCode(final String code){ - this.code = code; - return this; - } - public TokenCreator setRedirectUri(final String redirectUri){ - this.redirectUri = redirectUri; - return this; - } - public TokenCreator setAudience(final String audience){ - this.audience = audience; - return this; - } - public TokenCreator setRefreshToken(final String refreshToken){ - this.refreshToken = refreshToken; - return this; - } - public TokenCreator setScope(final String scope){ - this.scope = scope; - return this; - } + +public TokenCreator setGrantType(final String grantType){ + this.grantType = grantType; + return this; +} + + +public TokenCreator setClientId(final String clientId){ + this.clientId = clientId; + return this; +} + + +public TokenCreator setClientSecret(final String clientSecret){ + this.clientSecret = clientSecret; + return this; +} + + +public TokenCreator setCode(final String code){ + this.code = code; + return this; +} + + +public TokenCreator setRedirectUri(final String redirectUri){ + this.redirectUri = redirectUri; + return this; +} + + +public TokenCreator setAudience(final String audience){ + this.audience = audience; + return this; +} + + +public TokenCreator setRefreshToken(final String refreshToken){ + this.refreshToken = refreshToken; + return this; +} + + +public TokenCreator setScope(final String scope){ + this.scope = scope; + return this; +} + @Override - public Token create(final NoAuthTwilioRestClient client){ - String path = "/v2/token"; + public Token create(final TwilioRestClient client) { + + String path = "/v2/token"; - NoAuthRequest request = new NoAuthRequest( + + Request request = new Request( HttpMethod.POST, Domains.OAUTH.toString(), path ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + request.setAuth(NoAuthStrategy.getInstance()); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Token creation failed: Unable to connect to server"); - } else if (!NoAuthTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Token.fromJson(response.getStream(), client.getObjectMapper()); } - private void addPostParams(final NoAuthRequest request) { - if (grantType != null) { - request.addPostParam("grant_type", grantType); - - } - if (clientId != null) { - request.addPostParam("client_id", clientId); - - } - if (clientSecret != null) { - request.addPostParam("client_secret", clientSecret); - - } - if (code != null) { - request.addPostParam("code", code); - - } - if (redirectUri != null) { - request.addPostParam("redirect_uri", redirectUri); - - } - if (audience != null) { - request.addPostParam("audience", audience); - - } - if (refreshToken != null) { - request.addPostParam("refresh_token", refreshToken); - - } - if (scope != null) { - request.addPostParam("scope", scope); - - } + private void addPostParams(final Request request) { + + if (grantType != null) { + Serializer.toString(request, "grant_type", grantType, ParameterType.URLENCODED); + } + + + + if (clientId != null) { + Serializer.toString(request, "client_id", clientId, ParameterType.URLENCODED); + } + + + + if (clientSecret != null) { + Serializer.toString(request, "client_secret", clientSecret, ParameterType.URLENCODED); + } + + + + if (code != null) { + Serializer.toString(request, "code", code, ParameterType.URLENCODED); } + + + if (redirectUri != null) { + Serializer.toString(request, "redirect_uri", redirectUri, ParameterType.URLENCODED); + } + + + + if (audience != null) { + Serializer.toString(request, "audience", audience, ParameterType.URLENCODED); + } + + + + if (refreshToken != null) { + Serializer.toString(request, "refresh_token", refreshToken, ParameterType.URLENCODED); + } + + + + if (scope != null) { + Serializer.toString(request, "scope", scope, ParameterType.URLENCODED); + } + + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/User.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/User.java deleted file mode 100644 index fa2d3197b..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/User.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.bearertoken.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Request; -import com.twilio.http.Response; -import com.twilio.http.TwilioRestClient; -import com.twilio.rest.Domains; - -import lombok.ToString; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; - -@JsonIgnoreProperties(ignoreUnknown = true) -@ToString -public class User extends Resource { - private static final long serialVersionUID = 281207691925540L; - - - @ToString - static public class ScimName { - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("givenName") - @Getter @Setter private String givenName; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("familyName") - @Getter @Setter private String familyName; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("TestAnyType") - @Getter @Setter private Object testAnyType; - - public static ScimName fromJson(String jsonString, ObjectMapper mapper) throws IOException { - return mapper.readValue(jsonString, ScimName.class); - } - } - @ToString - static public class ScimEmailAddress { - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("primary") - @Getter @Setter private Boolean primary; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("value") - @Getter @Setter private String value; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("type") - @Getter @Setter private String type; - - - public static ScimEmailAddress fromJson(String jsonString, ObjectMapper mapper) throws IOException { - return mapper.readValue(jsonString, ScimEmailAddress.class); - } - } - @ToString - static public class ScimMeta { - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("resourceType") - @Getter @Setter private String resourceType; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("created") - @Getter @Setter private ZonedDateTime created; - public String getCreated() { - return created.toInstant().toString(); - } - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("lastModified") - @Getter @Setter private ZonedDateTime lastModified; - public String getLastModified() { - return lastModified.toInstant().toString(); - } - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("version") - @Getter @Setter private String version; - - - public static ScimMeta fromJson(String jsonString, ObjectMapper mapper) throws IOException { - return mapper.readValue(jsonString, ScimMeta.class); - } - } - @ToString - static public class ScimUser { - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("id") - @Getter @Setter private String id; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("externalId") - @Getter @Setter private String externalId; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("userName") - @Getter @Setter private String userName; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("displayName") - @Getter @Setter private String displayName; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("name") - @Getter @Setter private ScimName name; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("emails") - @Getter @Setter private List emails; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("active") - @Getter @Setter private Boolean active; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("locale") - @Getter @Setter private String locale; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("timezone") - @Getter @Setter private String timezone; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("schemas") - @Getter @Setter private List schemas; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("meta") - @Getter @Setter private ScimMeta meta; - - public ScimUser(final String userName ) { - this.userName = userName; - } - - public static ScimUser fromJson(String jsonString, ObjectMapper mapper) throws IOException { - return mapper.readValue(jsonString, ScimUser.class); - } - } - - public static UserCreator creator(final String pathOrganizationSid, final User.ScimUser scimUser){ - return new UserCreator(pathOrganizationSid, scimUser); - } - - public static UserDeleter deleter(final String pathOrganizationSid, final String pathUserSid){ - return new UserDeleter(pathOrganizationSid, pathUserSid); - } - - public static UserFetcher fetcher(final String pathOrganizationSid, final String pathUserSid){ - return new UserFetcher(pathOrganizationSid, pathUserSid); - } - - public static UserReader reader(final String pathOrganizationSid){ - return new UserReader(pathOrganizationSid); - } - - public static UserUpdater updater(final String pathOrganizationSid, final String pathUserSid, final User.ScimUser scimUser){ - return new UserUpdater(pathOrganizationSid, pathUserSid, scimUser); - } - - /** - * Converts a JSON String into a User object using the provided ObjectMapper. - * - * @param json Raw JSON String - * @param objectMapper Jackson ObjectMapper - * @return User object represented by the provided JSON - */ - public static User fromJson(final String json, final ObjectMapper objectMapper) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, User.class); - } catch (final JsonMappingException | JsonParseException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - - /** - * Converts a JSON InputStream into a User object using the provided - * ObjectMapper. - * - * @param json Raw JSON InputStream - * @param objectMapper Jackson ObjectMapper - * @return User object represented by the provided JSON - */ - public static User fromJson(final InputStream json, final ObjectMapper objectMapper) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, User.class); - } catch (final JsonMappingException | JsonParseException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - public static String toJson(Object object, ObjectMapper mapper) { - try { - return mapper.writeValueAsString(object); - } catch (final JsonMappingException e) { - throw new ApiException(e.getMessage(), e); - } catch (JsonProcessingException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - private final String id; - private final String externalId; - private final String userName; - private final String displayName; - private final ScimName name; - private final List emails; - private final Boolean active; - private final String locale; - private final String timezone; - private final List schemas; - private final ScimMeta meta; - - @JsonCreator - private User( - @JsonProperty("id") - final String id, - - @JsonProperty("external_id") - final String externalId, - - @JsonProperty("user_name") - final String userName, - - @JsonProperty("display_name") - final String displayName, - - @JsonProperty("name") - final ScimName name, - - @JsonProperty("emails") - final List emails, - - @JsonProperty("active") - final Boolean active, - - @JsonProperty("locale") - final String locale, - - @JsonProperty("timezone") - final String timezone, - - @JsonProperty("schemas") - final List schemas, - - @JsonProperty("meta") - final ScimMeta meta - ) { - this.id = id; - this.externalId = externalId; - this.userName = userName; - this.displayName = displayName; - this.name = name; - this.emails = emails; - this.active = active; - this.locale = locale; - this.timezone = timezone; - this.schemas = schemas; - this.meta = meta; - } - - public final String getId() { - return this.id; - } - public final String getExternalId() { - return this.externalId; - } - public final String getUserName() { - return this.userName; - } - public final String getDisplayName() { - return this.displayName; - } - public final ScimName getName() { - return this.name; - } - public final List getEmails() { - return this.emails; - } - public final Boolean getActive() { - return this.active; - } - public final String getLocale() { - return this.locale; - } - public final String getTimezone() { - return this.timezone; - } - public final List getSchemas() { - return this.schemas; - } - public final ScimMeta getMeta() { - return this.meta; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - User other = (User) o; - - return Objects.equals(id, other.id) && Objects.equals(externalId, other.externalId) && Objects.equals(userName, other.userName) && Objects.equals(displayName, other.displayName) && Objects.equals(name, other.name) && Objects.equals(emails, other.emails) && Objects.equals(active, other.active) && Objects.equals(locale, other.locale) && Objects.equals(timezone, other.timezone) && Objects.equals(schemas, other.schemas) && Objects.equals(meta, other.meta) ; - } - - @Override - public int hashCode() { - return Objects.hash(id, externalId, userName, displayName, name, emails, active, locale, timezone, schemas, meta); - } - - -} - diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java deleted file mode 100644 index 30ba8054f..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.constant.EnumConstants; -import com.twilio.converter.Promoter; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; - -import lombok.ToString; - -import java.net.URI; - -import com.twilio.base.bearertoken.Creator; -import com.twilio.http.bearertoken.BearerTokenRequest; -import com.twilio.http.bearertoken.BearerTokenTwilioRestClient; - -public class UserCreator extends Creator{ - private String pathOrganizationSid; - private User.ScimUser scimUser; - - public UserCreator(final String pathOrganizationSid, final User.ScimUser scimUser) { - this.pathOrganizationSid = pathOrganizationSid; - this.scimUser = scimUser; - } - - public UserCreator setScimUser(final User.ScimUser scimUser){ - this.scimUser = scimUser; - return this; - } - - @Override - public User create(final BearerTokenTwilioRestClient client){ - String path = "/Organizations/{organizationSid}/scim/Users"; - - path = path.replace("{"+"organizationSid"+"}", this.pathOrganizationSid.toString()); - path = path.replace("{"+"ScimUser"+"}", this.scimUser.toString()); - - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.POST, - Domains.PREVIEWIAM.toString(), - path - ); - request.setContentType(EnumConstants.ContentType.JSON); - addPostParams(request, client); - Response response = client.request(request); - if (response == null) { - throw new ApiConnectionException("User creation failed: Unable to connect to server"); - } else if (!BearerTokenTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - - return User.fromJson(response.getStream(), client.getObjectMapper()); - } - private void addPostParams(final BearerTokenRequest request, BearerTokenTwilioRestClient client) { - ObjectMapper objectMapper = client.getObjectMapper(); - if (scimUser != null) { - request.setBody(User.toJson(scimUser, objectMapper)); - } - } -} diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserDeleter.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserDeleter.java deleted file mode 100644 index 261caefb2..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserDeleter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.converter.Promoter; -import com.twilio.constant.EnumConstants; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.exception.ApiException; -import com.twilio.converter.Converter; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.bearertoken.Deleter; -import com.twilio.http.bearertoken.BearerTokenRequest; -import com.twilio.http.bearertoken.BearerTokenTwilioRestClient; - -public class UserDeleter extends Deleter { - private String pathOrganizationSid; - private String pathUserSid; - - public UserDeleter(final String pathOrganizationSid, final String pathUserSid){ - this.pathOrganizationSid = pathOrganizationSid; - this.pathUserSid = pathUserSid; - } - - - @Override - public boolean delete(final BearerTokenTwilioRestClient client) { - String path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; - - path = path.replace("{"+"organizationSid"+"}", this.pathOrganizationSid.toString()); - path = path.replace("{"+"userSid"+"}", this.pathUserSid.toString()); - - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.DELETE, - Domains.PREVIEWIAM.toString(), - path - ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); - Response response = client.request(request); - - if (response == null) { - throw new ApiConnectionException("User delete failed: Unable to connect to server"); - } else if (!BearerTokenTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - return response.getStatusCode() == 204; - } -} diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserFetcher.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserFetcher.java deleted file mode 100644 index afeab006a..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserFetcher.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.constant.EnumConstants; -import com.twilio.converter.Promoter; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; - -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.ZonedDateTime; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.bearertoken.Fetcher; -import com.twilio.http.bearertoken.BearerTokenRequest; -import com.twilio.http.bearertoken.BearerTokenTwilioRestClient; - -public class UserFetcher extends Fetcher { - private String pathOrganizationSid; - private String pathUserSid; - - public UserFetcher(final String pathOrganizationSid, final String pathUserSid){ - this.pathOrganizationSid = pathOrganizationSid; - this.pathUserSid = pathUserSid; - } - - - @Override - public User fetch(final BearerTokenTwilioRestClient client) { - String path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; - - path = path.replace("{"+"organizationSid"+"}", this.pathOrganizationSid.toString()); - path = path.replace("{"+"userSid"+"}", this.pathUserSid.toString()); - - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.GET, - Domains.PREVIEWIAM.toString(), - path - ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); - Response response = client.request(request); - - if (response == null) { - throw new ApiConnectionException("User fetch failed: Unable to connect to server"); - } else if (!BearerTokenTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - - return User.fromJson(response.getStream(), client.getObjectMapper()); - } -} diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserReader.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserReader.java deleted file mode 100644 index c99291016..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserReader.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.constant.EnumConstants; -import com.twilio.converter.Promoter; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.bearertoken.Page; -import com.twilio.base.bearertoken.Reader; -import com.twilio.base.bearertoken.ResourceSet; -import com.twilio.http.bearertoken.BearerTokenRequest; -import com.twilio.http.bearertoken.BearerTokenTwilioRestClient; - -public class UserReader extends Reader { - private String pathOrganizationSid; - private String filter; - - public UserReader(final String pathOrganizationSid){ - this.pathOrganizationSid = pathOrganizationSid; - } - - public UserReader setFilter(final String filter){ - this.filter = filter; - return this; - } - - @Override - public ResourceSet read(final BearerTokenTwilioRestClient client) { - return new ResourceSet<>(this, client, firstPage(client)); - } - - public Page firstPage(final BearerTokenTwilioRestClient client) { - String path = "/Organizations/{organizationSid}/scim/Users"; - path = path.replace("{"+"organizationSid"+"}", this.pathOrganizationSid.toString()); - - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.GET, - Domains.PREVIEWIAM.toString(), - path - ); - - addQueryParams(request); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); - return pageForRequest(client, request); - } - - private Page pageForRequest(final BearerTokenTwilioRestClient client, final BearerTokenRequest request) { - Response response = client.request(request); - - if (response == null) { - throw new ApiConnectionException("User read failed: Unable to connect to server"); - } else if (!BearerTokenTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - - return Page.fromJson( - "Resources", - response.getContent(), - User.class, - client.getObjectMapper() - ); - } - - @Override - public Page previousPage(final Page page, final BearerTokenTwilioRestClient client) { - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.GET, - page.getPreviousPageUrl(Domains.PREVIEWIAM.toString()) - ); - return pageForRequest(client, request); - } - - - @Override - public Page nextPage(final Page page, final BearerTokenTwilioRestClient client) { - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.GET, - page.getNextPageUrl(Domains.PREVIEWIAM.toString()) - ); - return pageForRequest(client, request); - } - - @Override - public Page getPage(final String targetUrl, final BearerTokenTwilioRestClient client) { - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.GET, - targetUrl - ); - - return pageForRequest(client, request); - } - private void addQueryParams(final BearerTokenRequest request) { - if (filter != null) { - - request.addQueryParam("filter", filter); - } - - if(getPageSize() != null) { - request.addQueryParam("PageSize", Integer.toString(getPageSize())); - } - } -} diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java deleted file mode 100644 index f56013776..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.organizations; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.constant.EnumConstants; -import com.twilio.converter.Promoter; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.ZonedDateTime; -import java.time.LocalDate; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.ToString; - -import com.twilio.base.bearertoken.Updater; -import com.twilio.http.bearertoken.BearerTokenRequest; -import com.twilio.http.bearertoken.BearerTokenTwilioRestClient; - - -public class UserUpdater extends Updater{ - private String pathOrganizationSid; - private String pathUserSid; - private User.ScimUser scimUser; - private String ifMatch; - - public UserUpdater(final String pathOrganizationSid, final String pathUserSid, final User.ScimUser scimUser){ - this.pathOrganizationSid = pathOrganizationSid; - this.pathUserSid = pathUserSid; - this.scimUser = scimUser; - } - - public UserUpdater setScimUser(final User.ScimUser scimUser){ - this.scimUser = scimUser; - return this; - } - public UserUpdater setIfMatch(final String ifMatch){ - this.ifMatch = ifMatch; - return this; - } - - @Override - public User update(final BearerTokenTwilioRestClient client){ - String path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; - - path = path.replace("{"+"organizationSid"+"}", this.pathOrganizationSid.toString()); - path = path.replace("{"+"userSid"+"}", this.pathUserSid.toString()); - path = path.replace("{"+"ScimUser"+"}", this.scimUser.toString()); - - BearerTokenRequest request = new BearerTokenRequest( - HttpMethod.PUT, - Domains.PREVIEWIAM.toString(), - path - ); - request.setContentType(EnumConstants.ContentType.JSON); - addPostParams(request, client); - addHeaderParams(request); - Response response = client.request(request); - if (response == null) { - throw new ApiConnectionException("User update failed: Unable to connect to server"); - } else if (!BearerTokenTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - - return User.fromJson(response.getStream(), client.getObjectMapper()); - } - - private void addPostParams(final BearerTokenRequest request, BearerTokenTwilioRestClient client) { - ObjectMapper objectMapper = client.getObjectMapper(); - if (scimUser != null) { - request.setBody(User.toJson(scimUser, objectMapper)); - } - } - private void addHeaderParams(final BearerTokenRequest request) { - if (ifMatch != null) { - request.addHeaderParam("If-Match", ifMatch); - - } - } -} diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java deleted file mode 100644 index 17b8ef4d7..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.v1; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.noauth.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Request; -import com.twilio.http.Response; -import com.twilio.http.TwilioRestClient; -import com.twilio.rest.Domains; - -import lombok.ToString; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; - -@JsonIgnoreProperties(ignoreUnknown = true) -@ToString -public class Token extends Resource { - private static final long serialVersionUID = 258139119277894L; - - - - public static TokenCreator creator(final String grantType, final String clientId){ - return new TokenCreator(grantType, clientId); - } - - /** - * Converts a JSON String into a Token object using the provided ObjectMapper. - * - * @param json Raw JSON String - * @param objectMapper Jackson ObjectMapper - * @return Token object represented by the provided JSON - */ - public static Token fromJson(final String json, final ObjectMapper objectMapper) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, Token.class); - } catch (final JsonMappingException | JsonParseException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - - /** - * Converts a JSON InputStream into a Token object using the provided - * ObjectMapper. - * - * @param json Raw JSON InputStream - * @param objectMapper Jackson ObjectMapper - * @return Token object represented by the provided JSON - */ - public static Token fromJson(final InputStream json, final ObjectMapper objectMapper) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, Token.class); - } catch (final JsonMappingException | JsonParseException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - - private final String accessToken; - private final String refreshToken; - private final String idToken; - private final String tokenType; - private final Long expiresIn; - - @JsonCreator - private Token( - @JsonProperty("access_token") - final String accessToken, - - @JsonProperty("refresh_token") - final String refreshToken, - - @JsonProperty("id_token") - final String idToken, - - @JsonProperty("token_type") - final String tokenType, - - @JsonProperty("expires_in") - final Long expiresIn - ) { - this.accessToken = accessToken; - this.refreshToken = refreshToken; - this.idToken = idToken; - this.tokenType = tokenType; - this.expiresIn = expiresIn; - } - - public final String getAccessToken() { - return this.accessToken; - } - public final String getRefreshToken() { - return this.refreshToken; - } - public final String getIdToken() { - return this.idToken; - } - public final String getTokenType() { - return this.tokenType; - } - public final Long getExpiresIn() { - return this.expiresIn; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - Token other = (Token) o; - - return Objects.equals(accessToken, other.accessToken) && Objects.equals(refreshToken, other.refreshToken) && Objects.equals(idToken, other.idToken) && Objects.equals(tokenType, other.tokenType) && Objects.equals(expiresIn, other.expiresIn) ; - } - - @Override - public int hashCode() { - return Objects.hash(accessToken, refreshToken, idToken, tokenType, expiresIn); - } - - -} - diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java deleted file mode 100644 index b441abe37..000000000 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.previewiam.v1; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.constant.EnumConstants; -import com.twilio.converter.Promoter; -import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; -import com.twilio.exception.ApiException; -import com.twilio.exception.RestException; -import com.twilio.http.HttpMethod; -import com.twilio.http.Response; -import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; - -import lombok.ToString; - -import java.net.URI; - -import com.twilio.base.noauth.Creator; -import com.twilio.http.noauth.NoAuthRequest; -import com.twilio.http.noauth.NoAuthTwilioRestClient; - -public class TokenCreator extends Creator{ - private String grantType; - private String clientId; - private String clientSecret; - private String code; - private String redirectUri; - private String audience; - private String refreshToken; - private String scope; - - public TokenCreator(final String grantType, final String clientId) { - this.grantType = grantType; - this.clientId = clientId; - } - - public TokenCreator setGrantType(final String grantType){ - this.grantType = grantType; - return this; - } - public TokenCreator setClientId(final String clientId){ - this.clientId = clientId; - return this; - } - public TokenCreator setClientSecret(final String clientSecret){ - this.clientSecret = clientSecret; - return this; - } - public TokenCreator setCode(final String code){ - this.code = code; - return this; - } - public TokenCreator setRedirectUri(final String redirectUri){ - this.redirectUri = redirectUri; - return this; - } - public TokenCreator setAudience(final String audience){ - this.audience = audience; - return this; - } - public TokenCreator setRefreshToken(final String refreshToken){ - this.refreshToken = refreshToken; - return this; - } - public TokenCreator setScope(final String scope){ - this.scope = scope; - return this; - } - - @Override - public Token create(final NoAuthTwilioRestClient client){ - String path = "/v1/token"; - - path = path.replace("{"+"grant_type"+"}", this.grantType.toString()); - path = path.replace("{"+"client_id"+"}", this.clientId.toString()); - - NoAuthRequest request = new NoAuthRequest( - HttpMethod.POST, - Domains.PREVIEWIAM.toString(), - path - ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); - addPostParams(request); - Response response = client.request(request); - if (response == null) { - throw new ApiConnectionException("Token creation failed: Unable to connect to server"); - } else if (!NoAuthTwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); - if (restException == null) { - throw new ApiException("Server Error, no content", response.getStatusCode()); - } - throw new ApiException(restException); - } - - return Token.fromJson(response.getStream(), client.getObjectMapper()); - } - private void addPostParams(final NoAuthRequest request) { - if (grantType != null) { - request.addPostParam("grant_type", grantType); - - } - if (clientId != null) { - request.addPostParam("client_id", clientId); - - } - if (clientSecret != null) { - request.addPostParam("client_secret", clientSecret); - - } - if (code != null) { - request.addPostParam("code", code); - - } - if (redirectUri != null) { - request.addPostParam("redirect_uri", redirectUri); - - } - if (audience != null) { - request.addPostParam("audience", audience); - - } - if (refreshToken != null) { - request.addPostParam("refresh_token", refreshToken); - - } - if (scope != null) { - request.addPostParam("scope", scope); - - } - } - -} diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java index d85e41843..c1610e3ee 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,56 +39,80 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Fleet extends Resource { - private static final long serialVersionUID = 163787776958144L; - - public static FleetCreator creator(){ - return new FleetCreator(); + + public static FleetCreator creator() { + return new FleetCreator( + + ); } - public static FleetFetcher fetcher(final String pathSid){ - return new FleetFetcher(pathSid); + + + + + + + + + + + public static FleetFetcher fetcher(final String pathSid) { + return new FleetFetcher( + pathSid + ); } + + + + + + /** * Converts a JSON String into a Fleet object using the provided ObjectMapper. * @@ -126,63 +150,74 @@ public static Fleet fromJson(final InputStream json, final ObjectMapper objectMa } } + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter + private final String friendlyName; + @Getter private final String name; - private final Map testIntMap; + @Getter private final String sid; - private final String friendlyName; - - @JsonCreator - private Fleet( - @JsonProperty("name") - final String name, - - @JsonProperty("test_int_map") - final Map testIntMap, + @Getter + private final Map testIntMap; - @JsonProperty("sid") - final String sid, +@JsonCreator +private Fleet( + @JsonProperty("friendly_name") + final String friendlyName, + @JsonProperty("name") + final String name, + @JsonProperty("sid") + final String sid, + @JsonProperty("test_int_map") + final Map testIntMap +){ + this.friendlyName = friendlyName; + this.name = name; + this.sid = sid; + this.testIntMap = testIntMap; +} - @JsonProperty("friendly_name") - final String friendlyName - ) { - this.name = name; - this.testIntMap = testIntMap; - this.sid = sid; - this.friendlyName = friendlyName; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public final String getName() { - return this.name; - } - public final Map getTestIntMap() { - return this.testIntMap; - } - public final String getSid() { - return this.sid; - } - public final String getFriendlyName() { - return this.friendlyName; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + if (o == null || getClass() != o.getClass()) { + return false; + } - Fleet other = (Fleet) o; + Fleet other = (Fleet) o; + return ( + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(name, other.name) && + Objects.equals(sid, other.sid) && + Objects.equals(testIntMap, other.testIntMap) + ); +} - return Objects.equals(name, other.name) && Objects.equals(testIntMap, other.testIntMap) && Objects.equals(sid, other.sid) && Objects.equals(friendlyName, other.friendlyName) ; - } +@Override +public int hashCode() { + return Objects.hash( + friendlyName, + name, + sid, + testIntMap + ); +} - @Override - public int hashCode() { - return Objects.hash(name, testIntMap, sid, friendlyName); - } } diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java index 4a98021c8..f7e2cd981 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java @@ -14,61 +14,89 @@ package com.twilio.rest.versionless.deployedDevices; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import com.twilio.converter.Converter; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; -import java.util.UUID; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import java.net.URI; +public class FleetCreator extends Creator { -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - -public class FleetCreator extends Creator{ private String name; public FleetCreator() { } - public FleetCreator setName(final String name){ - this.name = name; - return this; - } + +public FleetCreator setName(final String name){ + this.name = name; + return this; +} + @Override - public Fleet create(final TwilioRestClient client){ - String path = "/DeployedDevices/Fleets"; + public Fleet create(final TwilioRestClient client) { + + String path = "/DeployedDevices/Fleets"; + Request request = new Request( HttpMethod.POST, Domains.VERSIONLESS.toString(), @@ -76,24 +104,30 @@ public Fleet create(final TwilioRestClient client){ ); request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); addPostParams(request); + Response response = client.request(request); + if (response == null) { throw new ApiConnectionException("Fleet creation failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - + return Fleet.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (name != null) { - request.addPostParam("Name", name); - - } + + if (name != null) { + Serializer.toString(request, "Name", name, ParameterType.URLENCODED); } + +} } diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java index 87af1ec75..4479a3dfe 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java @@ -13,72 +13,105 @@ */ package com.twilio.rest.versionless.deployedDevices; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.ZonedDateTime; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; + public class FleetFetcher extends Fetcher { -public class FleetFetcher extends Fetcher { - private String pathSid; + private String pathSid; - public FleetFetcher(final String pathSid){ + public FleetFetcher(final String pathSid) { this.pathSid = pathSid; } - - @Override + + @Override public Fleet fetch(final TwilioRestClient client) { - String path = "/DeployedDevices/Fleets/{Sid}"; + + String path = "/DeployedDevices/Fleets/{Sid}"; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + Request request = new Request( HttpMethod.GET, Domains.VERSIONLESS.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("Fleet fetch failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); } - return Fleet.fromJson(response.getStream(), client.getObjectMapper()); } -} + } diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java index 011b6a32c..13358125f 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java @@ -16,22 +16,22 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.converter.Converter; -import java.util.Currency; -import com.twilio.converter.DateConverter; -import com.twilio.converter.Promoter; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.CurrencyDeserializer; -import com.twilio.exception.ApiConnectionException; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; +import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; @@ -39,52 +39,67 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; - +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; +import java.util.function.Predicate; -import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URI; +import java.time.LocalDate; import java.time.ZonedDateTime; - -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; -import java.time.LocalDate; -import java.math.BigDecimal; -import com.twilio.type.PhoneNumberCapabilities; -import com.twilio.type.FeedbackIssue; -import com.twilio.type.IceServer; -import com.twilio.type.InboundCallPrice; -import com.twilio.type.OutboundPrefixPriceWithOrigin; -import com.twilio.type.OutboundPrefixPrice; -import com.twilio.type.OutboundCallPriceWithOrigin; -import com.twilio.type.PhoneNumberPrice; -import com.twilio.type.InboundSmsPrice; -import com.twilio.type.OutboundSmsPrice; -import com.twilio.type.OutboundCallPrice; -import com.twilio.type.RecordingRule; -import com.twilio.type.SubscribeRule; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Assistant extends Resource { - private static final long serialVersionUID = 163787776958144L; - - public static AssistantReader reader(){ - return new AssistantReader(); + + + + + + public static AssistantReader reader() { + return new AssistantReader( + + ); } + + + + + /** * Converts a JSON String into a Assistant object using the provided ObjectMapper. * @@ -122,47 +137,60 @@ public static Assistant fromJson(final InputStream json, final ObjectMapper obje } } - private final String sid; + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + + @Getter private final String friendlyName; + @Getter + private final String sid; - @JsonCreator - private Assistant( - @JsonProperty("sid") - final String sid, +@JsonCreator +private Assistant( + @JsonProperty("friendly_name") + final String friendlyName, + @JsonProperty("sid") + final String sid +){ + this.friendlyName = friendlyName; + this.sid = sid; +} - @JsonProperty("friendly_name") - final String friendlyName - ) { - this.sid = sid; - this.friendlyName = friendlyName; +@Override +public boolean equals(final Object o) { + if (this == o) { + return true; } - public final String getSid() { - return this.sid; - } - public final String getFriendlyName() { - return this.friendlyName; - } - - @Override - public boolean equals(final Object o) { - if (this==o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } + if (o == null || getClass() != o.getClass()) { + return false; + } - Assistant other = (Assistant) o; + Assistant other = (Assistant) o; + return ( + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(sid, other.sid) + ); +} - return Objects.equals(sid, other.sid) && Objects.equals(friendlyName, other.friendlyName) ; - } +@Override +public int hashCode() { + return Objects.hash( + friendlyName, + sid + ); +} - @Override - public int hashCode() { - return Objects.hash(sid, friendlyName); - } } diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java index a500e7a50..7363e82ec 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java @@ -13,128 +13,151 @@ */ package com.twilio.rest.versionless.understand; - +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import com.twilio.auth_strategy.NoAuthStrategy; +import com.twilio.base.Creator; +import com.twilio.base.Deleter; +import com.twilio.base.Fetcher; +import com.twilio.base.Reader; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; import com.twilio.converter.Promoter; +import com.twilio.converter.Serializer; import com.twilio.exception.ApiConnectionException; -import com.twilio.converter.PrefixedCollapsibleMap; -import com.twilio.converter.Converter; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; import com.twilio.http.HttpMethod; +import com.twilio.http.Request; import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.io.IOException; +import com.twilio.type.FeedbackIssue; +import com.twilio.type.IceServer; +import com.twilio.type.InboundCallPrice; +import com.twilio.type.InboundSmsPrice; +import com.twilio.type.OutboundCallPrice; +import com.twilio.type.OutboundCallPriceWithOrigin; +import com.twilio.type.OutboundPrefixPrice; +import com.twilio.type.OutboundPrefixPriceWithOrigin; +import com.twilio.type.OutboundSmsPrice; +import com.twilio.type.PhoneNumberCapabilities; +import com.twilio.type.PhoneNumberPrice; +import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import java.util.function.Predicate; + import java.io.InputStream; import java.math.BigDecimal; import java.net.URI; -import java.time.format.DateTimeFormatter; -import com.twilio.converter.DateConverter; - -import java.util.ArrayList; -import java.util.HashMap; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Currency; import java.util.List; import java.util.Map; +import com.twilio.type.*; import java.util.Objects; - -import lombok.ToString; +import com.twilio.base.Resource; +import java.io.IOException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; import com.twilio.base.Page; -import com.twilio.base.Reader; import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; public class AssistantReader extends Reader { - private Integer pageSize; - public AssistantReader(){ - } + private Integer pageSize; - public AssistantReader setPageSize(final Integer pageSize){ - this.pageSize = pageSize; - return this; + public AssistantReader() { } - @Override + +public AssistantReader setPageSize(final Integer pageSize){ + this.pageSize = pageSize; + return this; +} + + + @Override public ResourceSet read(final TwilioRestClient client) { return new ResourceSet<>(this, client, firstPage(client)); } - + public Page firstPage(final TwilioRestClient client) { - String path = "/understand/Assistants"; + + String path = "/understand/Assistants"; + Request request = new Request( HttpMethod.GET, Domains.VERSIONLESS.toString(), path ); - addQueryParams(request); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); } private Page pageForRequest(final TwilioRestClient client, final Request request) { Response response = client.request(request); - if (response == null) { throw new ApiConnectionException("Assistant read failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { - RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper()); + if (restException == null) { throw new ApiException("Server Error, no content", response.getStatusCode()); } throw new ApiException(restException); - } + } return Page.fromJson( "assistants", response.getContent(), Assistant.class, - client.getObjectMapper() - ); + client.getObjectMapper()); } @Override - public Page previousPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getPreviousPageUrl(Domains.VERSIONLESS.toString()) - ); + public Page previousPage(final Page page, final TwilioRestClient client ) { + Request request = new Request(HttpMethod.GET, page.getPreviousPageUrl(Domains.API.toString())); return pageForRequest(client, request); } - @Override public Page nextPage(final Page page, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - page.getNextPageUrl(Domains.VERSIONLESS.toString()) - ); - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, page.getNextPageUrl(Domains.API.toString())); + return pageForRequest(client, request); } @Override public Page getPage(final String targetUrl, final TwilioRestClient client) { - Request request = new Request( - HttpMethod.GET, - targetUrl - ); - - return pageForRequest(client, request); + Request request = new Request(HttpMethod.GET, targetUrl); + return pageForRequest(client, request); } private void addQueryParams(final Request request) { - if (pageSize != null) { - - request.addQueryParam("PageSize", pageSize.toString()); - } - if(getPageSize() != null) { - request.addQueryParam("PageSize", Integer.toString(getPageSize())); - } + + if (pageSize != null) { + Serializer.toString(request, "PageSize", pageSize, ParameterType.QUERY); } + + + +} } diff --git a/examples/node/src/rest/api/v2010/account.ts b/examples/node/src/rest/api/v2010/account.ts index 6e4f7c923..ce503f85f 100644 --- a/examples/node/src/rest/api/v2010/account.ts +++ b/examples/node/src/rest/api/v2010/account.ts @@ -33,7 +33,7 @@ export type AccountStatus = | "completed" | "absent"; -export class TestResponseObjectTestArrayOfObjects { +export class TestResponseObjectTestArrayOfObjectsInner { "count"?: number; "description"?: string; } @@ -313,12 +313,12 @@ interface AccountResource { from: string; price_unit: string; test_number_float: number; - test_number_decimal: number; + test_number_decimal: string; test_enum: AccountStatus; a2p_profile_bundle_sid: string; test_array_of_integers: Array; test_array_of_array_of_integers: Array>; - test_array_of_objects: Array; + test_array_of_objects: Array; test_array_of_enum: Array; status: string; message: string; @@ -366,7 +366,7 @@ export class AccountInstance { from: string; priceUnit: string; testNumberFloat: number; - testNumberDecimal: number; + testNumberDecimal: string; testEnum: AccountStatus; /** * A2P Messaging Profile Bundle BundleSid @@ -374,7 +374,7 @@ export class AccountInstance { a2pProfileBundleSid: string; testArrayOfIntegers: Array; testArrayOfArrayOfIntegers: Array>; - testArrayOfObjects: Array; + testArrayOfObjects: Array; /** * Permissions authorized to the app */ diff --git a/examples/node/src/rest/api/v2010/account/call.ts b/examples/node/src/rest/api/v2010/account/call.ts index 0c3a5a152..15817ab9c 100644 --- a/examples/node/src/rest/api/v2010/account/call.ts +++ b/examples/node/src/rest/api/v2010/account/call.ts @@ -28,7 +28,7 @@ export type CallStatus = | "completed" | "absent"; -export class TestResponseObjectTestArrayOfObjects { +export class TestResponseObjectTestArrayOfObjectsInner { "count"?: number; "description"?: string; } @@ -181,12 +181,12 @@ interface CallResource { from: string; price_unit: string; test_number_float: number; - test_number_decimal: number; + test_number_decimal: string; test_enum: CallStatus; a2p_profile_bundle_sid: string; test_array_of_integers: Array; test_array_of_array_of_integers: Array>; - test_array_of_objects: Array; + test_array_of_objects: Array; test_array_of_enum: Array; status: string; message: string; @@ -238,7 +238,7 @@ export class CallInstance { from: string; priceUnit: string; testNumberFloat: number; - testNumberDecimal: number; + testNumberDecimal: string; testEnum: CallStatus; /** * A2P Messaging Profile Bundle BundleSid @@ -246,7 +246,7 @@ export class CallInstance { a2pProfileBundleSid: string; testArrayOfIntegers: Array; testArrayOfArrayOfIntegers: Array>; - testArrayOfObjects: Array; + testArrayOfObjects: Array; /** * Permissions authorized to the app */ diff --git a/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts b/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts index 47c0d1e41..b1bec591c 100644 --- a/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts +++ b/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts @@ -27,7 +27,7 @@ export type FeedbackCallSummaryStatus = | "completed" | "absent"; -export class TestResponseObjectTestArrayOfObjects { +export class TestResponseObjectTestArrayOfObjectsInner { "count"?: number; "description"?: string; } @@ -175,12 +175,12 @@ interface FeedbackCallSummaryResource { from: string; price_unit: string; test_number_float: number; - test_number_decimal: number; + test_number_decimal: string; test_enum: FeedbackCallSummaryStatus; a2p_profile_bundle_sid: string; test_array_of_integers: Array; test_array_of_array_of_integers: Array>; - test_array_of_objects: Array; + test_array_of_objects: Array; test_array_of_enum: Array; status: string; message: string; @@ -229,7 +229,7 @@ export class FeedbackCallSummaryInstance { from: string; priceUnit: string; testNumberFloat: number; - testNumberDecimal: number; + testNumberDecimal: string; testEnum: FeedbackCallSummaryStatus; /** * A2P Messaging Profile Bundle BundleSid @@ -237,7 +237,7 @@ export class FeedbackCallSummaryInstance { a2pProfileBundleSid: string; testArrayOfIntegers: Array; testArrayOfArrayOfIntegers: Array>; - testArrayOfObjects: Array; + testArrayOfObjects: Array; /** * Permissions authorized to the app */ diff --git a/examples/node/src/rest/previewIam/V1.ts b/examples/node/src/rest/previewIam/V1.ts deleted file mode 100644 index 6a27dc820..000000000 --- a/examples/node/src/rest/previewIam/V1.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import PreviewIamBase from "../PreviewIamBase"; -import Version from "../../base/Version"; -import { AuthorizeListInstance } from "./v1/authorize"; -import { TokenListInstance } from "./v1/token"; - -export default class V1 extends Version { - /** - * Initialize the V1 version of PreviewIam - * - * @param domain - The Twilio (Twilio.PreviewIam) domain - */ - constructor(domain: PreviewIamBase) { - super(domain, "v1"); - } - - /** authorize - { Twilio.PreviewIam.V1.AuthorizeListInstance } resource */ - protected _authorize?: AuthorizeListInstance; - /** token - { Twilio.PreviewIam.V1.TokenListInstance } resource */ - protected _token?: TokenListInstance; - - /** Getter for authorize resource */ - get authorize(): AuthorizeListInstance { - this._authorize = this._authorize || AuthorizeListInstance(this); - return this._authorize; - } - - /** Getter for token resource */ - get token(): TokenListInstance { - this._token = this._token || TokenListInstance(this); - return this._token; - } -} diff --git a/examples/node/src/rest/previewIam/Versionless.ts b/examples/node/src/rest/previewIam/Versionless.ts deleted file mode 100644 index 57a41e82e..000000000 --- a/examples/node/src/rest/previewIam/Versionless.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import PreviewIamBase from "../PreviewIamBase"; -import Version from "../../base/Version"; -import { OrganizationListInstance } from "./versionless/organization"; - -export default class Versionless extends Version { - /** - * Initialize the Versionless version of PreviewIam - * - * @param domain - The Twilio (Twilio.PreviewIam) domain - */ - constructor(domain: PreviewIamBase) { - super(domain, "Organizations"); - } - - /** organization - { Twilio.PreviewIam.Versionless.OrganizationListInstance } resource */ - protected _organization?: OrganizationListInstance; - - /** Getter for organization resource */ - get organization(): OrganizationListInstance { - this._organization = this._organization || OrganizationListInstance(this); - return this._organization; - } -} diff --git a/examples/node/src/rest/previewIam/v1/authorize.ts b/examples/node/src/rest/previewIam/v1/authorize.ts deleted file mode 100644 index 476a4eb78..000000000 --- a/examples/node/src/rest/previewIam/v1/authorize.ts +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; - -/** - * Options to pass to fetch a AuthorizeInstance - */ -export interface AuthorizeListInstanceFetchOptions { - /** Response Type */ - responseType?: string; - /** The Client Identifier */ - clientId?: string; - /** The url to which response will be redirected to */ - redirectUri?: string; - /** The scope of the access request */ - scope?: string; - /** An opaque value which can be used to maintain state between the request and callback */ - state?: string; -} - -export interface AuthorizeSolution {} - -export interface AuthorizeListInstance { - _version: V1; - _solution: AuthorizeSolution; - _uri: string; - - /** - * Fetch a AuthorizeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AuthorizeInstance - */ - fetch( - callback?: (error: Error | null, item?: AuthorizeInstance) => any, - ): Promise; - /** - * Fetch a AuthorizeInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AuthorizeInstance - */ - fetch( - params: AuthorizeListInstanceFetchOptions, - callback?: (error: Error | null, item?: AuthorizeInstance) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function AuthorizeListInstance(version: V1): AuthorizeListInstance { - const instance = {} as AuthorizeListInstance; - - instance._version = version; - instance._solution = {}; - instance._uri = `/authorize`; - - instance.fetch = function fetch( - params?: - | AuthorizeListInstanceFetchOptions - | ((error: Error | null, items: AuthorizeInstance) => any), - callback?: (error: Error | null, items: AuthorizeInstance) => any, - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["responseType"] !== undefined) - data["response_type"] = params["responseType"]; - if (params["clientId"] !== undefined) - data["client_id"] = params["clientId"]; - if (params["redirectUri"] !== undefined) - data["redirect_uri"] = params["redirectUri"]; - if (params["scope"] !== undefined) data["scope"] = params["scope"]; - if (params["state"] !== undefined) data["state"] = params["state"]; - - const headers: any = {}; - headers["Accept"] = "application/json"; - - let operationVersion = version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new AuthorizeInstance(operationVersion, payload), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -interface AuthorizePayload extends AuthorizeResource {} - -interface AuthorizeResource { - redirect_to: string; -} - -export class AuthorizeInstance { - constructor( - protected _version: V1, - payload: AuthorizeResource, - ) { - this.redirectTo = payload.redirect_to; - } - - /** - * The callback URL - */ - redirectTo: string; - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - redirectTo: this.redirectTo, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/examples/node/src/rest/previewIam/v1/token.ts b/examples/node/src/rest/previewIam/v1/token.ts deleted file mode 100644 index dccf7a7cf..000000000 --- a/examples/node/src/rest/previewIam/v1/token.ts +++ /dev/null @@ -1,203 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; - -/** - * Options to pass to create a TokenInstance - */ -export interface TokenListInstanceCreateOptions { - /** Grant type is a credential representing resource owner\\\'s authorization which can be used by client to obtain access token. */ - grantType: string; - /** A 34 character string that uniquely identifies this OAuth App. */ - clientId: string; - /** The credential for confidential OAuth App. */ - clientSecret?: string; - /** JWT token related to the authorization code grant type. */ - code?: string; - /** The redirect uri */ - redirectUri?: string; - /** The targeted audience uri */ - audience?: string; - /** JWT token related to refresh access token. */ - refreshToken?: string; - /** The scope of token */ - scope?: string; -} - -export interface TokenSolution {} - -export interface TokenListInstance { - _version: V1; - _solution: TokenSolution; - _uri: string; - - /** - * Create a TokenInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TokenInstance - */ - create( - params: TokenListInstanceCreateOptions, - callback?: (error: Error | null, item?: TokenInstance) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function TokenListInstance(version: V1): TokenListInstance { - const instance = {} as TokenListInstance; - - instance._version = version; - instance._solution = {}; - instance._uri = `/token`; - - instance.create = function create( - params: TokenListInstanceCreateOptions, - callback?: (error: Error | null, items: TokenInstance) => any, - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["grantType"] === null || params["grantType"] === undefined) { - throw new Error("Required parameter \"params['grantType']\" missing."); - } - - if (params["clientId"] === null || params["clientId"] === undefined) { - throw new Error("Required parameter \"params['clientId']\" missing."); - } - - let data: any = {}; - - data["grant_type"] = params["grantType"]; - - data["client_id"] = params["clientId"]; - if (params["clientSecret"] !== undefined) - data["client_secret"] = params["clientSecret"]; - if (params["code"] !== undefined) data["code"] = params["code"]; - if (params["redirectUri"] !== undefined) - data["redirect_uri"] = params["redirectUri"]; - if (params["audience"] !== undefined) data["audience"] = params["audience"]; - if (params["refreshToken"] !== undefined) - data["refresh_token"] = params["refreshToken"]; - if (params["scope"] !== undefined) data["scope"] = params["scope"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - headers["Accept"] = "application/json"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new TokenInstance(operationVersion, payload), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -interface TokenPayload extends TokenResource {} - -interface TokenResource { - access_token: string; - refresh_token: string; - id_token: string; - token_type: string; - expires_in: number; -} - -export class TokenInstance { - constructor( - protected _version: V1, - payload: TokenResource, - ) { - this.accessToken = payload.access_token; - this.refreshToken = payload.refresh_token; - this.idToken = payload.id_token; - this.tokenType = payload.token_type; - this.expiresIn = payload.expires_in; - } - - /** - * Token which carries the necessary information to access a Twilio resource directly. - */ - accessToken: string; - /** - * Token which carries the information necessary to get a new access token. - */ - refreshToken: string; - /** - * Token which carries the information necessary of user profile. - */ - idToken: string; - /** - * Token type - */ - tokenType: string; - expiresIn: number; - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accessToken: this.accessToken, - refreshToken: this.refreshToken, - idToken: this.idToken, - tokenType: this.tokenType, - expiresIn: this.expiresIn, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/examples/node/src/rest/previewIam/versionless/organization.ts b/examples/node/src/rest/previewIam/versionless/organization.ts deleted file mode 100644 index d70eb7b96..000000000 --- a/examples/node/src/rest/previewIam/versionless/organization.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Versionless from "../Versionless"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; -import { AccountListInstance } from "./organization/account"; -import { RoleAssignmentListInstance } from "./organization/roleAssignment"; -import { UserListInstance } from "./organization/user"; - -export interface OrganizationContext { - accounts: AccountListInstance; - roleAssignments: RoleAssignmentListInstance; - users: UserListInstance; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface OrganizationContextSolution { - organizationSid: string; -} - -export class OrganizationContextImpl implements OrganizationContext { - protected _solution: OrganizationContextSolution; - protected _uri: string; - - protected _accounts?: AccountListInstance; - protected _roleAssignments?: RoleAssignmentListInstance; - protected _users?: UserListInstance; - - constructor( - protected _version: Versionless, - organizationSid: string, - ) { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - this._solution = { organizationSid }; - this._uri = `/${organizationSid}`; - } - - get accounts(): AccountListInstance { - this._accounts = - this._accounts || - AccountListInstance(this._version, this._solution.organizationSid); - return this._accounts; - } - - get roleAssignments(): RoleAssignmentListInstance { - this._roleAssignments = - this._roleAssignments || - RoleAssignmentListInstance(this._version, this._solution.organizationSid); - return this._roleAssignments; - } - - get users(): UserListInstance { - this._users = - this._users || - UserListInstance(this._version, this._solution.organizationSid); - return this._users; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface OrganizationSolution {} - -export interface OrganizationListInstance { - _version: Versionless; - _solution: OrganizationSolution; - _uri: string; - - (organizationSid: string): OrganizationContext; - get(organizationSid: string): OrganizationContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function OrganizationListInstance( - version: Versionless, -): OrganizationListInstance { - const instance = ((organizationSid) => - instance.get(organizationSid)) as OrganizationListInstance; - - instance.get = function get(organizationSid): OrganizationContext { - return new OrganizationContextImpl(version, organizationSid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = ``; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} diff --git a/examples/node/src/rest/previewIam/versionless/organization/account.ts b/examples/node/src/rest/previewIam/versionless/organization/account.ts deleted file mode 100644 index 2d237df03..000000000 --- a/examples/node/src/rest/previewIam/versionless/organization/account.ts +++ /dev/null @@ -1,471 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Versionless from "../../Versionless"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to each - */ -export interface AccountListInstanceEachOptions { - /** */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: (item: AccountInstance, done: (err?: Error) => void) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface AccountListInstanceOptions { - /** */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface AccountListInstancePageOptions { - /** */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface AccountContext { - /** - * Fetch a AccountInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AccountInstance - */ - fetch( - callback?: (error: Error | null, item?: AccountInstance) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface AccountContextSolution { - organizationSid: string; - accountSid: string; -} - -export class AccountContextImpl implements AccountContext { - protected _solution: AccountContextSolution; - protected _uri: string; - - constructor( - protected _version: Versionless, - organizationSid: string, - accountSid: string, - ) { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - if (!isValidPathParam(accountSid)) { - throw new Error("Parameter 'accountSid' is not valid."); - } - - this._solution = { organizationSid, accountSid }; - this._uri = `/${organizationSid}/Accounts/${accountSid}`; - } - - fetch( - callback?: (error: Error | null, item?: AccountInstance) => any, - ): Promise { - const headers: any = {}; - headers["Accept"] = "application/json"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new AccountInstance( - operationVersion, - payload, - instance._solution.organizationSid, - instance._solution.accountSid, - ), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface AccountPayload extends TwilioResponsePayload { - content: AccountResource[]; -} - -interface AccountResource { - account_sid: string; - friendly_name: string; - status: string; - owner_sid: string; - date_created: Date; -} - -/** - * Page content - */ -export class AccountInstance { - protected _solution: AccountContextSolution; - protected _context?: AccountContext; - - constructor( - protected _version: Versionless, - payload: AccountResource, - organizationSid: string, - accountSid?: string, - ) { - this.accountSid = payload.account_sid; - this.friendlyName = payload.friendly_name; - this.status = payload.status; - this.ownerSid = payload.owner_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - - this._solution = { - organizationSid, - accountSid: accountSid || this.accountSid, - }; - } - - /** - * Twilio account sid - */ - accountSid: string; - /** - * Account friendly name - */ - friendlyName: string; - /** - * Account status - */ - status: string; - /** - * Twilio account sid - */ - ownerSid: string; - /** - * The date and time when the account was created in the system - */ - dateCreated: Date; - - private get _proxy(): AccountContext { - this._context = - this._context || - new AccountContextImpl( - this._version, - this._solution.organizationSid, - this._solution.accountSid, - ); - return this._context; - } - - /** - * Fetch a AccountInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AccountInstance - */ - fetch( - callback?: (error: Error | null, item?: AccountInstance) => any, - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - friendlyName: this.friendlyName, - status: this.status, - ownerSid: this.ownerSid, - dateCreated: this.dateCreated, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface AccountSolution { - organizationSid: string; -} - -export interface AccountListInstance { - _version: Versionless; - _solution: AccountSolution; - _uri: string; - - (accountSid: string): AccountContext; - get(accountSid: string): AccountContext; - - /** - * Streams AccountInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { AccountListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: AccountInstance, done: (err?: Error) => void) => void, - ): void; - each( - params: AccountListInstanceEachOptions, - callback?: (item: AccountInstance, done: (err?: Error) => void) => void, - ): void; - /** - * Retrieve a single target page of AccountInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: AccountPage) => any, - ): Promise; - /** - * Lists AccountInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { AccountListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: AccountInstance[]) => any, - ): Promise; - list( - params: AccountListInstanceOptions, - callback?: (error: Error | null, items: AccountInstance[]) => any, - ): Promise; - /** - * Retrieve a single page of AccountInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { AccountListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: AccountPage) => any, - ): Promise; - page( - params: AccountListInstancePageOptions, - callback?: (error: Error | null, items: AccountPage) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function AccountListInstance( - version: Versionless, - organizationSid: string, -): AccountListInstance { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - const instance = ((accountSid) => - instance.get(accountSid)) as AccountListInstance; - - instance.get = function get(accountSid): AccountContext { - return new AccountContextImpl(version, organizationSid, accountSid); - }; - - instance._version = version; - instance._solution = { organizationSid }; - instance._uri = `/${organizationSid}/Accounts`; - - instance.page = function page( - params?: - | AccountListInstancePageOptions - | ((error: Error | null, items: AccountPage) => any), - callback?: (error: Error | null, items: AccountPage) => any, - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - headers["Accept"] = "application/json"; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new AccountPage(operationVersion, payload, instance._solution), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: AccountPage) => any, - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new AccountPage(instance._version, payload, instance._solution), - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class AccountPage extends Page< - Versionless, - AccountPayload, - AccountResource, - AccountInstance -> { - /** - * Initialize the AccountPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Versionless, - response: Response, - solution: AccountSolution, - ) { - super(version, response, solution); - } - - /** - * Build an instance of AccountInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: AccountResource): AccountInstance { - return new AccountInstance( - this._version, - payload, - this._solution.organizationSid, - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/examples/node/src/rest/previewIam/versionless/organization/roleAssignment.ts b/examples/node/src/rest/previewIam/versionless/organization/roleAssignment.ts deleted file mode 100644 index 7aeb00419..000000000 --- a/examples/node/src/rest/previewIam/versionless/organization/roleAssignment.ts +++ /dev/null @@ -1,578 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Versionless from "../../Versionless"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -export class PublicApiCreateRoleAssignmentRequest { - /** - * Twilio Role Sid representing assigned role - */ - "roleSid": string; - /** - * Twilio Sid representing scope of this assignment - */ - "scope": string; - /** - * Twilio Sid representing identity of this assignment - */ - "identity": string; -} - -/** - * Options to pass to create a RoleAssignmentInstance - */ -export interface RoleAssignmentListInstanceCreateOptions { - /** */ - publicApiCreateRoleAssignmentRequest: PublicApiCreateRoleAssignmentRequest; -} -/** - * Options to pass to each - */ -export interface RoleAssignmentListInstanceEachOptions { - /** */ - pageSize?: number; - /** */ - identity?: string; - /** */ - scope?: string; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: ( - item: RoleAssignmentInstance, - done: (err?: Error) => void, - ) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface RoleAssignmentListInstanceOptions { - /** */ - pageSize?: number; - /** */ - identity?: string; - /** */ - scope?: string; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface RoleAssignmentListInstancePageOptions { - /** */ - pageSize?: number; - /** */ - identity?: string; - /** */ - scope?: string; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface RoleAssignmentContext { - /** - * Remove a RoleAssignmentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface RoleAssignmentContextSolution { - organizationSid: string; - sid: string; -} - -export class RoleAssignmentContextImpl implements RoleAssignmentContext { - protected _solution: RoleAssignmentContextSolution; - protected _uri: string; - - constructor( - protected _version: Versionless, - organizationSid: string, - sid: string, - ) { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { organizationSid, sid }; - this._uri = `/${organizationSid}/RoleAssignments/${sid}`; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise { - const headers: any = {}; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - headers, - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface RoleAssignmentPayload extends TwilioResponsePayload { - content: RoleAssignmentResource[]; -} - -interface RoleAssignmentResource { - sid: string; - role_sid: string; - scope: string; - identity: string; - code: number; - message: string; - moreInfo: string; - status: number; -} - -export class RoleAssignmentInstance { - protected _solution: RoleAssignmentContextSolution; - protected _context?: RoleAssignmentContext; - - constructor( - protected _version: Versionless, - payload: RoleAssignmentResource, - organizationSid: string, - sid?: string, - ) { - this.sid = payload.sid; - this.roleSid = payload.role_sid; - this.scope = payload.scope; - this.identity = payload.identity; - this.code = payload.code; - this.message = payload.message; - this.moreInfo = payload.moreInfo; - this.status = payload.status; - - this._solution = { organizationSid, sid: sid || this.sid }; - } - - /** - * Twilio Role Assignment Sid representing this role assignment - */ - sid: string; - /** - * Twilio Role Sid representing assigned role - */ - roleSid: string; - /** - * Twilio Sid representing identity of this assignment - */ - scope: string; - /** - * Twilio Sid representing scope of this assignment - */ - identity: string; - /** - * Twilio-specific error code - */ - code: number; - /** - * Error message - */ - message: string; - /** - * Link to Error Code References - */ - moreInfo: string; - /** - * HTTP response status code - */ - status: number; - - private get _proxy(): RoleAssignmentContext { - this._context = - this._context || - new RoleAssignmentContextImpl( - this._version, - this._solution.organizationSid, - this._solution.sid, - ); - return this._context; - } - - /** - * Remove a RoleAssignmentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - roleSid: this.roleSid, - scope: this.scope, - identity: this.identity, - code: this.code, - message: this.message, - moreInfo: this.moreInfo, - status: this.status, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface RoleAssignmentSolution { - organizationSid: string; -} - -export interface RoleAssignmentListInstance { - _version: Versionless; - _solution: RoleAssignmentSolution; - _uri: string; - - (sid: string): RoleAssignmentContext; - get(sid: string): RoleAssignmentContext; - - /** - * Create a RoleAssignmentInstance - * - * @param params - Body for request - * @param headers - header params for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed RoleAssignmentInstance - */ - create( - params: PublicApiCreateRoleAssignmentRequest, - headers?: any, - callback?: (error: Error | null, item?: RoleAssignmentInstance) => any, - ): Promise; - - /** - * Streams RoleAssignmentInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { RoleAssignmentListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: ( - item: RoleAssignmentInstance, - done: (err?: Error) => void, - ) => void, - ): void; - each( - params: RoleAssignmentListInstanceEachOptions, - callback?: ( - item: RoleAssignmentInstance, - done: (err?: Error) => void, - ) => void, - ): void; - /** - * Retrieve a single target page of RoleAssignmentInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: RoleAssignmentPage) => any, - ): Promise; - /** - * Lists RoleAssignmentInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { RoleAssignmentListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: RoleAssignmentInstance[]) => any, - ): Promise; - list( - params: RoleAssignmentListInstanceOptions, - callback?: (error: Error | null, items: RoleAssignmentInstance[]) => any, - ): Promise; - /** - * Retrieve a single page of RoleAssignmentInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { RoleAssignmentListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: RoleAssignmentPage) => any, - ): Promise; - page( - params: RoleAssignmentListInstancePageOptions, - callback?: (error: Error | null, items: RoleAssignmentPage) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function RoleAssignmentListInstance( - version: Versionless, - organizationSid: string, -): RoleAssignmentListInstance { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as RoleAssignmentListInstance; - - instance.get = function get(sid): RoleAssignmentContext { - return new RoleAssignmentContextImpl(version, organizationSid, sid); - }; - - instance._version = version; - instance._solution = { organizationSid }; - instance._uri = `/${organizationSid}/RoleAssignments`; - - instance.create = function create( - params: PublicApiCreateRoleAssignmentRequest, - headers?: any, - callback?: (error: Error | null, items: RoleAssignmentInstance) => any, - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - let data: any = {}; - - data = params; - - if (headers === null || headers === undefined) { - headers = {}; - } - - headers["Content-Type"] = "application/json"; - headers["Accept"] = "application/json"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new RoleAssignmentInstance( - operationVersion, - payload, - instance._solution.organizationSid, - ), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | RoleAssignmentListInstancePageOptions - | ((error: Error | null, items: RoleAssignmentPage) => any), - callback?: (error: Error | null, items: RoleAssignmentPage) => any, - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; - if (params["identity"] !== undefined) data["Identity"] = params["identity"]; - if (params["scope"] !== undefined) data["Scope"] = params["scope"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - headers["Accept"] = "application/json"; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new RoleAssignmentPage(operationVersion, payload, instance._solution), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: RoleAssignmentPage) => any, - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new RoleAssignmentPage(instance._version, payload, instance._solution), - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class RoleAssignmentPage extends Page< - Versionless, - RoleAssignmentPayload, - RoleAssignmentResource, - RoleAssignmentInstance -> { - /** - * Initialize the RoleAssignmentPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Versionless, - response: Response, - solution: RoleAssignmentSolution, - ) { - super(version, response, solution); - } - - /** - * Build an instance of RoleAssignmentInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: RoleAssignmentResource): RoleAssignmentInstance { - return new RoleAssignmentInstance( - this._version, - payload, - this._solution.organizationSid, - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/examples/node/src/rest/previewIam/versionless/organization/user.ts b/examples/node/src/rest/previewIam/versionless/organization/user.ts deleted file mode 100644 index e8bed099d..000000000 --- a/examples/node/src/rest/previewIam/versionless/organization/user.ts +++ /dev/null @@ -1,851 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Organization Public API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Versionless from "../../Versionless"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. - */ -export class ScimEmailAddress { - /** - * Indicates if this email address is the primary one - */ - "primary"?: boolean; - /** - * The actual email address value - */ - "value"?: string; - /** - * The type of email address (e.g., work, home, etc.) - */ - "type"?: string; -} - -/** - * Meta - */ -export class ScimMeta { - /** - * Indicates the type of the resource - */ - "resourceType"?: string; - /** - * The date and time when the resource was created in the system - */ - "created"?: Date; - /** - * The date and time when the resource was last modified - */ - "lastModified"?: Date; - /** - * A version identifier for the resource. This can be used to manage resource versioning and concurrency control. - */ - "version"?: string; -} - -/** - * User\'s name - */ -export class ScimName { - /** - * The user\'s first or given name - */ - "givenName"?: string; - /** - * The user\'s last or family name - */ - "familyName"?: string; -} - -export class ScimUser { - /** - * Unique Twilio user sid - */ - "id"?: string; - /** - * External unique resource id defined by provisioning client - */ - "externalId"?: string; - /** - * Unique username, MUST be same as primary email address - */ - "userName": string; - /** - * User friendly display name - */ - "displayName"?: string; - "name"?: ScimName; - /** - * Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. - */ - "emails"?: Array; - /** - * Indicates whether the user is active - */ - "active"?: boolean; - /** - * User\'s locale - */ - "locale"?: string; - /** - * User\'s time zone - */ - "timezone"?: string; - /** - * An array of URIs that indicate the schemas supported for this user resource - */ - "schemas"?: Array; - "meta"?: ScimMeta; - /** - * A human-readable description of the error - */ - "detail"?: string; - /** - * A scimType error code as defined in RFC7644 - */ - "scimType"?: string; - /** - * Http status code - */ - "status"?: string; - /** - * Twilio-specific error code - */ - "code"?: number; - /** - * Link to Error Code References - */ - "moreInfo"?: string; -} - -/** - * Options to pass to update a UserInstance - */ -export interface UserContextUpdateOptions { - /** */ - scimUser: ScimUser; - /** */ - ifMatch?: string; -} - -/** - * Options to pass to create a UserInstance - */ -export interface UserListInstanceCreateOptions { - /** */ - scimUser: ScimUser; -} -/** - * Options to pass to each - */ -export interface UserListInstanceEachOptions { - /** */ - filter?: string; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: (item: UserInstance, done: (err?: Error) => void) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface UserListInstanceOptions { - /** */ - filter?: string; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface UserListInstancePageOptions { - /** */ - filter?: string; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface UserContext { - /** - * Remove a UserInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise; - - /** - * Fetch a UserInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInstance - */ - fetch( - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise; - - /** - * Update a UserInstance - * - * @param params - Body for request - * @param headers - header params for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInstance - */ - update( - params: ScimUser, - headers?: any, - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface UserContextSolution { - organizationSid: string; - id: string; -} - -export class UserContextImpl implements UserContext { - protected _solution: UserContextSolution; - protected _uri: string; - - constructor( - protected _version: Versionless, - organizationSid: string, - id: string, - ) { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - if (!isValidPathParam(id)) { - throw new Error("Parameter 'id' is not valid."); - } - - this._solution = { organizationSid, id }; - this._uri = `/${organizationSid}/scim/Users/${id}`; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise { - const headers: any = {}; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - headers, - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise { - const headers: any = {}; - headers["Accept"] = "application/scim+json"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new UserInstance( - operationVersion, - payload, - instance._solution.organizationSid, - instance._solution.id, - ), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - } - - update( - params: ScimUser, - headers?: any, - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - let data: any = {}; - - data = params; - - if (headers === null || headers === undefined) { - headers = {}; - } - - headers["Content-Type"] = "application/json"; - headers["Accept"] = "application/scim+json"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "put", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new UserInstance( - operationVersion, - payload, - instance._solution.organizationSid, - instance._solution.id, - ), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface UserPayload extends TwilioResponsePayload { - Resources: UserResource[]; -} - -interface UserResource { - id: string; - externalId: string; - userName: string; - displayName: string; - name: ScimName; - emails: Array; - active: boolean; - locale: string; - timezone: string; - schemas: Array; - meta: ScimMeta; - detail: string; - scimType: string; - status: string; - code: number; - moreInfo: string; -} - -export class UserInstance { - protected _solution: UserContextSolution; - protected _context?: UserContext; - - constructor( - protected _version: Versionless, - payload: UserResource, - organizationSid: string, - id?: string, - ) { - this.id = payload.id; - this.externalId = payload.externalId; - this.userName = payload.userName; - this.displayName = payload.displayName; - this.name = payload.name; - this.emails = payload.emails; - this.active = payload.active; - this.locale = payload.locale; - this.timezone = payload.timezone; - this.schemas = payload.schemas; - this.meta = payload.meta; - this.detail = payload.detail; - this.scimType = payload.scimType; - this.status = payload.status; - this.code = payload.code; - this.moreInfo = payload.moreInfo; - - this._solution = { organizationSid, id: id || this.id }; - } - - /** - * Unique Twilio user sid - */ - id: string; - /** - * External unique resource id defined by provisioning client - */ - externalId: string; - /** - * Unique username, MUST be same as primary email address - */ - userName: string; - /** - * User friendly display name - */ - displayName: string; - name: ScimName; - /** - * Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. - */ - emails: Array; - /** - * Indicates whether the user is active - */ - active: boolean; - /** - * User\'s locale - */ - locale: string; - /** - * User\'s time zone - */ - timezone: string; - /** - * An array of URIs that indicate the schemas supported for this user resource - */ - schemas: Array; - meta: ScimMeta; - /** - * A human-readable description of the error - */ - detail: string; - /** - * A scimType error code as defined in RFC7644 - */ - scimType: string; - /** - * Http status code - */ - status: string; - /** - * Twilio-specific error code - */ - code: number; - /** - * Link to Error Code References - */ - moreInfo: string; - - private get _proxy(): UserContext { - this._context = - this._context || - new UserContextImpl( - this._version, - this._solution.organizationSid, - this._solution.id, - ); - return this._context; - } - - /** - * Remove a UserInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any, - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a UserInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInstance - */ - fetch( - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a UserInstance - * - * @param params - Body for request - * @param headers - header params for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInstance - */ - update( - params: ScimUser, - headers?: any, - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - id: this.id, - externalId: this.externalId, - userName: this.userName, - displayName: this.displayName, - name: this.name, - emails: this.emails, - active: this.active, - locale: this.locale, - timezone: this.timezone, - schemas: this.schemas, - meta: this.meta, - detail: this.detail, - scimType: this.scimType, - status: this.status, - code: this.code, - moreInfo: this.moreInfo, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface UserSolution { - organizationSid: string; -} - -export interface UserListInstance { - _version: Versionless; - _solution: UserSolution; - _uri: string; - - (id: string): UserContext; - get(id: string): UserContext; - - /** - * Create a UserInstance - * - * @param params - Body for request - * @param headers - header params for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInstance - */ - create( - params: ScimUser, - headers?: any, - callback?: (error: Error | null, item?: UserInstance) => any, - ): Promise; - - /** - * Streams UserInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { UserListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: UserInstance, done: (err?: Error) => void) => void, - ): void; - each( - params: UserListInstanceEachOptions, - callback?: (item: UserInstance, done: (err?: Error) => void) => void, - ): void; - /** - * Retrieve a single target page of UserInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: UserPage) => any, - ): Promise; - /** - * Lists UserInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { UserListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: UserInstance[]) => any, - ): Promise; - list( - params: UserListInstanceOptions, - callback?: (error: Error | null, items: UserInstance[]) => any, - ): Promise; - /** - * Retrieve a single page of UserInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { UserListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: UserPage) => any, - ): Promise; - page( - params: UserListInstancePageOptions, - callback?: (error: Error | null, items: UserPage) => any, - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function UserListInstance( - version: Versionless, - organizationSid: string, -): UserListInstance { - if (!isValidPathParam(organizationSid)) { - throw new Error("Parameter 'organizationSid' is not valid."); - } - - const instance = ((id) => instance.get(id)) as UserListInstance; - - instance.get = function get(id): UserContext { - return new UserContextImpl(version, organizationSid, id); - }; - - instance._version = version; - instance._solution = { organizationSid }; - instance._uri = `/${organizationSid}/scim/Users`; - - instance.create = function create( - params: ScimUser, - headers?: any, - callback?: (error: Error | null, items: UserInstance) => any, - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - let data: any = {}; - - data = params; - - if (headers === null || headers === undefined) { - headers = {}; - } - - headers["Content-Type"] = "application/json"; - headers["Accept"] = "application/scim+json"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new UserInstance( - operationVersion, - payload, - instance._solution.organizationSid, - ), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | UserListInstancePageOptions - | ((error: Error | null, items: UserPage) => any), - callback?: (error: Error | null, items: UserPage) => any, - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["filter"] !== undefined) data["filter"] = params["filter"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - headers["Accept"] = "application/scim+json"; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new UserPage(operationVersion, payload, instance._solution), - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback, - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: UserPage) => any, - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new UserPage(instance._version, payload, instance._solution), - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions, - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class UserPage extends Page< - Versionless, - UserPayload, - UserResource, - UserInstance -> { - /** - * Initialize the UserPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Versionless, - response: Response, - solution: UserSolution, - ) { - super(version, response, solution); - } - - /** - * Build an instance of UserInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: UserResource): UserInstance { - return new UserInstance( - this._version, - payload, - this._solution.organizationSid, - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010.php b/examples/php/src/Twilio/Rest/Api/V2010.php deleted file mode 100644 index c4a2eca29..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010.php +++ /dev/null @@ -1,132 +0,0 @@ -version = '2010-04-01'; - } - - protected function getAccounts(): AccountList - { - if (!$this->_accounts) { - $this->_accounts = new AccountList($this); - } - return $this->_accounts; - } - - /** - * @return AccountContext Account provided as the authenticating account - */ - protected function getAccount(): AccountContext - { - if (!$this->_account) { - $this->_account = new AccountContext( - $this, - $this->domain->getClient()->getAccountSid() - ); - } - return $this->_account; - } - - /** - * Setter to override the primary account - * - * @param AccountContext|AccountInstance $account account to use as the primary - * account - */ - public function setAccount($account): void - { - $this->_account = $account; - } - - protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList - { - return $this->account->calls; - } - - /** - * Magic getter to lazy load root resources - * - * @param string $name Resource to return - * @return \Twilio\ListResource The requested resource - * @throws TwilioException For unknown resource - */ - public function __get(string $name) - { - $method = 'get' . \ucfirst($name); - if (\method_exists($this, $method)) { - return $this->$method(); - } - - throw new TwilioException('Unknown resource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryContext.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryContext.php deleted file mode 100644 index 4281890cc..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryContext.php +++ /dev/null @@ -1,110 +0,0 @@ -solution = [ - 'accountSid' => - $accountSid, - 'sid' => - $sid, - ]; - - $this->uri = '/Accounts/' . \rawurlencode($accountSid) - .'/Calls/Feedback/Summary/' . \rawurlencode($sid) - .'.json'; - } - - /** - * Update the FeedbackCallSummaryInstance - * - * @param \DateTime $endDate - * @param \DateTime $startDate - * @param array|Options $options Optional Arguments - * @return FeedbackCallSummaryInstance Updated FeedbackCallSummaryInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance - { - - $options = new Values($options); - - $data = Values::of([ - 'EndDate' => - Serialize::iso8601Date($endDate), - 'StartDate' => - Serialize::iso8601Date($startDate), - 'AccountSid' => - $options['accountSid'], - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->update('POST', $this->uri, [], $data, $headers); - - return new FeedbackCallSummaryInstance( - $this->version, - $payload, - $this->solution['accountSid'], - $this->solution['sid'] - ); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.FeedbackCallSummaryContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryInstance.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryInstance.php deleted file mode 100644 index ef9360212..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryInstance.php +++ /dev/null @@ -1,159 +0,0 @@ -properties = [ - 'accountSid' => Values::array_get($payload, 'account_sid'), - 'sid' => Values::array_get($payload, 'sid'), - 'testString' => Values::array_get($payload, 'test_string'), - 'testInteger' => Values::array_get($payload, 'test_integer'), - 'testObject' => Deserialize::phoneNumberCapabilities(Values::array_get($payload, 'test_object')), - 'testDateTime' => Deserialize::dateTime(Values::array_get($payload, 'test_date_time')), - 'testNumber' => Values::array_get($payload, 'test_number'), - 'from' => Values::array_get($payload, 'from'), - 'priceUnit' => Values::array_get($payload, 'price_unit'), - 'testNumberFloat' => Values::array_get($payload, 'test_number_float'), - 'testNumberDecimal' => Values::array_get($payload, 'test_number_decimal'), - 'testEnum' => Values::array_get($payload, 'test_enum'), - 'a2PProfileBundleSid' => Values::array_get($payload, 'a2p_profile_bundle_sid'), - 'testArrayOfIntegers' => Values::array_get($payload, 'test_array_of_integers'), - 'testArrayOfArrayOfIntegers' => Values::array_get($payload, 'test_array_of_array_of_integers'), - 'testArrayOfObjects' => Values::array_get($payload, 'test_array_of_objects'), - 'testArrayOfEnum' => Values::array_get($payload, 'test_array_of_enum'), - ]; - - $this->solution = ['accountSid' => $accountSid, 'sid' => $sid ?: $this->properties['sid'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return FeedbackCallSummaryContext Context for this FeedbackCallSummaryInstance - */ - protected function proxy(): FeedbackCallSummaryContext - { - if (!$this->context) { - $this->context = new FeedbackCallSummaryContext( - $this->version, - $this->solution['accountSid'], - $this->solution['sid'] - ); - } - - return $this->context; - } - - /** - * Update the FeedbackCallSummaryInstance - * - * @param \DateTime $endDate - * @param \DateTime $startDate - * @param array|Options $options Optional Arguments - * @return FeedbackCallSummaryInstance Updated FeedbackCallSummaryInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance - { - - return $this->proxy()->update($endDate, $startDate, $options); - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.FeedbackCallSummaryInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryList.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryList.php deleted file mode 100644 index a2ad9a840..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryList.php +++ /dev/null @@ -1,80 +0,0 @@ -solution = [ - 'accountSid' => - $accountSid, - - ]; - } - - /** - * Constructs a FeedbackCallSummaryContext - * - * @param string $sid - */ - public function getContext( - string $sid - - ): FeedbackCallSummaryContext - { - return new FeedbackCallSummaryContext( - $this->version, - $this->solution['accountSid'], - $sid - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.FeedbackCallSummaryList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryOptions.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryOptions.php deleted file mode 100644 index 498e968f5..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryOptions.php +++ /dev/null @@ -1,83 +0,0 @@ -options['accountSid'] = $accountSid; - } - - /** - * @param string $accountSid - * @return $this Fluent Builder - */ - public function setAccountSid(string $accountSid): self - { - $this->options['accountSid'] = $accountSid; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.Api.V2010.UpdateFeedbackCallSummaryOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryPage.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryPage.php deleted file mode 100644 index bae3c9dcf..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return FeedbackCallSummaryInstance \Twilio\Rest\Api\V2010\Account\Call\FeedbackCallSummaryInstance - */ - public function buildInstance(array $payload): FeedbackCallSummaryInstance - { - return new FeedbackCallSummaryInstance($this->version, $payload, $this->solution['accountSid']); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.FeedbackCallSummaryPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallContext.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/CallContext.php deleted file mode 100644 index f9502e8e6..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallContext.php +++ /dev/null @@ -1,149 +0,0 @@ -solution = [ - 'accountSid' => - $accountSid, - 'testInteger' => - $testInteger, - ]; - - $this->uri = '/Accounts/' . \rawurlencode($accountSid) - .'/Calls/' . \rawurlencode($testInteger) - .'.json'; - } - - /** - * Delete the CallInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); - return $this->version->delete('DELETE', $this->uri, [], [], $headers); - } - - - /** - * Fetch the CallInstance - * - * @return CallInstance Fetched CallInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): CallInstance - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); - - return new CallInstance( - $this->version, - $payload, - $this->solution['accountSid'], - $this->solution['testInteger'] - ); - } - - - /** - * Magic getter to lazy load subresources - * - * @param string $name Subresource to return - * @return ListResource The requested subresource - * @throws TwilioException For unknown subresources - */ - public function __get(string $name): ListResource - { - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown subresource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.CallContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallInstance.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/CallInstance.php deleted file mode 100644 index 276da5d14..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallInstance.php +++ /dev/null @@ -1,169 +0,0 @@ -properties = [ - 'accountSid' => Values::array_get($payload, 'account_sid'), - 'sid' => Values::array_get($payload, 'sid'), - 'testString' => Values::array_get($payload, 'test_string'), - 'testInteger' => Values::array_get($payload, 'test_integer'), - 'testObject' => Deserialize::phoneNumberCapabilities(Values::array_get($payload, 'test_object')), - 'testDateTime' => Deserialize::dateTime(Values::array_get($payload, 'test_date_time')), - 'testNumber' => Values::array_get($payload, 'test_number'), - 'from' => Values::array_get($payload, 'from'), - 'priceUnit' => Values::array_get($payload, 'price_unit'), - 'testNumberFloat' => Values::array_get($payload, 'test_number_float'), - 'testNumberDecimal' => Values::array_get($payload, 'test_number_decimal'), - 'testEnum' => Values::array_get($payload, 'test_enum'), - 'a2PProfileBundleSid' => Values::array_get($payload, 'a2p_profile_bundle_sid'), - 'testArrayOfIntegers' => Values::array_get($payload, 'test_array_of_integers'), - 'testArrayOfArrayOfIntegers' => Values::array_get($payload, 'test_array_of_array_of_integers'), - 'testArrayOfObjects' => Values::array_get($payload, 'test_array_of_objects'), - 'testArrayOfEnum' => Values::array_get($payload, 'test_array_of_enum'), - ]; - - $this->solution = ['accountSid' => $accountSid, 'testInteger' => $testInteger ?: $this->properties['testInteger'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return CallContext Context for this CallInstance - */ - protected function proxy(): CallContext - { - if (!$this->context) { - $this->context = new CallContext( - $this->version, - $this->solution['accountSid'], - $this->solution['testInteger'] - ); - } - - return $this->context; - } - - /** - * Delete the CallInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - return $this->proxy()->delete(); - } - - /** - * Fetch the CallInstance - * - * @return CallInstance Fetched CallInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): CallInstance - { - - return $this->proxy()->fetch(); - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.CallInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallList.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/CallList.php deleted file mode 100644 index d73eea3ff..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallList.php +++ /dev/null @@ -1,174 +0,0 @@ -solution = [ - 'accountSid' => - $accountSid, - - ]; - - $this->uri = '/Accounts/' . \rawurlencode($accountSid) - .'/Calls.json'; - } - - /** - * Create the CallInstance - * - * @param string $requiredStringProperty - * @param string $testMethod The HTTP method that we should use to request the `TestArrayOfUri`. - * @param array|Options $options Optional Arguments - * @return CallInstance Created CallInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function create(string $requiredStringProperty, string $testMethod, array $options = []): CallInstance - { - - $options = new Values($options); - - $data = Values::of([ - 'RequiredStringProperty' => - $requiredStringProperty, - 'TestMethod' => - $testMethod, - 'TestArrayOfStrings' => - Serialize::map($options['testArrayOfStrings'], function ($e) { return $e; }), - 'TestArrayOfUri' => - Serialize::map($options['testArrayOfUri'], function ($e) { return $e; }), - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->create('POST', $this->uri, [], $data, $headers); - - return new CallInstance( - $this->version, - $payload, - $this->solution['accountSid'] - ); - } - - - /** - * Constructs a CallContext - * - * @param int $testInteger INTEGER ID param!!! - */ - public function getContext( - int $testInteger - - ): CallContext - { - return new CallContext( - $this->version, - $this->solution['accountSid'], - $testInteger - ); - } - - /** - * Access the feedbackCallSummary - */ - protected function getFeedbackCallSummary(): FeedbackCallSummaryList - { - if (!$this->_feedbackCallSummary) { - $this->_feedbackCallSummary = new FeedbackCallSummaryList( - $this->version, - $this->solution['accountSid'] - ); - } - return $this->_feedbackCallSummary; - } - - /** - * Magic getter to lazy load subresources - * - * @param string $name Subresource to return - * @return \Twilio\ListResource The requested subresource - * @throws TwilioException For unknown subresources - */ - public function __get(string $name) - { - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown subresource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.CallList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallOptions.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/CallOptions.php deleted file mode 100644 index 39174b145..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallOptions.php +++ /dev/null @@ -1,104 +0,0 @@ -options['testArrayOfStrings'] = $testArrayOfStrings; - $this->options['testArrayOfUri'] = $testArrayOfUri; - } - - /** - * @param string[] $testArrayOfStrings - * @return $this Fluent Builder - */ - public function setTestArrayOfStrings(array $testArrayOfStrings): self - { - $this->options['testArrayOfStrings'] = $testArrayOfStrings; - return $this; - } - - /** - * @param string[] $testArrayOfUri - * @return $this Fluent Builder - */ - public function setTestArrayOfUri(array $testArrayOfUri): self - { - $this->options['testArrayOfUri'] = $testArrayOfUri; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.Api.V2010.CreateCallOptions ' . $options . ']'; - } -} - - - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallPage.php b/examples/php/src/Twilio/Rest/Api/V2010/Account/CallPage.php deleted file mode 100644 index 40aa75c27..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/Account/CallPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return CallInstance \Twilio\Rest\Api\V2010\Account\CallInstance - */ - public function buildInstance(array $payload): CallInstance - { - return new CallInstance($this->version, $payload, $this->solution['accountSid']); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.CallPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/AccountContext.php b/examples/php/src/Twilio/Rest/Api/V2010/AccountContext.php deleted file mode 100644 index 7d313aa36..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/AccountContext.php +++ /dev/null @@ -1,192 +0,0 @@ -solution = [ - 'sid' => - $sid, - ]; - - $this->uri = '/Accounts/' . \rawurlencode($sid) - .'.json'; - } - - /** - * Delete the AccountInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); - return $this->version->delete('DELETE', $this->uri, [], [], $headers); - } - - - /** - * Fetch the AccountInstance - * - * @return AccountInstance Fetched AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): AccountInstance - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); - - return new AccountInstance( - $this->version, - $payload, - $this->solution['sid'] - ); - } - - - /** - * Update the AccountInstance - * - * @param string $status - * @param array|Options $options Optional Arguments - * @return AccountInstance Updated AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(string $status, array $options = []): AccountInstance - { - - $options = new Values($options); - - $data = Values::of([ - 'Status' => - $status, - 'PauseBehavior' => - $options['pauseBehavior'], - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->update('POST', $this->uri, [], $data, $headers); - - return new AccountInstance( - $this->version, - $payload, - $this->solution['sid'] - ); - } - - - /** - * Access the calls - */ - protected function getCalls(): CallList - { - if (!$this->_calls) { - $this->_calls = new CallList( - $this->version, - $this->solution['sid'] - ); - } - - return $this->_calls; - } - - /** - * Magic getter to lazy load subresources - * - * @param string $name Subresource to return - * @return ListResource The requested subresource - * @throws TwilioException For unknown subresources - */ - public function __get(string $name): ListResource - { - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown subresource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.AccountContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/AccountInstance.php b/examples/php/src/Twilio/Rest/Api/V2010/AccountInstance.php deleted file mode 100644 index fe2f7433c..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/AccountInstance.php +++ /dev/null @@ -1,195 +0,0 @@ -properties = [ - 'accountSid' => Values::array_get($payload, 'account_sid'), - 'sid' => Values::array_get($payload, 'sid'), - 'testString' => Values::array_get($payload, 'test_string'), - 'testInteger' => Values::array_get($payload, 'test_integer'), - 'testObject' => Deserialize::phoneNumberCapabilities(Values::array_get($payload, 'test_object')), - 'testDateTime' => Deserialize::dateTime(Values::array_get($payload, 'test_date_time')), - 'testNumber' => Values::array_get($payload, 'test_number'), - 'from' => Values::array_get($payload, 'from'), - 'priceUnit' => Values::array_get($payload, 'price_unit'), - 'testNumberFloat' => Values::array_get($payload, 'test_number_float'), - 'testNumberDecimal' => Values::array_get($payload, 'test_number_decimal'), - 'testEnum' => Values::array_get($payload, 'test_enum'), - 'a2PProfileBundleSid' => Values::array_get($payload, 'a2p_profile_bundle_sid'), - 'testArrayOfIntegers' => Values::array_get($payload, 'test_array_of_integers'), - 'testArrayOfArrayOfIntegers' => Values::array_get($payload, 'test_array_of_array_of_integers'), - 'testArrayOfObjects' => Values::array_get($payload, 'test_array_of_objects'), - 'testArrayOfEnum' => Values::array_get($payload, 'test_array_of_enum'), - 'status' => Values::array_get($payload, 'status'), - 'message' => Values::array_get($payload, 'message'), - ]; - - $this->solution = ['sid' => $sid ?: $this->properties['sid'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return AccountContext Context for this AccountInstance - */ - protected function proxy(): AccountContext - { - if (!$this->context) { - $this->context = new AccountContext( - $this->version, - $this->solution['sid'] - ); - } - - return $this->context; - } - - /** - * Delete the AccountInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - return $this->proxy()->delete(); - } - - /** - * Fetch the AccountInstance - * - * @return AccountInstance Fetched AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): AccountInstance - { - - return $this->proxy()->fetch(); - } - - /** - * Update the AccountInstance - * - * @param string $status - * @param array|Options $options Optional Arguments - * @return AccountInstance Updated AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(string $status, array $options = []): AccountInstance - { - - return $this->proxy()->update($status, $options); - } - - /** - * Access the calls - */ - protected function getCalls(): CallList - { - return $this->proxy()->calls; - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.Api.V2010.AccountInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/AccountList.php b/examples/php/src/Twilio/Rest/Api/V2010/AccountList.php deleted file mode 100644 index 9febd6381..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/AccountList.php +++ /dev/null @@ -1,213 +0,0 @@ -solution = [ - ]; - - $this->uri = '/Accounts.json'; - } - - /** - * Create the AccountInstance - * - * @param array|Options $options Optional Arguments - * @return AccountInstance Created AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function create(array $options = []): AccountInstance - { - - $options = new Values($options); - - $data = Values::of([ - 'RecordingStatusCallback' => - $options['recordingStatusCallback'], - 'RecordingStatusCallbackEvent' => - Serialize::map($options['recordingStatusCallbackEvent'], function ($e) { return $e; }), - 'Twiml' => - $options['twiml'], - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' , 'X-Twilio-Webhook-Enabled' => $options['xTwilioWebhookEnabled']]); - $payload = $this->version->create('POST', $this->uri, [], $data, $headers); - - return new AccountInstance( - $this->version, - $payload - ); - } - - - /** - * Reads AccountInstance records from the API as a list. - * Unlike stream(), this operation is eager and will load `limit` records into - * memory before returning. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. read() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, read() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return AccountInstance[] Array of results - */ - public function read(array $options = [], ?int $limit = null, $pageSize = null): array - { - return \iterator_to_array($this->stream($options, $limit, $pageSize), false); - } - - /** - * Streams AccountInstance records from the API as a generator stream. - * This operation lazily loads records as efficiently as possible until the - * limit - * is reached. - * The results are returned as a generator, so this operation is memory - * efficient. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. stream() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, stream() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return Stream stream of results - */ - public function stream(array $options = [], ?int $limit = null, $pageSize = null): Stream - { - $limits = $this->version->readLimits($limit, $pageSize); - - $page = $this->page($options, $limits['pageSize']); - - return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); - } - - /** - * Retrieve a single page of AccountInstance records from the API. - * Request is executed immediately - * - * @param mixed $pageSize Number of records to return, defaults to 50 - * @param string $pageToken PageToken provided by the API - * @param mixed $pageNumber Page Number, this value is simply for client state - * @return AccountPage Page of AccountInstance - */ - public function page( - array $options = [], - $pageSize = Values::NONE, - string $pageToken = Values::NONE, - $pageNumber = Values::NONE - ): AccountPage - { - $options = new Values($options); - - $params = Values::of([ - 'DateCreated' => - Serialize::iso8601DateTime($options['dateCreated']), - 'Date.Test' => - Serialize::iso8601Date($options['dateTest']), - 'DateCreated<' => - Serialize::iso8601DateTime($options['dateCreatedBefore']), - 'DateCreated>' => - Serialize::iso8601DateTime($options['dateCreatedAfter']), - 'PageToken' => $pageToken, - 'Page' => $pageNumber, - 'PageSize' => $pageSize, - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']); - $response = $this->version->page('GET', $this->uri, $params, [], $headers); - - return new AccountPage($this->version, $response, $this->solution); - } - - /** - * Retrieve a specific page of AccountInstance records from the API. - * Request is executed immediately - * - * @param string $targetUrl API-generated URL for the requested results page - * @return AccountPage Page of AccountInstance - */ - public function getPage(string $targetUrl): AccountPage - { - $response = $this->version->getDomain()->getClient()->request( - 'GET', - $targetUrl - ); - - return new AccountPage($this->version, $response, $this->solution); - } - - - /** - * Constructs a AccountContext - * - * @param string $sid - */ - public function getContext( - string $sid - - ): AccountContext - { - return new AccountContext( - $this->version, - $sid - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.AccountList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/Api/V2010/AccountOptions.php b/examples/php/src/Twilio/Rest/Api/V2010/AccountOptions.php deleted file mode 100644 index 187eaa852..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/AccountOptions.php +++ /dev/null @@ -1,284 +0,0 @@ -options['recordingStatusCallback'] = $recordingStatusCallback; - $this->options['recordingStatusCallbackEvent'] = $recordingStatusCallbackEvent; - $this->options['twiml'] = $twiml; - $this->options['xTwilioWebhookEnabled'] = $xTwilioWebhookEnabled; - } - - /** - * @param string $recordingStatusCallback - * @return $this Fluent Builder - */ - public function setRecordingStatusCallback(string $recordingStatusCallback): self - { - $this->options['recordingStatusCallback'] = $recordingStatusCallback; - return $this; - } - - /** - * @param string[] $recordingStatusCallbackEvent - * @return $this Fluent Builder - */ - public function setRecordingStatusCallbackEvent(array $recordingStatusCallbackEvent): self - { - $this->options['recordingStatusCallbackEvent'] = $recordingStatusCallbackEvent; - return $this; - } - - /** - * @param string $twiml - * @return $this Fluent Builder - */ - public function setTwiml(string $twiml): self - { - $this->options['twiml'] = $twiml; - return $this; - } - - /** - * @param string $xTwilioWebhookEnabled - * @return $this Fluent Builder - */ - public function setXTwilioWebhookEnabled(string $xTwilioWebhookEnabled): self - { - $this->options['xTwilioWebhookEnabled'] = $xTwilioWebhookEnabled; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.Api.V2010.CreateAccountOptions ' . $options . ']'; - } -} - - - -class ReadAccountOptions extends Options - { - /** - * @param \DateTime $dateCreated - * @param \DateTime $dateTest - * @param \DateTime $dateCreatedBefore - * @param \DateTime $dateCreatedAfter - */ - public function __construct( - - ?\DateTime $dateCreated = null, - ?\DateTime $dateTest = null, - ?\DateTime $dateCreatedBefore = null, - ?\DateTime $dateCreatedAfter = null - - ) { - $this->options['dateCreated'] = $dateCreated; - $this->options['dateTest'] = $dateTest; - $this->options['dateCreatedBefore'] = $dateCreatedBefore; - $this->options['dateCreatedAfter'] = $dateCreatedAfter; - } - - /** - * @param \DateTime $dateCreated - * @return $this Fluent Builder - */ - public function setDateCreated(\DateTime $dateCreated): self - { - $this->options['dateCreated'] = $dateCreated; - return $this; - } - - /** - * @param \DateTime $dateTest - * @return $this Fluent Builder - */ - public function setDateTest(\DateTime $dateTest): self - { - $this->options['dateTest'] = $dateTest; - return $this; - } - - /** - * @param \DateTime $dateCreatedBefore - * @return $this Fluent Builder - */ - public function setDateCreatedBefore(\DateTime $dateCreatedBefore): self - { - $this->options['dateCreatedBefore'] = $dateCreatedBefore; - return $this; - } - - /** - * @param \DateTime $dateCreatedAfter - * @return $this Fluent Builder - */ - public function setDateCreatedAfter(\DateTime $dateCreatedAfter): self - { - $this->options['dateCreatedAfter'] = $dateCreatedAfter; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.Api.V2010.ReadAccountOptions ' . $options . ']'; - } -} - -class UpdateAccountOptions extends Options - { - /** - * @param string $pauseBehavior - */ - public function __construct( - - string $pauseBehavior = Values::NONE - - ) { - $this->options['pauseBehavior'] = $pauseBehavior; - } - - /** - * @param string $pauseBehavior - * @return $this Fluent Builder - */ - public function setPauseBehavior(string $pauseBehavior): self - { - $this->options['pauseBehavior'] = $pauseBehavior; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.Api.V2010.UpdateAccountOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/Api/V2010/AccountPage.php b/examples/php/src/Twilio/Rest/Api/V2010/AccountPage.php deleted file mode 100644 index cbe2029c3..000000000 --- a/examples/php/src/Twilio/Rest/Api/V2010/AccountPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return AccountInstance \Twilio\Rest\Api\V2010\AccountInstance - */ - public function buildInstance(array $payload): AccountInstance - { - return new AccountInstance($this->version, $payload); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.Api.V2010.AccountPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1.php b/examples/php/src/Twilio/Rest/PreviewIam/V1.php deleted file mode 100644 index 7188dd400..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1.php +++ /dev/null @@ -1,105 +0,0 @@ -version = 'v1'; - } - - protected function getAuthorize(): AuthorizeList - { - if (!$this->_authorize) { - $this->_authorize = new AuthorizeList($this); - } - return $this->_authorize; - } - - protected function getToken(): TokenList - { - if (!$this->_token) { - $this->_token = new TokenList($this); - } - return $this->_token; - } - - /** - * Magic getter to lazy load root resources - * - * @param string $name Resource to return - * @return \Twilio\ListResource The requested resource - * @throws TwilioException For unknown resource - */ - public function __get(string $name) - { - $method = 'get' . \ucfirst($name); - if (\method_exists($this, $method)) { - return $this->$method(); - } - - throw new TwilioException('Unknown resource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeInstance.php deleted file mode 100644 index bdf1bc18e..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeInstance.php +++ /dev/null @@ -1,87 +0,0 @@ -properties = [ - 'redirectTo' => Values::array_get($payload, 'redirect_to'), - ]; - - $this->solution = []; - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.AuthorizeInstance]'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeList.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeList.php deleted file mode 100644 index 3b591aba2..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeList.php +++ /dev/null @@ -1,95 +0,0 @@ -solution = [ - ]; - - $this->uri = '/authorize'; - } - - /** - * Fetch the AuthorizeInstance - * - * @param array|Options $options Optional Arguments - * @return AuthorizeInstance Fetched AuthorizeInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(array $options = []): AuthorizeInstance - { - - $options = new Values($options); - - $params = Values::of([ - 'response_type' => - $options['responseType'], - 'client_id' => - $options['clientId'], - 'redirect_uri' => - $options['redirectUri'], - 'scope' => - $options['scope'], - 'state' => - $options['state'], - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->fetch('GET', $this->uri, $params, [], $headers); - - return new AuthorizeInstance( - $this->version, - $payload - ); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.AuthorizeList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeOptions.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeOptions.php deleted file mode 100644 index e19a2319f..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizeOptions.php +++ /dev/null @@ -1,157 +0,0 @@ -options['responseType'] = $responseType; - $this->options['clientId'] = $clientId; - $this->options['redirectUri'] = $redirectUri; - $this->options['scope'] = $scope; - $this->options['state'] = $state; - } - - /** - * Response Type - * - * @param string $responseType Response Type - * @return $this Fluent Builder - */ - public function setResponseType(string $responseType): self - { - $this->options['responseType'] = $responseType; - return $this; - } - - /** - * The Client Identifier - * - * @param string $clientId The Client Identifier - * @return $this Fluent Builder - */ - public function setClientId(string $clientId): self - { - $this->options['clientId'] = $clientId; - return $this; - } - - /** - * The url to which response will be redirected to - * - * @param string $redirectUri The url to which response will be redirected to - * @return $this Fluent Builder - */ - public function setRedirectUri(string $redirectUri): self - { - $this->options['redirectUri'] = $redirectUri; - return $this; - } - - /** - * The scope of the access request - * - * @param string $scope The scope of the access request - * @return $this Fluent Builder - */ - public function setScope(string $scope): self - { - $this->options['scope'] = $scope; - return $this; - } - - /** - * An opaque value which can be used to maintain state between the request and callback - * - * @param string $state An opaque value which can be used to maintain state between the request and callback - * @return $this Fluent Builder - */ - public function setState(string $state): self - { - $this->options['state'] = $state; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.PreviewIam.V1.FetchAuthorizeOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizePage.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizePage.php deleted file mode 100644 index a913372e8..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/AuthorizePage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return AuthorizeInstance \Twilio\Rest\PreviewIam\V1\AuthorizeInstance - */ - public function buildInstance(array $payload): AuthorizeInstance - { - return new AuthorizeInstance($this->version, $payload); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.AuthorizePage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenInstance.php deleted file mode 100644 index f84a278da..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenInstance.php +++ /dev/null @@ -1,95 +0,0 @@ -properties = [ - 'accessToken' => Values::array_get($payload, 'access_token'), - 'refreshToken' => Values::array_get($payload, 'refresh_token'), - 'idToken' => Values::array_get($payload, 'id_token'), - 'tokenType' => Values::array_get($payload, 'token_type'), - 'expiresIn' => Values::array_get($payload, 'expires_in'), - ]; - - $this->solution = []; - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.TokenInstance]'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenList.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenList.php deleted file mode 100644 index 7363d60ce..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenList.php +++ /dev/null @@ -1,103 +0,0 @@ -solution = [ - ]; - - $this->uri = '/token'; - } - - /** - * Create the TokenInstance - * - * @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. - * @param string $clientId A 34 character string that uniquely identifies this OAuth App. - * @param array|Options $options Optional Arguments - * @return TokenInstance Created TokenInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function create(string $grantType, string $clientId, array $options = []): TokenInstance - { - - $options = new Values($options); - - $data = Values::of([ - 'grant_type' => - $grantType, - 'client_id' => - $clientId, - 'client_secret' => - $options['clientSecret'], - 'code' => - $options['code'], - 'redirect_uri' => - $options['redirectUri'], - 'audience' => - $options['audience'], - 'refresh_token' => - $options['refreshToken'], - 'scope' => - $options['scope'], - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->create('POST', $this->uri, [], $data, $headers); - - return new TokenInstance( - $this->version, - $payload - ); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.TokenList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenOptions.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenOptions.php deleted file mode 100644 index 09843aeeb..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenOptions.php +++ /dev/null @@ -1,175 +0,0 @@ -options['clientSecret'] = $clientSecret; - $this->options['code'] = $code; - $this->options['redirectUri'] = $redirectUri; - $this->options['audience'] = $audience; - $this->options['refreshToken'] = $refreshToken; - $this->options['scope'] = $scope; - } - - /** - * The credential for confidential OAuth App. - * - * @param string $clientSecret The credential for confidential OAuth App. - * @return $this Fluent Builder - */ - public function setClientSecret(string $clientSecret): self - { - $this->options['clientSecret'] = $clientSecret; - return $this; - } - - /** - * JWT token related to the authorization code grant type. - * - * @param string $code JWT token related to the authorization code grant type. - * @return $this Fluent Builder - */ - public function setCode(string $code): self - { - $this->options['code'] = $code; - return $this; - } - - /** - * The redirect uri - * - * @param string $redirectUri The redirect uri - * @return $this Fluent Builder - */ - public function setRedirectUri(string $redirectUri): self - { - $this->options['redirectUri'] = $redirectUri; - return $this; - } - - /** - * The targeted audience uri - * - * @param string $audience The targeted audience uri - * @return $this Fluent Builder - */ - public function setAudience(string $audience): self - { - $this->options['audience'] = $audience; - return $this; - } - - /** - * JWT token related to refresh access token. - * - * @param string $refreshToken JWT token related to refresh access token. - * @return $this Fluent Builder - */ - public function setRefreshToken(string $refreshToken): self - { - $this->options['refreshToken'] = $refreshToken; - return $this; - } - - /** - * The scope of token - * - * @param string $scope The scope of token - * @return $this Fluent Builder - */ - public function setScope(string $scope): self - { - $this->options['scope'] = $scope; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.PreviewIam.V1.CreateTokenOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenPage.php b/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenPage.php deleted file mode 100644 index b0a2f26f8..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/V1/TokenPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return TokenInstance \Twilio\Rest\PreviewIam\V1\TokenInstance - */ - public function buildInstance(array $payload): TokenInstance - { - return new TokenInstance($this->version, $payload); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.V1.TokenPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless.php deleted file mode 100644 index d1014f233..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless.php +++ /dev/null @@ -1,95 +0,0 @@ -version = 'Organizations'; - } - - protected function getOrganization(): OrganizationList - { - if (!$this->_organization) { - $this->_organization = new OrganizationList($this); - } - return $this->_organization; - } - - /** - * Magic getter to lazy load root resources - * - * @param string $name Resource to return - * @return \Twilio\ListResource The requested resource - * @throws TwilioException For unknown resource - */ - public function __get(string $name) - { - $method = 'get' . \ucfirst($name); - if (\method_exists($this, $method)) { - return $this->$method(); - } - - throw new TwilioException('Unknown resource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountContext.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountContext.php deleted file mode 100644 index cdb911e11..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountContext.php +++ /dev/null @@ -1,96 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - 'accountSid' => - $accountSid, - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/Accounts/' . \rawurlencode($accountSid) - .''; - } - - /** - * Fetch the AccountInstance - * - * @return AccountInstance Fetched AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): AccountInstance - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]); - $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); - - return new AccountInstance( - $this->version, - $payload, - $this->solution['organizationSid'], - $this->solution['accountSid'] - ); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.AccountContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountInstance.php deleted file mode 100644 index c69419ab2..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountInstance.php +++ /dev/null @@ -1,132 +0,0 @@ -properties = [ - 'accountSid' => Values::array_get($payload, 'account_sid'), - 'friendlyName' => Values::array_get($payload, 'friendly_name'), - 'status' => Values::array_get($payload, 'status'), - 'ownerSid' => Values::array_get($payload, 'owner_sid'), - 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), - ]; - - $this->solution = ['organizationSid' => $organizationSid, 'accountSid' => $accountSid ?: $this->properties['accountSid'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return AccountContext Context for this AccountInstance - */ - protected function proxy(): AccountContext - { - if (!$this->context) { - $this->context = new AccountContext( - $this->version, - $this->solution['organizationSid'], - $this->solution['accountSid'] - ); - } - - return $this->context; - } - - /** - * Fetch the AccountInstance - * - * @return AccountInstance Fetched AccountInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): AccountInstance - { - - return $this->proxy()->fetch(); - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.AccountInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountList.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountList.php deleted file mode 100644 index 1bcf2b9ca..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountList.php +++ /dev/null @@ -1,176 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/Accounts'; - } - - /** - * Reads AccountInstance records from the API as a list. - * Unlike stream(), this operation is eager and will load `limit` records into - * memory before returning. - * - * @param int $limit Upper limit for the number of records to return. read() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, read() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return AccountInstance[] Array of results - */ - public function read(?int $limit = null, $pageSize = null): array - { - return \iterator_to_array($this->stream($limit, $pageSize), false); - } - - /** - * Streams AccountInstance records from the API as a generator stream. - * This operation lazily loads records as efficiently as possible until the - * limit - * is reached. - * The results are returned as a generator, so this operation is memory - * efficient. - * - * @param int $limit Upper limit for the number of records to return. stream() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, stream() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return Stream stream of results - */ - public function stream(?int $limit = null, $pageSize = null): Stream - { - $limits = $this->version->readLimits($limit, $pageSize); - - $page = $this->page($limits['pageSize']); - - return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); - } - - /** - * Retrieve a single page of AccountInstance records from the API. - * Request is executed immediately - * - * @param mixed $pageSize Number of records to return, defaults to 50 - * @param string $pageToken PageToken provided by the API - * @param mixed $pageNumber Page Number, this value is simply for client state - * @return AccountPage Page of AccountInstance - */ - public function page( - $pageSize = Values::NONE, - string $pageToken = Values::NONE, - $pageNumber = Values::NONE - ): AccountPage - { - - $params = Values::of([ - 'PageToken' => $pageToken, - 'Page' => $pageNumber, - 'PageSize' => $pageSize, - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']); - $response = $this->version->page('GET', $this->uri, $params, [], $headers); - - return new AccountPage($this->version, $response, $this->solution); - } - - /** - * Retrieve a specific page of AccountInstance records from the API. - * Request is executed immediately - * - * @param string $targetUrl API-generated URL for the requested results page - * @return AccountPage Page of AccountInstance - */ - public function getPage(string $targetUrl): AccountPage - { - $response = $this->version->getDomain()->getClient()->request( - 'GET', - $targetUrl - ); - - return new AccountPage($this->version, $response, $this->solution); - } - - - /** - * Constructs a AccountContext - * - * @param string $accountSid - */ - public function getContext( - string $accountSid - - ): AccountContext - { - return new AccountContext( - $this->version, - $this->solution['organizationSid'], - $accountSid - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.AccountList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountPage.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountPage.php deleted file mode 100644 index e668c8f52..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/AccountPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return AccountInstance \Twilio\Rest\PreviewIam\Versionless\Organization\AccountInstance - */ - public function buildInstance(array $payload): AccountInstance - { - return new AccountInstance($this->version, $payload, $this->solution['organizationSid']); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.AccountPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentContext.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentContext.php deleted file mode 100644 index 5332ffc37..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentContext.php +++ /dev/null @@ -1,89 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - 'sid' => - $sid, - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/RoleAssignments/' . \rawurlencode($sid) - .''; - } - - /** - * Delete the RoleAssignmentInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); - return $this->version->delete('DELETE', $this->uri, [], [], $headers); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.RoleAssignmentContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentInstance.php deleted file mode 100644 index 6152b68fb..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentInstance.php +++ /dev/null @@ -1,130 +0,0 @@ -properties = [ - 'sid' => Values::array_get($payload, 'sid'), - 'roleSid' => Values::array_get($payload, 'role_sid'), - 'scope' => Values::array_get($payload, 'scope'), - 'identity' => Values::array_get($payload, 'identity'), - ]; - - $this->solution = ['organizationSid' => $organizationSid, 'sid' => $sid ?: $this->properties['sid'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return RoleAssignmentContext Context for this RoleAssignmentInstance - */ - protected function proxy(): RoleAssignmentContext - { - if (!$this->context) { - $this->context = new RoleAssignmentContext( - $this->version, - $this->solution['organizationSid'], - $this->solution['sid'] - ); - } - - return $this->context; - } - - /** - * Delete the RoleAssignmentInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - return $this->proxy()->delete(); - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.RoleAssignmentInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentList.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentList.php deleted file mode 100644 index 6bf745a2a..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentList.php +++ /dev/null @@ -1,206 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/RoleAssignments'; - } - - /** - * Create the RoleAssignmentInstance - * - * @param PublicApiCreateRoleAssignmentRequest $publicApiCreateRoleAssignmentRequest - * @return RoleAssignmentInstance Created RoleAssignmentInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function create(PublicApiCreateRoleAssignmentRequest $publicApiCreateRoleAssignmentRequest): RoleAssignmentInstance - { - - $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/json' ]); - $data = $publicApiCreateRoleAssignmentRequest->toArray(); - $payload = $this->version->create('POST', $this->uri, [], $data, $headers); - - return new RoleAssignmentInstance( - $this->version, - $payload, - $this->solution['organizationSid'] - ); - } - - - /** - * Reads RoleAssignmentInstance records from the API as a list. - * Unlike stream(), this operation is eager and will load `limit` records into - * memory before returning. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. read() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, read() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return RoleAssignmentInstance[] Array of results - */ - public function read(array $options = [], ?int $limit = null, $pageSize = null): array - { - return \iterator_to_array($this->stream($options, $limit, $pageSize), false); - } - - /** - * Streams RoleAssignmentInstance records from the API as a generator stream. - * This operation lazily loads records as efficiently as possible until the - * limit - * is reached. - * The results are returned as a generator, so this operation is memory - * efficient. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. stream() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, stream() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return Stream stream of results - */ - public function stream(array $options = [], ?int $limit = null, $pageSize = null): Stream - { - $limits = $this->version->readLimits($limit, $pageSize); - - $page = $this->page($options, $limits['pageSize']); - - return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); - } - - /** - * Retrieve a single page of RoleAssignmentInstance records from the API. - * Request is executed immediately - * - * @param mixed $pageSize Number of records to return, defaults to 50 - * @param string $pageToken PageToken provided by the API - * @param mixed $pageNumber Page Number, this value is simply for client state - * @return RoleAssignmentPage Page of RoleAssignmentInstance - */ - public function page( - array $options = [], - $pageSize = Values::NONE, - string $pageToken = Values::NONE, - $pageNumber = Values::NONE - ): RoleAssignmentPage - { - $options = new Values($options); - - $params = Values::of([ - 'Identity' => - $options['identity'], - 'Scope' => - $options['scope'], - 'PageToken' => $pageToken, - 'Page' => $pageNumber, - 'PageSize' => $pageSize, - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']); - $response = $this->version->page('GET', $this->uri, $params, [], $headers); - - return new RoleAssignmentPage($this->version, $response, $this->solution); - } - - /** - * Retrieve a specific page of RoleAssignmentInstance records from the API. - * Request is executed immediately - * - * @param string $targetUrl API-generated URL for the requested results page - * @return RoleAssignmentPage Page of RoleAssignmentInstance - */ - public function getPage(string $targetUrl): RoleAssignmentPage - { - $response = $this->version->getDomain()->getClient()->request( - 'GET', - $targetUrl - ); - - return new RoleAssignmentPage($this->version, $response, $this->solution); - } - - - /** - * Constructs a RoleAssignmentContext - * - * @param string $sid - */ - public function getContext( - string $sid - - ): RoleAssignmentContext - { - return new RoleAssignmentContext( - $this->version, - $this->solution['organizationSid'], - $sid - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.RoleAssignmentList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentModels.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentModels.php deleted file mode 100644 index 5e89365cb..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentModels.php +++ /dev/null @@ -1,64 +0,0 @@ -roleSid = Values::array_get($payload, 'role_sid'); - $this->scope = Values::array_get($payload, 'scope'); - $this->identity = Values::array_get($payload, 'identity'); - } - - public function toArray(): array - { - return $this->jsonSerialize(); - } - - public function jsonSerialize(): array - { - $jsonString = [ - 'role_sid' => $this->roleSid, - 'scope' => $this->scope, - 'identity' => $this->identity - ]; - return $jsonString; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentOptions.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentOptions.php deleted file mode 100644 index 3536cbe4e..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentOptions.php +++ /dev/null @@ -1,103 +0,0 @@ -options['identity'] = $identity; - $this->options['scope'] = $scope; - } - - /** - * @param string $identity - * @return $this Fluent Builder - */ - public function setIdentity(string $identity): self - { - $this->options['identity'] = $identity; - return $this; - } - - /** - * @param string $scope - * @return $this Fluent Builder - */ - public function setScope(string $scope): self - { - $this->options['scope'] = $scope; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.PreviewIam.Versionless.ReadRoleAssignmentOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentPage.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentPage.php deleted file mode 100644 index 388730206..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/RoleAssignmentPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return RoleAssignmentInstance \Twilio\Rest\PreviewIam\Versionless\Organization\RoleAssignmentInstance - */ - public function buildInstance(array $payload): RoleAssignmentInstance - { - return new RoleAssignmentInstance($this->version, $payload, $this->solution['organizationSid']); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.RoleAssignmentPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserContext.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserContext.php deleted file mode 100644 index dad2359d5..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserContext.php +++ /dev/null @@ -1,136 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - 'id' => - $id, - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/scim/Users/' . \rawurlencode($id) - .''; - } - - /** - * Delete the UserInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); - return $this->version->delete('DELETE', $this->uri, [], [], $headers); - } - - - /** - * Fetch the UserInstance - * - * @return UserInstance Fetched UserInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): UserInstance - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/scim+json' ]); - $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); - - return new UserInstance( - $this->version, - $payload, - $this->solution['organizationSid'], - $this->solution['id'] - ); - } - - - /** - * Update the UserInstance - * - * @param ScimUser $scimUser - * @param array|Options $options Optional Arguments - * @return UserInstance Updated UserInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(ScimUser $scimUser, array $options = []): UserInstance - { - - $options = new Values($options); - - $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/scim+json' , 'If-Match' => $options['ifMatch']]); - $data = $scimUser->toArray(); - $payload = $this->version->update('PUT', $this->uri, [], $data, $headers); - - return new UserInstance( - $this->version, - $payload, - $this->solution['organizationSid'], - $this->solution['id'] - ); - } - - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.UserContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserInstance.php deleted file mode 100644 index f671f6ccd..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserInstance.php +++ /dev/null @@ -1,170 +0,0 @@ -properties = [ - 'id' => Values::array_get($payload, 'id'), - 'externalId' => Values::array_get($payload, 'external_id'), - 'userName' => Values::array_get($payload, 'user_name'), - 'displayName' => Values::array_get($payload, 'display_name'), - 'name' => Values::array_get($payload, 'name'), - 'emails' => Values::array_get($payload, 'emails'), - 'active' => Values::array_get($payload, 'active'), - 'locale' => Values::array_get($payload, 'locale'), - 'timezone' => Values::array_get($payload, 'timezone'), - 'schemas' => Values::array_get($payload, 'schemas'), - 'meta' => Values::array_get($payload, 'meta'), - ]; - - $this->solution = ['organizationSid' => $organizationSid, 'id' => $id ?: $this->properties['id'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return UserContext Context for this UserInstance - */ - protected function proxy(): UserContext - { - if (!$this->context) { - $this->context = new UserContext( - $this->version, - $this->solution['organizationSid'], - $this->solution['id'] - ); - } - - return $this->context; - } - - /** - * Delete the UserInstance - * - * @return bool True if delete succeeds, false otherwise - * @throws TwilioException When an HTTP error occurs. - */ - public function delete(): bool - { - - return $this->proxy()->delete(); - } - - /** - * Fetch the UserInstance - * - * @return UserInstance Fetched UserInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): UserInstance - { - - return $this->proxy()->fetch(); - } - - /** - * Update the UserInstance - * - * @param ScimUser $scimUser - * @param array|Options $options Optional Arguments - * @return UserInstance Updated UserInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function update(ScimUser $scimUser, array $options = []): UserInstance - { - - return $this->proxy()->update($scimUser, $options); - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.UserInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserList.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserList.php deleted file mode 100644 index 420df960d..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserList.php +++ /dev/null @@ -1,204 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .'/scim/Users'; - } - - /** - * Create the UserInstance - * - * @param ScimUser $scimUser - * @return UserInstance Created UserInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function create(ScimUser $scimUser): UserInstance - { - - $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/scim+json' ]); - $data = $scimUser->toArray(); - $payload = $this->version->create('POST', $this->uri, [], $data, $headers); - - return new UserInstance( - $this->version, - $payload, - $this->solution['organizationSid'] - ); - } - - - /** - * Reads UserInstance records from the API as a list. - * Unlike stream(), this operation is eager and will load `limit` records into - * memory before returning. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. read() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, read() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return UserInstance[] Array of results - */ - public function read(array $options = [], ?int $limit = null, $pageSize = null): array - { - return \iterator_to_array($this->stream($options, $limit, $pageSize), false); - } - - /** - * Streams UserInstance records from the API as a generator stream. - * This operation lazily loads records as efficiently as possible until the - * limit - * is reached. - * The results are returned as a generator, so this operation is memory - * efficient. - * - * @param array|Options $options Optional Arguments - * @param int $limit Upper limit for the number of records to return. stream() - * guarantees to never return more than limit. Default is no - * limit - * @param mixed $pageSize Number of records to fetch per request, when not set - * will use the default value of 50 records. If no - * page_size is defined but a limit is defined, stream() - * will attempt to read the limit with the most - * efficient page size, i.e. min(limit, 1000) - * @return Stream stream of results - */ - public function stream(array $options = [], ?int $limit = null, $pageSize = null): Stream - { - $limits = $this->version->readLimits($limit, $pageSize); - - $page = $this->page($options, $limits['pageSize']); - - return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); - } - - /** - * Retrieve a single page of UserInstance records from the API. - * Request is executed immediately - * - * @param mixed $pageSize Number of records to return, defaults to 50 - * @param string $pageToken PageToken provided by the API - * @param mixed $pageNumber Page Number, this value is simply for client state - * @return UserPage Page of UserInstance - */ - public function page( - array $options = [], - $pageSize = Values::NONE, - string $pageToken = Values::NONE, - $pageNumber = Values::NONE - ): UserPage - { - $options = new Values($options); - - $params = Values::of([ - 'filter' => - $options['filter'], - 'PageToken' => $pageToken, - 'Page' => $pageNumber, - 'PageSize' => $pageSize, - ]); - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/scim+json']); - $response = $this->version->page('GET', $this->uri, $params, [], $headers); - - return new UserPage($this->version, $response, $this->solution); - } - - /** - * Retrieve a specific page of UserInstance records from the API. - * Request is executed immediately - * - * @param string $targetUrl API-generated URL for the requested results page - * @return UserPage Page of UserInstance - */ - public function getPage(string $targetUrl): UserPage - { - $response = $this->version->getDomain()->getClient()->request( - 'GET', - $targetUrl - ); - - return new UserPage($this->version, $response, $this->solution); - } - - - /** - * Constructs a UserContext - * - * @param string $id - */ - public function getContext( - string $id - - ): UserContext - { - return new UserContext( - $this->version, - $this->solution['organizationSid'], - $id - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.UserList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserModels.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserModels.php deleted file mode 100644 index aedcc0179..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserModels.php +++ /dev/null @@ -1,268 +0,0 @@ -givenName = Values::array_get($payload, 'givenName'); - $this->familyName = Values::array_get($payload, 'familyName'); - } - - public function toArray(): array - { - return $this->jsonSerialize(); - } - - public function jsonSerialize(): array - { - $jsonString = [ - ]; - if (isset($this->givenName)) { - $jsonString['givenName'] = $this->givenName; - } - if (isset($this->familyName)) { - $jsonString['familyName'] = $this->familyName; - } - return $jsonString; - } -} - -class ScimEmailAddress implements \JsonSerializable -{ - /** - * @property bool $primary Indicates if this email address is the primary one - * @property string $value The actual email address value - * @property string $type The type of email address (e.g., work, home, etc.) - */ - protected $primary; - protected $value; - protected $type; - public function __construct(array $payload = []) { - $this->primary = Values::array_get($payload, 'primary'); - $this->value = Values::array_get($payload, 'value'); - $this->type = Values::array_get($payload, 'type'); - } - - public function toArray(): array - { - return $this->jsonSerialize(); - } - - public function jsonSerialize(): array - { - $jsonString = [ - ]; - if (isset($this->primary)) { - $jsonString['primary'] = $this->primary; - } - if (isset($this->value)) { - $jsonString['value'] = $this->value; - } - if (isset($this->type)) { - $jsonString['type'] = $this->type; - } - return $jsonString; - } -} - -class ScimMeta implements \JsonSerializable -{ - /** - * @property string $resourceType Indicates the type of the resource - * @property \DateTime $created The date and time when the resource was created in the system - * @property \DateTime $lastModified The date and time when the resource was last modified - * @property string $version A version identifier for the resource. This can be used to manage resource versioning and concurrency control. - */ - protected $resourceType; - protected $created; - protected $lastModified; - protected $version; - public function __construct(array $payload = []) { - $this->resourceType = Values::array_get($payload, 'resourceType'); - $this->created = Values::array_get($payload, 'created'); - $this->lastModified = Values::array_get($payload, 'lastModified'); - $this->version = Values::array_get($payload, 'version'); - } - - public function toArray(): array - { - return $this->jsonSerialize(); - } - - public function jsonSerialize(): array - { - $jsonString = [ - ]; - if (isset($this->resourceType)) { - $jsonString['resourceType'] = $this->resourceType; - } - if (isset($this->created)) { - $jsonString['created'] = $this->created; - } - if (isset($this->lastModified)) { - $jsonString['lastModified'] = $this->lastModified; - } - if (isset($this->version)) { - $jsonString['version'] = $this->version; - } - return $jsonString; - } -} - -class ScimUser implements \JsonSerializable -{ - /** - * @property string $id Unique Twilio user sid - * @property string $externalId External unique resource id defined by provisioning client - * @property string $userName Unique username, MUST be same as primary email address - * @property string $displayName User friendly display name - * @property string $name - * @property string[] $emails Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. - * @property bool $active Indicates whether the user is active - * @property string $locale User's locale - * @property string $timezone User's time zone - * @property string[] $schemas An array of URIs that indicate the schemas supported for this user resource - * @property string $meta - */ - protected $id; - protected $externalId; - protected $userName; - protected $displayName; - protected $name; - protected $emails; - protected $active; - protected $locale; - protected $timezone; - protected $schemas; - protected $meta; - public function __construct(array $payload = []) { - $this->id = Values::array_get($payload, 'id'); - $this->externalId = Values::array_get($payload, 'externalId'); - $this->userName = Values::array_get($payload, 'userName'); - $this->displayName = Values::array_get($payload, 'displayName'); - $this->name = Values::array_get($payload, 'name'); - $this->emails = Values::array_get($payload, 'emails'); - $this->active = Values::array_get($payload, 'active'); - $this->locale = Values::array_get($payload, 'locale'); - $this->timezone = Values::array_get($payload, 'timezone'); - $this->schemas = Values::array_get($payload, 'schemas'); - $this->meta = Values::array_get($payload, 'meta'); - } - - public function toArray(): array - { - return $this->jsonSerialize(); - } - - public function jsonSerialize(): array - { - $jsonString = [ - 'userName' => $this->userName - ]; - if (isset($this->id)) { - $jsonString['id'] = $this->id; - } - if (isset($this->externalId)) { - $jsonString['externalId'] = $this->externalId; - } - if (isset($this->displayName)) { - $jsonString['displayName'] = $this->displayName; - } - if (isset($this->name)) { - $jsonString['name'] = $this->name; - } - if (isset($this->emails)) { - $jsonString['emails'] = $this->emails; - } - if (isset($this->active)) { - $jsonString['active'] = $this->active; - } - if (isset($this->locale)) { - $jsonString['locale'] = $this->locale; - } - if (isset($this->timezone)) { - $jsonString['timezone'] = $this->timezone; - } - if (isset($this->schemas)) { - $jsonString['schemas'] = $this->schemas; - } - if (isset($this->meta)) { - $jsonString['meta'] = $this->meta; - } - return $jsonString; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserOptions.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserOptions.php deleted file mode 100644 index d6c85a79b..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserOptions.php +++ /dev/null @@ -1,139 +0,0 @@ -options['filter'] = $filter; - } - - /** - * @param string $filter - * @return $this Fluent Builder - */ - public function setFilter(string $filter): self - { - $this->options['filter'] = $filter; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.PreviewIam.Versionless.ReadUserOptions ' . $options . ']'; - } -} - -class UpdateUserOptions extends Options - { - /** - * @param string $ifMatch - */ - public function __construct( - - string $ifMatch = Values::NONE - - ) { - $this->options['ifMatch'] = $ifMatch; - } - - /** - * @param string $ifMatch - * @return $this Fluent Builder - */ - public function setIfMatch(string $ifMatch): self - { - $this->options['ifMatch'] = $ifMatch; - return $this; - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $options = \http_build_query(Values::of($this->options), '', ' '); - return '[Twilio.PreviewIam.Versionless.UpdateUserOptions ' . $options . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserPage.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserPage.php deleted file mode 100644 index 0c51b9337..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/Organization/UserPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return UserInstance \Twilio\Rest\PreviewIam\Versionless\Organization\UserInstance - */ - public function buildInstance(array $payload): UserInstance - { - return new UserInstance($this->version, $payload, $this->solution['organizationSid']); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.UserPage]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationContext.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationContext.php deleted file mode 100644 index 43c5edff2..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationContext.php +++ /dev/null @@ -1,203 +0,0 @@ -solution = [ - 'organizationSid' => - $organizationSid, - ]; - - $this->uri = '/' . \rawurlencode($organizationSid) - .''; - } - - /** - * Fetch the OrganizationInstance - * - * @return OrganizationInstance Fetched OrganizationInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): OrganizationInstance - { - - $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/scim+json' ]); - $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); - - return new OrganizationInstance( - $this->version, - $payload, - $this->solution['organizationSid'] - ); - } - - - /** - * Access the accounts - */ - protected function getAccounts(): AccountList - { - if (!$this->_accounts) { - $this->_accounts = new AccountList( - $this->version, - $this->solution['organizationSid'] - ); - } - - return $this->_accounts; - } - - /** - * Access the users - */ - protected function getUsers(): UserList - { - if (!$this->_users) { - $this->_users = new UserList( - $this->version, - $this->solution['organizationSid'] - ); - } - - return $this->_users; - } - - /** - * Access the roleAssignments - */ - protected function getRoleAssignments(): RoleAssignmentList - { - if (!$this->_roleAssignments) { - $this->_roleAssignments = new RoleAssignmentList( - $this->version, - $this->solution['organizationSid'] - ); - } - - return $this->_roleAssignments; - } - - /** - * Access the resourceTypes - */ - protected function getResourceTypes(): ResourceTypeList - { - if (!$this->_resourceTypes) { - $this->_resourceTypes = new ResourceTypeList( - $this->version, - $this->solution['organizationSid'] - ); - } - - return $this->_resourceTypes; - } - - /** - * Magic getter to lazy load subresources - * - * @param string $name Subresource to return - * @return ListResource The requested subresource - * @throws TwilioException For unknown subresources - */ - public function __get(string $name): ListResource - { - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown subresource ' . $name); - } - - /** - * Magic caller to get resource contexts - * - * @param string $name Resource to return - * @param array $arguments Context parameters - * @return InstanceContext The requested resource context - * @throws TwilioException For unknown resource - */ - public function __call(string $name, array $arguments): InstanceContext - { - $property = $this->$name; - if (\method_exists($property, 'getContext')) { - return \call_user_func_array(array($property, 'getContext'), $arguments); - } - - throw new TwilioException('Resource does not have a context'); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.OrganizationContext ' . \implode(' ', $context) . ']'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationInstance.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationInstance.php deleted file mode 100644 index 1bb637baa..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationInstance.php +++ /dev/null @@ -1,155 +0,0 @@ -solution = ['organizationSid' => $organizationSid ?: $this->properties['organizationSid'], ]; - } - - /** - * Generate an instance context for the instance, the context is capable of - * performing various actions. All instance actions are proxied to the context - * - * @return OrganizationContext Context for this OrganizationInstance - */ - protected function proxy(): OrganizationContext - { - if (!$this->context) { - $this->context = new OrganizationContext( - $this->version, - $this->solution['organizationSid'] - ); - } - - return $this->context; - } - - /** - * Fetch the OrganizationInstance - * - * @return OrganizationInstance Fetched OrganizationInstance - * @throws TwilioException When an HTTP error occurs. - */ - public function fetch(): OrganizationInstance - { - - return $this->proxy()->fetch(); - } - - /** - * Access the accounts - */ - protected function getAccounts(): AccountList - { - return $this->proxy()->accounts; - } - - /** - * Access the users - */ - protected function getUsers(): UserList - { - return $this->proxy()->users; - } - - /** - * Access the roleAssignments - */ - protected function getRoleAssignments(): RoleAssignmentList - { - return $this->proxy()->roleAssignments; - } - - /** - * Access the resourceTypes - */ - protected function getResourceTypes(): ResourceTypeList - { - return $this->proxy()->resourceTypes; - } - - /** - * Magic getter to access properties - * - * @param string $name Property to access - * @return mixed The requested property - * @throws TwilioException For unknown properties - */ - public function __get(string $name) - { - if (\array_key_exists($name, $this->properties)) { - return $this->properties[$name]; - } - - if (\property_exists($this, '_' . $name)) { - $method = 'get' . \ucfirst($name); - return $this->$method(); - } - - throw new TwilioException('Unknown property: ' . $name); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - $context = []; - foreach ($this->solution as $key => $value) { - $context[] = "$key=$value"; - } - return '[Twilio.PreviewIam.Versionless.OrganizationInstance ' . \implode(' ', $context) . ']'; - } -} - diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationList.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationList.php deleted file mode 100644 index 8bb33c0bb..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationList.php +++ /dev/null @@ -1,78 +0,0 @@ -solution = [ - ]; - } - - /** - * Constructs a OrganizationContext - * - * @param string $organizationSid - */ - public function getContext( - string $organizationSid - - ): OrganizationContext - { - return new OrganizationContext( - $this->version, - $organizationSid - ); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.OrganizationList]'; - } -} diff --git a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationPage.php b/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationPage.php deleted file mode 100644 index db5a39880..000000000 --- a/examples/php/src/Twilio/Rest/PreviewIam/Versionless/OrganizationPage.php +++ /dev/null @@ -1,55 +0,0 @@ -solution = $solution; - } - - /** - * @param array $payload Payload response from the API - * @return OrganizationInstance \Twilio\Rest\PreviewIam\Versionless\OrganizationInstance - */ - public function buildInstance(array $payload): OrganizationInstance - { - return new OrganizationInstance($this->version, $payload); - } - - /** - * Provide a friendly representation - * - * @return string Machine friendly representation - */ - public function __toString(): string - { - return '[Twilio.PreviewIam.Versionless.OrganizationPage]'; - } -} diff --git a/src/main/resources/twilio-java/common/imports.mustache b/src/main/resources/twilio-java/common/imports.mustache index 2dce9d03f..37161458a 100644 --- a/src/main/resources/twilio-java/common/imports.mustache +++ b/src/main/resources/twilio-java/common/imports.mustache @@ -40,7 +40,7 @@ import lombok.Builder; import lombok.Getter; import lombok.Setter; import lombok.ToString; - +import java.util.function.Predicate; import java.io.InputStream; import java.math.BigDecimal; @@ -57,4 +57,4 @@ import java.io.IOException; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import com.fasterxml.jackson.core.JsonProcessingException; \ No newline at end of file +import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/src/main/resources/twilio-java/deleter/operationMethod.mustache b/src/main/resources/twilio-java/deleter/operationMethod.mustache index ba98e2ba1..9d38d3001 100644 --- a/src/main/resources/twilio-java/deleter/operationMethod.mustache +++ b/src/main/resources/twilio-java/deleter/operationMethod.mustache @@ -1,6 +1,6 @@ -{{! +{{! resourceName: Api Name as identified by Directory Structure service -x-common-action-method: used to define operation method and can have values: create, read, update, delete, fetch +x-common-action-method: used to define operation method and can have values: create, read, update, delete, fetch Example: https://github.com/twilio/twilio-java/blob/9c2ba4dbc185c5576e67fbeb82ec6f4899093e79/src/main/java/com/twilio/rest/api/v2010/account/MessageCreator.java#L309 httpMethod: http method associated in the current operation. @@ -10,7 +10,8 @@ vendorExtensions.x-content-type: content type of the request, example: applicati @Override public boolean delete(final TwilioRestClient client) { {{>common/generateUri}} - + + Predicate deleteStatues = i -> i != null && i >= 200 && i < 300; Request request = new Request( HttpMethod.{{httpMethod}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), @@ -28,9 +29,9 @@ vendorExtensions.x-content-type: content type of the request, example: applicati {{#headerParams.0}} addHeaderParams(request); {{/headerParams.0}} - + Response response = client.request(request); - + if (response == null) { throw new ApiConnectionException("{{resourceName}} delete failed: Unable to connect to server"); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { @@ -43,5 +44,5 @@ vendorExtensions.x-content-type: content type of the request, example: applicati } throw new ApiException(restException); } - return response.getStatusCode() == 204; - } \ No newline at end of file + return deleteStatues.test(response.getStatusCode()); + }