Skip to content

Commit

Permalink
Use codegen for enum constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Feb 14, 2020
1 parent f7c6462 commit c4729ee
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 197 deletions.
30 changes: 6 additions & 24 deletions lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,28 @@ class Account extends ApiResource
use ApiOperations\NestedResource;
use ApiOperations\Update;

use ApiOperations\Retrieve {
retrieve as protected _retrieve;
}

/**
* Possible string representations of an account's business type.
*
* @see https://stripe.com/docs/api/accounts/object#account_object-business_type
*/
const BUSINESS_TYPE_COMPANY = 'company';
const BUSINESS_TYPE_GOVERNMENT_ENTITY = 'government_entity';
const BUSINESS_TYPE_INDIVIDUAL = 'individual';
const BUSINESS_TYPE_NON_PROFIT = 'non_profit';

/**
* Possible string representations of an account's capabilities.
*
* @see https://stripe.com/docs/api/accounts/object#account_object-capabilities
*/
const CAPABILITY_CARD_PAYMENTS = 'card_payments';
const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments';
const CAPABILITY_PLATFORM_PAYMENTS = 'platform_payments';
const CAPABILITY_TRANSFERS = 'transfers';

/**
* Possible string representations of an account's capability status.
*
* @see https://stripe.com/docs/api/accounts/object#account_object-capabilities
*/
const CAPABILITY_STATUS_ACTIVE = 'active';
const CAPABILITY_STATUS_INACTIVE = 'inactive';
const CAPABILITY_STATUS_PENDING = 'pending';

/**
* Possible string representations of an account's type.
*
* @see https://stripe.com/docs/api/accounts/object#account_object-type
*/
const TYPE_CUSTOM = 'custom';
const TYPE_EXPRESS = 'express';
const TYPE_STANDARD = 'standard';

use ApiOperations\Retrieve {
retrieve as protected _retrieve;
}

public static function getSavedNestedResources()
{
static $savedNestedResources = null;
Expand Down
5 changes: 0 additions & 5 deletions lib/BalanceTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ class BalanceTransaction extends ApiResource
use ApiOperations\All;
use ApiOperations\Retrieve;

/**
* Possible string representations of the type of balance transaction.
*
* @see https://stripe.com/docs/api/balance/balance_transaction#balance_transaction_object-type
*/
const TYPE_ADJUSTMENT = 'adjustment';
const TYPE_ADVANCE = 'advance';
const TYPE_ADVANCE_FUNDING = 'advance_funding';
Expand Down
13 changes: 4 additions & 9 deletions lib/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Charge extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_SUCCEEDED = 'succeeded';

/**
* Possible string representations of decline codes.
* These strings are applicable to the decline_code property of the \Stripe\Exception\CardException exception.
Expand Down Expand Up @@ -113,15 +117,6 @@ class Charge extends ApiResource
const DECLINED_TRY_AGAIN_LATER = 'try_again_later';
const DECLINED_WITHDRAWAL_COUNT_LIMIT_EXCEEDED = 'withdrawal_count_limit_exceeded';

/**
* Possible string representations of the status of the charge.
*
* @see https://stripe.com/docs/api/charges/object#charge_object-status
*/
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_SUCCEEDED = 'succeeded';

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down
5 changes: 0 additions & 5 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class Session extends \Stripe\ApiResource
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;

/**
* Possible string representations of submit type.
*
* @see https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type
*/
const SUBMIT_TYPE_AUTO = 'auto';
const SUBMIT_TYPE_BOOK = 'book';
const SUBMIT_TYPE_DONATE = 'donate';
Expand Down
15 changes: 0 additions & 15 deletions lib/CreditNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,14 @@ class CreditNote extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Possible string representations of the credit note reason.
*
* @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-reason
*/
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_ORDER_CHANGE = 'order_change';
const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory';

/**
* Possible string representations of the credit note status.
*
* @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
*/
const STATUS_ISSUED = 'issued';
const STATUS_VOID = 'void';

/**
* Possible string representations of the credit note type.
*
* @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
*/
const TYPE_POST_PAYMENT = 'post_payment';
const TYPE_PRE_PAYMENT = 'pre_payment';

Expand Down
7 changes: 1 addition & 6 deletions lib/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@ class Customer extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Possible string representations of the customer's type of tax exemption.
*
* @see https://stripe.com/docs/api/customers/object#customer_object-tax_exempt
*/
const TAX_EXEMPT_NONE = 'none';
const TAX_EXEMPT_EXEMPT = 'exempt';
const TAX_EXEMPT_NONE = 'none';
const TAX_EXEMPT_REVERSE = 'reverse';

public static function getSavedNestedResources()
Expand Down
10 changes: 0 additions & 10 deletions lib/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class Dispute extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Possible string representations of dispute reasons.
*
* @see https://stripe.com/docs/api#dispute_object
*/
const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process';
const REASON_CHECK_RETURNED = 'check_returned';
const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed';
Expand All @@ -50,11 +45,6 @@ class Dispute extends ApiResource
const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled';
const REASON_UNRECOGNIZED = 'unrecognized';

/**
* Possible string representations of dispute statuses.
*
* @see https://stripe.com/docs/api#dispute_object
*/
const STATUS_CHARGE_REFUNDED = 'charge_refunded';
const STATUS_LOST = 'lost';
const STATUS_NEEDS_RESPONSE = 'needs_response';
Expand Down
29 changes: 5 additions & 24 deletions lib/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ class Invoice extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

use ApiOperations\NestedResource;
const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
const BILLING_SEND_INVOICE = 'send_invoice';

/**
* Possible string representations of the billing reason.
*
* @see https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
*/
const BILLING_REASON_AUTOMATIC_PENDING_INVOICE_ITEM_INVOICE = 'automatic_pending_invoice_item_invoice';
const BILLING_REASON_MANUAL = 'manual';
const BILLING_REASON_SUBSCRIPTION = 'subscription';
const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create';
Expand All @@ -91,33 +88,17 @@ class Invoice extends ApiResource
const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update';
const BILLING_REASON_UPCOMING = 'upcoming';

/**
* Possible string representations of the `collection_method` property.
*
* @see https://stripe.com/docs/api/invoices/object#invoice_object-collection_method
*/
const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically';
const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';

/**
* Possible string representations of the invoice status.
*
* @see https://stripe.com/docs/api/invoices/object#invoice_object-status
*/
const STATUS_DELETED = 'deleted';
const STATUS_DRAFT = 'draft';
const STATUS_OPEN = 'open';
const STATUS_PAID = 'paid';
const STATUS_UNCOLLECTIBLE = 'uncollectible';
const STATUS_VOID = 'void';

/**
* Possible string representations of the `billing` property.
*
* @deprecated use `collection_method` instead
* @see https://stripe.com/docs/api/invoices/object#invoice_object-billing
*/
const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
const BILLING_SEND_INVOICE = 'send_invoice';
use ApiOperations\NestedResource;

const PATH_LINES = '/lines';

Expand Down
5 changes: 0 additions & 5 deletions lib/PaymentIntent.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ class PaymentIntent extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* These constants are possible representations of the status field.
*
* @see https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_PROCESSING = 'processing';
const STATUS_REQUIRES_ACTION = 'requires_action';
Expand Down
24 changes: 2 additions & 22 deletions lib/Payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class Payout extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Types of payout failure codes.
*
* @see https://stripe.com/docs/api#payout_failures
*/
const FAILURE_ACCOUNT_CLOSED = 'account_closed';
const FAILURE_ACCOUNT_FROZEN = 'account_frozen';
const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted';
Expand All @@ -54,30 +49,15 @@ class Payout extends ApiResource
const FAILURE_NO_ACCOUNT = 'no_account';
const FAILURE_UNSUPPORTED_CARD = 'unsupported_card';

/**
* Possible string representations of the payout methods.
*
* @see https://stripe.com/docs/api/payouts/object#payout_object-method
*/
const METHOD_STANDARD = 'standard';
const METHOD_INSTANT = 'instant';
const METHOD_STANDARD = 'standard';

/**
* Possible string representations of the status of the payout.
*
* @see https://stripe.com/docs/api/payouts/object#payout_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_IN_TRANSIT = 'in_transit';
const STATUS_FAILED = 'failed';
const STATUS_IN_TRANSIT = 'in_transit';
const STATUS_PAID = 'paid';
const STATUS_PENDING = 'pending';

/**
* Possible string representations of the type of payout.
*
* @see https://stripe.com/docs/api/payouts/object#payout_object-type
*/
const TYPE_BANK_ACCOUNT = 'bank_account';
const TYPE_CARD = 'card';

Expand Down
5 changes: 0 additions & 5 deletions lib/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class Product extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Possible string representations of the type of product.
*
* @see https://stripe.com/docs/api/service_products/object#service_product_object-type
*/
const TYPE_GOOD = 'good';
const TYPE_SERVICE = 'service';
}
5 changes: 0 additions & 5 deletions lib/Radar/EarlyFraudWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ class EarlyFraudWarning extends \Stripe\ApiResource
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;

/**
* Possible string representations of an early fraud warning's fraud type.
*
* @see https://stripe.com/docs/api/early_fraud_warnings/object#early_fraud_warning_object-fraud_type
*/
const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received';
const FRAUD_TYPE_FRAUDULENT_CARD_APPLICATION = 'fraudulent_card_application';
const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card';
Expand Down
17 changes: 1 addition & 16 deletions lib/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,14 @@ class Refund extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* Possible string representations of the failure reason.
*
* @see https://stripe.com/docs/api/refunds/object#refund_object-failure_reason
*/
const FAILURE_REASON = 'expired_or_canceled_card';
const FAILURE_REASON_EXPIRED_OR_CANCELED_CARD = 'expired_or_canceled_card';
const FAILURE_REASON_LOST_OR_STOLEN_CARD = 'lost_or_stolen_card';
const FAILURE_REASON_UNKNOWN = 'unknown';

/**
* Possible string representations of the refund reason.
*
* @see https://stripe.com/docs/api/refunds/object#refund_object-reason
*/
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_REQUESTED_BY_CUSTOMER = 'requested_by_customer';

/**
* Possible string representations of the refund status.
*
* @see https://stripe.com/docs/api/refunds/object#refund_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
Expand Down
9 changes: 9 additions & 0 deletions lib/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ class Review extends ApiResource
use ApiOperations\All;
use ApiOperations\Retrieve;

const CLOSED_REASON_APPROVED = 'approved';
const CLOSED_REASON_DISPUTED = 'disputed';
const CLOSED_REASON_REFUNDED = 'refunded';
const CLOSED_REASON_REFUNDED_AS_FRAUD = 'refunded_as_fraud';

const OPENED_REASON_MANUAL = 'manual';
const OPENED_REASON_RULE = 'rule';

/**
* Possible string representations of the current, the opening or the closure reason of the review.
* Not all of these enumeration apply to all of the ´reason´ fields. Please consult the Review object to
* determine where these are apply.
*
* @see https://stripe.com/docs/api/radar/reviews/object
* @deprecated prefer using the OPENED_REASON_* or CLOSED_REASON_* constants
*/
const REASON_APPROVED = 'approved';
const REASON_DISPUTED = 'disputed';
Expand Down
5 changes: 0 additions & 5 deletions lib/SetupIntent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class SetupIntent extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* These constants are possible representations of the status field.
*
* @see https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_PROCESSING = 'processing';
const STATUS_REQUIRES_ACTION = 'requires_action';
Expand Down

0 comments on commit c4729ee

Please sign in to comment.