-
Notifications
You must be signed in to change notification settings - Fork 856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Updates #1094
Merged
Merged
API Updates #1094
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d8bf30
Codegen for openapi 403fdb8
richardm-stripe 79c1fdc
Add test
richardm-stripe a8b71e8
Bump stripe-mock
richardm-stripe a567b93
Bump mock again
richardm-stripe 3913be4
Fix test
richardm-stripe 54eedfb
Codegen from openapi eba69d9
richardm-stripe 886477d
Update tests/Stripe/Service/BillingPortal/ConfigurationServiceTest.php
richardm-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 'cs_123'; | ||
richardm-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** @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]); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id should be bpc_123