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

[WIP] Codegen more enum values #961

Closed
wants to merge 1 commit into from

Conversation

richardm-stripe
Copy link
Contributor

Up until now, we generate constants for enums that appear at the top-level of stripe responses and put them at the top of the corresponding resource class. We do not generate constants corresponding to

  • values of enums that appear above the top level. For example account.capabilities.card_issuing is an enum("active", "inactive", "pending"), which is not generated according to the current scheme.
  • values of enums that appear not on any responses, but are to be passed in on the request. For example, Subscription#create.payment_behavior (as reported in Add pending update constants #941).

This PR adds those enums.

Q. What about cases when the values of the request enum differs from the response enum, or other request enums on the resource?
A. The enum values represent the superset of all enums sharing that name.

TODO: This doesn't yet include enums "nullable" or "emptyStringable" enums, or arrays of enums (if those exist)

Copy link
Contributor

@remi-stripe remi-stripe left a comment

Choose a reason for hiding this comment

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

Didn't read through the whole PR for now as I think there are real problems with the namings and which constants we should put in stripe-php

I believe we need to have a high level conversation around those constants and their risks, especially around API versions and breaking changes.

@@ -42,24 +42,119 @@ class Account extends ApiResource
use ApiOperations\NestedResource;
use ApiOperations\Update;

const AU_BECS_DEBIT_PAYMENTS_ACTIVE = 'active';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should do those this way since they are just identical. If I had done this right originally, it should be a list of STATUS_* constants inside the Capability class instead right?

const CARD_PAYMENTS_INACTIVE = 'inactive';
const CARD_PAYMENTS_PENDING = 'pending';

const CODE_INVALID_ADDRESS_CITY_STATE_POSTAL_CODE = 'invalid_address_city_state_postal_code';
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't think we should add something like this to the codebase, but I'm obviously biased against all those constants in the first place.

IMO those only make sense the day we start supporting real enums and API versions. Because right now, any value disappearing would be a breaking change or require an override

const CODE_VERIFICATION_FAILED_NAME_MATCH = 'verification_failed_name_match';
const CODE_VERIFICATION_FAILED_OTHER = 'verification_failed_other';

const INTERVAL_DAILY = 'daily';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this name is right. It should be something like SETTINGS_PAYOUTS_SCHEDULE_INTERVAL_DAILY instead? Back to "let's not add any of those" in my mind

const LEGACY_PAYMENTS_INACTIVE = 'inactive';
const LEGACY_PAYMENTS_PENDING = 'pending';

const STRUCTURE_GOVERNMENT_INSTRUMENTALITY = 'government_instrumentality';
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, it should be prefixed by the full path to avoid naming conflicts no?

const STRUCTURE_UNINCORPORATED_ASSOCIATION = 'unincorporated_association';
const STRUCTURE_UNINCORPORATED_NON_PROFIT = 'unincorporated_non_profit';

const TAX_REPORTING_US_1099_K_ACTIVE = 'active';
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor but why the different color?

@@ -46,6 +46,9 @@ class Card extends ApiResource
use ApiOperations\Delete;
use ApiOperations\Update;

const ACCOUNT_HOLDER_TYPE_COMPANY = 'company';
const ACCOUNT_HOLDER_TYPE_INDIVIDUAL = 'individual';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect, there's no such thing on Card

@richardm-stripe
Copy link
Contributor Author

^ was interesting as a proof of concept, will re-visit at a later time when the codegen infrastructure is more mature

@remi-stripe remi-stripe deleted the richardm-introduce-request-enums branch August 17, 2020 20:35
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