Skip to content

Commit 01eb901

Browse files
committed
refactor disputes
1 parent 77fda1f commit 01eb901

File tree

2 files changed

+26
-78
lines changed

2 files changed

+26
-78
lines changed

dispute.go

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ func (c *Client) UpdateDispute(ctx context.Context, disputeId string, params *Up
7575
if err != nil {
7676
return err
7777
}
78-
if err = c.SendWithAuth(req, nil); err != nil {
79-
return err
80-
}
81-
82-
return nil
78+
return c.SendWithAuth(req, nil)
8379
}
8480

8581
// Provides evidence for a dispute, by ID
@@ -90,11 +86,7 @@ func (c *Client) DisputeProvideEvidence(ctx context.Context, disputeId string, p
9086
if err != nil {
9187
return err
9288
}
93-
if err = c.SendWithAuth(req, nil); err != nil {
94-
return err
95-
}
96-
97-
return nil
89+
return c.SendWithAuth(req, nil)
9890
}
9991

10092
// Appeals a dispute, by ID
@@ -105,11 +97,7 @@ func (c *Client) DisputeAppeal(ctx context.Context, disputeId string, params *Di
10597
if err != nil {
10698
return err
10799
}
108-
if err = c.SendWithAuth(req, nil); err != nil {
109-
return err
110-
}
111-
112-
return nil
100+
return c.SendWithAuth(req, nil)
113101
}
114102

115103
// Accepts liability for a claim, by ID
@@ -120,11 +108,7 @@ func (c *Client) DisputeAcceptClaim(ctx context.Context, disputeId string, param
120108
if err != nil {
121109
return err
122110
}
123-
if err = c.SendWithAuth(req, nil); err != nil {
124-
return err
125-
}
126-
127-
return nil
111+
return c.SendWithAuth(req, nil)
128112
}
129113

130114
// Settles a dispute in either the customer's or merchant's favor.
@@ -135,11 +119,7 @@ func (c *Client) SettleDispute(ctx context.Context, disputeId string, adjudicate
135119
if err != nil {
136120
return err
137121
}
138-
if err = c.SendWithAuth(req, nil); err != nil {
139-
return err
140-
}
141-
142-
return nil
122+
return c.SendWithAuth(req, nil)
143123
}
144124

145125
// Updates the status of a dispute, by ID
@@ -151,11 +131,7 @@ func (c *Client) DisputeUpdateStatus(ctx context.Context, disputeId string, adju
151131
if err != nil {
152132
return err
153133
}
154-
if err = c.SendWithAuth(req, nil); err != nil {
155-
return err
156-
}
157-
158-
return nil
134+
return c.SendWithAuth(req, nil)
159135
}
160136

161137
// Escalates the dispute, by ID
@@ -166,11 +142,7 @@ func (c *Client) DisputeEscalateToClaim(ctx context.Context, disputeId string, n
166142
if err != nil {
167143
return err
168144
}
169-
if err = c.SendWithAuth(req, nil); err != nil {
170-
return err
171-
}
172-
173-
return nil
145+
return c.SendWithAuth(req, nil)
174146
}
175147

176148
// Sends a message about a dispute, by ID, to the other party in the dispute.
@@ -181,11 +153,7 @@ func (c *Client) DisputeSendMessageToOtherParty(ctx context.Context, disputeId s
181153
if err != nil {
182154
return err
183155
}
184-
if err = c.SendWithAuth(req, nil); err != nil {
185-
return err
186-
}
187-
188-
return nil
156+
return c.SendWithAuth(req, nil)
189157
}
190158

191159
// Makes an offer to the other party to resolve a dispute, by ID
@@ -196,11 +164,7 @@ func (c *Client) DisputeMakeOffer(ctx context.Context, disputeId string, params
196164
if err != nil {
197165
return err
198166
}
199-
if err = c.SendWithAuth(req, nil); err != nil {
200-
return err
201-
}
202-
203-
return nil
167+
return c.SendWithAuth(req, nil)
204168
}
205169

206170
// The customer accepts the offer from merchant to resolve a dispute, by ID
@@ -211,11 +175,7 @@ func (c *Client) DisputeAcceptOffer(ctx context.Context, disputeId string, note
211175
if err != nil {
212176
return err
213177
}
214-
if err = c.SendWithAuth(req, nil); err != nil {
215-
return err
216-
}
217-
218-
return nil
178+
return c.SendWithAuth(req, nil)
219179
}
220180

221181
// Denies an offer that the merchant proposes for a dispute, by ID.
@@ -226,11 +186,7 @@ func (c *Client) DisputeDenyOffer(ctx context.Context, disputeId string, note st
226186
if err != nil {
227187
return err
228188
}
229-
if err = c.SendWithAuth(req, nil); err != nil {
230-
return err
231-
}
232-
233-
return nil
189+
return c.SendWithAuth(req, nil)
234190
}
235191

236192
// Acknowledges that the customer returned an item for a dispute, by ID.
@@ -241,11 +197,7 @@ func (c *Client) DisputeAcknowledgeReturnItem(ctx context.Context, disputeId str
241197
if err != nil {
242198
return err
243199
}
244-
if err = c.SendWithAuth(req, nil); err != nil {
245-
return err
246-
}
247-
248-
return nil
200+
return c.SendWithAuth(req, nil)
249201
}
250202

251203
// Provides supporting information for a dispute, by ID.
@@ -256,9 +208,5 @@ func (c *Client) DisputeProvideSupportingInfo(ctx context.Context, disputeId str
256208
if err != nil {
257209
return err
258210
}
259-
if err = c.SendWithAuth(req, nil); err != nil {
260-
return err
261-
}
262-
263-
return nil
211+
return c.SendWithAuth(req, nil)
264212
}

dispute_types.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type ListDisputesResponse struct {
1919

2020
type DisputeItem struct {
2121
DisputeID string `json:"dispute_id,omitempty"`
22-
CreateTime time.Time `json:"create_time,omitempty"`
23-
UpdateTime time.Time `json:"update_time,omitempty"`
22+
CreateTime time.Time `json:"create_time"`
23+
UpdateTime time.Time `json:"update_time"`
2424
DisputedTransactions []*DisputedTransactionItem `json:"disputed_transactions,omitempty"`
2525
Reason string `json:"reason,omitempty"`
2626
Status string `json:"status,omitempty"`
@@ -35,8 +35,8 @@ type DisputeItem struct {
3535

3636
type DisputedTransactionItem struct {
3737
BuyerTransactionID string `json:"buyer_transaction_id,omitempty"`
38-
Buyer Buyer `json:"buyer,omitempty"`
39-
Seller Seller `json:"seller,omitempty"`
38+
Buyer Buyer `json:"buyer"`
39+
Seller Seller `json:"seller"`
4040
}
4141

4242
type Buyer struct {
@@ -52,8 +52,8 @@ type Seller struct {
5252

5353
type GetDisputeDetailResponse struct {
5454
DisputeID string `json:"dispute_id,omitempty"`
55-
CreateTime time.Time `json:"create_time,omitempty"`
56-
UpdateTime time.Time `json:"update_time,omitempty"`
55+
CreateTime time.Time `json:"create_time"`
56+
UpdateTime time.Time `json:"update_time"`
5757
DisputedTransactions []*DisputedTransactionDetail `json:"disputed_transactions,omitempty"`
5858
Reason string `json:"reason,omitempty"`
5959
Status string `json:"status,omitempty"`
@@ -74,15 +74,15 @@ type DisputeOutcome struct {
7474

7575
type DisputedTransactionDetail struct {
7676
SellerTransactionID string `json:"seller_transaction_id,omitempty"`
77-
CreateTime time.Time `json:"create_time,omitempty"`
77+
CreateTime time.Time `json:"create_time"`
7878
TransactionStatus string `json:"transaction_status,omitempty"`
7979
GrossAmount *Money `json:"gross_amount,omitempty"`
80-
Buyer Buyer `json:"buyer,omitempty"`
81-
Seller Seller `json:"seller,omitempty"`
80+
Buyer Buyer `json:"buyer"`
81+
Seller Seller `json:"seller"`
8282
}
8383

8484
type Extensions struct {
85-
MerchandizeDisputeProperties MerchandizeDisputeProperties `json:"merchandize_dispute_properties,omitempty"`
85+
MerchandizeDisputeProperties MerchandizeDisputeProperties `json:"merchandize_dispute_properties"`
8686
}
8787

8888
type MerchandizeDisputeProperties struct {
@@ -97,7 +97,7 @@ type ServiceDetails struct {
9797

9898
type Message struct {
9999
PostedBy string `json:"posted_by,omitempty"`
100-
TimePosted time.Time `json:"time_posted,omitempty"`
100+
TimePosted time.Time `json:"time_posted"`
101101
Content string `json:"content,omitempty"`
102102
Documents []*Document `json:"documents,omitempty"`
103103
}
@@ -114,7 +114,7 @@ type Offer struct {
114114
}
115115

116116
type History struct {
117-
OfferTime time.Time `json:"offer_time,omitempty"`
117+
OfferTime time.Time `json:"offer_time"`
118118
Actor string `json:"actor,omitempty"`
119119
EventType string `json:"event_type,omitempty"`
120120
OfferType string `json:"offer_type,omitempty"`
@@ -126,7 +126,7 @@ type History struct {
126126
type UpdateDisputeValue struct {
127127
ID string `json:"id,omitempty"`
128128
Name string `json:"name,omitempty"`
129-
CreateTime time.Time `json:"create_time,omitempty"`
129+
CreateTime time.Time `json:"create_time"`
130130
Reason string `json:"reason,omitempty"`
131131
Status string `json:"status,omitempty"`
132132
}

0 commit comments

Comments
 (0)