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

Improve expanding responses #43

Draft
wants to merge 1 commit into
base: smf
Choose a base branch
from

Conversation

maksym-tielnyi-solid
Copy link
Collaborator

@maksym-tielnyi-solid maksym-tielnyi-solid commented Oct 14, 2024

What is done

  • Added ExpandableObject that allows expanding fields with multi-level nesting.
    Example of ExpandableObject usage:
    expand: SubscriptionExpandableObject(
      latestInvoice: InvoiceExpandableObject(
        paymentIntent: PaymentIntentExpandableObject(),
        discounts: DiscountExpandableObject(),
      ),
    )
  • Added Expandable and ExpandableList classes that can handle both expanded and non-expanded fields. For non-expanded fields Expandable and ExpandableList will contain only IDs and for expanded fields they will additionally contain the expanded value.
  • Increased the minimum required SDK version from 2.12.0 to 2.15.0 to use some of the new language features for the implementation.

Notes

  • API changes: expandable fields on API models should be wrapped with Expandable<T> which means that the following changes should be done in the existing code:
    // Before
    final latestInvoiceId = subscription.latestInvoice;
    
    // After: we should additionally access the id property of latestInvoice.
    final latestInvoiceId = subscription.latestInvoice.id;
    // Now we can get the whole Invoice object from the subscription object if it was queried.
    final latestInvoice = subscription.latestInvoice?.expanded;

@maksym-tielnyi-solid maksym-tielnyi-solid self-assigned this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants