bitreserve 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +238 -7
- data/lib/bitreserve/api/auth_token.rb +6 -5
- data/lib/bitreserve/api/endpoints.rb +1 -1
- data/lib/bitreserve/request.rb +4 -12
- data/lib/bitreserve/request_data.rb +2 -2
- data/lib/bitreserve/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/pats.yml +61 -0
- data/spec/integration/api/auth_token_spec.rb +20 -0
- data/spec/support/webmock.rb +0 -13
- data/spec/unit/api/auth_spec.rb +2 -3
- data/spec/unit/request_spec.rb +16 -3
- metadata +6 -4
- data/spec/unit/auth_request_spec.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f186b06c781c63fe87bc6e16c2528b51fe2f9c6a
|
4
|
+
data.tar.gz: bd8d53c2aa34b64500f6a2bebe7d616510452d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ae05f969c7e315f6c6f1723c9269b7c8962678b93f5971d75bca765110223fe0e978995e026ad445729c342e72388e0d4c7b56e235f8a576247f8979dec98f
|
7
|
+
data.tar.gz: 94e73c2fb2aa3d2c6c17854f4d5277c71eab2fa138ece11256aff22c10482652b153fe7833eb8b15beab284176ae45b5c9f63dc1e16a8d748e66ee5f328d5315
|
data/README.md
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/groupbuddies/bitreserve/badges/gpa.svg)](https://codeclimate.com/github/groupbuddies/bitreserve)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/groupbuddies/bitreserve/badges/coverage.svg)](https://codeclimate.com/github/groupbuddies/bitreserve)
|
7
7
|
|
8
|
-
|
8
|
+
A ruby client for the [Bitreserve](https://bitreserve.org/) API.
|
9
9
|
|
10
|
-
|
10
|
+
# Installation
|
11
11
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
@@ -23,14 +23,245 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
$ gem install bitreserve
|
25
25
|
|
26
|
-
|
26
|
+
# Contents
|
27
27
|
|
28
|
-
|
28
|
+
* [Usage](#usage)
|
29
|
+
* [Creating an authenticated client](#creating-an-authenticated-client)
|
30
|
+
* [Personal Access Token](#personal-access-token)
|
31
|
+
* [Via argument](#via-argument)
|
32
|
+
* [Via environment variable](#via-environment-variable)
|
33
|
+
* [Endpoints](#endpoints)
|
34
|
+
* [Authentication](#authentication)
|
35
|
+
* [OAuth2](#oauth2)
|
36
|
+
* [Basic Authentication](#basic-authentication)
|
37
|
+
* [Tickers](#tickers)
|
38
|
+
* [Entities](#entities)
|
39
|
+
* [Cards](#cards)
|
40
|
+
* [Transactions](#transactions)
|
41
|
+
* [Public Transactions](#public-transactions)
|
42
|
+
* [Private Transactions](#private-transactions)
|
43
|
+
* [Contacts](#contacts)
|
44
|
+
* [Users](#users)
|
45
|
+
* [Transparency](#transparency)
|
46
|
+
* [Contributing](#contributing)
|
29
47
|
|
30
|
-
|
48
|
+
# Usage
|
31
49
|
|
32
|
-
|
50
|
+
To use the gem, you have to instantiate a client. All API calls are made from there. Here's a minimal working example:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'bitreserve'
|
54
|
+
|
55
|
+
client = Bitreserve::Client.new
|
56
|
+
puts client.all_tickers
|
57
|
+
```
|
58
|
+
|
59
|
+
# Creating an authenticated client
|
60
|
+
|
61
|
+
In order to make most of the API calls, you will need to authenticate your
|
62
|
+
client. Here's how you can do that.
|
63
|
+
|
64
|
+
## Personal Access Token
|
65
|
+
|
66
|
+
If you already have a token, you can use it by setting an environment variable,
|
67
|
+
or by passing it when instantiating the client.
|
68
|
+
|
69
|
+
### Via argument
|
70
|
+
|
71
|
+
Pass the token to the constructor:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
Bitreserve::Client.new(token: 'your-access-token')
|
75
|
+
```
|
76
|
+
|
77
|
+
### Via environment variable
|
78
|
+
|
79
|
+
Set the environment variable using [dotenv](https://github.com/bkeepers/dotenv), or by exporting it in your shell:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
$ export BITRESERVE_AUTH_TOKEN="your-access-token"
|
83
|
+
```
|
84
|
+
|
85
|
+
Then instantiate the client:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
Bitreserve::Client.new
|
89
|
+
```
|
90
|
+
|
91
|
+
# Endpoints
|
92
|
+
|
93
|
+
This is a comprehensive list of all the mappings between this wrapper and the
|
94
|
+
Bitreserve's API.
|
95
|
+
|
96
|
+
## Authentication
|
97
|
+
|
98
|
+
[*Bitreserve documentation on authentication*](https://developer.bitreserve.org/api/v0/#authentication)
|
99
|
+
|
100
|
+
### OAuth2
|
101
|
+
|
102
|
+
**NOT SUPPORTED YET**
|
103
|
+
|
104
|
+
### Basic Authentication
|
105
|
+
|
106
|
+
TODO
|
107
|
+
|
108
|
+
## Tickers
|
109
|
+
|
110
|
+
[*Bitreserve documentation on tickers*](https://developer.bitreserve.org/api/v0/#tickers)
|
111
|
+
|
112
|
+
**Return the current rates on Bitreserve for all currency pairs:**
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
client.all_tickers
|
116
|
+
```
|
117
|
+
|
118
|
+
**Return the current rates on Bitreserve for a specific currency:**
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
client.find_ticker(currency: 'EUR')
|
122
|
+
```
|
123
|
+
|
124
|
+
## Cards
|
125
|
+
|
126
|
+
[*Bitreserve documentation on cards*](https://developer.bitreserve.org/api/v0/#cards)
|
127
|
+
|
128
|
+
**Return all the user's cards:**
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
client.all_cards
|
132
|
+
```
|
133
|
+
|
134
|
+
**Return the details for a specific card associated with the user:**
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
client.find_card(id: '37e002a7-8508-4268-a18c-7335a6ddf24b')
|
138
|
+
```
|
139
|
+
|
140
|
+
**Create a card for the user:**
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
client.create_card(label: 'My label', currency: 'BTC')
|
144
|
+
```
|
145
|
+
|
146
|
+
## Transactions
|
147
|
+
|
148
|
+
[*Bitreserve documentation on transactions*](https://developer.bitreserve.org/api/v0/#transactions)
|
149
|
+
|
150
|
+
You can interact with both the authenticated user's and public transactions.
|
151
|
+
|
152
|
+
### Public Transactions
|
153
|
+
|
154
|
+
**Return the public view of all transactions in the reserve:**
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
client.all_public_transactions
|
158
|
+
```
|
159
|
+
|
160
|
+
**Return the public view of a specific transaction:**
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
client.find_public_transactions(id: 'a97bb994-6e24-4a89-b653-e0a6d0bcf634')
|
164
|
+
```
|
165
|
+
|
166
|
+
### Private Transactions
|
167
|
+
|
168
|
+
**Create a transaction:**
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
client.create_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', currency:
|
172
|
+
'BTC', amount: 0.1, destination: 'foo@bar.com')
|
173
|
+
```
|
174
|
+
|
175
|
+
**Commit a transaction:**
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
client.commit_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', transaction_id:
|
179
|
+
'd51b4e4e-9827-40fb-8763-e0ea2880085b')
|
180
|
+
```
|
181
|
+
|
182
|
+
**Cancel a transaction:**
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
client.cancel_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', transaction_id:
|
186
|
+
'd51b4e4e-9827-40fb-8763-e0ea2880085b')
|
187
|
+
```
|
188
|
+
|
189
|
+
**Resend a transaction:**
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
client.resend_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', transaction_id:
|
193
|
+
'd51b4e4e-9827-40fb-8763-e0ea2880085b')
|
194
|
+
```
|
195
|
+
|
196
|
+
**Return all transactions associated with the user:**
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
client.all_user_transactions
|
200
|
+
```
|
201
|
+
|
202
|
+
**Return all transactions associated with a card:**
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
client.all_card_transactions
|
206
|
+
```
|
207
|
+
|
208
|
+
## Contacts
|
209
|
+
|
210
|
+
[*Bitreserve documentation on contacts*](https://developer.bitreserve.org/api/v0/#contacts)
|
211
|
+
|
212
|
+
**Return all the user's contacts:**
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
client.all_contacts
|
216
|
+
```
|
217
|
+
|
218
|
+
**Return the details for a specific contact associated with the user:**
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
client.find_contact(id: '9fae84eb-712d-4b6a-9b2c-764bdde4c079')
|
222
|
+
```
|
223
|
+
|
224
|
+
**Create a contact for the user:**
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
client.create_contact(first_name: 'Luke', last_name: 'Skywalker', company: 'Lars
|
228
|
+
Moisture Farm Inc', emails: ['support@larsmoisturefarm.com')
|
229
|
+
```
|
230
|
+
|
231
|
+
## Users
|
232
|
+
|
233
|
+
[*Bitreserve documentation on users*](https://developer.bitreserve.org/api/v0/#users)
|
234
|
+
|
235
|
+
**Return the details of the user:**
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
client.me
|
239
|
+
```
|
240
|
+
|
241
|
+
**Return the list of phone numbers associated with the user:**
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
client.phones
|
245
|
+
```
|
246
|
+
|
247
|
+
## Transparency
|
248
|
+
|
249
|
+
[*Bitreserve documentation on transparency*](https://developer.bitreserve.org/api/v0/#reserve-status)
|
250
|
+
|
251
|
+
**Return a summary of all obligations and assets:**
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
client.statistics
|
255
|
+
```
|
256
|
+
|
257
|
+
# Contributing
|
258
|
+
|
259
|
+
1. Fork it ( https://github.com/groupbuddies/bitreserve/fork )
|
33
260
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
-
|
261
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
35
262
|
4. Push to the branch (`git push origin my-new-feature`)
|
36
263
|
5. Create a new Pull Request
|
264
|
+
|
265
|
+
# Copyright
|
266
|
+
|
267
|
+
Copyright (c) 2015 Group Buddies. See [LICENSE.txt](LICENSE.txt) for further details.
|
@@ -1,15 +1,16 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
1
3
|
module Bitreserve
|
2
4
|
module API
|
3
5
|
module AuthToken
|
4
|
-
def generate_access_token(username: '', password: '')
|
6
|
+
def generate_access_token(username: '', password: '', otp: '')
|
5
7
|
request_data = Bitreserve::RequestData.new(
|
6
8
|
Endpoints::AUTH,
|
7
9
|
Entities::AuthToken,
|
8
|
-
|
9
|
-
|
10
|
-
username: username, password: password
|
10
|
+
{ 'X-Bitreserve-OTP' => otp, 'Authorization' => 'Basic ' + Base64.encode64("#{username}:#{password}") },
|
11
|
+
description: 'Bitreserve ruby'
|
11
12
|
)
|
12
|
-
|
13
|
+
Request.perform_with_object(:post, request_data)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/bitreserve/request.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Bitreserve
|
2
|
-
class
|
2
|
+
class Request
|
3
3
|
include ::HTTParty
|
4
|
+
base_uri "#{Bitreserve.api_base}/v#{Bitreserve.api_version}"
|
4
5
|
|
5
6
|
def self.perform_with_objects(http_method, request_data)
|
6
7
|
response = new(request_data).public_send(http_method)
|
@@ -15,7 +16,6 @@ module Bitreserve
|
|
15
16
|
def initialize(request_data)
|
16
17
|
@path = request_data.endpoint
|
17
18
|
@data = request_data.payload
|
18
|
-
@auth = request_data.auth
|
19
19
|
@headers = request_data.headers
|
20
20
|
end
|
21
21
|
|
@@ -36,21 +36,13 @@ module Bitreserve
|
|
36
36
|
attr_reader :path, :data, :auth, :headers
|
37
37
|
|
38
38
|
def options
|
39
|
-
{
|
39
|
+
{ body: data, headers: headers }.
|
40
40
|
reject { |_k, v| v.nil? }
|
41
41
|
end
|
42
42
|
|
43
43
|
def log_request_info(http_method, response)
|
44
|
-
Bitreserve.logger.info "[Bitreserve] #{http_method.to_s.upcase} #{self.class.base_uri}#{path} #{
|
44
|
+
Bitreserve.logger.info "[Bitreserve] #{http_method.to_s.upcase} #{self.class.base_uri}#{path} #{options[:headers]} #{response.code}"
|
45
45
|
Bitreserve.logger.debug response.parsed_response
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
49
|
-
class Request < BaseRequest
|
50
|
-
base_uri "#{Bitreserve.api_base}/v#{Bitreserve.api_version}"
|
51
|
-
end
|
52
|
-
|
53
|
-
class AuthRequest < Request
|
54
|
-
base_uri Bitreserve.api_base
|
55
|
-
end
|
56
48
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bitreserve
|
2
|
-
class RequestData < Struct.new(:endpoint, :entity, :headers, :payload
|
3
|
-
def initialize(endpoint, entity, headers = {}, payload = nil
|
2
|
+
class RequestData < Struct.new(:endpoint, :entity, :headers, :payload)
|
3
|
+
def initialize(endpoint, entity, headers = {}, payload = nil)
|
4
4
|
super
|
5
5
|
end
|
6
6
|
end
|
data/lib/bitreserve/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://example:Password123@api.bitreserve.org/v0/me/tokens
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: description=Bitreserve%20ruby
|
9
|
+
headers:
|
10
|
+
X-Bitreserve-Otp:
|
11
|
+
- '5960110'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- cloudflare-nginx
|
19
|
+
Date:
|
20
|
+
- Thu, 29 Jan 2015 16:24:12 GMT
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
Content-Length:
|
24
|
+
- '106'
|
25
|
+
Connection:
|
26
|
+
- keep-alive
|
27
|
+
Set-Cookie:
|
28
|
+
- __cfduid=d8a73547e05f107f8c796bfcc238d8f851422548652; expires=Fri, 29-Jan-16
|
29
|
+
16:24:12 GMT; path=/; domain=.bitreserve.org; HttpOnly
|
30
|
+
X-Content-Security-Policy:
|
31
|
+
- default-src "none"
|
32
|
+
Content-Security-Policy:
|
33
|
+
- default-src "none"
|
34
|
+
X-Webkit-Csp:
|
35
|
+
- default-src "none"
|
36
|
+
Strict-Transport-Security:
|
37
|
+
- max-age=31536000
|
38
|
+
X-Xss-Protection:
|
39
|
+
- 1; mode=block
|
40
|
+
X-Content-Type-Options:
|
41
|
+
- nosniff
|
42
|
+
- nosniff
|
43
|
+
X-Frame-Options:
|
44
|
+
- DENY
|
45
|
+
X-Bitreserve-Request-Id:
|
46
|
+
- 9eed6cc1-c6f3-43ac-9acf-9286a83935c7
|
47
|
+
X-Ratelimit-Limit:
|
48
|
+
- '300'
|
49
|
+
X-Ratelimit-Remaining:
|
50
|
+
- '298'
|
51
|
+
X-Ratelimit-Reset:
|
52
|
+
- '1422548935'
|
53
|
+
Cf-Ray:
|
54
|
+
- 1b06c7540a6e0ddb-MAD
|
55
|
+
body:
|
56
|
+
encoding: UTF-8
|
57
|
+
string: '{"access_token":"853d580429364a90a6e02cb1f89e257a58da9064","description":"Bitreserve
|
58
|
+
ruby","expires":null}'
|
59
|
+
http_version:
|
60
|
+
recorded_at: Thu, 29 Jan 2015 16:24:14 GMT
|
61
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Bitreserve
|
4
|
+
module API
|
5
|
+
describe AuthToken do
|
6
|
+
let(:client) { Client.new }
|
7
|
+
|
8
|
+
context '#generate_access_token' do
|
9
|
+
it 'generates a personal access token' do
|
10
|
+
VCR.use_cassette('pats') do
|
11
|
+
token = client.generate_access_token(username: 'example', password: 'Password123', otp: '5960110')
|
12
|
+
|
13
|
+
expect(token).to be_a(Entities::AuthToken)
|
14
|
+
expect(token.access_token).to be_a(String)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/support/webmock.rb
CHANGED
@@ -8,17 +8,4 @@ module WebMockHelpers
|
|
8
8
|
WebMock::API.stub_request(method, Bitreserve::Request.base_uri + url).
|
9
9
|
to_return(body: response.to_json, headers: { 'Content-Type' => 'application/json' })
|
10
10
|
end
|
11
|
-
|
12
|
-
def self.bitreserve_stub_request_with_auth(method, url, response = [], auth = nil)
|
13
|
-
new_url = generate_auth_url(url, auth)
|
14
|
-
WebMock::API.stub_request(method, new_url).
|
15
|
-
to_return(body: response.to_json, headers: { 'Content-Type' => 'application/json' })
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def self.generate_auth_url(url, auth)
|
21
|
-
uri = URI.parse(Bitreserve::AuthRequest.base_uri)
|
22
|
-
uri.scheme + '://' + auth[:username] + ':' + auth[:password] + '@' + uri.host + url
|
23
|
-
end
|
24
11
|
end
|
data/spec/unit/api/auth_spec.rb
CHANGED
@@ -7,14 +7,13 @@ module Bitreserve
|
|
7
7
|
|
8
8
|
context '#generate_access_token' do
|
9
9
|
it 'generates a personal access token' do
|
10
|
-
auth = { username: 'user', password: 'pass' }
|
11
|
-
request_data = RequestData.new(Endpoints::AUTH, Entities::AuthToken, client.authorization_header, nil, auth)
|
10
|
+
auth = { username: 'user', password: 'pass', otp: 'otp' }
|
12
11
|
allow(Request).to receive(:perform_with_object)
|
13
12
|
|
14
13
|
client.generate_access_token(auth)
|
15
14
|
|
16
15
|
expect(Request).to have_received(:perform_with_object).
|
17
|
-
with(:post,
|
16
|
+
with(:post, anything)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
data/spec/unit/request_spec.rb
CHANGED
@@ -4,7 +4,7 @@ module Bitreserve
|
|
4
4
|
shared_examples 'perform request method' do |method_name|
|
5
5
|
let(:object_class) { double('ObjectClass', new: nil, from_collection: nil) }
|
6
6
|
let(:request) { spy('request') }
|
7
|
-
let(:client) {
|
7
|
+
let(:client) { Client.new }
|
8
8
|
|
9
9
|
context ".#{method_name}" do
|
10
10
|
it 'makes the correct call for a GET' do
|
@@ -43,11 +43,24 @@ module Bitreserve
|
|
43
43
|
|
44
44
|
expect(Request).to have_received(:post).with(url, body: data, headers: client.authorization_header)
|
45
45
|
end
|
46
|
+
|
47
|
+
it 'makes a call with basic auth' do
|
48
|
+
url = '/some-url'
|
49
|
+
headers = { header1: 'I am a header' }
|
50
|
+
body = { description: 'whatever' }
|
51
|
+
request_data = RequestData.new(url, object_class, headers, body)
|
52
|
+
WebMockHelpers.bitreserve_stub_request(:get, url)
|
53
|
+
allow(Request).to receive(:get).and_call_original
|
54
|
+
|
55
|
+
Request.public_send(method_name, :get, request_data)
|
56
|
+
|
57
|
+
expect(Request).to have_received(:get).with(url, headers: headers, body: body)
|
58
|
+
end
|
46
59
|
end
|
47
60
|
|
48
|
-
def request_data(url = anything, client = nil, payload = nil
|
61
|
+
def request_data(url = anything, client = nil, payload = nil)
|
49
62
|
client ||= double('Client', authorization_header: {})
|
50
|
-
RequestData.new(url, object_class, client.authorization_header, payload
|
63
|
+
RequestData.new(url, object_class, client.authorization_header, payload)
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitreserve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Group Buddies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -177,10 +177,12 @@ files:
|
|
177
177
|
- spec/fixtures/vcr_cassettes/me/transactions/create_waiting_cancel.yml
|
178
178
|
- spec/fixtures/vcr_cassettes/me/transactions/create_waiting_resend.yml
|
179
179
|
- spec/fixtures/vcr_cassettes/me/transactions/resend.yml
|
180
|
+
- spec/fixtures/vcr_cassettes/pats.yml
|
180
181
|
- spec/fixtures/vcr_cassettes/reserve/transaction.yml
|
181
182
|
- spec/fixtures/vcr_cassettes/reserve/transactions.yml
|
182
183
|
- spec/fixtures/vcr_cassettes/tickers.yml
|
183
184
|
- spec/fixtures/vcr_cassettes/transparency.yml
|
185
|
+
- spec/integration/api/auth_token_spec.rb
|
184
186
|
- spec/integration/api/card_spec.rb
|
185
187
|
- spec/integration/api/contact_spec.rb
|
186
188
|
- spec/integration/api/private_transactions_spec.rb
|
@@ -199,7 +201,6 @@ files:
|
|
199
201
|
- spec/unit/api/ticker_spec.rb
|
200
202
|
- spec/unit/api/transparency_spec.rb
|
201
203
|
- spec/unit/api/user_spec.rb
|
202
|
-
- spec/unit/auth_request_spec.rb
|
203
204
|
- spec/unit/client_spec.rb
|
204
205
|
- spec/unit/entities/base_entity_spec.rb
|
205
206
|
- spec/unit/entities/user_spec.rb
|
@@ -244,10 +245,12 @@ test_files:
|
|
244
245
|
- spec/fixtures/vcr_cassettes/me/transactions/create_waiting_cancel.yml
|
245
246
|
- spec/fixtures/vcr_cassettes/me/transactions/create_waiting_resend.yml
|
246
247
|
- spec/fixtures/vcr_cassettes/me/transactions/resend.yml
|
248
|
+
- spec/fixtures/vcr_cassettes/pats.yml
|
247
249
|
- spec/fixtures/vcr_cassettes/reserve/transaction.yml
|
248
250
|
- spec/fixtures/vcr_cassettes/reserve/transactions.yml
|
249
251
|
- spec/fixtures/vcr_cassettes/tickers.yml
|
250
252
|
- spec/fixtures/vcr_cassettes/transparency.yml
|
253
|
+
- spec/integration/api/auth_token_spec.rb
|
251
254
|
- spec/integration/api/card_spec.rb
|
252
255
|
- spec/integration/api/contact_spec.rb
|
253
256
|
- spec/integration/api/private_transactions_spec.rb
|
@@ -266,7 +269,6 @@ test_files:
|
|
266
269
|
- spec/unit/api/ticker_spec.rb
|
267
270
|
- spec/unit/api/transparency_spec.rb
|
268
271
|
- spec/unit/api/user_spec.rb
|
269
|
-
- spec/unit/auth_request_spec.rb
|
270
272
|
- spec/unit/client_spec.rb
|
271
273
|
- spec/unit/entities/base_entity_spec.rb
|
272
274
|
- spec/unit/entities/user_spec.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Bitreserve
|
4
|
-
shared_examples 'perform auth request method' do |method_name|
|
5
|
-
let(:object_class) { double('ObjectClass', new: nil, from_collection: nil) }
|
6
|
-
let(:request) { spy('request') }
|
7
|
-
let(:client) { Bitreserve::Client.new }
|
8
|
-
|
9
|
-
context ".#{method_name}" do
|
10
|
-
it 'makes a call with basic auth' do
|
11
|
-
url = '/some-url'
|
12
|
-
auth = { username: 'user', password: 'pass' }
|
13
|
-
WebMockHelpers.bitreserve_stub_request_with_auth(:get, url, [], auth)
|
14
|
-
allow(AuthRequest).to receive(:get).and_call_original
|
15
|
-
|
16
|
-
AuthRequest.public_send(method_name, :get, request_data(url, client, nil, auth))
|
17
|
-
|
18
|
-
expect(AuthRequest).to have_received(:get).with(url, basic_auth: auth, headers: client.authorization_header)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def request_data(url = anything, client = nil, payload = nil, auth = nil)
|
23
|
-
client ||= double('Client', authorization_header: {})
|
24
|
-
RequestData.new(url, object_class, client.authorization_header, payload, auth)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe AuthRequest do
|
29
|
-
include_examples 'perform auth request method', :perform_with_object
|
30
|
-
include_examples 'perform auth request method', :perform_with_objects
|
31
|
-
end
|
32
|
-
end
|