bitpay-client 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/bitpay/client.rb +21 -13
- data/lib/bitpay/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58908ccf542a4fde0d28f13ccd59c9aae77b4916
|
4
|
+
data.tar.gz: b50be1b001ab2a3a8cbf9e72619051e385855531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07d7b3a8ff9dd4d6fe2a1d78dbf2f96a32268b22801498e6d08908cd0d6d09c575bae3619312663b7add7bff569c1dcf747debc7572b93d5f3389efcee14dcd5
|
7
|
+
data.tar.gz: f6a7251e498a226f9e7d4f686ebb067b55a043c51a871c70db2aa4be15e81a43d56982a14c2de667c491f41ffb0bb3cb03dd4c1d5b80d4d979fe4369d3a7b2a8
|
data/README.md
CHANGED
@@ -42,6 +42,14 @@ To get updated information on this invoice, make a get call with the id returned
|
|
42
42
|
|
43
43
|
invoice = client.get 'invoice/DGrAEmbsXe9bavBPMJ8kuk'
|
44
44
|
|
45
|
+
## Testnet Usage
|
46
|
+
|
47
|
+
During development and testing, take advantage of the [Bitcoin TestNet](https://en.bitcoin.it/wiki/Testnet) by passing a custom `api_uri` option on initialization:
|
48
|
+
|
49
|
+
BitPay::Client.new("myAPIKey", {api_uri: "https://test.bitpay.com/api"})
|
50
|
+
|
51
|
+
Note that you will need a separate API key for `test.bitpay.com` which can be obtained by registering for a test account at https://test.bitpay.com/start
|
52
|
+
|
45
53
|
## API Documentation
|
46
54
|
|
47
55
|
API Documentation is available on the [BitPay site](https://bitpay.com/bitcoin-payment-gateway-api).
|
data/lib/bitpay/client.rb
CHANGED
@@ -37,11 +37,7 @@ module BitPay
|
|
37
37
|
# # Get an invoice:
|
38
38
|
# existing_invoice = client.get 'invoice/YOUR_INVOICE_ID'
|
39
39
|
def get(path)
|
40
|
-
request
|
41
|
-
request.basic_auth @api_key, ''
|
42
|
-
request['User-Agent'] = USER_AGENT
|
43
|
-
response = @https.request request
|
44
|
-
JSON.parse response.body
|
40
|
+
request(Net::HTTP::Get, path)
|
45
41
|
end
|
46
42
|
|
47
43
|
# Makes a POST call to the BitPay API.
|
@@ -50,15 +46,27 @@ module BitPay
|
|
50
46
|
# # Create an invoice:
|
51
47
|
# created_invoice = client.post 'invoice', {:price => 1.45, :currency => 'BTC'}
|
52
48
|
def post(path, params={})
|
49
|
+
request(Net::HTTP::Post, path, params)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def request(request_klass, path, params=nil)
|
55
|
+
request = make_request(request_klass, path, params)
|
56
|
+
response = @https.request(request)
|
57
|
+
return JSON.parse(response.body)
|
58
|
+
rescue => e
|
59
|
+
fail BitPayError, "Bitpay Request Error: #{e}"
|
60
|
+
end
|
53
61
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
def make_request(request_klass, path, params)
|
63
|
+
request_klass.new(@uri.path + '/' + path).tap do |r|
|
64
|
+
r.basic_auth @api_key, ''
|
65
|
+
r['User-Agent'] = USER_AGENT
|
66
|
+
r['Content-Type'] = 'application/json'
|
67
|
+
r['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION
|
68
|
+
r.body = params.to_json if params
|
69
|
+
end
|
62
70
|
end
|
63
71
|
end
|
64
72
|
end
|
data/lib/bitpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitpay-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitpay, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: 1.3.4
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project: bitpay-client
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.2.2
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Official ruby client library for the BitPay API
|