Skip to content

Commit

Permalink
Codegen for openapi v215
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe committed Dec 15, 2022
1 parent 93e81a7 commit deb6250
Show file tree
Hide file tree
Showing 14 changed files with 426 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v213
v215
4 changes: 4 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@
require __DIR__ . '/lib/Subscription.php';
require __DIR__ . '/lib/SubscriptionItem.php';
require __DIR__ . '/lib/SubscriptionSchedule.php';
require __DIR__ . '/lib/TaxCalculation.php';
require __DIR__ . '/lib/TaxCode.php';
require __DIR__ . '/lib/TaxId.php';
require __DIR__ . '/lib/TaxRate.php';
require __DIR__ . '/lib/TaxTransaction.php';
require __DIR__ . '/lib/Terminal/Configuration.php';
require __DIR__ . '/lib/Terminal/ConnectionToken.php';
require __DIR__ . '/lib/Terminal/Location.php';
Expand Down Expand Up @@ -257,8 +259,10 @@
require __DIR__ . '/lib/Service/SubscriptionService.php';
require __DIR__ . '/lib/Service/SubscriptionItemService.php';
require __DIR__ . '/lib/Service/SubscriptionScheduleService.php';
require __DIR__ . '/lib/Service/TaxCalculationService.php';
require __DIR__ . '/lib/Service/TaxCodeService.php';
require __DIR__ . '/lib/Service/TaxRateService.php';
require __DIR__ . '/lib/Service/TaxTransactionService.php';
require __DIR__ . '/lib/Service/Terminal/ConfigurationService.php';
require __DIR__ . '/lib/Service/Terminal/ConnectionTokenService.php';
require __DIR__ . '/lib/Service/Terminal/LocationService.php';
Expand Down
1 change: 1 addition & 0 deletions lib/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* @property int $amount_remaining The difference between amount_due and amount_paid, in %s.
* @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the invoice.
* @property null|int $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
* @property null|\Stripe\StripeObject $applies_to
* @property int $attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
* @property bool $attempted Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the <code>invoice.created</code> webhook, for example, so you might not want to display that invoice as unpaid to your users.
* @property bool $auto_advance Controls whether Stripe will perform <a href="https://stripe.com/docs/billing/invoices/workflow/#auto_advance">automatic collection</a> of the invoice. When <code>false</code>, the invoice's state will not automatically advance without an explicit action.
Expand Down
1 change: 1 addition & 0 deletions lib/InvoiceLineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $amount The amount, in %s.
* @property null|int $amount_excluding_tax The integer amount in %s representing the amount for this line item, excluding all tax and discounts.
* @property null|\Stripe\StripeObject $applies_to
* @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 null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
* @property null|\Stripe\StripeObject[] $discount_amounts The amount of discount calculated per discount for this line item.
Expand Down
116 changes: 116 additions & 0 deletions lib/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@
* @property null|string|\Stripe\Invoice $invoice The invoice that was created from this quote.
* @property null|\Stripe\StripeObject $invoice_settings All invoices will be billed using the specified settings.
* @property \Stripe\Collection<\Stripe\LineItem> $line_items A list of items the customer is being quoted for.
* @property null|string[] $lines A list of lines on the quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.
* @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 null|string $number A unique number that identifies this particular quote. This number is assigned once the quote is <a href="https://stripe.com/docs/quotes/overview#finalize">finalized</a>.
* @property null|string|\Stripe\Account $on_behalf_of The account on behalf of which to charge. See the <a href="https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts">Connect documentation</a> for details.
* @property string $status The status of the quote.
* @property null|\Stripe\StripeObject $status_details Details on when and why a quote has been marked as stale or canceled.
* @property \Stripe\StripeObject $status_transitions
* @property null|string|\Stripe\Subscription $subscription The subscription that was created or updated from this quote.
* @property \Stripe\StripeObject $subscription_data
* @property null|\Stripe\StripeObject[] $subscription_data_overrides
* @property null|string|\Stripe\SubscriptionSchedule $subscription_schedule The subscription schedule that was created or updated from this quote.
* @property null|\Stripe\StripeObject[] $subscription_schedules The subscription schedules that were created or updated from this quote.
* @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this quote belongs to.
* @property \Stripe\StripeObject $total_details
* @property null|\Stripe\StripeObject $transfer_data The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the invoices.
Expand All @@ -58,9 +62,11 @@ class Quote extends ApiResource
const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';

const STATUS_ACCEPTED = 'accepted';
const STATUS_ACCEPTING = 'accepting';
const STATUS_CANCELED = 'canceled';
const STATUS_DRAFT = 'draft';
const STATUS_OPEN = 'open';
const STATUS_STALE = 'stale';

/**
* @param callable $readBodyChunkCallable
Expand Down Expand Up @@ -114,6 +120,23 @@ public function cancel($params = null, $opts = null)
return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Quote the drafted quote
*/
public function draftQuote($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/draft';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down Expand Up @@ -168,4 +191,97 @@ public static function allLineItems($id, $params = null, $opts = null)

return $obj;
}

/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\QuoteLine> list of QuoteLines
*/
public static function allLines($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/lines';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\InvoiceLineItem> list of InvoiceLineItems
*/
public static function previewInvoiceLines($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/preview_invoice_lines';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Invoice> list of Invoices
*/
public static function previewInvoices($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/preview_invoices';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\SubscriptionSchedule> list of SubscriptionSchedules
*/
public static function previewSubscriptionSchedules($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/preview_subscription_schedules';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Quote the reestimated quote
*/
public function reestimate($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/reestimate';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}
}
4 changes: 4 additions & 0 deletions lib/Service/CoreServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
* @property SubscriptionItemService $subscriptionItems
* @property SubscriptionService $subscriptions
* @property SubscriptionScheduleService $subscriptionSchedules
* @property TaxCalculationService $taxCalculations
* @property TaxCodeService $taxCodes
* @property TaxRateService $taxRates
* @property TaxTransactionService $taxTransactions
* @property Terminal\TerminalServiceFactory $terminal
* @property TestHelpers\TestHelpersServiceFactory $testHelpers
* @property TokenService $tokens
Expand Down Expand Up @@ -129,8 +131,10 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory
'subscriptionItems' => SubscriptionItemService::class,
'subscriptions' => SubscriptionService::class,
'subscriptionSchedules' => SubscriptionScheduleService::class,
'taxCalculations' => TaxCalculationService::class,
'taxCodes' => TaxCodeService::class,
'taxRates' => TaxRateService::class,
'taxTransactions' => TaxTransactionService::class,
'terminal' => Terminal\TerminalServiceFactory::class,
'testHelpers' => TestHelpers\TestHelpersServiceFactory::class,
'tokens' => TokenService::class,
Expand Down
98 changes: 98 additions & 0 deletions lib/Service/QuoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ public function allLineItems($id, $params = null, $opts = null)
return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/line_items', $id), $params, $opts);
}

/**
* When retrieving a quote, there is an includable <strong>lines</strong> property
* containing the first handful of those items. There is also a URL where you can
* retrieve the full (paginated) list of lines.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\QuoteLine>
*/
public function allLines($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/lines', $id), $params, $opts);
}

/**
* Cancels the quote.
*
Expand Down Expand Up @@ -108,6 +126,22 @@ public function create($params = null, $opts = null)
return $this->request('post', '/v1/quotes', $params, $opts);
}

/**
* Converts a stale quote to draft.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Quote
*/
public function draftQuote($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/quotes/%s/draft', $id), $params, $opts);
}

/**
* Finalizes the quote.
*
Expand All @@ -124,6 +158,70 @@ public function finalizeQuote($id, $params = null, $opts = null)
return $this->request('post', $this->buildPath('/v1/quotes/%s/finalize', $id), $params, $opts);
}

/**
* Preview the invoice line items that would be generated by accepting the quote.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\InvoiceLineItem>
*/
public function previewInvoiceLines($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/preview_invoice_lines', $id), $params, $opts);
}

/**
* Preview the invoices that would be generated by accepting the quote.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Invoice>
*/
public function previewInvoices($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/preview_invoices', $id), $params, $opts);
}

/**
* Preview the schedules that would be generated by accepting the quote.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\SubscriptionSchedule>
*/
public function previewSubscriptionSchedules($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/preview_subscription_schedules', $id), $params, $opts);
}

/**
* Recompute the upcoming invoice estimate for the quote.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Quote
*/
public function reestimate($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/quotes/%s/reestimate', $id), $params, $opts);
}

/**
* Retrieves the quote with the given ID.
*
Expand Down
39 changes: 39 additions & 0 deletions lib/Service/TaxCalculationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service;

class TaxCalculationService extends \Stripe\Service\AbstractService
{
/**
* Retrieves the line items of a persisted tax calculation as a collection.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\LineItem>
*/
public function allLineItems($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/tax/calculations/%s/line_items', $id), $params, $opts);
}

/**
* Calculates tax based on input and returns a Tax <code>Calculation</code> object.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\TaxCalculation
*/
public function create($params = null, $opts = null)
{
return $this->request('post', '/v1/tax/calculations', $params, $opts);
}
}
Loading

0 comments on commit deb6250

Please sign in to comment.