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

Add explicit attributes for fields in resources, and rbis for resources #1490

Open
wants to merge 8 commits into
base: beta
Choose a base branch
from

Conversation

helenye-stripe
Copy link
Contributor

@helenye-stripe helenye-stripe commented Nov 19, 2024

Why?

This is the first step in #1479 - this adds explicit attributes for fields in resources, and adds RBIs with type annotations for them. This is not yet ready for use as it does not define any methods, so I have not included the RBIs in the gemspec.

What?

I recommend reviewing this mostly through the codegen PR, as this is almost entirely generated changes.

Important notes:

  • There are a set of files that do not have any methods, and are returned solely in deprecated APIs. However, they are described in the return types for these methods, so I have added them and their corresponding RBIs. They are:
    • lib/stripe/resources/application.rb
    • lib/stripe/resources/billing/alert_triggered.rb
    • lib/stripe/resources/billing/meter_error_report.rb
    • lib/stripe/resources/connect_collection_transfer.rb
    • lib/stripe/resources/entitlements/active_entitlement_summary.rb
    • lib/stripe/resources/issuing/settlement.rb
    • lib/stripe/resources/quote_line.rb
    • lib/stripe/resources/reserve_transaction.rb
    • lib/stripe/resources/source_mandate_notification.rb
    • lib/stripe/resources/tax_deducted_at_source.rb
  • Added lib/stripe/resources/amount.rb and rbi/stripe/resources/amount.rbi because it is a type used in V2.
  • Added an additional step in StripeObject.add_accessors (lib/stripe/stripe_object.rb) to appropriately set instance variables upon creation.
  • Updated .rubocop.yml to ignore variable numbers, since we have field names in various conventions in the API.

@helenye-stripe helenye-stripe changed the title Helenye beta fields Add explicit attributes for fields in resources, and rbis for resources Nov 20, 2024
@helenye-stripe helenye-stripe marked this pull request as ready for review November 20, 2024 04:29
Copy link
Member

@xavdid-stripe xavdid-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor formatting things, but no big concerns. looks awesome!

sig { returns(T.nilable(Integer)) }
attr_reader :void_at
end
sig { returns(Integer) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that anyone is really reading these, but they'd be a little more legible with the comment first, then sign, then attr, then a line break:

# Change to a FinancialAccount's balance
sig { returns(BalanceImpact) }
attr_reader :balance_impact

# Change to a FinancialAccount's balance
sig { returns(BalanceImpact) }
attr_reader :balance_impact

Assuming that ordering plays nicely with hovering in VScode. Either way, a line break might be nice (but that can be in a later PR, not important to regenerate this for that)

# The last four digits of the token.
attr_reader :last4
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line breaks would be nice in here as well, IMO

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