forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispute_gateway.go
69 lines (62 loc) · 1.73 KB
/
dispute_gateway.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package braintree
import (
"context"
)
type DisputeGateway struct {
*Braintree
}
func (g *DisputeGateway) Find(ctx context.Context, disputeID string) (*Dispute, error) {
resp, err := g.executeVersion(ctx, "GET", "disputes/"+disputeID, nil, apiVersion4)
if err != nil {
return nil, err
}
switch resp.StatusCode {
case 200:
return resp.dispute()
}
return nil, &invalidResponseError{resp}
}
func (g *DisputeGateway) AddTextEvidence(ctx context.Context, disputeID string, textEvidenceRequest *DisputeTextEvidenceRequest) (*DisputeEvidence, error) {
resp, err := g.executeVersion(ctx, "POST", "disputes/"+disputeID+"/evidence", textEvidenceRequest, apiVersion4)
if err != nil {
return nil, err
}
switch resp.StatusCode {
case 200:
return resp.disputeEvidence()
}
return nil, &invalidResponseError{resp}
}
func (g *DisputeGateway) RemoveEvidence(ctx context.Context, disputeID string, evidenceId string) error {
resp, err := g.executeVersion(ctx, "DELETE", "disputes/"+disputeID+"/evidence/"+evidenceId, nil, apiVersion4)
if err != nil {
return err
}
switch resp.StatusCode {
case 200:
return nil
}
return &invalidResponseError{resp}
}
func (g *DisputeGateway) Accept(ctx context.Context, disputeID string) error {
resp, err := g.executeVersion(ctx, "PUT", "disputes/"+disputeID+"/accept", nil, apiVersion4)
if err != nil {
return nil
}
switch resp.StatusCode {
case 200:
return nil
}
return &invalidResponseError{resp}
}
func (g *DisputeGateway) Finalize(ctx context.Context, disputeID string) error {
resp, err := g.executeVersion(ctx, "PUT", "disputes/"+disputeID+"/finalize", nil, apiVersion4)
if err != nil {
return err
}
switch resp.StatusCode {
case 200:
return nil
}
return &invalidResponseError{resp}
}