~evanj/cms

ref: f2ad8887d95788430ed361e00b18eec1699b2253 cms/vendor/github.com/stripe/stripe-go/v71/discount.go -rw-r--r-- 1.3 KiB
f2ad8887Evan J Feat(vendor): Updating deps. 1 year, 18 days ago
                                                                                
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
package stripe

import "encoding/json"

// DiscountParams is the set of parameters that can be used when deleting a discount.
type DiscountParams struct {
	Params `form:"*"`
}

// Discount is the resource representing a Stripe discount.
// For more details see https://stripe.com/docs/api#discounts.
type Discount struct {
	APIResource
	Coupon        *Coupon        `json:"coupon"`
	Customer      string         `json:"customer"`
	Deleted       bool           `json:"deleted"`
	End           int64          `json:"end"`
	ID            string         `json:"id"`
	Invoice       string         `json:"invoice"`
	InvoiceItem   string         `json:"invoice_item"`
	Object        string         `json:"object"`
	PromotionCode *PromotionCode `json:"promotion_code"`
	Start         int64          `json:"start"`
	Subscription  string         `json:"subscription"`
}

// UnmarshalJSON handles deserialization of a Discount.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (s *Discount) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		s.ID = id
		return nil
	}

	type discount Discount
	var v discount
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*s = Discount(v)
	return nil
}