bitpay-sdk 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/bitpay-sdk-2.4.0.gem +0 -0
- data/features/step_definitions/refund_steps.rb +1 -0
- data/lib/bitpay/client.rb +16 -8
- data/lib/bitpay/rest_connector.rb +2 -2
- data/lib/bitpay/version.rb +1 -1
- data/spec/client_spec.rb +14 -0
- data/spec/fixtures/response-nodata.json +10 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a0b02cec388fe32a5afd21b0a9ad92340818107
|
4
|
+
data.tar.gz: d539b63ee8a0dca065562a5a5ebb6f539fb8d240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd3cb6688d3ba5387fccdf67c0cd9f044e7e5fd8978147d3d024831f2dc657ae751afd961418bc3cbfa35992438281bbc624e961bb88b5455cb72e8f55f9769
|
7
|
+
data.tar.gz: ad97799266a00b43413ccb956296ce27121a55201e7d8d7fdff1a4d3bb5295c35898ca56a65145c143f329820df1a3e180f25ad414e3e821a421248feb74a753
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
## [2.4.1] - 2015-03-11
|
6
|
+
### Fixed
|
7
|
+
- GitHub issue 40: error for endpoints that did not return a 'data' field
|
8
|
+
|
9
|
+
## [2.4.0] - 2015-03-05
|
10
|
+
### Changed
|
11
|
+
- Add feature: Accept refunds
|
12
|
+
- Fix Bug: Accept bitcoin payments like 0.003
|
Binary file
|
data/lib/bitpay/client.rb
CHANGED
@@ -47,7 +47,8 @@ module BitPay
|
|
47
47
|
# => Pass {pairingCode: 'WfD01d2'} to claim a server-initiated pairing code
|
48
48
|
#
|
49
49
|
def pair_client(params={})
|
50
|
-
post(path: 'tokens', params: params)
|
50
|
+
tokens = post(path: 'tokens', params: params)
|
51
|
+
return tokens["data"]
|
51
52
|
end
|
52
53
|
|
53
54
|
## Compatibility method for pos pairing
|
@@ -69,7 +70,8 @@ module BitPay
|
|
69
70
|
raise BitPay::ArgumentError, "Illegal Argument: Currency is invalid." unless /^[[:upper:]]{3}$/.match(currency)
|
70
71
|
params.merge!({price: price, currency: currency})
|
71
72
|
token = get_token(facade)
|
72
|
-
post(path: "invoices", token: token, params: params)
|
73
|
+
invoice = post(path: "invoices", token: token, params: params)
|
74
|
+
invoice["data"]
|
73
75
|
end
|
74
76
|
|
75
77
|
## Gets the privileged merchant-version of the invoice
|
@@ -77,13 +79,15 @@ module BitPay
|
|
77
79
|
#
|
78
80
|
def get_invoice(id:)
|
79
81
|
token = get_token('merchant')
|
80
|
-
get(path: "invoices/#{id}", token: token)
|
82
|
+
invoice = get(path: "invoices/#{id}", token: token)
|
83
|
+
invoice["data"]
|
81
84
|
end
|
82
85
|
|
83
86
|
## Gets the public version of the invoice
|
84
87
|
#
|
85
88
|
def get_public_invoice(id:)
|
86
|
-
get(path: "invoices/#{id}", public: true)
|
89
|
+
invoice = get(path: "invoices/#{id}", public: true)
|
90
|
+
invoice["data"]
|
87
91
|
end
|
88
92
|
|
89
93
|
|
@@ -102,7 +106,8 @@ module BitPay
|
|
102
106
|
#
|
103
107
|
def refund_invoice(id:, params:{})
|
104
108
|
invoice = get_invoice(id: id)
|
105
|
-
post(path: "invoices/#{id}/refunds", token: invoice["token"], params: params)
|
109
|
+
refund = post(path: "invoices/#{id}/refunds", token: invoice["token"], params: params)
|
110
|
+
refund["data"]
|
106
111
|
end
|
107
112
|
|
108
113
|
## Get All Refunds for Invoice
|
@@ -116,7 +121,8 @@ module BitPay
|
|
116
121
|
def get_all_refunds_for_invoice(id:)
|
117
122
|
urlpath = "invoices/#{id}/refunds"
|
118
123
|
invoice = get_invoice(id: id)
|
119
|
-
get(path: urlpath, token: invoice["token"])
|
124
|
+
refunds = get(path: urlpath, token: invoice["token"])
|
125
|
+
refunds["data"]
|
120
126
|
end
|
121
127
|
|
122
128
|
## Get Refund
|
@@ -128,7 +134,8 @@ module BitPay
|
|
128
134
|
def get_refund(invoice_id:, request_id:)
|
129
135
|
urlpath = "invoices/#{invoice_id}/refunds/#{request_id}"
|
130
136
|
invoice = get_invoice(id: invoice_id)
|
131
|
-
get(path: urlpath, token: invoice["token"])
|
137
|
+
refund = get(path: urlpath, token: invoice["token"])
|
138
|
+
refund["data"]
|
132
139
|
end
|
133
140
|
|
134
141
|
## Cancel Refund
|
@@ -140,7 +147,8 @@ module BitPay
|
|
140
147
|
def cancel_refund(invoice_id:, request_id:)
|
141
148
|
urlpath = "invoices/#{invoice_id}/refunds/#{request_id}"
|
142
149
|
refund = get_refund(invoice_id: invoice_id, request_id: request_id)
|
143
|
-
delete(path: urlpath, token: refund["token"])
|
150
|
+
deletion = delete(path: urlpath, token: refund["token"])
|
151
|
+
deletion["data"]
|
144
152
|
end
|
145
153
|
|
146
154
|
## Checks that the passed tokens are valid by
|
@@ -67,7 +67,7 @@ module BitPay
|
|
67
67
|
end
|
68
68
|
|
69
69
|
if response.kind_of? Net::HTTPSuccess
|
70
|
-
return JSON.parse(response.body)
|
70
|
+
return JSON.parse(response.body)
|
71
71
|
elsif JSON.parse(response.body)["error"]
|
72
72
|
raise(BitPayError, "#{response.code}: #{JSON.parse(response.body)['error']}")
|
73
73
|
else
|
@@ -80,7 +80,7 @@ module BitPay
|
|
80
80
|
# updates @tokens
|
81
81
|
#
|
82
82
|
def refresh_tokens
|
83
|
-
response = get(path: 'tokens')
|
83
|
+
response = get(path: 'tokens')["data"]
|
84
84
|
token_array = response || {}
|
85
85
|
tokens = {}
|
86
86
|
token_array.each do |t|
|
data/lib/bitpay/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -25,6 +25,12 @@ describe BitPay::SDK::Client do
|
|
25
25
|
to_return(:body => get_fixture('invoices_{id}_refunds-GET.json'))
|
26
26
|
stub_request(:post, "#{BitPay::TEST_API_URI}/invoices/TEST_INVOICE_ID/refunds").
|
27
27
|
to_return(:body => get_fixture('invoices_{id}_refunds-POST.json'))
|
28
|
+
stub_request(:post, "#{BitPay::TEST_API_URI}/nuttin").
|
29
|
+
to_return(:body => get_fixture('response-nodata.json'))
|
30
|
+
stub_request(:get, "#{BitPay::TEST_API_URI}/nuttin").
|
31
|
+
to_return(:body => get_fixture('response-nodata.json'))
|
32
|
+
stub_request(:delete, "#{BitPay::TEST_API_URI}/nuttin").
|
33
|
+
to_return(:body => get_fixture('response-nodata.json'))
|
28
34
|
end
|
29
35
|
|
30
36
|
describe "#initialize" do
|
@@ -36,6 +42,14 @@ describe BitPay::SDK::Client do
|
|
36
42
|
|
37
43
|
end
|
38
44
|
|
45
|
+
describe "requests to endpoint without data field" do
|
46
|
+
it "should return the json body" do
|
47
|
+
expect(bitpay_client.post(path: "nuttin", params: {})["facile"]).to eq("is easy")
|
48
|
+
expect(bitpay_client.get(path: "nuttin")["facile"]).to eq("is easy")
|
49
|
+
expect(bitpay_client.delete(path: "nuttin")["facile"]).to eq( "is easy")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
39
53
|
describe "#send_request" do
|
40
54
|
before do
|
41
55
|
stub_const('ENV', {'BITPAY_PEM' => PEM})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitpay-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitpay, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -215,11 +215,13 @@ extra_rdoc_files: []
|
|
215
215
|
files:
|
216
216
|
- ".gitignore"
|
217
217
|
- ".travis.yml"
|
218
|
+
- CHANGELOG.md
|
218
219
|
- GUIDE.md
|
219
220
|
- Gemfile
|
220
221
|
- LICENSE.md
|
221
222
|
- README.md
|
222
223
|
- Rakefile
|
224
|
+
- bitpay-sdk-2.4.0.gem
|
223
225
|
- bitpay-sdk.gemspec
|
224
226
|
- config/capybara.rb
|
225
227
|
- config/constants.rb
|
@@ -243,6 +245,7 @@ files:
|
|
243
245
|
- spec/fixtures/invoices_{id}_refunds-GET.json
|
244
246
|
- spec/fixtures/invoices_{id}_refunds-POST.json
|
245
247
|
- spec/fixtures/invoices_{id}_refunds_{refund_id}-GET.json
|
248
|
+
- spec/fixtures/response-nodata.json
|
246
249
|
- spec/key_utils_spec.rb
|
247
250
|
- spec/set_constants.sh
|
248
251
|
- spec/spec_helper.rb
|