-
Notifications
You must be signed in to change notification settings - Fork 856
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1094 from stripe/latest-codegen
- Loading branch information
Showing
10 changed files
with
214 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
// File generated from our OpenAPI spec | ||
|
||
namespace Stripe\BillingPortal; | ||
|
||
/** | ||
* A portal configuration describes the functionality and behavior of a portal | ||
* session. | ||
* | ||
* @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 bool $active Whether the configuration is active and can be used to create portal sessions. | ||
* @property null|string $application ID of the Connect Application that created the configuration. | ||
* @property \Stripe\StripeObject $business_profile | ||
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. | ||
* @property null|string $default_return_url The default URL to redirect customers to when they click on the portal's link to return to your website. This can be <a href="https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url">overriden</a> when creating the session. | ||
* @property \Stripe\StripeObject $features | ||
* @property bool $is_default Whether the configuration is the default. If <code>true</code>, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session. | ||
* @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 $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. | ||
*/ | ||
class Configuration extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = 'billing_portal.configuration'; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
// File generated from our OpenAPI spec | ||
|
||
namespace Stripe\Service\BillingPortal; | ||
|
||
class ConfigurationService extends \Stripe\Service\AbstractService | ||
{ | ||
/** | ||
* Returns a list of configurations that describe the functionality of the customer | ||
* portal. | ||
* | ||
* @param null|array $params | ||
* @param null|array|\Stripe\Util\RequestOptions $opts | ||
* | ||
* @throws \Stripe\Exception\ApiErrorException if the request fails | ||
* | ||
* @return \Stripe\Collection | ||
*/ | ||
public function all($params = null, $opts = null) | ||
{ | ||
return $this->requestCollection('get', '/v1/billing_portal/configurations', $params, $opts); | ||
} | ||
|
||
/** | ||
* Creates a configuration that describes the functionality and behavior of a | ||
* PortalSession. | ||
* | ||
* @param null|array $params | ||
* @param null|array|\Stripe\Util\RequestOptions $opts | ||
* | ||
* @throws \Stripe\Exception\ApiErrorException if the request fails | ||
* | ||
* @return \Stripe\BillingPortal\Configuration | ||
*/ | ||
public function create($params = null, $opts = null) | ||
{ | ||
return $this->request('post', '/v1/billing_portal/configurations', $params, $opts); | ||
} | ||
|
||
/** | ||
* Retrieves a configuration that describes the functionality of the customer | ||
* portal. | ||
* | ||
* @param string $id | ||
* @param null|array $params | ||
* @param null|array|\Stripe\Util\RequestOptions $opts | ||
* | ||
* @throws \Stripe\Exception\ApiErrorException if the request fails | ||
* | ||
* @return \Stripe\BillingPortal\Configuration | ||
*/ | ||
public function retrieve($id, $params = null, $opts = null) | ||
{ | ||
return $this->request('get', $this->buildPath('/v1/billing_portal/configurations/%s', $id), $params, $opts); | ||
} | ||
|
||
/** | ||
* Updates a configuration that describes the functionality of the customer portal. | ||
* | ||
* @param string $id | ||
* @param null|array $params | ||
* @param null|array|\Stripe\Util\RequestOptions $opts | ||
* | ||
* @throws \Stripe\Exception\ApiErrorException if the request fails | ||
* | ||
* @return \Stripe\BillingPortal\Configuration | ||
*/ | ||
public function update($id, $params = null, $opts = null) | ||
{ | ||
return $this->request('post', $this->buildPath('/v1/billing_portal/configurations/%s', $id), $params, $opts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
tests/Stripe/Service/BillingPortal/ConfigurationServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace Stripe\Service\BillingPortal; | ||
|
||
/** | ||
* @internal | ||
* @covers \Stripe\Service\BillingPortal\ConfigurationService | ||
*/ | ||
final class ConfigurationServiceTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
use \Stripe\TestHelper; | ||
|
||
const TEST_RESOURCE_ID = 'bpc_123'; | ||
|
||
/** @var \Stripe\StripeClient */ | ||
private $client; | ||
|
||
/** @var ConfigurationService */ | ||
private $service; | ||
|
||
/** | ||
* @before | ||
*/ | ||
protected function setUpService() | ||
{ | ||
$this->client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]); | ||
$this->service = new ConfigurationService($this->client); | ||
} | ||
|
||
public function testCreate() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/billing_portal/configurations' | ||
); | ||
$resource = $this->service->create([ | ||
'business_profile' => [ | ||
'terms_of_service_url' => 'https://example.com/tos', | ||
'privacy_policy_url' => 'https://example.com/privacy', | ||
], | ||
'features' => [ | ||
'customer_update' => [ | ||
'allowed_updates' => ['address'], | ||
'enabled' => true, | ||
], | ||
], | ||
]); | ||
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource); | ||
} | ||
|
||
public function testUpdate() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/billing_portal/configurations/bpc_xyz' | ||
); | ||
$resource = $this->service->update('bpc_xyz', [ | ||
'active' => false, | ||
]); | ||
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource); | ||
} | ||
|
||
public function testRetrieve() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/billing_portal/configurations/bpc_xyz' | ||
); | ||
$resource = $this->service->retrieve('bpc_xyz'); | ||
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource); | ||
} | ||
|
||
public function testList() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/billing_portal/configurations' | ||
); | ||
$resource = $this->service->all(); | ||
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource->data[0]); | ||
} | ||
} |