Skip to content

Commit

Permalink
feat: Add JSON serialiser methods for all models
Browse files Browse the repository at this point in the history
  • Loading branch information
Antaris committed Feb 15, 2024
1 parent 74c97ef commit 7e6384a
Show file tree
Hide file tree
Showing 51 changed files with 120 additions and 73 deletions.
29 changes: 19 additions & 10 deletions apps/TrybeSDK.ConsoleSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@
var http = CreateHttpClient();
var api = new TrybeApiClient(http, settings);

//var response = await api.Shop.Packages.GetPackageAsync("6372bc492ea8f57d2508fe82");
var response = await api.Shop.ItemAvailability.GetOfferingDates(
new GetOfferingDatesRequest
{
OfferingType = "package",
OfferingId = "6372bc492ea8f57d2508fe82",
DateFrom = new(2024, 04, 01),
DateTo = new(2024, 04, 30),
Quantity = 1
});
var response = await api.Shop.Packages.GetPackageAsync("6372bc492ea8f57d2508fe82");
//var response = await api.Shop.ItemAvailability.GetOfferingDates(
// new GetOfferingDatesRequest
// {
// OfferingType = "package",
// OfferingId = "6372bc492ea8f57d2508fe82",
// DateFrom = new(2024, 04, 01),
// DateTo = new(2024, 04, 30),
// Quantity = 1
// });

if (response.IsSuccess && response.HasData)
{
var package = response.Data!;

string packageJson = package.ToJsonString();

var package2 = package.FromJsonString(packageJson);
}

Console.WriteLine(response);

Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/Basket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket object.
/// </summary>
public class Basket
public class Basket : Model<Basket>
{
/// <summary>
/// The ID of the basket.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketCouponSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket coupon summary instance.
/// </summary>
public class BasketCouponSummary
public class BasketCouponSummary : Model<BasketCouponSummary>
{
/// <summary>
/// The ID of the coupon.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket item instance.
/// </summary>
public class BasketItem
public class BasketItem : Model<BasketItem>
{
/// <summary>
/// A unique ID for the basket item
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketItemOptionBudget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket item option budget instance.
/// </summary>
public class BasketItemOptionBudget
public class BasketItemOptionBudget : Model<BasketItemOptionBudget>
{
/// <summary>
/// The ID of the choice this option budget belongs to.
Expand Down
4 changes: 2 additions & 2 deletions libs/TrybeSDK/Api/Shop/Basket/BasketItemValidity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket item validity instance.
/// </summary>
public class BasketItemValidity
public class BasketItemValidity : Model<BasketItemValidity>
{
/// <summary>
/// Whether the given basket item is valid.
Expand All @@ -28,7 +28,7 @@ public class BasketItemValidity
/// <summary>
/// A basket item validity error instance.
/// </summary>
public class BasketItemValidityErrors
public class BasketItemValidityErrors : Model<BasketItemValidityErrors>
{
/// <summary>
/// A friendly description of the error.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketPackageItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A basket package item.
/// </summary>
public class BasketPackageItem
public class BasketPackageItem : Model<BasketPackageItem>
{
/// <summary>
/// A unique ID for the basket package item
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketPromoCodeSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class BasketPromoCodeSummary
public class BasketPromoCodeSummary : Model<BasketPromoCodeSummary>
{
/// <summary>
/// The ID of the applied promo code.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketTotals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class BasketTotals
public class BasketTotals : Model<BasketTotals>
{
/// <summary>
/// The total cost of the basket before tax.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BasketVoucherSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class BasketVoucherSummary
public class BasketVoucherSummary : Model<BasketVoucherSummary>
{
/// <summary>
/// The ID of the voucher.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BookableAreaSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class BookableAreaSummary
public class BookableAreaSummary : Model<BookableAreaSummary>
{
/// <summary>
/// The ID of the area.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/BookingSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class BookingSummary
public class BookingSummary : Model<BookingSummary>
{
/// <summary>
/// Gets or Sets Id
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class Customer
public class Customer : Model<Customer>
{
/// <summary>
/// The ID of the customer.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/EquipmentSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class EquipmentSummary
public class EquipmentSummary : Model<EquipmentSummary>
{
/// <summary>
/// The ID of the equipment.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/Guest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A guest instance.
/// </summary>
public class Guest
public class Guest : Model<Guest>
{
/// <summary>
/// The ID of the guest.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/OfferingSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OfferingSummary
public class OfferingSummary : Model<OfferingSummary>
{
/// <summary>
/// The ID of the offering.
Expand Down
5 changes: 4 additions & 1 deletion libs/TrybeSDK/Api/Shop/Basket/PaymentSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

namespace TrybeSDK.Api;

public class PaymentSummary
public class PaymentSummary : PaymentSummary<PaymentSummary> { }

public class PaymentSummary<T> : Model<T>
where T : PaymentSummary<T>
{
/// <summary>
/// The ID of the item to be added.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/PractitionerSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class PractitionerSummary
public class PractitionerSummary : Model<PractitionerSummary>
{
/// <summary>
/// The ID of the practitioner.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/RoomSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class RoomSummary
public class RoomSummary : Model<RoomSummary>
{
/// <summary>
/// The ID of the room.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Basket/ShopDiscount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrybeSDK.Api;
/// <summary>
/// A shop discount instance.
/// </summary>
public class ShopDiscount
public class ShopDiscount : Model<ShopDiscount>
{
/// <summary>
/// The ID of the discount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace TrybeSDK.Api;

[DebuggerDisplay("{ToDebuggerString(),nq}")]
public class OfferingDateAvailability
public class OfferingDateAvailability : Model<OfferingDateAvailability>
{
/// <summary>
/// The date availability is for.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Offerings/OfferingEmailOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OfferingEmailOptions
public class OfferingEmailOptions : Model<OfferingEmailOptions>
{
/// <summary>
/// Enable to hide prices from customer emails, in cases where the customer didn't purchase the item directly.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Offerings/OfferingIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OfferingIdentifier
public class OfferingIdentifier : Model<OfferingIdentifier>
{
/// <summary>
/// The type of the offering.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OfferingRevenueAllocation
public class OfferingRevenueAllocation : Model<OfferingRevenueAllocation>
{
/// <summary>
/// The identifier of the revenue centre.
Expand Down
6 changes: 5 additions & 1 deletion libs/TrybeSDK/Api/Shop/Offerings/ShopOffering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
namespace TrybeSDK.Api;

[DebuggerDisplay("{ToDebuggerString(),nq}")]
public class ShopOffering
public class ShopOffering : ShopOffering<ShopOffering> { }

[DebuggerDisplay("{ToDebuggerString(),nq}")]
public class ShopOffering<T> : Model<T>
where T : ShopOffering<T>
{
/// <summary>
/// The ID of the offering
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Offerings/ShopOfferingCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace TrybeSDK.Api;

[DebuggerDisplay("{Name,nq} ({Id,nq})")]
public class ShopOfferingCategories
public class ShopOfferingCategories : Model<ShopOfferingCategories>
{
/// <summary>
/// The ID of the category
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/BookingOrderItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace TrybeSDK.Api;

public class BookingOrderItem
public class BookingOrderItem : Model<BookingOrderItem>
{
/// <summary>
/// Gets or Sets Id
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class Order
public class Order : Model<Order>
{
/// <summary>
/// The ID of the basket this order represents.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderDiscount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderDiscount
public class OrderDiscount : Model<OrderDiscount>
{
/// <summary>
/// The ID of the order discount
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderLabel
public class OrderLabel : Model<OrderLabel>
{
/// <summary>
/// The ID of the label.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderNote
public class OrderNote : Model<OrderNote>
{
/// <summary>
/// Gets or Sets Id
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderPayment : PaymentSummary
public class OrderPayment : PaymentSummary<OrderPayment>
{
/// <summary>
/// The amount of the payment that may be refunded.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderPaymentTotals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderPaymentTotals
public class OrderPaymentTotals : Model<OrderPaymentTotals>
{
/// <summary>
/// The total of payments in a paid status.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderServiceCharge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderServiceCharge
public class OrderServiceCharge : Model<OrderServiceCharge>
{
/// <summary>
/// The amount of the service charge, in minor units.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/OrderTotals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class OrderTotals
public class OrderTotals : Model<OrderTotals>
{
/// <summary>
/// The total cost of all items in the order. Item-level discounts are applied before this total is calculated.
Expand Down
2 changes: 1 addition & 1 deletion libs/TrybeSDK/Api/Shop/Orders/PackageOrderItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TrybeSDK.Api;

public class PackageOrderItem
public class PackageOrderItem : Model<PackageOrderItem>
{
/// <summary>
/// Gets or Sets Id
Expand Down
Loading

0 comments on commit 7e6384a

Please sign in to comment.