~evanj/cms

ref: 9d7fbcbdf7e7332ea56493092efe5cffbadccdd6 cms/vendor/github.com/stripe/stripe-go/v71/discount.go -rw-r--r-- 1.1 KiB
9d7fbcbdEvan M Jones Fix(go.mod/vendor): Attempting to fix vendoring for deploys. 10 months 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
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"`
	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
}