Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Updates #17

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 77 additions & 77 deletions AdvancedBilling.Standard/Controllers/APIExportsController.cs

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions AdvancedBilling.Standard/Controllers/AdvanceInvoiceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,65 +76,65 @@ public Models.Invoice IssueAdvanceInvoice(
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
/// Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.
/// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
/// A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice).
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <returns>Returns the Models.Invoice response from the API call.</returns>
public Models.Invoice ReadAdvanceInvoice(
int subscriptionId)
=> CoreHelper.RunTask(ReadAdvanceInvoiceAsync(subscriptionId));
public Models.Invoice VoidAdvanceInvoice(
int subscriptionId,
Models.VoidInvoiceRequest body = null)
=> CoreHelper.RunTask(VoidAdvanceInvoiceAsync(subscriptionId, body));

/// <summary>
/// Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.
/// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
/// A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice).
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.Invoice response from the API call.</returns>
public async Task<Models.Invoice> ReadAdvanceInvoiceAsync(
public async Task<Models.Invoice> VoidAdvanceInvoiceAsync(
int subscriptionId,
Models.VoidInvoiceRequest body = null,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.Invoice>()
.RequestBuilder(_requestBuilder => _requestBuilder
.Setup(HttpMethod.Get, "/subscriptions/{subscription_id}/advance_invoice.json")
.Setup(HttpMethod.Post, "/subscriptions/{subscription_id}/advance_invoice/void.json")
.WithAuth("global")
.Parameters(_parameters => _parameters
.Template(_template => _template.Setup("subscription_id", subscriptionId))))
.Body(_bodyParameter => _bodyParameter.Setup(body))
.Template(_template => _template.Setup("subscription_id", subscriptionId))
.Header(_header => _header.Setup("Content-Type", "application/json"))))
.ResponseHandler(_responseHandler => _responseHandler
.ErrorCase("404", CreateErrorCase("Not Found:'{$response.body}'", (_reason, _context) => new ApiException(_reason, _context), true)))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
/// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
/// A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice).
/// Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <returns>Returns the Models.Invoice response from the API call.</returns>
public Models.Invoice VoidAdvanceInvoice(
int subscriptionId,
Models.VoidInvoiceRequest body = null)
=> CoreHelper.RunTask(VoidAdvanceInvoiceAsync(subscriptionId, body));
public Models.Invoice ReadAdvanceInvoice(
int subscriptionId)
=> CoreHelper.RunTask(ReadAdvanceInvoiceAsync(subscriptionId));

/// <summary>
/// Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired.
/// A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice).
/// Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.Invoice response from the API call.</returns>
public async Task<Models.Invoice> VoidAdvanceInvoiceAsync(
public async Task<Models.Invoice> ReadAdvanceInvoiceAsync(
int subscriptionId,
Models.VoidInvoiceRequest body = null,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.Invoice>()
.RequestBuilder(_requestBuilder => _requestBuilder
.Setup(HttpMethod.Post, "/subscriptions/{subscription_id}/advance_invoice/void.json")
.Setup(HttpMethod.Get, "/subscriptions/{subscription_id}/advance_invoice.json")
.WithAuth("global")
.Parameters(_parameters => _parameters
.Body(_bodyParameter => _bodyParameter.Setup(body))
.Template(_template => _template.Setup("subscription_id", subscriptionId))
.Header(_header => _header.Setup("Content-Type", "application/json"))))
.Template(_template => _template.Setup("subscription_id", subscriptionId))))
.ResponseHandler(_responseHandler => _responseHandler
.ErrorCase("404", CreateErrorCase("Not Found:'{$response.body}'", (_reason, _context) => new ApiException(_reason, _context), true)))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);
Expand Down
6 changes: 3 additions & 3 deletions AdvancedBilling.Standard/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public class BaseController
protected static ErrorCase<HttpRequest, HttpResponse, HttpContext, ApiException> CreateErrorCase(string reason, Func<string, HttpContext, ApiException> error, bool isErrorTemplate = false)
=> new ErrorCase<HttpRequest, HttpResponse, HttpContext, ApiException>(reason, error, isErrorTemplate);

protected ApiCall<HttpRequest, HttpResponse, HttpContext, ApiException, T, T> CreateApiCall<T>()
protected ApiCall<HttpRequest, HttpResponse, HttpContext, ApiException, T, T> CreateApiCall<T>(ArraySerialization arraySerialization = ArraySerialization.CSV)
=> new ApiCall<HttpRequest, HttpResponse, HttpContext, ApiException, T, T>(
globalConfiguration,
compatibilityFactory,
globalErrors: globalErrors,
serialization: ArraySerialization.CSV
serialization: arraySerialization,
globalErrors: globalErrors
);

private static readonly CompatibilityFactory compatibilityFactory = new CompatibilityFactory();
Expand Down
64 changes: 32 additions & 32 deletions AdvancedBilling.Standard/Controllers/BillingPortalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@ public class BillingPortalController : BaseController
/// </summary>
internal BillingPortalController(GlobalConfiguration globalConfiguration) : base(globalConfiguration) { }

/// <summary>
/// You can revoke a customer's Billing Portal invitation.
/// If you attempt to revoke an invitation when the Billing Portal is already disabled for a Customer, you will receive a 422 error response.
/// ## Limitations.
/// This endpoint will only return a JSON response.
/// </summary>
/// <param name="customerId">Required parameter: The Chargify id of the customer.</param>
/// <returns>Returns the Models.RevokedInvitation response from the API call.</returns>
public Models.RevokedInvitation RevokeBillingPortalAccess(
int customerId)
=> CoreHelper.RunTask(RevokeBillingPortalAccessAsync(customerId));

/// <summary>
/// You can revoke a customer's Billing Portal invitation.
/// If you attempt to revoke an invitation when the Billing Portal is already disabled for a Customer, you will receive a 422 error response.
/// ## Limitations.
/// This endpoint will only return a JSON response.
/// </summary>
/// <param name="customerId">Required parameter: The Chargify id of the customer.</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.RevokedInvitation response from the API call.</returns>
public async Task<Models.RevokedInvitation> RevokeBillingPortalAccessAsync(
int customerId,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.RevokedInvitation>()
.RequestBuilder(_requestBuilder => _requestBuilder
.Setup(HttpMethod.Delete, "/portal/customers/{customer_id}/invitations/revoke.json")
.WithAuth("global")
.Parameters(_parameters => _parameters
.Template(_template => _template.Setup("customer_id", customerId))))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
/// ## Billing Portal Documentation.
/// Full documentation on how the Billing Portal operates within the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407648972443).
Expand Down Expand Up @@ -162,37 +194,5 @@ public Models.ResentInvitation ResendBillingPortalInvitation(
.ErrorCase("404", CreateErrorCase("Not Found:'{$response.body}'", (_reason, _context) => new ApiException(_reason, _context), true))
.ErrorCase("422", CreateErrorCase("HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", (_reason, _context) => new ErrorListResponseException(_reason, _context), true)))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
/// You can revoke a customer's Billing Portal invitation.
/// If you attempt to revoke an invitation when the Billing Portal is already disabled for a Customer, you will receive a 422 error response.
/// ## Limitations.
/// This endpoint will only return a JSON response.
/// </summary>
/// <param name="customerId">Required parameter: The Chargify id of the customer.</param>
/// <returns>Returns the Models.RevokedInvitation response from the API call.</returns>
public Models.RevokedInvitation RevokeBillingPortalAccess(
int customerId)
=> CoreHelper.RunTask(RevokeBillingPortalAccessAsync(customerId));

/// <summary>
/// You can revoke a customer's Billing Portal invitation.
/// If you attempt to revoke an invitation when the Billing Portal is already disabled for a Customer, you will receive a 422 error response.
/// ## Limitations.
/// This endpoint will only return a JSON response.
/// </summary>
/// <param name="customerId">Required parameter: The Chargify id of the customer.</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.RevokedInvitation response from the API call.</returns>
public async Task<Models.RevokedInvitation> RevokeBillingPortalAccessAsync(
int customerId,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.RevokedInvitation>()
.RequestBuilder(_requestBuilder => _requestBuilder
.Setup(HttpMethod.Delete, "/portal/customers/{customer_id}/invitations/revoke.json")
.WithAuth("global")
.Parameters(_parameters => _parameters
.Template(_template => _template.Setup("customer_id", customerId))))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);
}
}
Loading
Loading