Skip to content

Commit

Permalink
[DE-874] Release 4.0.0 (#37)
Browse files Browse the repository at this point in the history
DE-874 Increase timeout to 120s by default
SUB-3996 Ability to create products using the product family handle - ProductFamilyId in createProduct method is now String instead of Integer
IN-3434 Add API endpoints for finding price points by handle. Move PricePoint methods from ComponentsController to ComponentPricePointsController
  • Loading branch information
maciej-nedza authored Jun 25, 2024
1 parent 6e85eaf commit 8f0a916
Show file tree
Hide file tree
Showing 29 changed files with 2,219 additions and 1,354 deletions.
8 changes: 4 additions & 4 deletions AdvancedBilling.Standard/AdvancedBilling.Standard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Maxio.AdvancedBillingSdk</AssemblyName>
<Version>3.0.0.0</Version>
<Version>4.0.0.0</Version>
<Authors>MaxioSdk</Authors>
<Owners></Owners>
<Product>AdvancedBilling.Standard</Product>
<Copyright>Copyright © 2019</Copyright>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<Description>Ultimate billing and pricing flexibility for B2B SaaS.
Maxio integrates directly into your product, so you can seamlessly manage your product catalog, bill customers, and collect payments.</Description>
<LangVersion>7.3</LangVersion>
Expand All @@ -32,7 +32,7 @@ Maxio integrates directly into your product, so you can seamlessly manage your p
</PropertyGroup>

<ItemGroup>
<PackageReference Include= "APIMatic.Core" Version= "0.3.*" />
<PackageReference Include= "APIMatic.Core" Version= "0.4.*" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
Expand Down
10 changes: 9 additions & 1 deletion AdvancedBilling.Standard/AdvancedBillingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ public sealed class AdvancedBillingClient : IConfiguration
};

private readonly GlobalConfiguration globalConfiguration;
private const string userAgent = "AB SDK DotNet:3.0.0 on OS {os-info}";
private const string userAgent = "AB SDK DotNet:4.0.0 on OS {os-info}";
private readonly Lazy<APIExportsController> aPIExports;
private readonly Lazy<AdvanceInvoiceController> advanceInvoice;
private readonly Lazy<BillingPortalController> billingPortal;
private readonly Lazy<CouponsController> coupons;
private readonly Lazy<ComponentsController> components;
private readonly Lazy<ComponentPricePointsController> componentPricePoints;
private readonly Lazy<CustomersController> customers;
private readonly Lazy<CustomFieldsController> customFields;
private readonly Lazy<EventsController> events;
Expand Down Expand Up @@ -109,6 +110,8 @@ private AdvancedBillingClient(
() => new CouponsController(globalConfiguration));
this.components = new Lazy<ComponentsController>(
() => new ComponentsController(globalConfiguration));
this.componentPricePoints = new Lazy<ComponentPricePointsController>(
() => new ComponentPricePointsController(globalConfiguration));
this.customers = new Lazy<CustomersController>(
() => new CustomersController(globalConfiguration));
this.customFields = new Lazy<CustomFieldsController>(
Expand Down Expand Up @@ -188,6 +191,11 @@ private AdvancedBillingClient(
/// </summary>
public ComponentsController ComponentsController => this.components.Value;

/// <summary>
/// Gets ComponentPricePointsController controller.
/// </summary>
public ComponentPricePointsController ComponentPricePointsController => this.componentPricePoints.Value;

/// <summary>
/// Gets CustomersController controller.
/// </summary>
Expand Down
418 changes: 418 additions & 0 deletions AdvancedBilling.Standard/Controllers/ComponentPricePointsController.cs

Large diffs are not rendered by default.

354 changes: 2 additions & 352 deletions AdvancedBilling.Standard/Controllers/ComponentsController.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal ProductFamiliesController(GlobalConfiguration globalConfiguration) : ba
.Setup(HttpMethod.Get, "/product_families/{product_family_id}/products.json")
.WithAuth("BasicAuth")
.Parameters(_parameters => _parameters
.Template(_template => _template.Setup("product_family_id", input.ProductFamilyId))
.Template(_template => _template.Setup("product_family_id", input.ProductFamilyId).Required())
.Query(_query => _query.Setup("page", input.Page))
.Query(_query => _query.Setup("per_page", input.PerPage))
.Query(_query => _query.Setup("date_field", (input.DateField.HasValue) ? ApiHelper.JsonSerialize(input.DateField.Value).Trim('\"') : null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public Models.ListProductPricePointsResponse ListProductPricePoints(
/// Use this endpoint to update a product price point.
/// Note: Custom product price points are not able to be updated.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
public Models.ProductPricePointResponse UpdateProductPricePoint(
Expand All @@ -116,8 +116,8 @@ public Models.ProductPricePointResponse UpdateProductPricePoint(
/// Use this endpoint to update a product price point.
/// Note: Custom product price points are not able to be updated.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
Expand All @@ -138,10 +138,10 @@ public Models.ProductPricePointResponse UpdateProductPricePoint(
.ExecuteAsync(cancellationToken).ConfigureAwait(false);

/// <summary>
/// Use this endpoint to retrieve details for a specific product price point.
/// Use this endpoint to retrieve details for a specific product price point. You can achieve this by using either the product price point ID or handle.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <param name="currencyPrices">Optional parameter: When fetching a product's price points, if you have defined multiple currencies at the site level, you can optionally pass the ?currency_prices=true query param to include an array of currency price data in the response. If the product price point is set to use_site_exchange_rate: true, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency..</param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
public Models.ProductPricePointResponse ReadProductPricePoint(
Expand All @@ -151,10 +151,10 @@ public Models.ProductPricePointResponse ReadProductPricePoint(
=> CoreHelper.RunTask(ReadProductPricePointAsync(productId, pricePointId, currencyPrices));

/// <summary>
/// Use this endpoint to retrieve details for a specific product price point.
/// Use this endpoint to retrieve details for a specific product price point. You can achieve this by using either the product price point ID or handle.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <param name="currencyPrices">Optional parameter: When fetching a product's price points, if you have defined multiple currencies at the site level, you can optionally pass the ?currency_prices=true query param to include an array of currency price data in the response. If the product price point is set to use_site_exchange_rate: true, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency..</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
Expand All @@ -176,8 +176,8 @@ public Models.ProductPricePointResponse ReadProductPricePoint(
/// <summary>
/// Use this endpoint to archive a product price point.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
public Models.ProductPricePointResponse ArchiveProductPricePoint(
ArchiveProductPricePointProductId productId,
Expand All @@ -187,8 +187,8 @@ public Models.ProductPricePointResponse ArchiveProductPricePoint(
/// <summary>
/// Use this endpoint to archive a product price point.
/// </summary>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`.</param>
/// <param name="productId">Required parameter: The id or handle of the product. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle..</param>
/// <param name="pricePointId">Required parameter: The id or handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-price-point-handle` for a string handle..</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.ProductPricePointResponse response from the API call.</returns>
public async Task<Models.ProductPricePointResponse> ArchiveProductPricePointAsync(
Expand Down
10 changes: 5 additions & 5 deletions AdvancedBilling.Standard/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ internal ProductsController(GlobalConfiguration globalConfiguration) : base(glob
/// + [Products Documentation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405561405709).
/// + [Changing a Subscription's Product](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404225334669-Product-Changes-Migrations).
/// </summary>
/// <param name="productFamilyId">Required parameter: The Chargify id of the product family to which the product belongs.</param>
/// <param name="productFamilyId">Required parameter: Either the product family's id or its handle prefixed with `handle:`.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <returns>Returns the Models.ProductResponse response from the API call.</returns>
public Models.ProductResponse CreateProduct(
int productFamilyId,
string productFamilyId,
Models.CreateOrUpdateProductRequest body = null)
=> CoreHelper.RunTask(CreateProductAsync(productFamilyId, body));

Expand All @@ -51,12 +51,12 @@ public Models.ProductResponse CreateProduct(
/// + [Products Documentation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405561405709).
/// + [Changing a Subscription's Product](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404225334669-Product-Changes-Migrations).
/// </summary>
/// <param name="productFamilyId">Required parameter: The Chargify id of the product family to which the product belongs.</param>
/// <param name="productFamilyId">Required parameter: Either the product family's id or its handle prefixed with `handle:`.</param>
/// <param name="body">Optional parameter: Example: .</param>
/// <param name="cancellationToken"> cancellationToken. </param>
/// <returns>Returns the Models.ProductResponse response from the API call.</returns>
public async Task<Models.ProductResponse> CreateProductAsync(
int productFamilyId,
string productFamilyId,
Models.CreateOrUpdateProductRequest body = null,
CancellationToken cancellationToken = default)
=> await CreateApiCall<Models.ProductResponse>()
Expand All @@ -65,7 +65,7 @@ public Models.ProductResponse CreateProduct(
.WithAuth("BasicAuth")
.Parameters(_parameters => _parameters
.Body(_bodyParameter => _bodyParameter.Setup(body))
.Template(_template => _template.Setup("product_family_id", productFamilyId))
.Template(_template => _template.Setup("product_family_id", productFamilyId).Required())
.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 ErrorListResponseException(_reason, _context), true)))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using APIMatic.Core.Utilities.Converters;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;

namespace AdvancedBilling.Standard.Models.Containers
{
/// <summary>
/// This is a container class for one-of types.
/// </summary>
[JsonConverter(
typeof(UnionTypeConverter<ArchiveComponentPricePointComponentId>),
new Type[] {
typeof(NumberCase),
typeof(MStringCase)
},
true
)]
public abstract class ArchiveComponentPricePointComponentId
{
/// <summary>
/// This is Number case.
/// </summary>
/// <returns>
/// The ArchiveComponentPricePointComponentId instance, wrapping the provided int value.
/// </returns>
public static ArchiveComponentPricePointComponentId FromNumber(int number)
{
return new NumberCase().Set(number);
}

/// <summary>
/// This is String case.
/// </summary>
/// <returns>
/// The ArchiveComponentPricePointComponentId instance, wrapping the provided string value.
/// </returns>
public static ArchiveComponentPricePointComponentId FromString(string mString)
{
return new MStringCase().Set(mString);
}

/// <summary>
/// Method to match from the provided one-of cases. Here parameters
/// represents the callback functions for one-of type cases. All
/// callback functions must have the same return type T. This typeparam T
/// represents the type that will be returned after applying the selected
/// callback function.
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract T Match<T>(Func<int, T> number, Func<string, T> mString);

[JsonConverter(typeof(UnionTypeCaseConverter<NumberCase, int>), JTokenType.Integer)]
private sealed class NumberCase : ArchiveComponentPricePointComponentId, ICaseValue<NumberCase, int>
{
public int _value;

public override T Match<T>(Func<int, T> number, Func<string, T> mString)
{
return number(_value);
}

public NumberCase Set(int value)
{
_value = value;
return this;
}

public int Get()
{
return _value;
}

public override string ToString()
{
return _value.ToString();
}
}

[JsonConverter(typeof(UnionTypeCaseConverter<MStringCase, string>), JTokenType.String, JTokenType.Null)]
private sealed class MStringCase : ArchiveComponentPricePointComponentId, ICaseValue<MStringCase, string>
{
public string _value;

public override T Match<T>(Func<int, T> number, Func<string, T> mString)
{
return mString(_value);
}

public MStringCase Set(string value)
{
_value = value;
return this;
}

public string Get()
{
return _value;
}

public override string ToString()
{
return _value?.ToString();
}
}
}
}
Loading

0 comments on commit 8f0a916

Please sign in to comment.