Coupon::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\Coupon as CouponContract;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Coupon
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#coupon_object
12
 *
13
 * @property  string                            id
14
 * @property  string                            object              // 'coupon'
15
 * @property  int                               amount_off
16
 * @property  int                               created             // timestamp
17
 * @property  string                            currency
18
 * @property  bool|null                         deleted
19
 * @property  string                            duration            // 'forever', 'once' or 'repeating'
20
 * @property  int                               duration_in_months
21
 * @property  bool                              livemode
22
 * @property  int                               max_redemptions
23
 * @property  \Arcanedev\Stripe\AttachedObject  metadata
24
 * @property  int                               percent_off
25
 * @property  int                               redeem_by           // timestamp
26
 * @property  int                               times_redeemed
27
 * @property  bool                              valid
28
 */
29
class Coupon extends StripeResource implements CouponContract
30
{
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Main Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * List all Coupons.
37
     * @link   https://stripe.com/docs/api/php#list_coupons
38
     *
39
     * @param  array|null         $params
40
     * @param  array|string|null  $options
41
     *
42
     * @return \Arcanedev\Stripe\Collection|array
43
     */
44 2
    public static function all($params = [], $options = null)
45
    {
46 2
        return self::scopedAll($params, $options);
47
    }
48
49
    /**
50
     * Retrieve a Coupon.
51
     * @link   https://stripe.com/docs/api/php#retrieve_coupon
52
     *
53
     * @param  string             $id
54
     * @param  array|string|null  $options
55
     *
56
     * @return self
57
     */
58 10
    public static function retrieve($id, $options = null)
59
    {
60 10
        return self::scopedRetrieve($id, $options);
61
    }
62
63
    /**
64
     * Create a Coupon.
65
     * @link   https://stripe.com/docs/api/php#create_coupon
66
     *
67
     * @param  array|null         $params
68
     * @param  array|string|null  $options
69
     *
70
     * @return self|array
71
     */
72 10
    public static function create($params = [], $options = null)
73
    {
74 10
        return self::scopedCreate($params, $options);
75
    }
76
77
    /**
78
     * Update a Coupon.
79
     * @link   https://stripe.com/docs/api/php#update_coupon
80
     *
81
     * @param  string             $id
82
     * @param  array|null         $params
83
     * @param  array|string|null  $options
84
     *
85
     * @return self
86
     */
87 2
    public static function update($id, $params = [], $options = null)
88
    {
89 2
        return self::scopedUpdate($id, $params, $options);
90
    }
91
92
    /**
93
     * Update/Save a Coupon.
94
     * @link   https://stripe.com/docs/api/php#update_coupon
95
     *
96
     * @param  array|string|null  $options
97
     *
98
     * @return self
99
     */
100 2
    public function save($options = null)
101
    {
102 2
        return self::scopedSave($options);
103
    }
104
105
    /**
106
     * Delete a Coupon.
107
     * @link   https://stripe.com/docs/api/php#delete_coupon
108
     *
109
     * @param  array|null         $params
110
     * @param  array|string|null  $options
111
     *
112
     * @return self
113
     */
114 2
    public function delete($params = [], $options = null)
115
    {
116 2
        return self::scopedDelete($params, $options);
117
    }
118
}
119