Skip to content

Commit

Permalink
Merge pull request #134 from ordercloud-api/dev
Browse files Browse the repository at this point in the history
updates for latest api version
  • Loading branch information
djsteinmetz authored Nov 7, 2024
2 parents a3c4954 + 4aa69bd commit a30bb41
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/OrderCloud.SDK/Generated/ErrorCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public static class ApiClient
/// <summary>IsAnonBuyer can be true only when a buyer user is set as the Default Context User.</summary>
public const string RequiredNotAnonBuyer = "ApiClient.RequiredNotAnonBuyer";
}
public static class ApiClientSecret
{
/// <summary>The maximum number of client secrets has been reached for this API client.</summary>
public const string MaximumClientSecretsReached = "ApiClientSecret.MaximumClientSecretsReached";
/// <summary>Cannot create a client secret that is already expired.</summary>
public const string InvalidExpirationDate = "ApiClientSecret.InvalidExpirationDate";
}
public static class ApprovalRule
{
/// <summary>Cannot delete Approval Rule because it has pending Approvals.</summary>
Expand Down
28 changes: 28 additions & 0 deletions src/OrderCloud.SDK/Generated/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,29 @@ public class ApiClientAssignment : OrderCloudModel
/// <summary>ID of the supplier. Sortable: priority level 1.</summary>
public string SupplierID { get => GetProp<string>("SupplierID"); set => SetProp<string>("SupplierID", value); }
}
public class ApiClientSecret : OrderCloudModel
{
/// <summary>ID of the api client secret. Can only contain characters Aa-Zz, 0-9, -, and _. Searchable: priority level 1. Sortable: priority level 1.</summary>
public string ID { get => GetProp<string>("ID"); set => SetProp<string>("ID", value); }
/// <summary>Name of the api client secret. Required.</summary>
[Required]
public string Name { get => GetProp<string>("Name"); set => SetProp<string>("Name", value); }
/// <summary>Expiration of the api client secret.</summary>
public DateTimeOffset? Expiration { get => GetProp<DateTimeOffset?>("Expiration"); set => SetProp<DateTimeOffset?>("Expiration", value); }
}
public class ApiClientSecretCreateResponse : OrderCloudModel
{
/// <summary>Client secret of the api client secret create response.</summary>
[ApiReadOnly]
public string ClientSecret { get => GetProp<string>("ClientSecret"); set => SetProp<string>("ClientSecret", value); }
/// <summary>ID of the api client secret create response. Can only contain characters Aa-Zz, 0-9, -, and _. Searchable: priority level 1. Sortable: priority level 1.</summary>
public string ID { get => GetProp<string>("ID"); set => SetProp<string>("ID", value); }
/// <summary>Name of the api client secret create response. Required.</summary>
[Required]
public string Name { get => GetProp<string>("Name"); set => SetProp<string>("Name", value); }
/// <summary>Expiration of the api client secret create response.</summary>
public DateTimeOffset? Expiration { get => GetProp<DateTimeOffset?>("Expiration"); set => SetProp<DateTimeOffset?>("Expiration", value); }
}
public class ApprovalInfo : OrderCloudModel
{
/// <summary>Comments to be saved with the order approval or denial.</summary>
Expand Down Expand Up @@ -1080,6 +1103,8 @@ public class InventoryRecord : OrderCloudModel
public bool OrderCanExceed { get => GetProp<bool>("OrderCanExceed"); set => SetProp<bool>("OrderCanExceed", value); }
/// <summary>Quantity available of the inventory record.</summary>
public int QuantityAvailable { get => GetProp<int>("QuantityAvailable"); set => SetProp<int>("QuantityAvailable", value); }
/// <summary>Notification point of the inventory record.</summary>
public int? NotificationPoint { get => GetProp<int?>("NotificationPoint"); set => SetProp<int?>("NotificationPoint", value); }
/// <summary>Last updated of the inventory record.</summary>
[ApiReadOnly]
public DateTimeOffset LastUpdated { get => GetProp<DateTimeOffset>("LastUpdated"); set => SetProp<DateTimeOffset>("LastUpdated", value); }
Expand Down Expand Up @@ -3122,6 +3147,8 @@ public class VariantInventory : OrderCloudModel
{
/// <summary>Quantity available of the variant inventory.</summary>
public int? QuantityAvailable { get => GetProp<int?>("QuantityAvailable"); set => SetProp<int?>("QuantityAvailable", value); }
/// <summary>Notification point of the variant inventory.</summary>
public int? NotificationPoint { get => GetProp<int?>("NotificationPoint"); set => SetProp<int?>("NotificationPoint", value); }
/// <summary>Last updated of the variant inventory.</summary>
[ApiReadOnly]
public DateTimeOffset LastUpdated { get => GetProp<DateTimeOffset>("LastUpdated"); set => SetProp<DateTimeOffset>("LastUpdated", value); }
Expand Down Expand Up @@ -3195,6 +3222,7 @@ public class PartialApiClient : ApiClient, IPartial { }
/// <typeparam name="Txp">Specific type of the xp property. If not using a custom type, use the non-generic PartialApiClient class instead.</typeparam>
public class PartialApiClient<Txp> : PartialApiClient
{ }
public class PartialApiClientSecret : ApiClientSecret, IPartial { }
public class PartialApprovalRule : ApprovalRule, IPartial { }
/// <typeparam name="Txp">Specific type of the xp property. If not using a custom type, use the non-generic PartialApprovalRule class instead.</typeparam>
public class PartialApprovalRule<Txp> : PartialApprovalRule
Expand Down
42 changes: 42 additions & 0 deletions src/OrderCloud.SDK/Generated/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,42 @@ public interface IApiClientsResource
/// <param name="supplierID">ID of the supplier.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task DeleteSupplierAssignmentAsync(string apiClientID, string supplierID, string accessToken = null);
/// <summary>Get a single API client secret.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="apiClientSecretID">ID of the api client secret.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task<ApiClientSecret> GetSecretAsync(string apiClientID, string apiClientSecretID, string accessToken = null);
/// <summary>Get a list of API client secrets.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="search">Word or phrase to search for.</param>
/// <param name="searchOn">Comma-delimited list of fields to search on.</param>
/// <param name="sortBy">Comma-delimited list of fields to sort by.</param>
/// <param name="page">Page of results to return. Default: 1. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.</param>
/// <param name="pageSize">Number of results to return per page. Default: 20, max: 100.</param>
/// <param name="filters">An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???'</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task<ListPage<ApiClientSecret>> ListSecretsAsync(string apiClientID, string search = null, string searchOn = null, string sortBy = null, int page = 1, int pageSize = 20, object filters = null, string accessToken = null);
/// <summary>Get a list of API client secrets.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="buildListOpts">A lambda or function for specifying various list options fluently.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task<ListPage<ApiClientSecret>> ListSecretsAsync(string apiClientID, Action<ListOptionsBuilder<ApiClientSecret>> buildListOpts, string accessToken = null);
/// <summary>Create a new API client secret.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="apiClientSecret">The object that will be serialized to JSON and sent in the request body.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task<ApiClientSecretCreateResponse> CreateSecretAsync(string apiClientID, ApiClientSecret apiClientSecret, string accessToken = null);
/// <summary>Partially update a API client secret.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="apiClientSecretID">ID of the api client secret.</param>
/// <param name="partialApiClientSecret">The object that will be partially serialized to JSON and sent in the request body.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task<ApiClientSecret> PatchSecretAsync(string apiClientID, string apiClientSecretID, PartialApiClientSecret partialApiClientSecret, string accessToken = null);
/// <summary>Delete a API client secret.</summary>
/// <param name="apiClientID">ID of the api client.</param>
/// <param name="apiClientSecretID">ID of the api client secret.</param>
/// <param name="accessToken">Optional. Use to provide an existing token instead of authenticating implicitly.</param>
Task DeleteSecretAsync(string apiClientID, string apiClientSecretID, string accessToken = null);
}

public interface IApprovalRulesResource
Expand Down Expand Up @@ -6741,6 +6777,12 @@ internal ApiClientsResource(OrderCloudClient client) : base(client) { }
public Task SaveAssignmentAsync(ApiClientAssignment apiClientAssignment, string accessToken = null) => Request("v1", "apiclients", "assignments").WithOAuthBearerToken(accessToken).PostJsonAsync(ValidateModel(apiClientAssignment));
public Task DeleteBuyerAssignmentAsync(string apiClientID, string buyerID, string accessToken = null) => Request("v1", "buyers", buyerID, "ApiClients", "Assignments", apiClientID).WithOAuthBearerToken(accessToken).DeleteAsync();
public Task DeleteSupplierAssignmentAsync(string apiClientID, string supplierID, string accessToken = null) => Request("v1", "suppliers", supplierID, "ApiClients", "Assignments", apiClientID).WithOAuthBearerToken(accessToken).DeleteAsync();
public Task<ApiClientSecret> GetSecretAsync(string apiClientID, string apiClientSecretID, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets", apiClientSecretID).WithOAuthBearerToken(accessToken).GetJsonAsync<ApiClientSecret>();
public Task<ListPage<ApiClientSecret>> ListSecretsAsync(string apiClientID, string search = null, string searchOn = null, string sortBy = null, int page = 1, int pageSize = 20, object filters = null, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets").WithOAuthBearerToken(accessToken).SetQueryParams(new { search, searchOn, sortBy, page, pageSize }).SetQueryParams(filters).GetJsonAsync<ListPage<ApiClientSecret>>();
public Task<ListPage<ApiClientSecret>> ListSecretsAsync(string apiClientID, Action<ListOptionsBuilder<ApiClientSecret>> buildListOpts, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets").WithOAuthBearerToken(accessToken).SetListOptions(buildListOpts).GetJsonAsync<ListPage<ApiClientSecret>>();
public Task<ApiClientSecretCreateResponse> CreateSecretAsync(string apiClientID, ApiClientSecret apiClientSecret, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets").WithOAuthBearerToken(accessToken).PostJsonAsync(ValidateModel(apiClientSecret)).ReceiveJson<ApiClientSecretCreateResponse>();
public Task<ApiClientSecret> PatchSecretAsync(string apiClientID, string apiClientSecretID, PartialApiClientSecret partialApiClientSecret, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets", apiClientSecretID).WithOAuthBearerToken(accessToken).PatchJsonAsync(ValidateModel(partialApiClientSecret)).ReceiveJson<ApiClientSecret>();
public Task DeleteSecretAsync(string apiClientID, string apiClientSecretID, string accessToken = null) => Request("v1", "apiclients", apiClientID, "secrets", apiClientSecretID).WithOAuthBearerToken(accessToken).DeleteAsync();
}

public class ApprovalRulesResource : OrderCloudResource, IApprovalRulesResource
Expand Down
47 changes: 47 additions & 0 deletions src/OrderCloud.SDK/Generated/WebhookPayloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,53 @@ public class DeleteSupplierAssignmentRouteParams
public string ApiClientID { get; set; }
public string SupplierID { get; set; }
}
/// <summary>Webhook payload sent by OrderCloud on POST v1/apiclients/{apiClientID}/secrets.</summary>
[SentOn("POST", "v1/apiclients/{apiClientID}/secrets")]
public class CreateSecret : WebhookPayload<ApiClientSecret, ApiClientSecretCreateResponse, CreateSecretRouteParams, dynamic> { }
/// <summary>Webhook payload sent by OrderCloud on POST v1/apiclients/{apiClientID}/secrets.</summary>
/// <typeparam name="TConfigData">Specific type of the ConfigData. If not using a custom type, specify dynamic.</typeparam>
/// <typeparam name="TApiClientSecret">Specific type of the ApiClientSecret. If not using a custom type, specify ApiClientSecret.</typeparam>
/// <typeparam name="TApiClientSecretCreateResponse">Specific type of the ApiClientSecretCreateResponse. If not using a custom type, specify ApiClientSecretCreateResponse.</typeparam>
[SentOn("POST", "v1/apiclients/{apiClientID}/secrets")]
public class CreateSecret<TConfigData, TApiClientSecret, TApiClientSecretCreateResponse> : WebhookPayload<TApiClientSecret, TApiClientSecretCreateResponse, CreateSecretRouteParams, TConfigData>
where TApiClientSecret : ApiClientSecret
where TApiClientSecretCreateResponse : ApiClientSecretCreateResponse
{ }
/// <summary>Type used to represent route parameter name/value pairs for v1/apiclients/{apiClientID}/secrets.</summary>
public class CreateSecretRouteParams
{
public string ApiClientID { get; set; }
}
/// <summary>Webhook payload sent by OrderCloud on PATCH v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
[SentOn("PATCH", "v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}")]
public class PatchSecret : WebhookPayload<ApiClientSecret, ApiClientSecret, PatchSecretRouteParams, dynamic> { }
/// <summary>Webhook payload sent by OrderCloud on PATCH v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
/// <typeparam name="TConfigData">Specific type of the ConfigData. If not using a custom type, specify dynamic.</typeparam>
/// <typeparam name="TApiClientSecret">Specific type of the ApiClientSecret. If not using a custom type, specify ApiClientSecret.</typeparam>
[SentOn("PATCH", "v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}")]
public class PatchSecret<TConfigData, TApiClientSecret> : WebhookPayload<TApiClientSecret, TApiClientSecret, PatchSecretRouteParams, TConfigData>
where TApiClientSecret : ApiClientSecret
{ }
/// <summary>Type used to represent route parameter name/value pairs for v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
public class PatchSecretRouteParams
{
public string ApiClientID { get; set; }
public string ApiClientSecretID { get; set; }
}
/// <summary>Webhook payload sent by OrderCloud on DELETE v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
[SentOn("DELETE", "v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}")]
public class DeleteSecret : WebhookPayload<object, object, DeleteSecretRouteParams, dynamic> { }
/// <summary>Webhook payload sent by OrderCloud on DELETE v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
/// <typeparam name="TConfigData">Specific type of the ConfigData. If not using a custom type, use the non-generic payload type instead.</typeparam>
[SentOn("DELETE", "v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}")]
public class DeleteSecret<TConfigData> : WebhookPayload<object, object, DeleteSecretRouteParams, TConfigData>
{ }
/// <summary>Type used to represent route parameter name/value pairs for v1/apiclients/{apiClientID}/secrets/{apiClientSecretID}.</summary>
public class DeleteSecretRouteParams
{
public string ApiClientID { get; set; }
public string ApiClientSecretID { get; set; }
}
}
public static class ApprovalRules
{
Expand Down
2 changes: 2 additions & 0 deletions src/OrderCloud.SDK/OAuthModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public OAuthTokenRequestWithPasswordGrant() {

public string username { get; set; }
public string password { get; set; }
public string client_secret { get; set; }
}

internal class OAuthTokenRequestWithClientCredentialsGrant : OAuthTokenRequest
Expand All @@ -45,5 +46,6 @@ public OAuthTokenRequestWithRefreshTokenGrant() {
}

public string refresh_token { get; set; }
public string client_secret { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/OrderCloud.SDK/OrderCloud.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- https://docs.microsoft.com/en-us/dotnet/core/tools/csproj -->
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>0.16.0</Version>
<Version>0.16.1</Version>
<PackageId>OrderCloud.SDK</PackageId>
<Title>OrderCloud SDK</Title>
<Authors>Todd Menier</Authors>
Expand Down
13 changes: 12 additions & 1 deletion src/OrderCloud.SDK/OrderCloudClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public async Task<TokenResponse> AuthenticateAsync() {

/// <inheritdoc/>
public Task<TokenResponse> AuthenticateAsync(string clientID, string username, string password, params ApiRole[] roles) {
return AuthenticateAsync(clientID, username, password, null, roles);
}

/// <inheritdoc/>
public Task<TokenResponse> AuthenticateAsync(string clientID, string username, string password, string clientSecret, params ApiRole[] roles) {
Require(clientID, nameof(clientID));
Require(username, nameof(username));
Require(password, nameof(password));
Expand All @@ -112,6 +117,7 @@ public Task<TokenResponse> AuthenticateAsync(string clientID, string username, s
client_id = clientID,
username = username,
password = password,
client_secret = clientSecret,
scope = string.Join(" ", roles)
};
return AuthenticateAsync(req);
Expand All @@ -132,12 +138,17 @@ public Task<TokenResponse> RefreshTokenAsync(string refreshToken) {
}

public Task<TokenResponse> RefreshTokenAsync(string clientID, string refreshToken) {
return RefreshTokenAsync(clientID, refreshToken, null);
}

public Task<TokenResponse> RefreshTokenAsync(string clientID, string refreshToken, string clientSecret) {
Require(clientID, nameof(clientID));
Require(refreshToken, nameof(refreshToken));

var req = new OAuthTokenRequestWithRefreshTokenGrant {
client_id = clientID,
refresh_token = refreshToken
refresh_token = refreshToken,
client_secret = clientSecret
};
return AuthenticateAsync(req);
}
Expand Down

0 comments on commit a30bb41

Please sign in to comment.