Skip to content

Commit

Permalink
[DE-733] Code fixes before the Release
Browse files Browse the repository at this point in the history
- Cleanup introduction section
- Add new Subscription Groups endpoints errors
- Use missing enums in Subscription Groups models
- Change Event's id format to long
- Added missing fields in the Account Balance model and added error schema for "createPrepayment" endpoint for 422 response
- Changed Prepayment `inCents` properties type to long
  • Loading branch information
patryk-grudzien-keen authored Mar 14, 2024
1 parent b742e2d commit 1fca65b
Show file tree
Hide file tree
Showing 52 changed files with 951 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AdvanceInvoiceController : BaseController
internal AdvanceInvoiceController(GlobalConfiguration globalConfiguration) : base(globalConfiguration) { }

/// <summary>
/// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
/// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs]($m/Invoice) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
/// A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error.
/// That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated.
/// We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.
Expand All @@ -48,7 +48,7 @@ public Models.Invoice IssueAdvanceInvoice(
=> CoreHelper.RunTask(IssueAdvanceInvoiceAsync(subscriptionId, body));

/// <summary>
/// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](reference/Chargify-API.v1.yaml/components/schemas/Invoice) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
/// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs]($m/Invoice) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided.
/// A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error.
/// That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated.
/// We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.
Expand Down Expand Up @@ -104,7 +104,7 @@ public Models.Invoice ReadAdvanceInvoice(

/// <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).
/// 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]($m/Invoice).
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
Expand All @@ -116,7 +116,7 @@ public Models.Invoice VoidAdvanceInvoice(

/// <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).
/// 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]($m/Invoice).
/// </summary>
/// <param name="subscriptionId">Required parameter: The Chargify id of the subscription.</param>
/// <param name="body">Optional parameter: Example: .</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Models.SubscriptionGroupResponse CreateSubscriptionGroup(
.Body(_bodyParameter => _bodyParameter.Setup(body))
.Header(_header => _header.Setup("Content-Type", "application/json"))))
.ResponseHandler(_responseHandler => _responseHandler
.ErrorCase("422", CreateErrorCase("HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", (_reason, _context) => new SingleStringErrorResponseException(_reason, _context), true)))
.ErrorCase("422", CreateErrorCase("HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", (_reason, _context) => new SubscriptionGroupCreateErrorResponseException(_reason, _context), true)))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
Expand Down Expand Up @@ -128,7 +128,7 @@ public Models.ListSubscriptionGroupsResponse ListSubscriptionGroups(
.Parameters(_parameters => _parameters
.Query(_query => _query.Setup("page", input.Page))
.Query(_query => _query.Setup("per_page", input.PerPage))
.Query(_query => _query.Setup("include", input.Include))))
.Query(_query => _query.Setup("include[]", input.Include?.Select(a => ApiHelper.JsonSerialize(a).Trim('\"')).ToList()))))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
Expand All @@ -137,28 +137,33 @@ public Models.ListSubscriptionGroupsResponse ListSubscriptionGroups(
/// Current billing amount for the subscription group is not returned by default. If this information is desired, the `include[]=current_billing_amount_in_cents` parameter must be provided with the request.
/// </summary>
/// <param name="uid">Required parameter: The uid of the subscription group.</param>
/// <param name="include">Optional parameter: Allows including additional data in the response. Use in query: `include[]=current_billing_amount_in_cents`..</param>
/// <returns>Returns the Models.FullSubscriptionGroupResponse response from the API call.</returns>
public Models.FullSubscriptionGroupResponse ReadSubscriptionGroup(
string uid)
=> CoreHelper.RunTask(ReadSubscriptionGroupAsync(uid));
string uid,
List<Models.SubscriptionGroupInclude> include = null)
=> CoreHelper.RunTask(ReadSubscriptionGroupAsync(uid, include));

/// <summary>
/// Use this endpoint to find subscription group details.
/// #### Current Billing Amount in Cents.
/// Current billing amount for the subscription group is not returned by default. If this information is desired, the `include[]=current_billing_amount_in_cents` parameter must be provided with the request.
/// </summary>
/// <param name="uid">Required parameter: The uid of the subscription group.</param>
/// <param name="include">Optional parameter: Allows including additional data in the response. Use in query: `include[]=current_billing_amount_in_cents`..</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.FullSubscriptionGroupResponse response from the API call.</returns>
public async Task<Models.FullSubscriptionGroupResponse> ReadSubscriptionGroupAsync(
string uid,
List<Models.SubscriptionGroupInclude> include = null,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.FullSubscriptionGroupResponse>()
.RequestBuilder(_requestBuilder => _requestBuilder
.Setup(HttpMethod.Get, "/subscription_groups/{uid}.json")
.WithAuth("BasicAuth")
.Parameters(_parameters => _parameters
.Template(_template => _template.Setup("uid", uid).Required())))
.Template(_template => _template.Setup("uid", uid).Required())
.Query(_query => _query.Setup("include[]", include?.Select(a => ApiHelper.JsonSerialize(a).Trim('\"')).ToList()))))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public Models.CreatePrepaymentResponse CreatePrepayment(
.Body(_bodyParameter => _bodyParameter.Setup(body))
.Template(_template => _template.Setup("subscription_id", subscriptionId))
.Header(_header => _header.Setup("Content-Type", "application/json"))))
.ResponseHandler(_responseHandler => _responseHandler
.ErrorCase("422", CreateErrorCase("HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.", (_reason, _context) => new ApiException(_reason, _context), true)))
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <copyright file="SubscriptionGroupCreateErrorResponseException.cs" company="APIMatic">
// Copyright (c) APIMatic. All rights reserved.
// </copyright>
namespace AdvancedBilling.Standard.Exceptions
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using APIMatic.Core.Utilities.Converters;
using AdvancedBilling.Standard;
using AdvancedBilling.Standard.Http.Client;
using AdvancedBilling.Standard.Models;
using AdvancedBilling.Standard.Models.Containers;
using AdvancedBilling.Standard.Utilities;
using JsonSubTypes;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

/// <summary>
/// SubscriptionGroupCreateErrorResponseException.
/// </summary>
public class SubscriptionGroupCreateErrorResponseException : ApiException
{
/// <summary>
/// Initializes a new instance of the <see cref="SubscriptionGroupCreateErrorResponseException"/> class.
/// </summary>
/// <param name="reason"> The reason for throwing exception.</param>
/// <param name="context"> The HTTP context that encapsulates request and response objects.</param>
public SubscriptionGroupCreateErrorResponseException(string reason, HttpContext context)
: base(reason, context)
{
}

/// <summary>
/// Gets or sets Errors.
/// </summary>
[JsonProperty("errors")]
public SubscriptionGroupCreateErrorResponseErrors Errors { get; set; }
}
}
100 changes: 98 additions & 2 deletions AdvancedBilling.Standard/Models/AccountBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ namespace AdvancedBilling.Standard.Models
/// </summary>
public class AccountBalance : BaseModel
{
private long? automaticBalanceInCents;
private long? remittanceBalanceInCents;
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
{
{ "automatic_balance_in_cents", false },
{ "remittance_balance_in_cents", false },
};

/// <summary>
/// Initializes a new instance of the <see cref="AccountBalance"/> class.
/// </summary>
Expand All @@ -33,10 +41,24 @@ public AccountBalance()
/// Initializes a new instance of the <see cref="AccountBalance"/> class.
/// </summary>
/// <param name="balanceInCents">balance_in_cents.</param>
/// <param name="automaticBalanceInCents">automatic_balance_in_cents.</param>
/// <param name="remittanceBalanceInCents">remittance_balance_in_cents.</param>
public AccountBalance(
long? balanceInCents = null)
long? balanceInCents = null,
long? automaticBalanceInCents = null,
long? remittanceBalanceInCents = null)
{
this.BalanceInCents = balanceInCents;
if (automaticBalanceInCents != null)
{
this.AutomaticBalanceInCents = automaticBalanceInCents;
}

if (remittanceBalanceInCents != null)
{
this.RemittanceBalanceInCents = remittanceBalanceInCents;
}

}

/// <summary>
Expand All @@ -45,6 +67,42 @@ public AccountBalance(
[JsonProperty("balance_in_cents", NullValueHandling = NullValueHandling.Ignore)]
public long? BalanceInCents { get; set; }

/// <summary>
/// The automatic balance in cents.
/// </summary>
[JsonProperty("automatic_balance_in_cents")]
public long? AutomaticBalanceInCents
{
get
{
return this.automaticBalanceInCents;
}

set
{
this.shouldSerialize["automatic_balance_in_cents"] = true;
this.automaticBalanceInCents = value;
}
}

/// <summary>
/// The remittance balance in cents.
/// </summary>
[JsonProperty("remittance_balance_in_cents")]
public long? RemittanceBalanceInCents
{
get
{
return this.remittanceBalanceInCents;
}

set
{
this.shouldSerialize["remittance_balance_in_cents"] = true;
this.remittanceBalanceInCents = value;
}
}

/// <inheritdoc/>
public override string ToString()
{
Expand All @@ -55,6 +113,40 @@ public override string ToString()
return $"AccountBalance : ({string.Join(", ", toStringOutput)})";
}

/// <summary>
/// Marks the field to not be serailized.
/// </summary>
public void UnsetAutomaticBalanceInCents()
{
this.shouldSerialize["automatic_balance_in_cents"] = false;
}

/// <summary>
/// Marks the field to not be serailized.
/// </summary>
public void UnsetRemittanceBalanceInCents()
{
this.shouldSerialize["remittance_balance_in_cents"] = false;
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
/// <returns>A boolean weather the field should be serialized or not.</returns>
public bool ShouldSerializeAutomaticBalanceInCents()
{
return this.shouldSerialize["automatic_balance_in_cents"];
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
/// <returns>A boolean weather the field should be serialized or not.</returns>
public bool ShouldSerializeRemittanceBalanceInCents()
{
return this.shouldSerialize["remittance_balance_in_cents"];
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
Expand All @@ -67,7 +159,9 @@ public override bool Equals(object obj)
{
return true;
}
return obj is AccountBalance other && ((this.BalanceInCents == null && other.BalanceInCents == null) || (this.BalanceInCents?.Equals(other.BalanceInCents) == true));
return obj is AccountBalance other && ((this.BalanceInCents == null && other.BalanceInCents == null) || (this.BalanceInCents?.Equals(other.BalanceInCents) == true)) &&
((this.AutomaticBalanceInCents == null && other.AutomaticBalanceInCents == null) || (this.AutomaticBalanceInCents?.Equals(other.AutomaticBalanceInCents) == true)) &&
((this.RemittanceBalanceInCents == null && other.RemittanceBalanceInCents == null) || (this.RemittanceBalanceInCents?.Equals(other.RemittanceBalanceInCents) == true));
}

/// <summary>
Expand All @@ -77,6 +171,8 @@ public override bool Equals(object obj)
protected new void ToString(List<string> toStringOutput)
{
toStringOutput.Add($"this.BalanceInCents = {(this.BalanceInCents == null ? "null" : this.BalanceInCents.ToString())}");
toStringOutput.Add($"this.AutomaticBalanceInCents = {(this.AutomaticBalanceInCents == null ? "null" : this.AutomaticBalanceInCents.ToString())}");
toStringOutput.Add($"this.RemittanceBalanceInCents = {(this.RemittanceBalanceInCents == null ? "null" : this.RemittanceBalanceInCents.ToString())}");

base.ToString(toStringOutput);
}
Expand Down
Loading

0 comments on commit 1fca65b

Please sign in to comment.