<?php



namespace Stripe;



class Subscription extends ApiResource

{

    /**

     * @param string $id The ID of the subscription to retrieve.

     * @param array|string|null $opts

     *

     * @return Subscription

     */

    public static function retrieve($id, $opts = null)

    {

        return self::_retrieve($id, $opts);

    }



    /**

     * @param array|null $params

     * @param array|string|null $opts

     *

     * @return Collection of Subscriptions

     */

    public static function all($params = null, $opts = null)

    {

        return self::_all($params, $opts);

    }



    /**

     * @param array|null $params

     * @param array|string|null $opts

     *

     * @return Subscription The created subscription.

     */

    public static function create($params = null, $opts = null)

    {

        return self::_create($params, $opts);

    }



    /**

     * @param array|null $params

     *

     * @return Subscription The deleted subscription.

     */

    public function cancel($params = null, $opts = null)

    {

        return $this->_delete($params, $opts);

    }



    /**

     * @param array|string|null $opts

     *

     * @return Subscription The saved subscription.

     */

    public function save($opts = null)

    {

        return $this->_save($opts);

    }



    /**

     * @return Subscription The updated subscription.

     */

    public function deleteDiscount()

    {

        $url = $this->instanceUrl() . '/discount';

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

        $this->refreshFrom(array('discount' => null), $opts, true);

    }

}

