localbitcoins 0.0.2 → 0.0.3

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: 328de725d7d4599c74ab908fd9ad80060ffbe506
4
- data.tar.gz: a2a025486733fb792f1451300e1881f8fbc72d76
3
+ metadata.gz: 9e26538ea5d0e612baff16fa2f93a3a5a7230e46
4
+ data.tar.gz: c1f6c5e4f42c2d26c9ad5b100f7bfa2ad5ca5432
5
5
  SHA512:
6
- metadata.gz: 12d1c22f51687f49306df32c0968999a9462981347a9b630e4f6cad74f69943ce0f8216e9ed2d7c5178cfe746bc48e201b537f42f17e7b17e1e694f93e204ed4
7
- data.tar.gz: 969062b433e58717379b54bbaac91652fc27b45327d4ef8f9f157632b35df77edb710e97dfce622f787914012335a85798db8fc0dda93d4e6c9ffb079e058b1d
6
+ metadata.gz: c125d972fab3ba0702599ddf27d25abee1deafc2b22dbc7206f935ae6528efb92cc75e1628ba93ab5afaf2f0ae241e9595a3029f7d423697d091dd9c6554a3fd
7
+ data.tar.gz: db8add4569e1b29a65d2010c59eb7f02041c10ecba0d846eeba33d73624e5254771a6c00176243f77e151134e6fcc73811507554eb6fb03ac9854d16e58aa0e6
data/.gitignore CHANGED
@@ -20,3 +20,6 @@ doc/
20
20
  # Vim temp files
21
21
  *~
22
22
  *.swp
23
+
24
+ # Gems
25
+ *.gem
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ localbitcoins (0.0.2)
5
+ activesupport (~> 3)
6
+ hashie (~> 2.0.2)
7
+ json (~> 1.8.0)
8
+ oauth (~> 0.4)
9
+ rest-client (~> 1.6)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (3.2.13)
15
+ i18n (= 0.6.1)
16
+ multi_json (~> 1.0)
17
+ addressable (2.3.5)
18
+ crack (0.4.0)
19
+ safe_yaml (~> 0.9.0)
20
+ diff-lcs (1.2.4)
21
+ hashie (2.0.5)
22
+ i18n (0.6.1)
23
+ json (1.8.0)
24
+ mime-types (1.23)
25
+ multi_json (1.7.7)
26
+ oauth (0.4.7)
27
+ rest-client (1.6.7)
28
+ mime-types (>= 1.16)
29
+ rspec (2.14.1)
30
+ rspec-core (~> 2.14.0)
31
+ rspec-expectations (~> 2.14.0)
32
+ rspec-mocks (~> 2.14.0)
33
+ rspec-core (2.14.2)
34
+ rspec-expectations (2.14.0)
35
+ diff-lcs (>= 1.1.3, < 2.0)
36
+ rspec-mocks (2.14.1)
37
+ safe_yaml (0.9.4)
38
+ webmock (1.13.0)
39
+ addressable (>= 2.2.7)
40
+ crack (>= 0.3.2)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ localbitcoins!
47
+ rspec (~> 2.13)
48
+ webmock (~> 1.11)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # LocalBitcoins API Client
1
+ # LocalBitcoins API Gem 0.0.2
2
2
 
3
- This gem provides a simple, extensible Ruby client to access the [LocalBitcoins API](https://localbitcoins.com/api-docs/).
3
+ This gem provides a simple, extensible Ruby wrapper to access the [LocalBitcoins API](https://localbitcoins.com/api-docs/).
4
+
5
+ THIS IS A WORK IN PROGRESS AND DOES NOT YET HAVE A TEST SUITE. DO NOT USE THIS IN PRODUCTION APPLICATIONS UNTIL THE TEST SUITE HAS BEEN WRITTEN. THANKS!
4
6
 
5
7
  ## Installation
6
8
 
@@ -4,6 +4,7 @@ require 'localbitcoins/client/ads'
4
4
 
5
5
  module LocalBitcoins
6
6
  class Client
7
+ include LocalBitcoins::Request
7
8
  include LocalBitcoins::Escrows
8
9
  include LocalBitcoins::Ads
9
10
 
@@ -1,5 +1,5 @@
1
1
  module LocalBitcoins
2
2
  unless defined?(LocalBitcoins::VERSION)
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
data/spec/client_spec.rb CHANGED
@@ -2,5 +2,21 @@ require 'spec_helper'
2
2
  require 'oauth'
3
3
 
4
4
  describe 'Client' do
5
+ describe '#escrows' do
6
+ let(:consumer) { OAuth::Consumer.new('CLIENT_ID', 'CLIENT_SECRET', site: 'https://www.localbitcoins.com') }
7
+ let(:token) { OAuth::AccessToken.new(consumer, 'ACCESS_TOKEN', 'ACCESS_SECRET') }
5
8
 
9
+ before do
10
+ stub_request(:get, "https://www.localbitcoins.com/oauth2/access_token").
11
+ to_return(status: 200, body: fixture('oauth_response.json'), headers: {})
12
+ end
13
+
14
+ it 'returns escrows owner of the access token can release' do
15
+ client = LocalBitcoins::Client.new(oauth_token: token)
16
+
17
+ escrows = client.escrows
18
+
19
+ escrows.should be_a Hashie::Mash
20
+ end
21
+ end
6
22
  end
File without changes
File without changes
@@ -0,0 +1,24 @@
1
+ {
2
+ "escrow_list": [
3
+ {
4
+ "data": {
5
+ "created_at": "2013-06-20T15:23:01.61",
6
+ "buyer_username": "alice",
7
+ "reference_code": "123",
8
+ },
9
+ "actions": {
10
+ "release_url": "/api/escrow_release/1/"
11
+ }
12
+ },
13
+ {
14
+ "data": {
15
+ "created_at": "2013-06-21T16:20:13.04",
16
+ "buyer_username": "bob",
17
+ "reference_code": "456",
18
+ },
19
+ "actions": {
20
+ "release_url": "/api/escrow_release/2/"
21
+ }
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "access_token": "ABC123UANDME",
3
+ "scope": "read",
4
+ "expires_in": "69",
5
+ "refresh_token": "REFRESH"
6
+ }
@@ -1,4 +1,54 @@
1
- require 'spec-helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'LocalBitcoins' do
4
+ describe '.new' do
5
+ it 'returns a new client instance' do
6
+ LocalBitcoins.new.should be_a LocalBitcoins::Client
7
+ end
8
+ end
9
+
10
+ describe '.configure' do
11
+ it 'sets a global configuration options' do
12
+ r = LocalBitcoins.configure(client_id: 'TEST_ID', client_secret: 'TEST_SECRET')
13
+ r.should be_a Hash
14
+ r.should have_key(:client_id)
15
+ r.should have_key(:client_secret)
16
+ r[:client_id].should eql('TEST_ID')
17
+ r[:client_secret].should eql('TEST_SECRET')
18
+ end
19
+
20
+ it 'raises ConfigurationError on invalid config parameter' do
21
+ proc { LocalBitcoins.configure(nil) }.
22
+ should raise_error(ArgumentError, "Options hash required.")
23
+
24
+ proc { LocalBitcoins.configure('foo') }.
25
+ should raise_error ArgumentError, "Options hash required."
26
+ end
27
+ end
28
+
29
+ describe '.configuration' do
30
+ before do
31
+ LocalBitcoins.configure(client_id: 'TEST_ID', client_secret: 'TEST_SECRET')
32
+ end
33
+
34
+ it 'returns global configuration options' do
35
+ r = LocalBitcoins.configuration
36
+ r.should be_a Hash
37
+ r.should have_key(:client_id)
38
+ r.should have_key(:client_secret)
39
+ r[:client_id].should eql('TEST_ID')
40
+ r[:client_secret].should eql('TEST_SECRET')
41
+ end
42
+ end
43
+
44
+ describe '.reset_configuration' do
45
+ before do
46
+ LocalBitcoins.configure(client_id: 'TEST_ID', client_secret: 'TEST_SECRET')
47
+ end
48
+
49
+ it 'resets global configuration options' do
50
+ LocalBitcoins.reset_configuration
51
+ LocalBitcoins.configuration.should eql({})
52
+ end
53
+ end
4
54
  end
data/spec/spec_helper.rb CHANGED
@@ -8,3 +8,43 @@ require 'webmock/rspec'
8
8
  RSpec.configure do |config|
9
9
  config.color_enabled = true
10
10
  end
11
+
12
+ def stub_get(path, fixture_name)
13
+ stub_request(:get, api_url(path)).
14
+ with(headers: {
15
+ 'Accept'=>'application/json'
16
+ }).
17
+ to_return(
18
+ status: 200,
19
+ body: fixture(fixture_name),
20
+ headers: {}
21
+ )
22
+ end
23
+
24
+ def stub_post(path, fixture_name)
25
+ stub_request(:put, api_url(path)).
26
+ with(
27
+ body: {},
28
+ headers: {
29
+ 'Accept' => 'application/json',
30
+ 'Content-Type' => 'application/json',
31
+ }).
32
+ to_return(
33
+ status: 200,
34
+ body: fixture(fixture_name),
35
+ headers: {}
36
+ )
37
+ end
38
+
39
+ def fixture_path(file=nil)
40
+ path = File.expand_path("../fixtures", __FILE__)
41
+ file.nil? ? path : File.join(path, file)
42
+ end
43
+
44
+ def fixture(file)
45
+ File.read(fixture_path(file))
46
+ end
47
+
48
+ def api_url(path)
49
+ "https://www.localbitcoins.com#{path}"
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localbitcoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Shutt
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
119
  - Gemfile
120
+ - Gemfile.lock
120
121
  - README.md
121
122
  - Rakefile
122
123
  - lib/localbitcoins.rb
@@ -128,6 +129,10 @@ files:
128
129
  - lib/localbitcoins/version.rb
129
130
  - localbitcoins.gemspec
130
131
  - spec/client_spec.rb
132
+ - spec/fixtures/ads.json
133
+ - spec/fixtures/escrow_release.json
134
+ - spec/fixtures/escrows.json
135
+ - spec/fixtures/oauth_response.json
131
136
  - spec/localbitcoins_spec.rb
132
137
  - spec/spec_helper.rb
133
138
  homepage: http://shutt.in