coins_paid_api 1.0.2 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/coins_paid_api.gemspec +1 -1
- data/lib/coins_paid/api/callback_data.rb +4 -3
- data/lib/coins_paid/api/withdrawal.rb +1 -0
- data/lib/coins_paid/api.rb +2 -5
- data/spec/callback_spec.rb +28 -8
- data/spec/support/shared/data.rb +29 -0
- data/spec/withdrawal_spec.rb +20 -8
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 020d45404c81037d89565ba5e7dcb231982db444abdbd00a6f1535bfd9e73170
|
4
|
+
data.tar.gz: 84f0ab1f61a80fe45dedca5cc0d0ce8467e5328315fc75d0f3812702e84774a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd4a488e8434dd0ccc78b68feed059545f1d193bbaf2b226e597da371b04b454f459c4a157f55d56750805181048135322ef1671c09f82c78bb8e83186fc50f
|
7
|
+
data.tar.gz: c7ad6dea7bc2c80882df508506df798d7864cb59073db39f14cf46df55ea8d904d20a4416daf4e26ce8c5eee44570cd3c41b8a451760b2642f1ad1b9dc6761b9
|
data/Gemfile
CHANGED
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.6'
|
5
5
|
s.files = `git ls-files`.split("\n")
|
6
6
|
s.summary = 'Coins Paid Integration'
|
7
7
|
s.license = 'MIT'
|
@@ -7,17 +7,18 @@ 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
|
|
19
19
|
attribute? :transactions, Types::Array do
|
20
20
|
attribute :transaction_type, Types::String
|
21
|
+
attribute :type, Types::String
|
21
22
|
attribute :id, Types::Integer
|
22
23
|
end
|
23
24
|
|
@@ -31,7 +32,7 @@ module CoinsPaid
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def self.from_json(attributes)
|
34
|
-
attributes[:foreign_id] ||= attributes.dig(:crypto_address, :foreign_id)
|
35
|
+
attributes[:foreign_id] ||= attributes.dig(:crypto_address, :foreign_id) || ''
|
35
36
|
new(attributes)
|
36
37
|
end
|
37
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
@@ -39,8 +39,8 @@ describe CoinsPaid::API, '.callback' do
|
|
39
39
|
currency: 'BTC'
|
40
40
|
},
|
41
41
|
transactions: [
|
42
|
-
{ transaction_type: 'blockchain', id: 714576 },
|
43
|
-
{ transaction_type: 'exchange', id: 714577 }
|
42
|
+
{ transaction_type: 'blockchain', type: 'deposit', id: 714576 },
|
43
|
+
{ transaction_type: 'exchange', type: 'exchange', id: 714577 }
|
44
44
|
],
|
45
45
|
currency_sent: { amount: '0.01000000' },
|
46
46
|
currency_received: {
|
@@ -66,8 +66,8 @@ describe CoinsPaid::API, '.callback' do
|
|
66
66
|
currency: 'BTC'
|
67
67
|
},
|
68
68
|
transactions: [
|
69
|
-
{ transaction_type: 'blockchain', id: 714576 },
|
70
|
-
{ transaction_type: 'exchange', id: 714577 }
|
69
|
+
{ transaction_type: 'blockchain', type: 'deposit', id: 714576 },
|
70
|
+
{ transaction_type: 'exchange', type: 'exchange', id: 714577 }
|
71
71
|
]
|
72
72
|
}
|
73
73
|
end
|
@@ -88,8 +88,8 @@ describe CoinsPaid::API, '.callback' do
|
|
88
88
|
currency: 'EUR'
|
89
89
|
},
|
90
90
|
transactions: [
|
91
|
-
{ transaction_type: 'exchange', id: 1 },
|
92
|
-
{ transaction_type: 'blockchain', id: 1 }
|
91
|
+
{ transaction_type: 'exchange', type: 'exchange', id: 1 },
|
92
|
+
{ transaction_type: 'blockchain', type: 'withdrawal', id: 1 }
|
93
93
|
],
|
94
94
|
currency_sent: { amount: '381' },
|
95
95
|
currency_received: {
|
@@ -114,8 +114,28 @@ describe CoinsPaid::API, '.callback' do
|
|
114
114
|
currency: 'EUR'
|
115
115
|
},
|
116
116
|
transactions: [
|
117
|
-
{ transaction_type: 'exchange', id: 714576 },
|
118
|
-
{ transaction_type: 'blockchain', id: 714577 }
|
117
|
+
{ transaction_type: 'exchange', type: 'exchange', id: 714576 },
|
118
|
+
{ transaction_type: 'blockchain', type: 'withdrawal', id: 714577 }
|
119
|
+
]
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
it { is_expected.to be_struct_with_params(CoinsPaid::API::CallbackData, expected_params) }
|
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 },
|
119
139
|
]
|
120
140
|
}
|
121
141
|
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/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,15 +1,15 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Biserov(artembiserov)
|
8
8
|
- Oleg Ivanov(morhekil)
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-struct
|
@@ -81,8 +81,8 @@ dependencies:
|
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '3.7'
|
84
|
-
description:
|
85
|
-
email:
|
84
|
+
description:
|
85
|
+
email:
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
@@ -112,11 +112,11 @@ files:
|
|
112
112
|
- spec/support/shared/data.rb
|
113
113
|
- spec/take_address_spec.rb
|
114
114
|
- spec/withdrawal_spec.rb
|
115
|
-
homepage:
|
115
|
+
homepage:
|
116
116
|
licenses:
|
117
117
|
- MIT
|
118
118
|
metadata: {}
|
119
|
-
post_install_message:
|
119
|
+
post_install_message:
|
120
120
|
rdoc_options: []
|
121
121
|
require_paths:
|
122
122
|
- lib
|
@@ -131,9 +131,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
|
-
rubyforge_project:
|
134
|
+
rubyforge_project:
|
135
135
|
rubygems_version: 2.7.6
|
136
|
-
signing_key:
|
136
|
+
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Coins Paid Integration
|
139
139
|
test_files: []
|