diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs index 1081d3a76..91e2b7351 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010.Account.Call { public class FeedbackCallSummaryResource : Resource @@ -88,7 +90,7 @@ public static FeedbackCallSummaryResource Update(UpdateFeedbackCallSummaryOption /// Task that resolves to A single instance of FeedbackCallSummary #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateFeedbackCallSummaryOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -110,7 +112,7 @@ public static FeedbackCallSummaryResource Update( DateTime? startDate, string pathAccountSid = null, string accountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateFeedbackCallSummaryOptions(pathSid, endDate, startDate){ PathAccountSid = pathAccountSid, AccountSid = accountSid }; return Update(options, client); @@ -131,7 +133,7 @@ public static async System.Threading.Tasks.Task Upd DateTime? startDate, string pathAccountSid = null, string accountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateFeedbackCallSummaryOptions(pathSid, endDate, startDate){ PathAccountSid = pathAccountSid, AccountSid = accountSid }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs index 92b48c64b..7f0c78496 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010.Account { public class CallResource : Resource @@ -85,8 +87,7 @@ public static CallResource Create(CreateCallOptions options, ITwilioRestClient c /// Create Call parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -108,7 +109,7 @@ public static CallResource Create( string pathAccountSid = null, List testArrayOfStrings = null, List testArrayOfUri = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateCallOptions(requiredStringProperty, testMethod){ PathAccountSid = pathAccountSid, TestArrayOfStrings = testArrayOfStrings, TestArrayOfUri = testArrayOfUri }; return Create(options, client); @@ -129,7 +130,7 @@ public static async System.Threading.Tasks.Task CreateAsync( string pathAccountSid = null, List testArrayOfStrings = null, List testArrayOfUri = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateCallOptions(requiredStringProperty, testMethod){ PathAccountSid = pathAccountSid, TestArrayOfStrings = testArrayOfStrings, TestArrayOfUri = testArrayOfUri }; return await CreateAsync(options, client); @@ -176,7 +177,7 @@ public static bool Delete(DeleteCallOptions options, ITwilioRestClient client = /// Client to make requests to Twilio /// Task that resolves to A single instance of Call public static async System.Threading.Tasks.Task DeleteAsync(DeleteCallOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -243,8 +244,7 @@ public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient cli /// Fetch Call parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -259,7 +259,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchCa public static CallResource Fetch( int? pathTestInteger, string pathAccountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchCallOptions(pathTestInteger){ PathAccountSid = pathAccountSid }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs index 7043f5a2a..77545c99d 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010 { public class AccountResource : Resource @@ -95,8 +97,7 @@ public static AccountResource Create(CreateAccountOptions options, ITwilioRestCl /// Create Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -116,7 +117,7 @@ public static AccountResource Create( List recordingStatusCallbackEvent = null, Types.Twiml twiml = null, AccountResource.XTwilioWebhookEnabledEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateAccountOptions(){ RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Twiml = twiml, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; return Create(options, client); @@ -135,7 +136,7 @@ public static async System.Threading.Tasks.Task CreateAsync( List recordingStatusCallbackEvent = null, Types.Twiml twiml = null, AccountResource.XTwilioWebhookEnabledEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateAccountOptions(){ RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Twiml = twiml, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; return await CreateAsync(options, client); @@ -180,7 +181,7 @@ public static bool Delete(DeleteAccountOptions options, ITwilioRestClient client /// Client to make requests to Twilio /// Task that resolves to A single instance of Account public static async System.Threading.Tasks.Task DeleteAsync(DeleteAccountOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -243,8 +244,7 @@ public static AccountResource Fetch(FetchAccountOptions options, ITwilioRestClie /// Fetch Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -257,7 +257,7 @@ public static async System.Threading.Tasks.Task FetchAsync(Fetc /// A single instance of Account public static AccountResource Fetch( string pathSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchAccountOptions(){ PathSid = pathSid }; return Fetch(options, client); @@ -306,8 +306,7 @@ public static ResourceSet Read(ReadAccountOptions options, ITwi /// Read Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -332,7 +331,7 @@ public static ResourceSet Read( DateTime? dateCreatedAfter = null, int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAccountOptions(){ DateCreated = dateCreated, DateTest = dateTest, DateCreatedBefore = dateCreatedBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -355,7 +354,7 @@ public static async System.Threading.Tasks.Task> Re DateTime? dateCreatedAfter = null, int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAccountOptions(){ DateCreated = dateCreated, DateTest = dateTest, DateCreatedBefore = dateCreatedBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); @@ -446,7 +445,7 @@ public static AccountResource Update(UpdateAccountOptions options, ITwilioRestCl /// Task that resolves to A single instance of Account #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateAccountOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -464,7 +463,7 @@ public static AccountResource Update( AccountResource.StatusEnum status, string pathSid = null, string pauseBehavior = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAccountOptions(status){ PathSid = pathSid, PauseBehavior = pauseBehavior }; return Update(options, client); @@ -481,7 +480,7 @@ public static async System.Threading.Tasks.Task UpdateAsync( AccountResource.StatusEnum status, string pathSid = null, string pauseBehavior = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAccountOptions(status){ PathSid = pathSid, PauseBehavior = pauseBehavior }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Domain.cs b/examples/csharp/src/Twilio/Rest/Domain.cs index 1e97dbdb2..0440f1f2d 100644 --- a/examples/csharp/src/Twilio/Rest/Domain.cs +++ b/examples/csharp/src/Twilio/Rest/Domain.cs @@ -14,5 +14,6 @@ public static implicit operator Domain(string value) public static readonly Domain Api = new Domain("api"); public static readonly Domain FlexApi = new Domain("flex-api"); public static readonly Domain Versionless = new Domain("versionless"); + public static readonly Domain PreviewIam = new Domain("preview-iam"); } } diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs index e09f5cbed..17d61aa0a 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1 { public class CallResource : Resource @@ -69,7 +71,7 @@ public static CallResource Update(UpdateCallOptions options, ITwilioRestClient c /// Task that resolves to A single instance of Call #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateCallOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -83,7 +85,7 @@ public static async System.Threading.Tasks.Task UpdateAsync(Update /// A single instance of Call public static CallResource Update( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateCallOptions(pathSid){ }; return Update(options, client); @@ -96,7 +98,7 @@ public static CallResource Update( /// Task that resolves to A single instance of Call public static async System.Threading.Tasks.Task UpdateAsync( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateCallOptions(pathSid){ }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs index edb7bb8f2..52d16c36f 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1.Credential.Aws { public class HistoryResource : Resource @@ -67,8 +69,7 @@ public static HistoryResource Fetch(FetchHistoryOptions options, ITwilioRestClie /// Fetch History parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of History - public static async System.Threading.Tasks.Task FetchAsync(FetchHistoryOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchHistoryOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -83,7 +84,7 @@ public static async System.Threading.Tasks.Task FetchAsync(Fetc public static HistoryResource Fetch( string pathSid, Dictionary addOnsData = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchHistoryOptions(pathSid){ AddOnsData = addOnsData }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs index 20abf0368..8b9f121fb 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1.Credential { public class AwsResource : Resource @@ -72,7 +74,7 @@ public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = n /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws public static async System.Threading.Tasks.Task DeleteAsync(DeleteAwsOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -135,8 +137,7 @@ public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient clien /// Fetch Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -149,7 +150,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchAws /// A single instance of Aws public static AwsResource Fetch( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchAwsOptions(pathSid){ }; return Fetch(options, client); @@ -198,8 +199,7 @@ public static ResourceSet Read(ReadAwsOptions options, ITwilioRestC /// Read Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -216,7 +216,7 @@ public static async System.Threading.Tasks.Task> ReadAs public static ResourceSet Read( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -231,7 +231,7 @@ public static ResourceSet Read( public static async System.Threading.Tasks.Task> ReadAsync( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); @@ -322,7 +322,7 @@ public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient cli /// Task that resolves to A single instance of Aws #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -340,7 +340,7 @@ public static AwsResource Update( string pathSid, string testString = null, bool? testBoolean = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAwsOptions(pathSid){ TestString = testString, TestBoolean = testBoolean }; return Update(options, client); @@ -357,7 +357,7 @@ public static async System.Threading.Tasks.Task UpdateAsync( string pathSid, string testString = null, bool? testBoolean = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAwsOptions(pathSid){ TestString = testString, TestBoolean = testBoolean }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs index 29ab953c6..8b9293561 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.FlexApi.V1.Credential { public class NewCredentialsResource : Resource @@ -94,8 +96,7 @@ public static NewCredentialsResource Create(CreateNewCredentialsOptions options, /// Create NewCredentials parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of NewCredentials - public static async System.Threading.Tasks.Task CreateAsync(CreateNewCredentialsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateNewCredentialsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -141,7 +142,7 @@ public static NewCredentialsResource Create( List testAnyArray = null, List permissions = null, string someA2PThing = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateNewCredentialsOptions(testString){ TestInteger = testInteger, TestDate = testDate, TestNumberFloat = testNumberFloat, TestObject = testObject, TestBoolean = testBoolean, TestNumber = testNumber, TestNumberDouble = testNumberDouble, TestNumberInt32 = testNumberInt32, TestNumberInt64 = testNumberInt64, TestDateTime = testDateTime, TestEnum = testEnum, TestObjectArray = testObjectArray, TestAnyType = testAnyType, TestAnyArray = testAnyArray, Permissions = permissions, SomeA2PThing = someA2PThing }; return Create(options, client); @@ -186,7 +187,7 @@ public static async System.Threading.Tasks.Task CreateAs List testAnyArray = null, List permissions = null, string someA2PThing = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateNewCredentialsOptions(testString){ TestInteger = testInteger, TestDate = testDate, TestNumberFloat = testNumberFloat, TestObject = testObject, TestBoolean = testBoolean, TestNumber = testNumber, TestNumberDouble = testNumberDouble, TestNumberInt32 = testNumberInt32, TestNumberInt64 = testNumberInt64, TestDateTime = testDateTime, TestEnum = testEnum, TestObjectArray = testObjectArray, TestAnyType = testAnyType, TestAnyArray = testAnyArray, Permissions = permissions, SomeA2PThing = someA2PThing }; return await CreateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs new file mode 100644 index 000000000..e0e20bc05 --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs @@ -0,0 +1,225 @@ +/* + * 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. + */ + + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + + + + +namespace Twilio.Rest.PreviewIam.Organizations +{ + + /// create + public class CreateUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public UserResource.ScimUser ScimUser { get; } + + + /// Construct a new CreateOrganizationUserOptions + /// + /// + public CreateUserOptions(string pathOrganizationSid, UserResource.ScimUser scimUser) + { + PathOrganizationSid = pathOrganizationSid; + ScimUser = scimUser; + } + + + /// Generate the request body + public string GetBody() + { + string body = ""; + + if (ScimUser != null) + { + body = UserResource.ToJson(ScimUser); + } + return body; + } + + + } + /// delete + public class DeleteUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + + /// Construct a new DeleteOrganizationUserOptions + /// + /// + public DeleteUserOptions(string pathOrganizationSid, string pathUserSid) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + return p; + } + + + + } + + + /// fetch + public class FetchUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + + /// Construct a new FetchOrganizationUserOptions + /// + /// + public FetchUserOptions(string pathOrganizationSid, string pathUserSid) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + return p; + } + + + + } + + + /// read + public class ReadUserOptions : ReadOptions + { + + + public string PathOrganizationSid { get; } + + + public string Filter { get; set; } + + + + /// Construct a new ListOrganizationUsersOptions + /// + public ReadUserOptions(string pathOrganizationSid) + { + PathOrganizationSid = pathOrganizationSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + if (Filter != null) + { + p.Add(new KeyValuePair("filter", Filter)); + } + return p; + } + + + + } + + /// update + public class UpdateUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + public UserResource.ScimUser ScimUser { get; } + + + public string IfMatch { get; set; } + + + + /// Construct a new UpdateOrganizationUserOptions + /// + /// + /// + public UpdateUserOptions(string pathOrganizationSid, string pathUserSid, UserResource.ScimUser scimUser) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + ScimUser = scimUser; + } + + + /// Generate the request body + public string GetBody() + { + string body = ""; + + if (ScimUser != null) + { + body = UserResource.ToJson(ScimUser); + } + return body; + } + + /// Generate the necessary header parameters + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + return p; + } + + } + + +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs new file mode 100644 index 000000000..0d8660353 --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs @@ -0,0 +1,749 @@ +/* + * 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. + */ + + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Clients; +using Twilio.Constant; +using Twilio.Converters; +using Twilio.Exceptions; +using Twilio.Http; + +using Twilio.Base.BearerToken; +using Twilio.Clients.BearerToken; +using Twilio.Http.BearerToken; + + + +namespace Twilio.Rest.PreviewIam.Organizations +{ + public class UserResource : Resource + { + + public class ScimName + { + [JsonProperty("givenName")] + private string GivenName {get; set;} + [JsonProperty("familyName")] + private string FamilyName {get; set;} + public ScimName() { } + public class Builder + { + private ScimName _scimName = new ScimName(); + public Builder() + { + } + public Builder WithGivenName(string givenName) + { + _scimName.GivenName= givenName; + return this; + } + public Builder WithFamilyName(string familyName) + { + _scimName.FamilyName= familyName; + return this; + } + public ScimName Build() + { + return _scimName; + } + } + } + public class ScimEmailAddress + { + [JsonProperty("primary")] + private bool? Primary {get; set;} + [JsonProperty("value")] + private string Value {get; set;} + [JsonProperty("type")] + private string Type {get; set;} + public ScimEmailAddress() { } + public class Builder + { + private ScimEmailAddress _scimEmailAddress = new ScimEmailAddress(); + public Builder() + { + } + public Builder WithPrimary(bool? primary) + { + _scimEmailAddress.Primary= primary; + return this; + } + public Builder WithValue(string value) + { + _scimEmailAddress.Value= value; + return this; + } + public Builder WithType(string type) + { + _scimEmailAddress.Type= type; + return this; + } + public ScimEmailAddress Build() + { + return _scimEmailAddress; + } + } + } + public class ScimMeta + { + [JsonProperty("resourceType")] + private string ResourceType {get; set;} + [JsonProperty("created")] + private DateTime? Created {get; set;} + [JsonProperty("lastModified")] + private DateTime? LastModified {get; set;} + [JsonProperty("version")] + private string Version {get; set;} + public ScimMeta() { } + public class Builder + { + private ScimMeta _scimMeta = new ScimMeta(); + public Builder() + { + } + public Builder WithResourceType(string resourceType) + { + _scimMeta.ResourceType= resourceType; + return this; + } + public Builder WithCreated(DateTime? created) + { + _scimMeta.Created= created; + return this; + } + public Builder WithLastModified(DateTime? lastModified) + { + _scimMeta.LastModified= lastModified; + return this; + } + public Builder WithVersion(string version) + { + _scimMeta.Version= version; + return this; + } + public ScimMeta Build() + { + return _scimMeta; + } + } + } + public class ScimUser + { + [JsonProperty("id")] + private string Id {get; set;} + [JsonProperty("externalId")] + private string ExternalId {get; set;} + [JsonProperty("userName")] + private string UserName {get; set;} + [JsonProperty("displayName")] + private string DisplayName {get; set;} + [JsonProperty("name")] + private ScimName Name {get; set;} + [JsonProperty("emails")] + private List Emails {get; set;} + [JsonProperty("active")] + private bool? Active {get; set;} + [JsonProperty("locale")] + private string Locale {get; set;} + [JsonProperty("timezone")] + private string Timezone {get; set;} + [JsonProperty("schemas")] + private List Schemas {get; set;} + [JsonProperty("meta")] + private ScimMeta Meta {get; set;} + public ScimUser() { } + public class Builder + { + private ScimUser _scimUser = new ScimUser(); + public Builder() + { + } + public Builder WithId(string id) + { + _scimUser.Id= id; + return this; + } + public Builder WithExternalId(string externalId) + { + _scimUser.ExternalId= externalId; + return this; + } + public Builder WithUserName(string userName) + { + _scimUser.UserName= userName; + return this; + } + public Builder WithDisplayName(string displayName) + { + _scimUser.DisplayName= displayName; + return this; + } + public Builder WithName(ScimName name) + { + _scimUser.Name= name; + return this; + } + public Builder WithEmails(List emails) + { + _scimUser.Emails= emails; + return this; + } + public Builder WithActive(bool? active) + { + _scimUser.Active= active; + return this; + } + public Builder WithLocale(string locale) + { + _scimUser.Locale= locale; + return this; + } + public Builder WithTimezone(string timezone) + { + _scimUser.Timezone= timezone; + return this; + } + public Builder WithSchemas(List schemas) + { + _scimUser.Schemas= schemas; + return this; + } + public Builder WithMeta(ScimMeta meta) + { + _scimUser.Meta= meta; + return this; + } + public ScimUser Build() + { + return _scimUser; + } + } + } + + + + + private static TokenRequest BuildCreateRequest(CreateUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + + return new TokenRequest( + HttpMethod.Post, + Rest.Domain.PreviewIam, + path, + + contentType: EnumConstants.ContentTypeEnum.JSON, + body: options.GetBody(), + headerParams: null + ); + } + + /// create + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// create + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// create + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create( + string pathOrganizationSid, + UserResource.ScimUser scimUser, + TwilioOrgsTokenRestClient client = null) + { + var options = new CreateUserOptions(pathOrganizationSid, scimUser){ }; + return Create(options, client); + } + + #if !NET35 + /// create + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync( + string pathOrganizationSid, + UserResource.ScimUser scimUser, + TwilioOrgsTokenRestClient client = null) + { + var options = new CreateUserOptions(pathOrganizationSid, scimUser){ }; + return await CreateAsync(options, client); + } + #endif + + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + private static TokenRequest BuildDeleteRequest(DeleteUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Delete, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + + #if !NET35 + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + #endif + + /// delete + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new DeleteUserOptions(pathOrganizationSid, pathUserSid) ; + return Delete(options, client); + } + + #if !NET35 + /// delete + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new DeleteUserOptions(pathOrganizationSid, pathUserSid) ; + return await DeleteAsync(options, client); + } + #endif + + private static TokenRequest BuildFetchRequest(FetchUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Get, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// fetch + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// fetch + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + #endif + /// fetch + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch( + string pathOrganizationSid, + string pathUserSid, + TwilioOrgsTokenRestClient client = null) + { + var options = new FetchUserOptions(pathOrganizationSid, pathUserSid){ }; + return Fetch(options, client); + } + + #if !NET35 + /// fetch + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new FetchUserOptions(pathOrganizationSid, pathUserSid){ }; + return await FetchAsync(options, client); + } + #endif + + private static TokenRequest BuildReadRequest(ReadUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + + return new TokenRequest( + HttpMethod.Get, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + /// read + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static TokenResourceSet Read(ReadUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + var page = Page.FromJson("Resources", response.Content); + return new TokenResourceSet(page, options, client); + } + + #if !NET35 + /// read + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("Resources", response.Content); + return new TokenResourceSet(page, options, client); + } + #endif + /// read + /// + /// + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static TokenResourceSet Read( + string pathOrganizationSid, + string filter = null, + long? limit = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new ReadUserOptions(pathOrganizationSid){ Filter = filter, Limit = limit}; + return Read(options, client); + } + + #if !NET35 + /// read + /// + /// + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync( + string pathOrganizationSid, + string filter = null, + long? limit = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new ReadUserOptions(pathOrganizationSid){ Filter = filter, Limit = limit}; + return await ReadAsync(options, client); + } + #endif + + + /// Fetch the target page of records + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, TwilioOrgsTokenRestClient client) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + + var request = new TokenRequest( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + /// Fetch the next page of records + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, TwilioOrgsTokenRestClient client) + { + var request = new TokenRequest( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + /// Fetch the previous page of records + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, TwilioOrgsTokenRestClient client) + { + var request = new TokenRequest( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + + private static TokenRequest BuildUpdateRequest(UpdateUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Put, + Rest.Domain.PreviewIam, + path, + + contentType: EnumConstants.ContentTypeEnum.JSON, + body: options.GetBody(), + headerParams: options.GetHeaderParams() + ); + } + + /// update + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + + /// update + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + #if !NET35 + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// update + /// + /// + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update( + string pathOrganizationSid, + string pathUserSid, + UserResource.ScimUser scimUser, + string ifMatch = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new UpdateUserOptions(pathOrganizationSid, pathUserSid, scimUser){ IfMatch = ifMatch }; + return Update(options, client); + } + + #if !NET35 + /// update + /// + /// + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync( + string pathOrganizationSid, + string pathUserSid, + UserResource.ScimUser scimUser, + string ifMatch = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new UpdateUserOptions(pathOrganizationSid, pathUserSid, scimUser){ IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } + #endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + /// + /// Converts an object into a json string + /// + /// C# model + /// JSON string + public static string ToJson(object model) + { + try + { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + + /// Unique Twilio user sid + [JsonProperty("id")] + public string Id { get; private set; } + + /// External unique resource id defined by provisioning client + [JsonProperty("externalId")] + public string ExternalId { get; private set; } + + /// Unique username, MUST be same as primary email address + [JsonProperty("userName")] + public string UserName { get; } + + /// User friendly display name + [JsonProperty("displayName")] + public string DisplayName { get; private set; } + + /// The name + [JsonProperty("name")] + public ScimName Name { get; private set; } + + /// Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + [JsonProperty("emails")] + public List Emails { get; private set; } + + /// Indicates whether the user is active + [JsonProperty("active")] + public bool? Active { get; private set; } + + /// User's locale + [JsonProperty("locale")] + public string Locale { get; private set; } + + /// User's time zone + [JsonProperty("timezone")] + public string Timezone { get; private set; } + + /// An array of URIs that indicate the schemas supported for this user resource + [JsonProperty("schemas")] + public List Schemas { get; private set; } + + /// The meta + [JsonProperty("meta")] + public ScimMeta Meta { get; private set; } + + + + private UserResource() { + + } + } +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs new file mode 100644 index 000000000..95adbbe9f --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs @@ -0,0 +1,110 @@ +/* + * 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. + */ + + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + + + + +namespace Twilio.Rest.PreviewIam.V1 +{ + + /// create + public class CreateTokenOptions : IOptions + { + + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + public string GrantType { get; } + + /// A 34 character string that uniquely identifies this OAuth App. + public string ClientId { get; } + + /// The credential for confidential OAuth App. + public string ClientSecret { get; set; } + + /// JWT token related to the authorization code grant type. + public string Code { get; set; } + + /// The redirect uri + public string RedirectUri { get; set; } + + /// The targeted audience uri + public string Audience { get; set; } + + /// JWT token related to refresh access token. + public string RefreshToken { get; set; } + + /// The scope of token + public string Scope { get; set; } + + + /// Construct a new CreateTokenOptions + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + public CreateTokenOptions(string grantType, string clientId) + { + GrantType = grantType; + ClientId = clientId; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + if (GrantType != null) + { + p.Add(new KeyValuePair("grant_type", GrantType)); + } + if (ClientId != null) + { + p.Add(new KeyValuePair("client_id", ClientId)); + } + if (ClientSecret != null) + { + p.Add(new KeyValuePair("client_secret", ClientSecret)); + } + if (Code != null) + { + p.Add(new KeyValuePair("code", Code)); + } + if (RedirectUri != null) + { + p.Add(new KeyValuePair("redirect_uri", RedirectUri)); + } + if (Audience != null) + { + p.Add(new KeyValuePair("audience", Audience)); + } + if (RefreshToken != null) + { + p.Add(new KeyValuePair("refresh_token", RefreshToken)); + } + if (Scope != null) + { + p.Add(new KeyValuePair("scope", Scope)); + } + return p; + } + + + + } +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs new file mode 100644 index 000000000..9f79ada3c --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs @@ -0,0 +1,195 @@ +/* + * 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. + */ + + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Clients; +using Twilio.Constant; +using Twilio.Converters; +using Twilio.Exceptions; +using Twilio.Http; + + +using Twilio.Clients.NoAuth; +using Twilio.Http.NoAuth; + + +namespace Twilio.Rest.PreviewIam.V1 +{ + public class TokenResource : Resource + { + + + + + + private static NoAuthRequest BuildCreateRequest(CreateTokenOptions options, TwilioNoAuthRestClient client) + { + + string path = "/v1/token"; + + + return new NoAuthRequest( + HttpMethod.Post, + Rest.Domain.PreviewIam, + path, + contentType: EnumConstants.ContentTypeEnum.FORM_URLENCODED, + postParams: options.GetParams(), + headerParams: null + ); + } + + /// create + /// Create Token parameters + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create(CreateTokenOptions options, TwilioNoAuthRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetNoAuthRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// create + /// Create Token parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync(CreateTokenOptions options, TwilioNoAuthRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetNoAuthRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// create + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + /// The credential for confidential OAuth App. + /// JWT token related to the authorization code grant type. + /// The redirect uri + /// The targeted audience uri + /// JWT token related to refresh access token. + /// The scope of token + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create( + string grantType, + string clientId, + string clientSecret = null, + string code = null, + string redirectUri = null, + string audience = null, + string refreshToken = null, + string scope = null, + TwilioNoAuthRestClient client = null) + { + var options = new CreateTokenOptions(grantType, clientId){ ClientSecret = clientSecret, Code = code, RedirectUri = redirectUri, Audience = audience, RefreshToken = refreshToken, Scope = scope }; + return Create(options, client); + } + + #if !NET35 + /// create + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + /// The credential for confidential OAuth App. + /// JWT token related to the authorization code grant type. + /// The redirect uri + /// The targeted audience uri + /// JWT token related to refresh access token. + /// The scope of token + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync( + string grantType, + string clientId, + string clientSecret = null, + string code = null, + string redirectUri = null, + string audience = null, + string refreshToken = null, + string scope = null, + TwilioNoAuthRestClient client = null) + { + var options = new CreateTokenOptions(grantType, clientId){ ClientSecret = clientSecret, Code = code, RedirectUri = redirectUri, Audience = audience, RefreshToken = refreshToken, Scope = scope }; + return await CreateAsync(options, client); + } + #endif + + /// + /// Converts a JSON string into a TokenResource object + /// + /// Raw JSON string + /// TokenResource object represented by the provided JSON + public static TokenResource FromJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + /// + /// Converts an object into a json string + /// + /// C# model + /// JSON string + public static string ToJson(object model) + { + try + { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + + /// Token which carries the necessary information to access a Twilio resource directly. + [JsonProperty("access_token")] + public string AccessToken { get; private set; } + + /// Token which carries the information necessary to get a new access token. + [JsonProperty("refresh_token")] + public string RefreshToken { get; private set; } + + /// Token which carries the information necessary of user profile. + [JsonProperty("id_token")] + public string IdToken { get; private set; } + + /// Token type + [JsonProperty("token_type")] + public string TokenType { get; private set; } + + /// The expires_in + [JsonProperty("expires_in")] + public long? ExpiresIn { get; private set; } + + + + private TokenResource() { + + } + } +} + diff --git a/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs b/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs index 01deb6ea8..3e418d40d 100644 --- a/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs +++ b/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.Versionless.DeployedDevices { public class FleetResource : Resource @@ -66,8 +68,7 @@ public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient /// Create Fleet parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -81,7 +82,7 @@ public static async System.Threading.Tasks.Task CreateAsync(Creat /// A single instance of Fleet public static FleetResource Create( string name = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateFleetOptions(){ Name = name }; return Create(options, client); @@ -94,7 +95,7 @@ public static FleetResource Create( /// Task that resolves to A single instance of Fleet public static async System.Threading.Tasks.Task CreateAsync( string name = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateFleetOptions(){ Name = name }; return await CreateAsync(options, client); @@ -134,8 +135,7 @@ public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient c /// Fetch Fleet parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -148,7 +148,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchF /// A single instance of Fleet public static FleetResource Fetch( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchFleetOptions(pathSid){ }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs b/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs index 324cc8e77..be48d22c3 100644 --- a/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs +++ b/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.Versionless.Understand { public class AssistantResource : Resource @@ -65,8 +67,7 @@ public static ResourceSet Read(ReadAssistantOptions options, /// Read Assistant parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -83,7 +84,7 @@ public static async System.Threading.Tasks.Task> public static ResourceSet Read( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAssistantOptions(){ PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -98,7 +99,7 @@ public static ResourceSet Read( public static async System.Threading.Tasks.Task> ReadAsync( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAssistantOptions(){ PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); diff --git a/examples/prism/docker-compose.yml b/examples/prism/docker-compose.yml index e4e307ab1..aad0b0d97 100644 --- a/examples/prism/docker-compose.yml +++ b/examples/prism/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' services: go-test: build: diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index bf3809e01..7baa756f8 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -18,7 +18,7 @@ 'php': 'Rest' } generateForLanguages = { - 'twilio_iam_organizations.json' : ['java'] + 'twilio_iam_organizations.json' : ['java', 'csharp'] } CLEANUP_IMPORT_LANGUAGES = ['java', 'php'] REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node'] diff --git a/scripts/generate.sh b/scripts/generate.sh index cc6444ae6..fcf9017ad 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ function generate() { rm -rf tmp mkdir -p tmp for api_spec in $files_regex; do - if [ "$1" != "twilio-java" ] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then + if [ "$1" != "twilio-java" ] && [ "$1" != "twilio-csharp" ] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 12724ab7b..9d6a81eca 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -25,6 +25,7 @@ import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenSecurity; import org.openapitools.codegen.languages.CSharpClientCodegen; import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelsMap; @@ -42,6 +43,12 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final TwilioCodegenAdapter twilioCodegen; + private final String BEARER_TOKEN_PREFIX = "BearerToken"; + private final String NO_AUTH_PREFIX = "NoAuth"; + private final String EMPTY_STRING = ""; + private final String ORGS_TOKEN_CLIENT = "TwilioOrgsTokenAuthClient"; + private final String BASIC_CLIENT = "TwilioClient"; + private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -125,10 +132,65 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L final OperationsMap results = super.postProcessOperationsWithModels(objs, allModels); final List opList = directoryStructureService.processOperations(results); CsharpApiResources apiResources = processCodegenOperations(opList); + apiResources.setAuthMethod(processAuthMethods(opList)); + apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); + apiResources.setDomainClass(fetchDomainClass(apiResources.getAuthMethod())); + apiResources.setRestClientMethodName(fetchRestClientClassName(apiResources.getAuthMethod())); + apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); + apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); results.put("resources", apiResources); return results; } + private String fetchDomainClass(String authMethod) { + if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return ORGS_TOKEN_CLIENT; + return BASIC_CLIENT; + } + + private String setResourceSetPrefix(String authMethod){ + return authMethod == BEARER_TOKEN_PREFIX ? "Token" : EMPTY_STRING; + } + + private String fetchClientName(String authMethod){ + if(authMethod == BEARER_TOKEN_PREFIX) return "TwilioOrgsTokenRestClient"; + if(authMethod == NO_AUTH_PREFIX) return "TwilioNoAuthRestClient"; + return "ITwilioRestClient"; + } + + private String fetchRequestName(String authMethod){ + if(authMethod == BEARER_TOKEN_PREFIX) return "Token"; + if(authMethod == NO_AUTH_PREFIX) return "NoAuth"; + return EMPTY_STRING; + } + + private String fetchRestClientClassName(String authMethod){ + return authMethod == NO_AUTH_PREFIX ? "GetNoAuthRestClient" : "GetRestClient"; + } + + + private String processAuthMethods(List opList) { + boolean isBasicAuthPresent = false; + boolean isTokenAuthPresent = false; + + if(opList != null){ + List authMethods = opList.get(0).authMethods; + if(authMethods != null){ + for(CodegenSecurity c : authMethods){ + if(c.isOAuth == true){ + isTokenAuthPresent = true; + } + if(c.isBasic == true){ + isBasicAuthPresent = true; + } + } + } + else return "NoAuth"; + } + if(isBasicAuthPresent) + return ""; + return "BearerToken"; + } + @Override protected ImmutableMap.Builder addMustacheLambdas() { ImmutableMap.Builder lambdaBuilder = super.addMustacheLambdas(); diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 3bfb70e19..464781f7f 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -15,10 +15,12 @@ import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; +import org.openapitools.codegen.CodegenSecurity; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -34,9 +36,12 @@ public class CsharpApiResourceBuilder extends ApiResourceBuilder { + public String authMethod = ""; + public CsharpApiResourceBuilder(IApiActionTemplate template, List codegenOperations, List allModels) { super(template, codegenOperations, allModels); + processAuthMethods(codegenOperations); } public IApiResourceBuilder updateTemplate() { @@ -62,6 +67,13 @@ public IApiResourceBuilder setImports(DirectoryStructureService directoryStructu metaAPIProperties.put("array-exists-options", true); } }); + + if(this.authMethod == EnumConstants.AuthType.BEARER_TOKEN.getValue()){ + metaAPIProperties.put("auth_method-bearer-token", true); + } + else if(this.authMethod == EnumConstants.AuthType.NOAUTH.getValue()){ + metaAPIProperties.put("auth_method-no-auth", true); + } if (OperationStore.getInstance().isEnumPresentInOptions()) metaAPIProperties.put("enum-exists-options", true); @@ -78,14 +90,39 @@ public CsharpApiResources build() { @Override public ApiResourceBuilder updateOperations(Resolver codegenParameterIResolver) { // CsharpParameterResolver super.updateOperations(codegenParameterIResolver); + processAuthMethods(this.codegenOperationList); this.codegenOperationList.forEach(co -> { co.headerParams.forEach(e -> codegenParameterIResolver.resolve(e, this)); populateRequestBodyArgument(co); resolveIngressModel(co); }); - return this; } + + public void processAuthMethods(List opList) { + boolean isBasicAuthPresent = false; + boolean isTokenAuthPresent = false; + if(opList != null){ + List authMethods = opList.get(0).authMethods; + if(authMethods != null){ + for(CodegenSecurity c : authMethods){ + if(c.isOAuth == true){ + isTokenAuthPresent = true; + } + if(c.isBasic == true){ + isBasicAuthPresent = true; + } + } + if(isBasicAuthPresent != true && isTokenAuthPresent){ + this.authMethod = EnumConstants.AuthType.BEARER_TOKEN.getValue(); + } + } + else{ + this.authMethod = EnumConstants.AuthType.NOAUTH.getValue(); + } + } + } + @Override public void updateHttpMethod(CodegenOperation co) { switch (co.httpMethod) { @@ -179,7 +216,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP modelName = response.baseType; } Optional responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation); - if (responseModel.isEmpty()) { + if ((responseModel == null) || responseModel.isEmpty() || (Integer.parseInt(response.code) >= 400)) { return; } codegenModelResolver.resolve(responseModel.get(), this); @@ -191,6 +228,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { + HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -207,6 +245,11 @@ public Set getDistinctResponseModel(List response property.isOverridden = isOverridden; } } + for(CodegenProperty s : distinctResponseModels){ + if(modelVars.contains(s.name)){ + s.nameInCamelCase = "_" + s.nameInCamelCase; + }else modelVars.add(s.nameInCamelCase); + } return distinctResponseModels; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 64c8704cb..8920ac332 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -2,12 +2,20 @@ import com.twilio.oai.common.ApplicationConstants; import com.twilio.oai.resolver.csharp.OperationStore; +import lombok.Getter; +import lombok.Setter; import org.openapitools.codegen.IJsonSchemaValidationProperties; import java.util.ArrayList; import java.util.List; public class CsharpApiResources extends ApiResources { + @Getter @Setter private String authMethod; + @Getter @Setter private String resourceSetPrefix; + @Getter @Setter private String domainClass; + @Getter @Setter private String restClientMethodName; + @Getter @Setter private String clientName; + @Getter @Setter private String requestName; List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 75b20d804..c342a9559 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -614,6 +614,7 @@ private CodegenModel getConcatenatedResponseModel(List responseMod Boolean isOverridden = var.isOverridden; if(isOverridden != null && isOverridden == false) var.isOverridden = null; + var.baseName = StringHelper.camelize(var.baseName, true); if(!codegenProperties.contains(var)) codegenProperties.add(var); var.isOverridden = isOverridden; diff --git a/src/main/java/com/twilio/oai/common/EnumConstants.java b/src/main/java/com/twilio/oai/common/EnumConstants.java index 45e457ad1..e1cdb6ec1 100644 --- a/src/main/java/com/twilio/oai/common/EnumConstants.java +++ b/src/main/java/com/twilio/oai/common/EnumConstants.java @@ -43,6 +43,15 @@ public enum PathType { private final String value; } + @Getter + @RequiredArgsConstructor + public enum AuthType { + BEARER_TOKEN("BearerToken"), + NOAUTH("NoAuth"); + + private final String value; + } + @Getter @RequiredArgsConstructor public enum CsharpDataTypes implements LanguageDataType { diff --git a/src/main/java/com/twilio/oai/common/Utility.java b/src/main/java/com/twilio/oai/common/Utility.java index acdb18c6b..9268f6a25 100644 --- a/src/main/java/com/twilio/oai/common/Utility.java +++ b/src/main/java/com/twilio/oai/common/Utility.java @@ -118,7 +118,7 @@ public Optional getModel(final List models, .map(CodegenProperty::getComplexType) .map(classname -> getModelByClassname(models, classname)) .findFirst() - .orElseThrow(); + .orElse(null); } return getModelByClassname(models, className); diff --git a/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java b/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java index 05974c4d4..e20bd9950 100644 --- a/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java +++ b/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java @@ -73,9 +73,12 @@ private void resolveEnum(CodegenProperty property) { } String className = OperationStore.getInstance().getClassName(); property.isEnum = true; - property.enumName = property.complexType.contains("Enum") || property.complexType.contains("enum") - ? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM + if(property.complexType != null){ + property.enumName = property.complexType.contains("Enum") || property.complexType.contains("enum") + ? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM : Utility.removeEnumName(property.complexType); + } + // In case enum is an array if (property.items != null) { property.items.enumName = property.enumName; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index b168fa05a..9d556062c 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,11 +3,11 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records - public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); - var request = new Request( + var request = new {{requestName}}Request( HttpMethod.Get, targetUrl ); @@ -20,9 +20,9 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records - public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { - var request = new Request( + var request = new {{requestName}}Request( HttpMethod.Get, page.GetNextPageUrl(Rest.Domain.Api) ); @@ -35,9 +35,9 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records - public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { - var request = new Request( + var request = new {{requestName}}Request( HttpMethod.Get, page.GetPreviousPageUrl(Rest.Domain.Api) ); diff --git a/src/main/resources/twilio-csharp/ResourceUsings.mustache b/src/main/resources/twilio-csharp/ResourceUsings.mustache index 62029cbac..5d8b87fed 100644 --- a/src/main/resources/twilio-csharp/ResourceUsings.mustache +++ b/src/main/resources/twilio-csharp/ResourceUsings.mustache @@ -7,4 +7,9 @@ using Twilio.Constant; using Twilio.Converters; using Twilio.Exceptions; using Twilio.Http; -{{#metaProperties}}{{#enum-exists-resource}}using Twilio.Types;{{/enum-exists-resource}}{{/metaProperties}} \ No newline at end of file +{{#metaProperties}}{{#enum-exists-resource}}using Twilio.Types;{{/enum-exists-resource}}{{/metaProperties}} +{{#metaProperties}}{{#auth_method-bearer-token}}using Twilio.Base.BearerToken; +using Twilio.Clients.BearerToken; +using Twilio.Http.BearerToken;{{/auth_method-bearer-token}}{{/metaProperties}} +{{#metaProperties}}{{#auth_method-no-auth}}using Twilio.Clients.NoAuth; +using Twilio.Http.NoAuth;{{/auth_method-no-auth}}{{/metaProperties}} \ No newline at end of file diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 711c90881..14e5feed4 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildCreateRequest(Create{{apiName}}Options options, ITwilioRestClient client) + private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} - return new Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +21,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -33,10 +33,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +45,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -57,7 +56,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index bb1e253a8..a21ca756b 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,10 +3,10 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - private static Request BuildDeleteRequest(Delete{{apiName}}Options options, ITwilioRestClient client) + private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} - return new Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -19,9 +19,9 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static bool Delete(Delete{{apiName}}Options options, ITwilioRestClient client = null) + public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -32,9 +32,9 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, - ITwilioRestClient client = null) + {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -42,7 +42,7 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -51,7 +51,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index a9dc6f78c..ede568d26 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildFetchRequest(Fetch{{apiName}}Options options, ITwilioRestClient client) + private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} - return new Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -15,9 +15,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -27,10 +27,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -39,7 +38,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -48,7 +47,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index 0f07af260..a5ead39b4 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildReadRequest(Read{{apiName}}Options options, ITwilioRestClient client) + private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} - return new Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -14,12 +14,12 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, ITwilioRestClient client = null) + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); - return new ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); + return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); } #if !NET35 @@ -27,22 +27,21 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task> ReadAsync(Read{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); - return new ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); + return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); } #endif {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -51,10 +50,10 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task> ReadAsync({{#vendorExtensions.x-request-body-param}} + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 7777b00a2..9ce79f3c3 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildUpdateRequest(Update{{apiName}}Options options, ITwilioRestClient client) + private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} - return new Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +21,9 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -34,9 +34,9 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, - ITwilioRestClient client = null) + {{clientName}} client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +46,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -57,7 +57,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{clientName}} client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client);