Skip to content
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

Added PHPDocs for create, update, delete, all, retrieve methods after moving them out of traits. #1701

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 123 additions & 3 deletions lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class Account extends ApiResource
{
const OBJECT_NAME = 'account';

use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\NestedResource;
use ApiOperations\Update;

Expand All @@ -61,6 +58,129 @@ class Account extends ApiResource
const TYPE_NONE = 'none';
const TYPE_STANDARD = 'standard';

/**
* With <a href="/docs/connect">Connect</a>, you can create Stripe accounts for
* your users. To do this, you’ll first need to <a
* href="https://dashboard.stripe.com/account/applications/settings">register your
* platform</a>.
*
* If you’ve already collected information for your connected accounts, you <a
* href="/docs/connect/best-practices#onboarding">can prefill that information</a>
* when creating the account. Connect Onboarding won’t ask for the prefilled
* information during account onboarding. You can prefill any information on the
* account.
*
* @param null|array $params
* @param null|array|string $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Account the created resource
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();

list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* With <a href="/connect">Connect</a>, you can delete accounts you manage.
*
* Test-mode accounts can be deleted at any time.
*
* Live-mode accounts where Stripe is responsible for negative account balances
* cannot be deleted, which includes Standard accounts. Live-mode accounts where
* your platform is liable for negative account balances, which includes Custom and
* Express accounts, can be deleted when all <a
* href="/api/balance/balanace_object">balances</a> are zero.
*
* If you want to delete your own account, use the <a
* href="https://dashboard.stripe.com/settings/account">account information tab in
* your account settings</a> instead.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Account the deleted resource
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);

$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* Returns a list of accounts connected to your platform via <a
* href="/docs/connect">Connect</a>. If you’re not a platform, the list is empty.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Account> of ApiResources
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();

return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}

/**
* Updates a <a href="/connect/accounts">connected account</a> by setting the
* values of the parameters passed. Any parameters not provided are left unchanged.
*
* For accounts where <a
* href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a>
* is <code>application</code>, which includes Custom accounts, you can update any
* information on the account.
*
* For accounts where <a
* href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a>
* is <code>stripe</code>, which includes Standard and Express accounts, you can
* update all information until you create an <a href="/api/account_links">Account
* Link</a> or <a href="/api/account_sessions">Account Session</a> to start Connect
* onboarding, after which some properties can no longer be updated.
*
* To update your own account, use the <a
* href="https://dashboard.stripe.com/settings/account">Dashboard</a>. Refer to our
* <a href="/docs/connect/updating-accounts">Connect</a> documentation to learn
* more about updating accounts.
*
* @param string $id the ID of the resource to update
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Account the updated resource
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);

list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

use ApiOperations\Retrieve {
retrieve as protected _retrieve;
}
Expand Down
24 changes: 23 additions & 1 deletion lib/AccountLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,27 @@ class AccountLink extends ApiResource
{
const OBJECT_NAME = 'account_link';

use ApiOperations\Create;
/**
* Creates an AccountLink object that includes a single-use Stripe URL that the
* platform can redirect their user to in order to take them through the Connect
* Onboarding flow.
*
* @param null|array $params
* @param null|array|string $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\AccountLink the created resource
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();

list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}
}
23 changes: 22 additions & 1 deletion lib/AccountSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,26 @@ class AccountSession extends ApiResource
{
const OBJECT_NAME = 'account_session';

use ApiOperations\Create;
/**
* Creates a AccountSession object that includes a single-use token that the
* platform can use on their front-end to grant client-side API access.
*
* @param null|array $params
* @param null|array|string $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\AccountSession the created resource
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();

list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}
}
82 changes: 78 additions & 4 deletions lib/ApplePayDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,84 @@ class ApplePayDomain extends ApiResource
{
const OBJECT_NAME = 'apple_pay_domain';

use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
/**
* Create an apple pay domain.
*
* @param null|array $params
* @param null|array|string $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ApplePayDomain the created resource
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();

list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* Delete an apple pay domain.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ApplePayDomain the deleted resource
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);

$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* List apple pay domains.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\ApplePayDomain> of ApiResources
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();

return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}

/**
* Retrieve an apple pay domain.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ApplePayDomain
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();

return $instance;
}

/**
* @return string The class URL for this resource. It needs to be special
Expand Down
40 changes: 38 additions & 2 deletions lib/ApplicationFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,45 @@ class ApplicationFee extends ApiResource
{
const OBJECT_NAME = 'application_fee';

use ApiOperations\All;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;

/**
* Returns a list of application fees you’ve previously collected. The application
* fees are returned in sorted order, with the most recent fees appearing first.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\ApplicationFee> of ApiResources
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();

return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}

/**
* Retrieves the details of an application fee that your account has collected. The
* same information is returned when refunding the application fee.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ApplicationFee
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();

return $instance;
}

const PATH_REFUNDS = '/refunds';

Expand Down
40 changes: 38 additions & 2 deletions lib/Apps/Secret.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,44 @@ class Secret extends \Stripe\ApiResource
{
const OBJECT_NAME = 'apps.secret';

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
/**
* Create or replace a secret in the secret store.
*
* @param null|array $params
* @param null|array|string $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Apps\Secret the created resource
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();

list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* List all secrets stored on the given scope.
*
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Apps\Secret> of ApiResources
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();

return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}

/**
* @param null|array $params
Expand Down
Loading
Loading