chargehound 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG +6 -0
- data/README.md +27 -0
- data/chargehound.gemspec +0 -2
- data/lib/chargehound/api_request.rb +79 -38
- data/lib/chargehound/disputes.rb +20 -30
- data/lib/chargehound/models.rb +45 -0
- data/lib/chargehound/version.rb +1 -1
- data/test/disputes_test.rb +141 -8
- metadata +17 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa72d540f445fd4d59ce60f6b24fb5dbe6caa79d
|
4
|
+
data.tar.gz: 9667364aa8f85ea683df1c2d4fcea9430f025747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c403bacda18d58039275be0eb992b103d98efff3bfedb759d037ac72214e105da27252d4b1231e0b0fb2401362d4cda164b557147e04b6e1ad671089b7edc0c8
|
7
|
+
data.tar.gz: ab489aec72d890dd38bf8cd2ed6019fa0fa567f2704f8f016e2f290f24fd45a2e566cadd53aa2400e8fef8828246ef7d3ee03352fcb596810267c019c9ee450b
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -4,3 +4,9 @@
|
|
4
4
|
- Added APIs to pass product lists
|
5
5
|
1.2.0 July, 2016
|
6
6
|
- Added timeout option
|
7
|
+
2.0.0 October, 2016
|
8
|
+
- Add Dispute create method
|
9
|
+
- Add Dispute response retrieve method
|
10
|
+
- Expose response status codes
|
11
|
+
- Drop CI support for Ruby 1.9.3
|
12
|
+
- Add typed response models
|
data/README.md
CHANGED
@@ -15,6 +15,33 @@ require 'chargehound'
|
|
15
15
|
Chargehound.api_key = '{ YOUR_API_KEY }'
|
16
16
|
```
|
17
17
|
|
18
|
+
### Requests
|
19
|
+
|
20
|
+
Every resource is accessed via the Chargehound module.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Chargehound::Disputes.submit('dp_123', {
|
24
|
+
fields: {
|
25
|
+
customer_name: 'Susie'
|
26
|
+
}
|
27
|
+
})
|
28
|
+
```
|
29
|
+
|
30
|
+
### Responses
|
31
|
+
|
32
|
+
Responses from the API are automatically parsed from JSON and returned as Ruby objects.
|
33
|
+
|
34
|
+
Responses also include the HTTP status code on the response object as the status field.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
dispute = Chargehound::Disputes.retrieve('dp_123')
|
38
|
+
|
39
|
+
puts dispute.state
|
40
|
+
# 'needs_response'
|
41
|
+
puts dispute.response.status
|
42
|
+
# '200'
|
43
|
+
```
|
44
|
+
|
18
45
|
## Documentation
|
19
46
|
|
20
47
|
[Disputes](https://www.chargehound.com/docs/api/index.html?ruby#disputes)
|
data/chargehound.gemspec
CHANGED
@@ -14,8 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Automatically fight disputes in Stripe'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.add_dependency 'typhoeus', '<2.0'
|
18
|
-
|
19
17
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
20
18
|
spec.add_development_dependency 'minitest', '~> 5.8'
|
21
19
|
spec.add_development_dependency 'rake', '~> 11.1'
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'chargehound/models'
|
2
2
|
require 'chargehound/error'
|
3
3
|
require 'chargehound/version'
|
4
4
|
require 'json'
|
5
|
-
require '
|
5
|
+
require 'net/http'
|
6
6
|
|
7
7
|
module Chargehound
|
8
8
|
# Send a request to the Chargehound API
|
@@ -12,68 +12,109 @@ module Chargehound
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
host = @request.uri.host
|
16
|
+
port = @request.uri.port
|
17
|
+
Net::HTTP.start(host, port, build_http_opts) do |http|
|
18
|
+
begin
|
19
|
+
response = http.request @request
|
20
|
+
handle_response response
|
21
|
+
rescue Net::ReadTimeout
|
22
|
+
raise ChargehoundError.create_timeout_error
|
23
|
+
rescue Timeout::Error
|
24
|
+
raise ChargehoundError.create_timeout_error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
20
28
|
|
21
|
-
|
29
|
+
def handle_response(response)
|
30
|
+
case response
|
31
|
+
when Net::HTTPSuccess
|
32
|
+
parse_response response
|
33
|
+
when Net::HTTPRequestTimeOut
|
34
|
+
raise ChargehoundError.create_timeout_error
|
35
|
+
else
|
36
|
+
body = JSON.parse response.body
|
22
37
|
raise ChargehoundError.create_chargehound_error body
|
23
38
|
end
|
39
|
+
end
|
24
40
|
|
25
|
-
|
41
|
+
def build_http_opts
|
42
|
+
{
|
43
|
+
use_ssl: true,
|
44
|
+
read_timeout: Chargehound.timeout
|
45
|
+
}
|
26
46
|
end
|
27
47
|
|
28
|
-
def build_headers(
|
48
|
+
def build_headers(body)
|
29
49
|
headers = {
|
30
50
|
'Accept' => 'application/json',
|
31
|
-
'Authorization' =>
|
32
|
-
"Basic #{Base64.encode64(Chargehound.api_key + ':').chomp}",
|
33
51
|
'User-Agent' => "Chargehound/v1 RubyBindings/#{VERSION}"
|
34
52
|
}
|
35
|
-
|
53
|
+
body && headers['Content-Type'] = 'application/json'
|
36
54
|
headers
|
37
55
|
end
|
38
56
|
|
39
|
-
def build_body(
|
40
|
-
if
|
41
|
-
req_body = build_request_body opts[:body]
|
42
|
-
req_opts.update body: req_body
|
43
|
-
end
|
57
|
+
def build_body(body)
|
58
|
+
body.to_json if body
|
44
59
|
end
|
45
60
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
def build_request_instance(http_method, uri, body, headers)
|
62
|
+
case http_method
|
63
|
+
when :get
|
64
|
+
Net::HTTP::Get.new uri, headers
|
65
|
+
when :put
|
66
|
+
req = Net::HTTP::Put.new uri, headers
|
67
|
+
req.body = body
|
68
|
+
req
|
69
|
+
when :post
|
70
|
+
req = Net::HTTP::Post.new uri, headers
|
71
|
+
req.body = body
|
72
|
+
req
|
73
|
+
end
|
57
74
|
end
|
58
75
|
|
59
76
|
def build_request(http_method, path, opts = {})
|
60
|
-
|
77
|
+
query_params = opts[:query_params] || {}
|
78
|
+
body = opts[:body]
|
61
79
|
http_method = http_method.to_sym.downcase
|
62
|
-
req_opts = build_opts http_method, opts
|
63
80
|
|
64
|
-
|
81
|
+
uri = build_uri path, query_params
|
82
|
+
headers = build_headers body
|
83
|
+
body = build_body body
|
84
|
+
|
85
|
+
req = build_request_instance http_method, uri, body, headers
|
86
|
+
req.basic_auth Chargehound.api_key, ''
|
87
|
+
req
|
65
88
|
end
|
66
89
|
|
67
|
-
def
|
68
|
-
'https://' + Chargehound.host + Chargehound.base_path + path
|
90
|
+
def build_uri(path, query_params)
|
91
|
+
url = 'https://' + Chargehound.host + Chargehound.base_path + path
|
92
|
+
uri = URI(url)
|
93
|
+
uri.query = URI.encode_www_form(query_params)
|
94
|
+
uri
|
69
95
|
end
|
70
96
|
|
71
|
-
def
|
72
|
-
|
97
|
+
def convert(dict)
|
98
|
+
case dict['object']
|
99
|
+
when 'dispute'
|
100
|
+
dict['products'].map! { |item| Product.new(item) }
|
101
|
+
Dispute.new(dict)
|
102
|
+
when 'list'
|
103
|
+
dict['data'].map! { |item| convert item }
|
104
|
+
list = List.new(dict)
|
105
|
+
list
|
106
|
+
when 'response'
|
107
|
+
Response.new(dict)
|
108
|
+
else
|
109
|
+
ChargehoundObject.new
|
110
|
+
end
|
73
111
|
end
|
74
112
|
|
75
|
-
def
|
76
|
-
JSON.parse body
|
113
|
+
def parse_response(response)
|
114
|
+
body = JSON.parse response.body
|
115
|
+
body = convert body
|
116
|
+
body.response = HTTPResponse.new(response.code)
|
117
|
+
body
|
77
118
|
end
|
78
119
|
end
|
79
120
|
end
|
data/lib/chargehound/disputes.rb
CHANGED
@@ -3,17 +3,18 @@ require 'chargehound/api_request'
|
|
3
3
|
module Chargehound
|
4
4
|
# Access the Chargehound dispute resource
|
5
5
|
class Disputes
|
6
|
+
# Create a dispute
|
7
|
+
# @option [Hash] A dispute create object
|
8
|
+
# @return [Dispute]
|
9
|
+
def self.create(create = {})
|
10
|
+
ApiRequest.new(:post, 'disputes', body: create).run
|
11
|
+
end
|
12
|
+
|
6
13
|
# A list of disputes
|
7
14
|
# This endpoint will list all the disputes that we have synced from Stripe.
|
8
15
|
# By default the disputes will be ordered by `created` with the most recent
|
9
16
|
# dispute first. { }`has_more` will be `true` if more results are available.
|
10
|
-
# @option [Hash] params the
|
11
|
-
# @option params [Float] :limit Maximum number of disputes to return.
|
12
|
-
# Default is 20, maximum is 100.
|
13
|
-
# @option params [String] :starting_after A dispute id.
|
14
|
-
# Fetch disputes created after this dispute.
|
15
|
-
# @option params [String] :ending_before A dispute id.
|
16
|
-
# Fetch disputes created before this dispute.
|
17
|
+
# @option [Hash] params the query parameters
|
17
18
|
# @return [Disputes]
|
18
19
|
def self.list(params = {})
|
19
20
|
ApiRequest.new(:get, 'disputes', query_params: params).run
|
@@ -21,12 +22,19 @@ module Chargehound
|
|
21
22
|
|
22
23
|
# Retrieve a dispute
|
23
24
|
# This endpoint will return a single dispute.
|
24
|
-
# @param dispute_id A dispute id
|
25
|
+
# @param [String] dispute_id A dispute id
|
25
26
|
# @return [Dispute]
|
26
27
|
def self.retrieve(dispute_id)
|
27
28
|
ApiRequest.new(:get, "disputes/#{dispute_id}").run
|
28
29
|
end
|
29
30
|
|
31
|
+
# Retrieve the response for a dispute.
|
32
|
+
# @param [String] dispute_id A dispute id
|
33
|
+
# @return [Dispute]
|
34
|
+
def self.response(dispute_id)
|
35
|
+
ApiRequest.new(:get, "disputes/#{dispute_id}/response").run
|
36
|
+
end
|
37
|
+
|
30
38
|
# Submitting a dispute
|
31
39
|
# You will want to submit the dispute through Chargehound after you recieve
|
32
40
|
# a notification from Stripe of a new dispute. With one `POST` request
|
@@ -36,38 +44,20 @@ module Chargehound
|
|
36
44
|
# The dispute will also be in the submitted state.
|
37
45
|
# @param dispute_id A dispute id
|
38
46
|
# @option [Hash] update A dispute update object
|
39
|
-
# @option update [String] :template The id of the template to use.
|
40
|
-
# @option update [Object] :fields Key value pairs to hydrate the
|
41
|
-
# template's evidence fields.
|
42
|
-
# @option update [Object] :products List of products the customer
|
43
|
-
# purchased.
|
44
|
-
# @option update [String] :customer_name Update the customer name.
|
45
|
-
# Will also update the customer name in the evidence fields.
|
46
|
-
# @option update [String] :customer_email Update the customer email.
|
47
|
-
# Will also update the customer email in the evidence fields.
|
48
|
-
# Must be a valid email address.
|
49
47
|
# @return [Dispute]
|
50
48
|
def self.submit(dispute_id, update = {})
|
51
|
-
ApiRequest.new(:post, "disputes/#{dispute_id}/submit",
|
49
|
+
ApiRequest.new(:post, "disputes/#{dispute_id}/submit",
|
50
|
+
body: update).run
|
52
51
|
end
|
53
52
|
|
54
53
|
# Updating a dispute
|
55
54
|
# You can update the template and the fields on a dispute.
|
56
55
|
# @param dispute_id A dispute id
|
57
56
|
# @option [Hash] update A dispute update object
|
58
|
-
# @option update [String] :template The id of the template to use.
|
59
|
-
# @option update [Object] :fields Key value pairs to hydrate the template's
|
60
|
-
# evidence fields.
|
61
|
-
# @option update [Object] :products List of products the customer
|
62
|
-
# purchased.
|
63
|
-
# @option update [String] :customer_name Update the customer name.
|
64
|
-
# Will also update the customer name in the evidence fields.
|
65
|
-
# @option update [String] :customer_email Update the customer email.
|
66
|
-
# Will also update the customer email in the evidence fields.
|
67
|
-
# Must be a valid email address.
|
68
57
|
# @return [Dispute]
|
69
58
|
def self.update(dispute_id, update = {})
|
70
|
-
ApiRequest.new(:put, "disputes/#{dispute_id}",
|
59
|
+
ApiRequest.new(:put, "disputes/#{dispute_id}",
|
60
|
+
body: update).run
|
71
61
|
end
|
72
62
|
end
|
73
63
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Chargehound
|
4
|
+
# Base class for Chargehound models
|
5
|
+
class ChargehoundObject < OpenStruct
|
6
|
+
def to_json(*a)
|
7
|
+
as_json(*a).to_json
|
8
|
+
end
|
9
|
+
|
10
|
+
def as_json(*_a)
|
11
|
+
hash = {}
|
12
|
+
each_pair do |key, value|
|
13
|
+
hash[key] = convert(value)
|
14
|
+
end
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def convert(value)
|
19
|
+
if value.is_a?(OpenStruct)
|
20
|
+
value.as_json
|
21
|
+
elsif value.is_a?(Array)
|
22
|
+
value.map { |item| convert(item) }
|
23
|
+
elsif value.is_a?(Struct)
|
24
|
+
value.to_h
|
25
|
+
else
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Dispute < ChargehoundObject
|
32
|
+
end
|
33
|
+
|
34
|
+
class Response < ChargehoundObject
|
35
|
+
end
|
36
|
+
|
37
|
+
class List < ChargehoundObject
|
38
|
+
end
|
39
|
+
|
40
|
+
class Product < ChargehoundObject
|
41
|
+
end
|
42
|
+
|
43
|
+
# Expose response properties via this struct on response objects
|
44
|
+
HTTPResponse = Struct.new(:status)
|
45
|
+
end
|
data/lib/chargehound/version.rb
CHANGED
data/test/disputes_test.rb
CHANGED
@@ -13,6 +13,10 @@ post_headers = {
|
|
13
13
|
'User-Agent' => "Chargehound/v1 RubyBindings/#{Chargehound::VERSION}"
|
14
14
|
}
|
15
15
|
|
16
|
+
dispute_create = {
|
17
|
+
id: 'dp_123'
|
18
|
+
}
|
19
|
+
|
16
20
|
dispute_update = {
|
17
21
|
fields: {
|
18
22
|
customer_name: 'Susie'
|
@@ -44,9 +48,52 @@ dispute_with_product_info_update = {
|
|
44
48
|
]
|
45
49
|
}
|
46
50
|
|
51
|
+
dispute_with_product_info_response = {
|
52
|
+
id: 'dp_123',
|
53
|
+
object: 'dispute',
|
54
|
+
fields: {
|
55
|
+
customer_name: 'Susie'
|
56
|
+
},
|
57
|
+
products: [
|
58
|
+
{
|
59
|
+
name: 'Saxophone',
|
60
|
+
description: 'Alto saxophone, with carrying case',
|
61
|
+
image: 'http://s3.amazonaws.com/chargehound/saxophone.png',
|
62
|
+
sku: '17283001272',
|
63
|
+
quantity: 1,
|
64
|
+
amount: 20_000,
|
65
|
+
url: 'http://www.example.com'
|
66
|
+
}, {
|
67
|
+
name: 'Milk',
|
68
|
+
description: 'Semi-skimmed Organic',
|
69
|
+
image: 'http://s3.amazonaws.com/chargehound/milk.png',
|
70
|
+
sku: '26377382910',
|
71
|
+
quantity: '64oz',
|
72
|
+
amount: 400,
|
73
|
+
url: 'http://www.example.com'
|
74
|
+
}
|
75
|
+
]
|
76
|
+
}
|
77
|
+
|
47
78
|
dispute_response = {
|
48
|
-
|
49
|
-
|
79
|
+
id: 'dp_123',
|
80
|
+
object: 'dispute',
|
81
|
+
products: []
|
82
|
+
}
|
83
|
+
|
84
|
+
dispute_list_response = {
|
85
|
+
object: 'list',
|
86
|
+
data: [{
|
87
|
+
id: 'dp_123',
|
88
|
+
object: 'dispute',
|
89
|
+
products: []
|
90
|
+
}]
|
91
|
+
}
|
92
|
+
|
93
|
+
response_response = {
|
94
|
+
dispute_id: 'dp_123',
|
95
|
+
object: 'response'
|
96
|
+
}
|
50
97
|
|
51
98
|
describe Chargehound::Disputes do
|
52
99
|
before do
|
@@ -57,10 +104,71 @@ describe Chargehound::Disputes do
|
|
57
104
|
WebMock.reset!
|
58
105
|
end
|
59
106
|
|
107
|
+
it 'can expose the response status code' do
|
108
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes')
|
109
|
+
.with(headers: get_headers)
|
110
|
+
.to_return(body: dispute_list_response.to_json)
|
111
|
+
|
112
|
+
list = Chargehound::Disputes.list
|
113
|
+
assert_requested stub
|
114
|
+
assert_equal('200', list.response.status)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'uses typed response objects' do
|
118
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes')
|
119
|
+
.with(headers: get_headers)
|
120
|
+
.to_return(body: dispute_list_response.to_json)
|
121
|
+
|
122
|
+
list = Chargehound::Disputes.list
|
123
|
+
assert_requested stub
|
124
|
+
|
125
|
+
assert_instance_of(Chargehound::List, list)
|
126
|
+
assert_instance_of(Chargehound::Dispute, list.data[0])
|
127
|
+
|
128
|
+
assert_equal('list', list.object)
|
129
|
+
assert_equal('dp_123', list.data[0].id)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'typed response objects can be JSON stringified' do
|
133
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes')
|
134
|
+
.with(headers: get_headers)
|
135
|
+
.to_return(body: dispute_list_response.to_json)
|
136
|
+
|
137
|
+
list = Chargehound::Disputes.list
|
138
|
+
assert_requested stub
|
139
|
+
|
140
|
+
list_hash = list.as_json
|
141
|
+
list_json = list.to_json
|
142
|
+
|
143
|
+
response = {
|
144
|
+
object: 'list',
|
145
|
+
data: [{
|
146
|
+
id: 'dp_123',
|
147
|
+
object: 'dispute',
|
148
|
+
products: []
|
149
|
+
}],
|
150
|
+
response: {
|
151
|
+
status: '200'
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
assert_equal(response, list_hash)
|
156
|
+
assert_equal(response.to_json, list_json)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'can create a dispute' do
|
160
|
+
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes')
|
161
|
+
.with(headers: post_headers)
|
162
|
+
.to_return(body: dispute_response.to_json)
|
163
|
+
|
164
|
+
Chargehound::Disputes.create(dispute_create)
|
165
|
+
assert_requested stub
|
166
|
+
end
|
167
|
+
|
60
168
|
it 'can list disputes' do
|
61
169
|
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes')
|
62
170
|
.with(headers: get_headers)
|
63
|
-
.to_return(body:
|
171
|
+
.to_return(body: dispute_list_response.to_json)
|
64
172
|
|
65
173
|
Chargehound::Disputes.list
|
66
174
|
assert_requested stub
|
@@ -69,17 +177,28 @@ describe Chargehound::Disputes do
|
|
69
177
|
it 'can retrieve a dispute' do
|
70
178
|
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes/dp_123')
|
71
179
|
.with(headers: get_headers)
|
72
|
-
.to_return(body: dispute_response)
|
180
|
+
.to_return(body: dispute_response.to_json)
|
73
181
|
|
74
182
|
Chargehound::Disputes.retrieve('dp_123')
|
75
183
|
assert_requested stub
|
76
184
|
end
|
77
185
|
|
186
|
+
it 'can retrieve a dispute response' do
|
187
|
+
stub = stub_request(:get, 'https://api.chargehound.com/v1/disputes/dp_123/response')
|
188
|
+
.with(headers: get_headers)
|
189
|
+
.to_return(body: response_response.to_json)
|
190
|
+
|
191
|
+
response = Chargehound::Disputes.response('dp_123')
|
192
|
+
assert_instance_of(Chargehound::Response, response)
|
193
|
+
assert_equal('dp_123', response.dispute_id)
|
194
|
+
assert_requested stub
|
195
|
+
end
|
196
|
+
|
78
197
|
it 'can submit a dispute' do
|
79
198
|
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes/dp_123/submit')
|
80
199
|
.with(headers: post_headers,
|
81
200
|
body: dispute_update.to_json)
|
82
|
-
.to_return(body: dispute_response,
|
201
|
+
.to_return(body: dispute_response.to_json,
|
83
202
|
status: 201)
|
84
203
|
|
85
204
|
Chargehound::Disputes.submit('dp_123', dispute_update)
|
@@ -90,17 +209,31 @@ describe Chargehound::Disputes do
|
|
90
209
|
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes/dp_123/submit')
|
91
210
|
.with(headers: post_headers,
|
92
211
|
body: dispute_with_product_info_update.to_json)
|
93
|
-
.to_return(body:
|
212
|
+
.to_return(body: dispute_with_product_info_response.to_json,
|
94
213
|
status: 201)
|
95
214
|
|
96
215
|
Chargehound::Disputes.submit('dp_123', dispute_with_product_info_update)
|
97
216
|
assert_requested stub
|
98
217
|
end
|
99
218
|
|
219
|
+
it 'has a model for product data' do
|
220
|
+
stub = stub_request(:post, 'https://api.chargehound.com/v1/disputes/dp_123/submit')
|
221
|
+
.with(headers: post_headers,
|
222
|
+
body: dispute_with_product_info_update.to_json)
|
223
|
+
.to_return(body: dispute_with_product_info_response.to_json,
|
224
|
+
status: 201)
|
225
|
+
|
226
|
+
dispute = Chargehound::Disputes.submit('dp_123',
|
227
|
+
dispute_with_product_info_update)
|
228
|
+
|
229
|
+
assert_instance_of(Chargehound::Product, dispute.products[0])
|
230
|
+
assert_requested stub
|
231
|
+
end
|
232
|
+
|
100
233
|
it 'can update a dispute' do
|
101
234
|
stub = stub_request(:put, 'https://api.chargehound.com/v1/disputes/dp_123')
|
102
235
|
.with(headers: post_headers, body: dispute_update.to_json)
|
103
|
-
.to_return(body: dispute_response)
|
236
|
+
.to_return(body: dispute_response.to_json)
|
104
237
|
|
105
238
|
Chargehound::Disputes.update('dp_123', dispute_update)
|
106
239
|
assert_requested stub
|
@@ -110,7 +243,7 @@ describe Chargehound::Disputes do
|
|
110
243
|
stub = stub_request(:put, 'https://api.chargehound.com/v1/disputes/dp_123')
|
111
244
|
.with(headers: post_headers,
|
112
245
|
body: dispute_with_product_info_update.to_json)
|
113
|
-
.to_return(body: dispute_response)
|
246
|
+
.to_return(body: dispute_response.to_json)
|
114
247
|
|
115
248
|
Chargehound::Disputes.update('dp_123', dispute_with_product_info_update)
|
116
249
|
assert_requested stub
|
metadata
CHANGED
@@ -1,69 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargehound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chargehound
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: typhoeus
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - <
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - <
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- - ~>
|
17
|
+
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
19
|
version: '1.5'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- - ~>
|
24
|
+
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: '1.5'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: minitest
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - ~>
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: '5.8'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - ~>
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '5.8'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - ~>
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '11.1'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - ~>
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '11.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
@@ -84,14 +70,14 @@ dependencies:
|
|
84
70
|
name: webmock
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - ~>
|
73
|
+
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: '2.0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- - ~>
|
80
|
+
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '2.0'
|
97
83
|
description: Automatically fight disputes in Stripe
|
@@ -102,9 +88,9 @@ extensions: []
|
|
102
88
|
extra_rdoc_files:
|
103
89
|
- README.md
|
104
90
|
files:
|
105
|
-
- .gitignore
|
106
|
-
- .rubocop.yml
|
107
|
-
- .travis.yml
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".travis.yml"
|
108
94
|
- CHANGELOG
|
109
95
|
- Gemfile
|
110
96
|
- LICENSE
|
@@ -116,6 +102,7 @@ files:
|
|
116
102
|
- lib/chargehound/api_request.rb
|
117
103
|
- lib/chargehound/disputes.rb
|
118
104
|
- lib/chargehound/error.rb
|
105
|
+
- lib/chargehound/models.rb
|
119
106
|
- lib/chargehound/version.rb
|
120
107
|
- test/chargehound_test.rb
|
121
108
|
- test/disputes_test.rb
|
@@ -131,17 +118,17 @@ require_paths:
|
|
131
118
|
- lib
|
132
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
120
|
requirements:
|
134
|
-
- -
|
121
|
+
- - ">="
|
135
122
|
- !ruby/object:Gem::Version
|
136
123
|
version: 1.9.3
|
137
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
125
|
requirements:
|
139
|
-
- -
|
126
|
+
- - ">="
|
140
127
|
- !ruby/object:Gem::Version
|
141
128
|
version: '0'
|
142
129
|
requirements: []
|
143
130
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.5.1
|
145
132
|
signing_key:
|
146
133
|
specification_version: 4
|
147
134
|
summary: Ruby bindings for the Chargehound API
|