From bec2fd3491c62e8a2eb6d2ef9f383e2adfbb6ab1 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 23 May 2022 10:45:22 -0700 Subject: [PATCH] Codegen for openapi v146 --- OPENAPI_VERSION | 1 + init.php | 3 + lib/Apps/Secret.php | 78 +++++++++++++++++++++++++ lib/PaymentMethod.php | 2 + lib/Service/Apps/AppsServiceFactory.php | 25 ++++++++ lib/Service/Apps/SecretService.php | 68 +++++++++++++++++++++ lib/Service/CoreServiceFactory.php | 2 + lib/StripeClient.php | 1 + lib/Util/ObjectTypes.php | 1 + tests/Stripe/GeneratedExamplesTest.php | 31 ++++++++++ 10 files changed, 212 insertions(+) create mode 100644 OPENAPI_VERSION create mode 100644 lib/Apps/Secret.php create mode 100644 lib/Service/Apps/AppsServiceFactory.php create mode 100644 lib/Service/Apps/SecretService.php diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION new file mode 100644 index 000000000..19a48dddd --- /dev/null +++ b/OPENAPI_VERSION @@ -0,0 +1 @@ +v146 \ No newline at end of file diff --git a/init.php b/init.php index 7b34170ab..5c32b6125 100644 --- a/init.php +++ b/init.php @@ -81,6 +81,7 @@ require __DIR__ . '/lib/ApplePayDomain.php'; require __DIR__ . '/lib/ApplicationFee.php'; require __DIR__ . '/lib/ApplicationFeeRefund.php'; +require __DIR__ . '/lib/Apps/Secret.php'; require __DIR__ . '/lib/Balance.php'; require __DIR__ . '/lib/BalanceTransaction.php'; require __DIR__ . '/lib/BankAccount.php'; @@ -191,6 +192,7 @@ require __DIR__ . '/lib/Service/AccountLinkService.php'; require __DIR__ . '/lib/Service/ApplePayDomainService.php'; require __DIR__ . '/lib/Service/ApplicationFeeService.php'; +require __DIR__ . '/lib/Service/Apps/SecretService.php'; require __DIR__ . '/lib/Service/BalanceService.php'; require __DIR__ . '/lib/Service/BalanceTransactionService.php'; require __DIR__ . '/lib/Service/BillingPortal/ConfigurationService.php'; @@ -275,6 +277,7 @@ require __DIR__ . '/lib/Service/WebhookEndpointService.php'; // Service factories +require __DIR__ . '/lib/Service/Apps/AppsServiceFactory.php'; require __DIR__ . '/lib/Service/BillingPortal/BillingPortalServiceFactory.php'; require __DIR__ . '/lib/Service/Checkout/CheckoutServiceFactory.php'; require __DIR__ . '/lib/Service/CoreServiceFactory.php'; diff --git a/lib/Apps/Secret.php b/lib/Apps/Secret.php new file mode 100644 index 000000000..dfcc36b85 --- /dev/null +++ b/lib/Apps/Secret.php @@ -0,0 +1,78 @@ +secret. Other apps can't + * view secrets created by an app. Additionally, secrets are scoped to provide + * further permission control. + * + * All Dashboard users and the app backend share account scoped + * secrets. Use the account scope for secrets that don't change + * per-user, like a third-party API key. + * + * A user scoped secret is accessible by the app backend and one + * specific Dashboard user. Use the user scope for per-user secrets + * like per-user OAuth tokens, where different users might have different + * permissions. + * + * Related guide: Store + * data between page reloads. + * + * @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 int $created Time at which the object was created. Measured in seconds since the Unix epoch. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property string $name A name for the secret that's unique within the scope. + * @property null|string $payload The plaintext secret value to be stored. + * @property \Stripe\StripeObject $scope + */ +class Secret extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'apps.secret'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Apps\Secret the deleted secret + */ + public static function deleteWhere($params = null, $opts = null) + { + $url = static::classUrl() . '/delete'; + list($response, $opts) = static::_staticRequest('post', $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\Apps\Secret the finded secret + */ + public static function find($params = null, $opts = null) + { + $url = static::classUrl() . '/find'; + list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } +} diff --git a/lib/PaymentMethod.php b/lib/PaymentMethod.php index e14e474e2..ed0112f7b 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -19,6 +19,7 @@ * @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 $acss_debit + * @property \Stripe\StripeObject $affirm * @property \Stripe\StripeObject $afterpay_clearpay * @property \Stripe\StripeObject $alipay * @property \Stripe\StripeObject $au_becs_debit @@ -39,6 +40,7 @@ * @property \Stripe\StripeObject $interac_present * @property \Stripe\StripeObject $klarna * @property \Stripe\StripeObject $konbini + * @property \Stripe\StripeObject $link * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\StripeObject $oxxo diff --git a/lib/Service/Apps/AppsServiceFactory.php b/lib/Service/Apps/AppsServiceFactory.php new file mode 100644 index 000000000..39f37345d --- /dev/null +++ b/lib/Service/Apps/AppsServiceFactory.php @@ -0,0 +1,25 @@ + + */ + private static $classMap = [ + 'secrets' => SecretService::class, + ]; + + protected function getServiceClass($name) + { + return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null; + } +} diff --git a/lib/Service/Apps/SecretService.php b/lib/Service/Apps/SecretService.php new file mode 100644 index 000000000..8c9c74b48 --- /dev/null +++ b/lib/Service/Apps/SecretService.php @@ -0,0 +1,68 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/apps/secrets', $params, $opts); + } + + /** + * Create or replace a secret in the secret store. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Apps\Secret + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/apps/secrets', $params, $opts); + } + + /** + * Deletes a secret from the secret store by name and scope. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Apps\Secret + */ + public function deleteWhere($params = null, $opts = null) + { + return $this->request('post', '/v1/apps/secrets/delete', $params, $opts); + } + + /** + * Finds a secret in the secret store by name and scope. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Apps\Secret + */ + public function find($params = null, $opts = null) + { + return $this->request('get', '/v1/apps/secrets/find', $params, $opts); + } +} diff --git a/lib/Service/CoreServiceFactory.php b/lib/Service/CoreServiceFactory.php index 570d3b842..ce9676c21 100644 --- a/lib/Service/CoreServiceFactory.php +++ b/lib/Service/CoreServiceFactory.php @@ -11,6 +11,7 @@ * @property AccountService $accounts * @property ApplePayDomainService $applePayDomains * @property ApplicationFeeService $applicationFees + * @property Apps\AppsServiceFactory $apps * @property BalanceService $balance * @property BalanceTransactionService $balanceTransactions * @property BillingPortal\BillingPortalServiceFactory $billingPortal @@ -76,6 +77,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory 'accounts' => AccountService::class, 'applePayDomains' => ApplePayDomainService::class, 'applicationFees' => ApplicationFeeService::class, + 'apps' => Apps\AppsServiceFactory::class, 'balance' => BalanceService::class, 'balanceTransactions' => BalanceTransactionService::class, 'billingPortal' => BillingPortal\BillingPortalServiceFactory::class, diff --git a/lib/StripeClient.php b/lib/StripeClient.php index d0e74c641..05989ff62 100644 --- a/lib/StripeClient.php +++ b/lib/StripeClient.php @@ -11,6 +11,7 @@ * @property \Stripe\Service\AccountService $accounts * @property \Stripe\Service\ApplePayDomainService $applePayDomains * @property \Stripe\Service\ApplicationFeeService $applicationFees + * @property \Stripe\Service\Apps\AppsServiceFactory $apps * @property \Stripe\Service\BalanceService $balance * @property \Stripe\Service\BalanceTransactionService $balanceTransactions * @property \Stripe\Service\BillingPortal\BillingPortalServiceFactory $billingPortal diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index 93f7095d9..637e0e885 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -16,6 +16,7 @@ class ObjectTypes \Stripe\ApplePayDomain::OBJECT_NAME => \Stripe\ApplePayDomain::class, \Stripe\ApplicationFee::OBJECT_NAME => \Stripe\ApplicationFee::class, \Stripe\ApplicationFeeRefund::OBJECT_NAME => \Stripe\ApplicationFeeRefund::class, + \Stripe\Apps\Secret::OBJECT_NAME => \Stripe\Apps\Secret::class, \Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class, \Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class, \Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class, diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index d32761538..fc1e37ba7 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -483,6 +483,37 @@ public function testCreateReceivedDebit() static::assertInstanceOf(\Stripe\Treasury\ReceivedDebit::class, $result); } + public function testCreateSecret() + { + $this->expectsRequest('post', '/v1/apps/secrets'); + $result = $this->client->apps->secrets->create( + [ + 'name' => 'sec_123', + 'payload' => 'very secret string', + 'scope' => ['type' => 'account'], + ] + ); + static::assertInstanceOf(\Stripe\Apps\Secret::class, $result); + } + + public function testFindSecret() + { + $this->expectsRequest('get', '/v1/apps/secrets/find'); + $result = $this->client->apps->secrets->find( + ['name' => 'sec_123', 'scope' => ['type' => 'account']] + ); + static::assertInstanceOf(\Stripe\Apps\Secret::class, $result); + } + + public function testDeleteWhereSecret() + { + $this->expectsRequest('post', '/v1/apps/secrets/delete'); + $result = $this->client->apps->secrets->deleteWhere( + ['name' => 'sec_123', 'scope' => ['type' => 'account']] + ); + static::assertInstanceOf(\Stripe\Apps\Secret::class, $result); + } + public function testListCustomer() { $this->expectsRequest('get', '/v1/customers');