coins_paid_api 1.0.3 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/coins_paid_api.gemspec +1 -1
- data/lib/coins_paid/api/callback_data.rb +3 -3
- data/lib/coins_paid/api/take_address.rb +1 -1
- data/lib/coins_paid/api/withdrawal.rb +1 -0
- data/lib/coins_paid/api.rb +2 -5
- data/spec/callback_spec.rb +20 -0
- data/spec/support/shared/data.rb +29 -0
- data/spec/take_address_spec.rb +2 -2
- data/spec/withdrawal_spec.rb +20 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344f70ed054fc21fbd7b99ab74a2be43af3c18faf178b8dc0e507bb8787c5361
|
4
|
+
data.tar.gz: 67d6cec032e4ee37950ae18f25e3319fbe64cd55aa7403116a93463197d4d52f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5ffcbb104c5b277f4196328cafc70392606541b6c840493f1896b0a35436e2338e049e4811da19f13daca8071b7a60b0b0d7a3192397096ace769fa05cb960
|
7
|
+
data.tar.gz: 13191a7d05cf3bd1cb8e0ef1d4e3fa005c4485b23233b080be73e1ae9481fda68ac262b761edc795d31039ec6c70d2605b96a4b8295a6ea040c3722e544ee663
|
data/coins_paid_api.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'coins_paid_api'
|
3
3
|
s.authors = ['Artem Biserov(artembiserov)', 'Oleg Ivanov(morhekil)']
|
4
|
-
s.version = '1.0.
|
4
|
+
s.version = '1.0.7'
|
5
5
|
s.files = `git ls-files`.split("\n")
|
6
6
|
s.summary = 'Coins Paid Integration'
|
7
7
|
s.license = 'MIT'
|
@@ -7,12 +7,12 @@ module CoinsPaid
|
|
7
7
|
CANCELLED = 'cancelled'
|
8
8
|
|
9
9
|
attribute :id, Types::Integer
|
10
|
-
attribute :foreign_id, Types::String
|
10
|
+
attribute? :foreign_id, Types::String
|
11
11
|
attribute? :type, Types::String
|
12
12
|
attribute? :status, Types::String
|
13
13
|
attribute? :error, Types::Coercible::String
|
14
14
|
|
15
|
-
attribute :crypto_address do
|
15
|
+
attribute? :crypto_address do
|
16
16
|
attribute :currency, Types::String
|
17
17
|
end
|
18
18
|
|
@@ -32,7 +32,7 @@ module CoinsPaid
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.from_json(attributes)
|
35
|
-
attributes[:foreign_id] ||= attributes.dig(:crypto_address, :foreign_id)
|
35
|
+
attributes[:foreign_id] ||= attributes.dig(:crypto_address, :foreign_id) || ''
|
36
36
|
new(attributes)
|
37
37
|
end
|
38
38
|
|
data/lib/coins_paid/api.rb
CHANGED
@@ -42,11 +42,8 @@ module CoinsPaid
|
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
45
|
-
def withdraw(
|
46
|
-
Requester.call(
|
47
|
-
Withdrawal,
|
48
|
-
foreign_id: foreign_id, amount: amount, currency: currency, convert_to: convert_to, address: address
|
49
|
-
)
|
45
|
+
def withdraw(data)
|
46
|
+
Requester.call(Withdrawal, data)
|
50
47
|
end
|
51
48
|
|
52
49
|
def currencies_list
|
data/spec/callback_spec.rb
CHANGED
@@ -122,4 +122,24 @@ describe CoinsPaid::API, '.callback' do
|
|
122
122
|
|
123
123
|
it { is_expected.to be_struct_with_params(CoinsPaid::API::CallbackData, expected_params) }
|
124
124
|
end
|
125
|
+
|
126
|
+
context 'when request_body is exchange callback data' do
|
127
|
+
let(:request_body) { exchange_callback_body.to_json }
|
128
|
+
let(:expected_params) do
|
129
|
+
{
|
130
|
+
id: 3268590,
|
131
|
+
type: 'exchange',
|
132
|
+
status: 'confirmed',
|
133
|
+
foreign_id: '',
|
134
|
+
error: '',
|
135
|
+
currency_sent: { amount: "0.56114000"},
|
136
|
+
currency_received: { amount: "80.21790617"},
|
137
|
+
transactions: [
|
138
|
+
{ transaction_type: 'exchange', type: 'exchange', id: 714576 },
|
139
|
+
]
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
it { is_expected.to be_struct_with_params(CoinsPaid::API::CallbackData, expected_params) }
|
144
|
+
end
|
125
145
|
end
|
data/spec/support/shared/data.rb
CHANGED
@@ -199,4 +199,33 @@ shared_context 'coins paid callbacks' do
|
|
199
199
|
'status' => 'cancelled'
|
200
200
|
}
|
201
201
|
end
|
202
|
+
|
203
|
+
let(:exchange_callback_body) do
|
204
|
+
{
|
205
|
+
'currency_received' => {
|
206
|
+
'amount' => '80.21790617',
|
207
|
+
'currency' => 'EUR'
|
208
|
+
},
|
209
|
+
'currency_sent' => {
|
210
|
+
'amount' => '0.56114000',
|
211
|
+
'currency' => 'ETH'
|
212
|
+
},
|
213
|
+
'error' => '',
|
214
|
+
'fees' => [{'type'=>'fee_crypto_sell_for_fiat', 'currency'=>'EUR', 'amount'=>'0.80217906'}],
|
215
|
+
'id' => 3268590,
|
216
|
+
'status' => 'confirmed',
|
217
|
+
'transactions' => [
|
218
|
+
{
|
219
|
+
'id'=>714576,
|
220
|
+
'currency'=>'ETH',
|
221
|
+
'currency_to'=>'EUR',
|
222
|
+
'transaction_type'=>'exchange',
|
223
|
+
'type'=>'exchange',
|
224
|
+
'amount'=>'0.56114000',
|
225
|
+
'amount_to'=>'80.21790617'
|
226
|
+
}
|
227
|
+
],
|
228
|
+
'type' => 'exchange'
|
229
|
+
}
|
230
|
+
end
|
202
231
|
end
|
data/spec/take_address_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe CoinsPaid::API, '.take_address' do
|
|
15
15
|
{
|
16
16
|
external_id: 1,
|
17
17
|
address: '12983h13ro1hrt24it432t',
|
18
|
-
tag: '
|
18
|
+
tag: '123'
|
19
19
|
}
|
20
20
|
end
|
21
21
|
subject(:take_address) { described_class.take_address(request_data) }
|
@@ -27,7 +27,7 @@ describe CoinsPaid::API, '.take_address' do
|
|
27
27
|
'currency' => 'BTC',
|
28
28
|
'convert_to' => 'EUR',
|
29
29
|
'address' => '12983h13ro1hrt24it432t',
|
30
|
-
'tag' =>
|
30
|
+
'tag' => 123,
|
31
31
|
'foreign_id' => 'user-id:2048'
|
32
32
|
}
|
33
33
|
}
|
data/spec/withdrawal_spec.rb
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative './request_examples'
|
4
4
|
|
5
|
-
|
5
|
+
RSpec.shared_examples 'CoinsPaid API withdrawal' do |request_data:|
|
6
6
|
endpoint = 'https://app.coinspaid.com/api/v2/withdrawal/crypto'
|
7
|
-
|
8
|
-
foreign_id: 'user-id:2048',
|
9
|
-
amount: '0.01',
|
10
|
-
currency: 'EUR',
|
11
|
-
convert_to: 'BTC',
|
12
|
-
address: 'abc123'
|
13
|
-
}
|
7
|
+
|
14
8
|
include_context 'CoinsPaid API request', request_data: request_data
|
15
9
|
|
16
10
|
let(:response_data) do
|
@@ -48,3 +42,21 @@ describe CoinsPaid::API, '.withdraw' do
|
|
48
42
|
end
|
49
43
|
end
|
50
44
|
end
|
45
|
+
|
46
|
+
describe CoinsPaid::API, '.withdraw' do
|
47
|
+
base_request_data = {
|
48
|
+
foreign_id: 'user-id:2048',
|
49
|
+
amount: '0.01',
|
50
|
+
currency: 'EUR',
|
51
|
+
convert_to: 'BTC',
|
52
|
+
address: 'abc123'
|
53
|
+
}
|
54
|
+
|
55
|
+
context 'request includes tag parameter' do
|
56
|
+
it_behaves_like 'CoinsPaid API withdrawal', request_data: base_request_data.merge(tag: 'thetag')
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'request does not include tag parameter' do
|
60
|
+
it_behaves_like 'CoinsPaid API withdrawal', request_data: base_request_data
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coins_paid_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Biserov(artembiserov)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-struct
|