forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview.go
41 lines (34 loc) · 1.01 KB
/
review.go
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
package stripe
import "encoding/json"
// Reason describes the reason why the review is open or closed.
// Allowed values are "rule", "manual", "approved", "refunded",
// "refunded_as_fraud", "disputed".
type ReasonType string
const (
ReasonRule ReasonType = "rule"
ReasonManual ReasonType = "manual"
ReasonApproved ReasonType = "approved"
ReasonRefunded ReasonType = "refunded"
ReasonRefundedAsFraud ReasonType = "refunded_as_fraud"
ReasonDisputed ReasonType = "disputed"
)
type Review struct {
Charge *Charge `json:"charge"`
Created int64 `json:"created"`
ID string `json:"id"`
Live bool `json:"livemode"`
Open bool `json:"open"`
Reason ReasonType `json:"reason"`
}
func (r *Review) UnmarshalJSON(data []byte) error {
type review Review
var rr review
err := json.Unmarshal(data, &rr)
if err == nil {
*r = Review(rr)
} else {
// Otherwise...we have to strip the escaping
r.ID = string(data[1 : len(data)-1])
}
return nil
}