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 +4 -4
- data/.gitignore +3 -0
- data/Gemfile.lock +48 -0
- data/README.md +4 -2
- data/lib/localbitcoins/client.rb +1 -0
- data/lib/localbitcoins/version.rb +1 -1
- data/spec/client_spec.rb +16 -0
- data/spec/fixtures/ads.json +0 -0
- data/spec/fixtures/escrow_release.json +0 -0
- data/spec/fixtures/escrows.json +24 -0
- data/spec/fixtures/oauth_response.json +6 -0
- data/spec/localbitcoins_spec.rb +51 -1
- data/spec/spec_helper.rb +40 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e26538ea5d0e612baff16fa2f93a3a5a7230e46
|
4
|
+
data.tar.gz: c1f6c5e4f42c2d26c9ad5b100f7bfa2ad5ca5432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c125d972fab3ba0702599ddf27d25abee1deafc2b22dbc7206f935ae6528efb92cc75e1628ba93ab5afaf2f0ae241e9595a3029f7d423697d091dd9c6554a3fd
|
7
|
+
data.tar.gz: db8add4569e1b29a65d2010c59eb7f02041c10ecba0d846eeba33d73624e5254771a6c00176243f77e151134e6fcc73811507554eb6fb03ac9854d16e58aa0e6
|
data/.gitignore
CHANGED
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
|
1
|
+
# LocalBitcoins API Gem 0.0.2
|
2
2
|
|
3
|
-
This gem provides a simple, extensible Ruby
|
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
|
|
data/lib/localbitcoins/client.rb
CHANGED
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
|
+
}
|
data/spec/localbitcoins_spec.rb
CHANGED
@@ -1,4 +1,54 @@
|
|
1
|
-
require '
|
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.
|
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
|