bitpay-client 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e3d4eeb84cbc430b978aaab8c2c6899eca6fd09
4
- data.tar.gz: 5a57e02d962b091e29acd5d7c54ef5b96731fef3
3
+ metadata.gz: b89d858903869387224cbfc1bed0fa7af77bb3e0
4
+ data.tar.gz: 878dffb1f70d00f6bc68610282aa9c66b7eb257f
5
5
  SHA512:
6
- metadata.gz: 5054359ee0c707be7887f3e728511b26b90c005ac174ac6cc342da477f8e1478b6fc979fa598e7d9b486583531685bc1fcd4162d347223029ed2af800b120479
7
- data.tar.gz: 1798ad5abc4efe5ac95e5ce046c5d7ce6ae6fdd53e4438b7b697a12eff9fe0712ffbadfcecd149e3dace9ded3af1d8b372768faff7b40dd5b15592fe272eb26a
6
+ metadata.gz: 2dcb62011cba1efd946651a4b356e73074ffc1b72e8773727538d43d7cd072f4382d78c30db04461e729ffb9b934ccb106a6915cfb7d5095b9b326f452ebeb06
7
+ data.tar.gz: 36518bd2dc0bae3e6dde01b78b33a47d20a6fb1e0fa1ff27bf218a5cf7817cead605b6ded6f09b2a493adc8b0141cda1404c8185014fa1cd0157299b13781be8
data/.travis.yml CHANGED
@@ -3,5 +3,3 @@ rvm:
3
3
  - 1.9.3
4
4
  - jruby-18mode
5
5
  - jruby-19mode
6
- - rbx-18mode
7
- - rbx-19mode
data/README.md CHANGED
@@ -17,6 +17,7 @@ Or directly:
17
17
 
18
18
  To create an invoice:
19
19
 
20
+ client = BitPay::Client.new 'YOUR_API_KEY'
20
21
  invoice = client.post 'invoice', {:price => 10.00, :currency => 'USD'}
21
22
 
22
23
  With invoice creation, `price` and `currency` are the only required fields. If you are sending a customer from your website to make a purchase, setting `redirectURL` is
data/lib/bitpay/client.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'uri'
2
+ require 'net/https'
3
+ require 'json'
4
+
1
5
  module BitPay
2
6
  # This class is used to instantiate a BitPay Client object. It is expected to be thread safe.
3
7
  #
@@ -45,7 +49,8 @@ module BitPay
45
49
  request = Net::HTTP::Post.new @uri.path+'/'+path
46
50
  request.basic_auth @api_key, ''
47
51
  request['User-Agent'] = USER_AGENT
48
- request.body = params
52
+ request['Content-Type'] = 'application/json'
53
+ request.body = params.to_json
49
54
  response = @https.request request
50
55
  JSON.parse response.body
51
56
  end
@@ -1,3 +1,3 @@
1
1
  module BitPay
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/bitpay.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  libdir = File.dirname(__FILE__)
2
2
  $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
- require 'json'
4
- require 'uri'
5
- require 'net/https'
6
3
  require 'bitpay/client'
7
4
  require 'bitpay/version'
8
5
 
@@ -2,7 +2,11 @@ require File.join File.dirname(__FILE__), '..', 'env.rb'
2
2
 
3
3
  USER_AGENT = 'ruby-bitpay-client '+BitPay::VERSION
4
4
 
5
- def invoice_body
5
+ def invoice_create_body
6
+ {:price => 1, :currency => 'USD'}
7
+ end
8
+
9
+ def invoice_response_body
6
10
  {
7
11
  "id" => "DGrAEmbsXe9bavBPMJ8kuk",
8
12
  "url" => "https://bitpay.com/invoice?id=DGrAEmbsXe9bavBPMJ8kuk",
@@ -17,12 +21,15 @@ def invoice_body
17
21
  end
18
22
 
19
23
  stub_request(:post, "https://KEY:@bitpay.com/api/invoice/create").
20
- with(:headers => {'User-Agent'=>USER_AGENT}).
21
- to_return(:body => invoice_body.to_json)
24
+ with(
25
+ :headers => {'User-Agent'=>USER_AGENT, 'Content-Type' => 'application/json'},
26
+ :body => invoice_create_body
27
+ ).
28
+ to_return(:body => invoice_response_body.to_json)
22
29
 
23
30
  stub_request(:get, "https://KEY:@bitpay.com/api/invoice/DGrAEmbsXe9bavBPMJ8kuk").
24
31
  with(:headers => {'User-Agent'=>USER_AGENT}).
25
- to_return(:body => invoice_body.to_json)
32
+ to_return(:body => invoice_response_body.to_json)
26
33
 
27
34
  describe BitPay::Client do
28
35
  before do
@@ -31,7 +38,7 @@ describe BitPay::Client do
31
38
 
32
39
  describe 'post' do
33
40
  it 'creates invoice' do
34
- response = @client.post 'invoice/create', {}
41
+ response = @client.post 'invoice/create', invoice_create_body
35
42
  response.class.must_equal Hash
36
43
  response['id'].must_equal 'DGrAEmbsXe9bavBPMJ8kuk'
37
44
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Drake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-29 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json