forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
review.go
39 lines (32 loc) · 1.04 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
package stripe
import "encoding/json"
// ReviewReasonType describes the reason why the review is open or closed.
type ReviewReasonType string
const (
ReviewReasonApproved ReviewReasonType = "approved"
ReviewReasonDisputed ReviewReasonType = "disputed"
ReviewReasonManual ReviewReasonType = "manual"
ReviewReasonRefunded ReviewReasonType = "refunded"
ReviewReasonRefundedAsFraud ReviewReasonType = "refunded_as_fraud"
ReviewReasonRule ReviewReasonType = "rule"
)
type Review struct {
Charge *Charge `json:"charge"`
Created int64 `json:"created"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
Open bool `json:"open"`
Reason ReviewReasonType `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
}