chargehound 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/CHANGELOG +2 -0
- data/chargehound.gemspec +1 -1
- data/lib/chargehound/api_request.rb +7 -5
- data/lib/chargehound/models.rb +3 -0
- data/lib/chargehound/version.rb +1 -1
- data/test/disputes_test.rb +105 -5
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10e5712b827a309931649f02599f15bfadcbf841e51c6dd2d6fdd1e983f45f3c
|
4
|
+
data.tar.gz: 465c1d4f2234ff6ee6935d743a02c91a7b297ef5b24bfb7140caa5643379deb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00a639c1ecf429abc9d2a002f54200c0f842e5fba32d81443b593dec097a71c0c09f8922bca0f063ab2834510bb3cfd4a20ec7505cede0fdb5285643dc29488d
|
7
|
+
data.tar.gz: 6a1676b358c82754387827303a85d32ac94d87847a4ffd6f01d4551c2d1349a186fb3c7d66ffed80cc76c90ad12e0a09528746e89c8476d8ad06436111be6e65
|
data/.rubocop.yml
CHANGED
data/CHANGELOG
CHANGED
data/chargehound.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Automatically fight disputes'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.add_development_dependency 'bundler'
|
17
|
+
spec.add_development_dependency 'bundler'
|
18
18
|
spec.add_development_dependency 'minitest', '~> 5.8'
|
19
19
|
spec.add_development_dependency 'rake', '~> 11.1'
|
20
20
|
spec.add_development_dependency 'rubocop', '~> 0.49'
|
@@ -39,10 +39,7 @@ module Chargehound
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def build_http_opts
|
42
|
-
{
|
43
|
-
use_ssl: true,
|
44
|
-
read_timeout: Chargehound.timeout
|
45
|
-
}
|
42
|
+
{ use_ssl: true, read_timeout: Chargehound.timeout }
|
46
43
|
end
|
47
44
|
|
48
45
|
def build_headers(body)
|
@@ -100,7 +97,12 @@ module Chargehound
|
|
100
97
|
def convert(dict)
|
101
98
|
case dict['object']
|
102
99
|
when 'dispute'
|
103
|
-
dict['products'].map
|
100
|
+
dict['products'] = dict.fetch('products', []).map { |item|
|
101
|
+
Product.new(item)
|
102
|
+
}
|
103
|
+
dict['correspondence'] = dict.fetch('correspondence', []).map { |item|
|
104
|
+
CorrespondenceItem.new(item)
|
105
|
+
}
|
104
106
|
Dispute.new(dict)
|
105
107
|
when 'list'
|
106
108
|
dict['data'].map! { |item| convert item }
|
data/lib/chargehound/models.rb
CHANGED
data/lib/chargehound/version.rb
CHANGED
data/test/disputes_test.rb
CHANGED
@@ -75,18 +75,60 @@ dispute_with_product_info_response = {
|
|
75
75
|
]
|
76
76
|
}
|
77
77
|
|
78
|
-
|
78
|
+
dispute_with_correspondence_info_update = {
|
79
|
+
fields: {
|
80
|
+
customer_name: 'Susie'
|
81
|
+
},
|
82
|
+
correspondence: [
|
83
|
+
{
|
84
|
+
to: 'customer@example.com',
|
85
|
+
from: 'noreply@example.com',
|
86
|
+
subject: 'Your Order',
|
87
|
+
body: 'Your order was received.',
|
88
|
+
caption: 'Order confirmation email.'
|
89
|
+
}, {
|
90
|
+
to: 'customer@example.com',
|
91
|
+
from: 'noreply@example.com',
|
92
|
+
subject: 'Your Order',
|
93
|
+
body: 'Your order was delivered.',
|
94
|
+
caption: 'Delivery confirmation email.'
|
95
|
+
}
|
96
|
+
]
|
97
|
+
}
|
98
|
+
|
99
|
+
dispute_with_correspondence_info_response = {
|
79
100
|
id: 'dp_123',
|
80
101
|
object: 'dispute',
|
81
|
-
|
102
|
+
fields: {
|
103
|
+
customer_name: 'Susie'
|
104
|
+
},
|
105
|
+
correspondence: [
|
106
|
+
{
|
107
|
+
to: 'customer@example.com',
|
108
|
+
from: 'noreply@example.com',
|
109
|
+
subject: 'Your Order',
|
110
|
+
body: 'Your order was received.',
|
111
|
+
caption: 'Order confirmation email.'
|
112
|
+
}, {
|
113
|
+
to: 'customer@example.com',
|
114
|
+
from: 'noreply@example.com',
|
115
|
+
subject: 'Your Order',
|
116
|
+
body: 'Your order was delivered.',
|
117
|
+
caption: 'Delivery confirmation email.'
|
118
|
+
}
|
119
|
+
]
|
120
|
+
}
|
121
|
+
|
122
|
+
dispute_response = {
|
123
|
+
id: 'dp_123',
|
124
|
+
object: 'dispute'
|
82
125
|
}
|
83
126
|
|
84
127
|
dispute_list_response = {
|
85
128
|
object: 'list',
|
86
129
|
data: [{
|
87
130
|
id: 'dp_123',
|
88
|
-
object: 'dispute'
|
89
|
-
products: []
|
131
|
+
object: 'dispute'
|
90
132
|
}]
|
91
133
|
}
|
92
134
|
|
@@ -145,7 +187,8 @@ describe Chargehound::Disputes do
|
|
145
187
|
data: [{
|
146
188
|
id: 'dp_123',
|
147
189
|
object: 'dispute',
|
148
|
-
products: []
|
190
|
+
products: [],
|
191
|
+
correspondence: []
|
149
192
|
}],
|
150
193
|
response: {
|
151
194
|
status: '200'
|
@@ -174,6 +217,24 @@ describe Chargehound::Disputes do
|
|
174
217
|
assert_requested stub
|
175
218
|
end
|
176
219
|
|
220
|
+
it 'can list disputes filtered by state' do
|
221
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes?state=needs_response')
|
222
|
+
.with(headers: get_headers)
|
223
|
+
.to_return(body: dispute_list_response.to_json)
|
224
|
+
|
225
|
+
Chargehound::Disputes.list(state: %w[needs_response])
|
226
|
+
assert_requested stub
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'can list disputes filtered by multiple states' do
|
230
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes?state=needs_response&state=warning_needs_response')
|
231
|
+
.with(headers: get_headers)
|
232
|
+
.to_return(body: dispute_list_response.to_json)
|
233
|
+
|
234
|
+
Chargehound::Disputes.list(state: %w[needs_response warning_needs_response])
|
235
|
+
assert_requested stub
|
236
|
+
end
|
237
|
+
|
177
238
|
it 'can retrieve a dispute' do
|
178
239
|
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes/dp_123')
|
179
240
|
.with(headers: get_headers)
|
@@ -242,6 +303,34 @@ describe Chargehound::Disputes do
|
|
242
303
|
assert_requested stub
|
243
304
|
end
|
244
305
|
|
306
|
+
it 'can submit a dispute with correspondence data' do
|
307
|
+
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes/dp_123/submit')
|
308
|
+
.with(headers: post_headers,
|
309
|
+
body: dispute_with_correspondence_info_update.to_json)
|
310
|
+
.to_return(body: dispute_with_correspondence_info_response.to_json,
|
311
|
+
status: 201)
|
312
|
+
|
313
|
+
Chargehound::Disputes.submit('dp_123',
|
314
|
+
dispute_with_correspondence_info_update)
|
315
|
+
assert_requested stub
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'has a model for correspondence data' do
|
319
|
+
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes/dp_123/submit')
|
320
|
+
.with(headers: post_headers,
|
321
|
+
body: dispute_with_correspondence_info_update.to_json)
|
322
|
+
.to_return(body: dispute_with_correspondence_info_response.to_json,
|
323
|
+
status: 201)
|
324
|
+
|
325
|
+
dispute = Chargehound::Disputes.submit(
|
326
|
+
'dp_123', dispute_with_correspondence_info_update
|
327
|
+
)
|
328
|
+
|
329
|
+
assert_instance_of(Chargehound::CorrespondenceItem,
|
330
|
+
dispute.correspondence[0])
|
331
|
+
assert_requested stub
|
332
|
+
end
|
333
|
+
|
245
334
|
it 'can update a dispute' do
|
246
335
|
stub = stub_request(:put, 'https://api.chargehound.com/v1/disputes/dp_123')
|
247
336
|
.with(headers: post_headers, body: dispute_update.to_json)
|
@@ -260,4 +349,15 @@ describe Chargehound::Disputes do
|
|
260
349
|
Chargehound::Disputes.update('dp_123', dispute_with_product_info_update)
|
261
350
|
assert_requested stub
|
262
351
|
end
|
352
|
+
|
353
|
+
it 'can update a dispute with correspondence data' do
|
354
|
+
stub = stub_request(:put, 'https://api.chargehound.com/v1/disputes/dp_123')
|
355
|
+
.with(headers: post_headers,
|
356
|
+
body: dispute_with_correspondence_info_update.to_json)
|
357
|
+
.to_return(body: dispute_response.to_json)
|
358
|
+
|
359
|
+
Chargehound::Disputes.update('dp_123',
|
360
|
+
dispute_with_correspondence_info_update)
|
361
|
+
assert_requested stub
|
362
|
+
end
|
263
363
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargehound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chargehound
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
|
131
|
-
rubygems_version: 2.7.6
|
130
|
+
rubygems_version: 3.0.3
|
132
131
|
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: Ruby bindings for the Chargehound API
|