Skip to content

Commit

Permalink
Codegen for openapi v182
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-stripe committed Aug 18, 2022
1 parent ec45723 commit 45b0090
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 12 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v178
v182
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
require __DIR__ . '/lib/CreditNoteLineItem.php';
require __DIR__ . '/lib/Customer.php';
require __DIR__ . '/lib/CustomerBalanceTransaction.php';
require __DIR__ . '/lib/CustomerCashBalanceTransaction.php';
require __DIR__ . '/lib/Discount.php';
require __DIR__ . '/lib/Dispute.php';
require __DIR__ . '/lib/EphemeralKey.php';
Expand Down
4 changes: 2 additions & 2 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* You can create a Checkout Session on your server and pass its ID to the client
* to begin Checkout.
*
* Related guide: <a href="https://stripe.com/docs/payments/checkout/api">Checkout
* Server Quickstart</a>.
* Related guide: <a href="https://stripe.com/docs/checkout/quickstart">Checkout
* Quickstart</a>.
*
* @property string $id Unique identifier for the object. Used to pass to <code>redirectToCheckout</code> in Stripe.js.
* @property string $object String representing the object's type. Objects of the same type share the same value.
Expand Down
30 changes: 30 additions & 0 deletions lib/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,36 @@ public static function updateBalanceTransaction($id, $balanceTransactionId, $par
{
return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
}
const PATH_CASH_BALANCE_TRANSACTIONS = '/cash_balance_transactions';

/**
* @param string $id the ID of the customer on which to retrieve the customer cash balance transactions
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\CustomerCashBalanceTransaction> the list of customer cash balance transactions
*/
public static function allCashBalanceTransactions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $params, $opts);
}

/**
* @param string $id the ID of the customer to which the customer cash balance transaction belongs
* @param string $cashBalanceTransactionId the ID of the customer cash balance transaction to retrieve
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\CustomerCashBalanceTransaction
*/
public static function retrieveCashBalanceTransaction($id, $cashBalanceTransactionId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $cashBalanceTransactionId, $params, $opts);
}
const PATH_SOURCES = '/sources';

/**
Expand Down
41 changes: 41 additions & 0 deletions lib/CustomerCashBalanceTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* Customers with certain payments enabled have a cash balance, representing funds
* that were paid by the customer to a merchant, but have not yet been allocated to
* a payment. Cash Balance Transactions represent when funds are moved into or out
* of this balance. This includes funding by the customer, allocation to payments,
* and refunds to the customer.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property \Stripe\StripeObject $applied_to_payment
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @property string|\Stripe\Customer $customer The customer whose available cash balance changed as a result of this transaction.
* @property int $ending_balance The total available cash balance for the specified currency after this transaction was applied. Represented in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>.
* @property \Stripe\StripeObject $funded
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property int $net_amount The amount by which the cash balance changed, represented in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. A positive value represents funds being added to the cash balance, a negative value represents funds being removed from the cash balance.
* @property \Stripe\StripeObject $refunded_from_payment
* @property string $type The type of the cash balance transaction. One of <code>applied_to_payment</code>, <code>unapplied_from_payment</code>, <code>refunded_from_payment</code>, <code>funded</code>, <code>return_initiated</code>, or <code>return_canceled</code>. New types may be added in future. See <a href="https://stripe.com/docs/payments/customer-balance#types">Customer Balance</a> to learn more about these types.
* @property \Stripe\StripeObject $unapplied_from_payment
*/
class CustomerCashBalanceTransaction extends ApiResource
{
const OBJECT_NAME = 'customer_cash_balance_transaction';

use ApiOperations\All;
use ApiOperations\Retrieve;

const TYPE_APPLIED_TO_PAYMENT = 'applied_to_payment';
const TYPE_FUNDED = 'funded';
const TYPE_REFUNDED_FROM_PAYMENT = 'refunded_from_payment';
const TYPE_RETURN_CANCELED = 'return_canceled';
const TYPE_RETURN_INITIATED = 'return_initiated';
const TYPE_UNAPPLIED_FROM_PAYMENT = 'unapplied_from_payment';
}
1 change: 1 addition & 0 deletions lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Event extends ApiResource
const CUSTOMER_TAX_ID_DELETED = 'customer.tax_id.deleted';
const CUSTOMER_TAX_ID_UPDATED = 'customer.tax_id.updated';
const CUSTOMER_UPDATED = 'customer.updated';
const CUSTOMER_CASH_BALANCE_TRANSACTION_CREATED = 'customer_cash_balance_transaction.created';
const FILE_CREATED = 'file.created';
const FINANCIAL_CONNECTIONS_ACCOUNT_CREATED = 'financial_connections.account.created';
const FINANCIAL_CONNECTIONS_ACCOUNT_DEACTIVATED = 'financial_connections.account.deactivated';
Expand Down
1 change: 1 addition & 0 deletions lib/PaymentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @property \Stripe\StripeObject $automatic_tax
* @property string $billing_address_collection Configuration for collecting the customer's billing address.
* @property null|\Stripe\StripeObject $consent_collection When set, provides configuration to gather active consent from customers.
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @property string $customer_creation Configuration for Customer creation during checkout.
* @property \Stripe\Collection<\Stripe\LineItem> $line_items The line items representing what is being sold.
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
Expand Down
35 changes: 35 additions & 0 deletions lib/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ public function allBalanceTransactions($parentId, $params = null, $opts = null)
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts);
}

/**
* Returns a list of transactions that modified the customer’s <a
* href="/docs/payments/customer-balance">cash balance</a>.
*
* @param string $parentId
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\CustomerCashBalanceTransaction>
*/
public function allCashBalanceTransactions($parentId, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions', $parentId), $params, $opts);
}

/**
* Returns a list of PaymentMethods for a given Customer.
*
Expand Down Expand Up @@ -292,6 +309,24 @@ public function retrieveCashBalance($parentId, $params = null, $opts = null)
return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts);
}

/**
* Retrieves a specific cash balance transaction, which updated the customer’s <a
* href="/docs/payments/customer-balance">cash balance</a>.
*
* @param string $parentId
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\CustomerCashBalanceTransaction
*/
public function retrieveCashBalanceTransaction($parentId, $id, $params = null, $opts = null)
{
return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions/%s', $parentId, $id), $params, $opts);
}

/**
* Retrieves a PaymentMethod object for a given Customer.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Topup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @property null|string $failure_message Message to user further explaining reason for top-up failure if available.
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
* @property \Stripe\Source $source <p><code>Source</code> objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Stripe API just like a <code>Card</code> object: once chargeable, they can be charged, or can be attached to customers.</p><p>Related guides: <a href="https://stripe.com/docs/sources">Sources API</a> and <a href="https://stripe.com/docs/sources/customers">Sources &amp; Customers</a>.</p>
* @property null|\Stripe\Source $source For most Stripe users, the source of every top-up is a bank account. This hash is then the <a href="https://stripe.com/docs/api#source_object">source object</a> describing that bank account.
* @property null|string $statement_descriptor Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter.
* @property string $status The status of the top-up is either <code>canceled</code>, <code>failed</code>, <code>pending</code>, <code>reversed</code>, or <code>succeeded</code>.
* @property null|string $transfer_group A string that identifies this top-up as part of a group.
Expand Down
1 change: 1 addition & 0 deletions lib/Util/ObjectTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ObjectTypes
\Stripe\CreditNoteLineItem::OBJECT_NAME => \Stripe\CreditNoteLineItem::class,
\Stripe\Customer::OBJECT_NAME => \Stripe\Customer::class,
\Stripe\CustomerBalanceTransaction::OBJECT_NAME => \Stripe\CustomerBalanceTransaction::class,
\Stripe\CustomerCashBalanceTransaction::OBJECT_NAME => \Stripe\CustomerCashBalanceTransaction::class,
\Stripe\Discount::OBJECT_NAME => \Stripe\Discount::class,
\Stripe\Dispute::OBJECT_NAME => \Stripe\Dispute::class,
\Stripe\EphemeralKey::OBJECT_NAME => \Stripe\EphemeralKey::class,
Expand Down
16 changes: 8 additions & 8 deletions tests/Stripe/GeneratedExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ public function testSearchCharge()
$result = $this->client->charges->search(
['query' => 'amount>999 AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Charge","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Charge","namespaces":[]},"hasSearchResultType":true}
}

public function testListSession()
Expand Down Expand Up @@ -1337,7 +1337,7 @@ public function testSearchCustomer()
$result = $this->client->customers->search(
['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]},"hasSearchResultType":true}
}

public function testSearchCustomer2()
Expand All @@ -1346,7 +1346,7 @@ public function testSearchCustomer2()
$result = $this->client->customers->search(
['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]},"hasSearchResultType":true}
}

public function testListDispute()
Expand Down Expand Up @@ -1732,7 +1732,7 @@ public function testSearchInvoice()
$result = $this->client->invoices->search(
['query' => 'total>999 AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Invoice","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Invoice","namespaces":[]},"hasSearchResultType":true}
}

public function testListAuthorization()
Expand Down Expand Up @@ -2065,7 +2065,7 @@ public function testSearchPaymentIntent()
$result = $this->client->paymentIntents->search(
['query' => 'status:\'succeeded\' AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"PaymentIntent","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"PaymentIntent","namespaces":[]},"hasSearchResultType":true}
}

public function testListPaymentLink()
Expand Down Expand Up @@ -2308,7 +2308,7 @@ public function testSearchPrice()
$result = $this->client->prices->search(
['query' => 'active:\'true\' AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Price","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Price","namespaces":[]},"hasSearchResultType":true}
}

public function testListProduct()
Expand Down Expand Up @@ -2356,7 +2356,7 @@ public function testSearchProduct()
$result = $this->client->products->search(
['query' => 'active:\'true\' AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Product","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Product","namespaces":[]},"hasSearchResultType":true}
}

public function testListPromotionCode()
Expand Down Expand Up @@ -3074,7 +3074,7 @@ public function testSearchSubscription()
$result = $this->client->subscriptions->search(
['query' => 'status:\'active\' AND metadata[\'order_id\']:\'6735\'']
);
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Subscription","namespaces":[]}}
// TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Subscription","namespaces":[]},"hasSearchResultType":true}
}

public function testListTaxCode()
Expand Down

0 comments on commit 45b0090

Please sign in to comment.