Capability.php 2.26 KB
Newer Older
mattwire's avatar
mattwire committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<?php

namespace Stripe;

/**
 * Class Capability
 *
 * @package Stripe
 *
 * @property string $id
 * @property string $object
 * @property string $account
 * @property bool $requested
 * @property int $requested_at
 * @property mixed $requirements
 * @property string $status
 */
class Capability extends ApiResource
{

    const OBJECT_NAME = "capability";

    use ApiOperations\Update;

    /**
     * Possible string representations of a capability's status.
     * @link https://stripe.com/docs/api/capabilities/object#capability_object-status
     */
    const STATUS_ACTIVE      = 'active';
    const STATUS_INACTIVE    = 'inactive';
    const STATUS_PENDING     = 'pending';
    const STATUS_UNREQUESTED = 'unrequested';

    /**
     * @return string The API URL for this Stripe account reversal.
     */
    public function instanceUrl()
    {
        $id = $this['id'];
        $account = $this['account'];
        if (!$id) {
            throw new Error\InvalidRequest(
                "Could not determine which URL to request: " .
                "class instance has invalid ID: $id",
                null
            );
        }
        $id = Util\Util::utf8($id);
        $account = Util\Util::utf8($account);

        $base = Account::classUrl();
        $accountExtn = urlencode($account);
        $extn = urlencode($id);
        return "$base/$accountExtn/capabilities/$extn";
    }

    /**
     * @param array|string $_id
     * @param array|string|null $_opts
     *
     * @throws \Stripe\Error\InvalidRequest
     */
    public static function retrieve($_id, $_opts = null)
    {
        $msg = "Capabilities cannot be accessed without an account ID. " .
               "Retrieve a Capability using \$account->retrieveCapability('acap_123') instead.";
        throw new Error\InvalidRequest($msg, null);
    }

    /**
     * @param string $_id
     * @param array|null $_params
     * @param array|string|null $_options
     *
     * @throws \Stripe\Error\InvalidRequest
     */
    public static function update($_id, $_params = null, $_options = null)
    {
        $msg = "Capabilities cannot be accessed without an account ID. " .
               "Update a Capability using \$account->updateCapability('acap_123') instead.";
        throw new Error\InvalidRequest($msg, null);
    }
}