coins_paid_api 1.0.3 → 1.0.7

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
  SHA256:
3
- metadata.gz: 62cd90114215368e128d6e06d4047d859bfe83ae4d919904c33ce114864deffe
4
- data.tar.gz: e3b9b821e9c0b082d58cb475b7806b4e4065df0d27f051f0a795af27718a6c7a
3
+ metadata.gz: 344f70ed054fc21fbd7b99ab74a2be43af3c18faf178b8dc0e507bb8787c5361
4
+ data.tar.gz: 67d6cec032e4ee37950ae18f25e3319fbe64cd55aa7403116a93463197d4d52f
5
5
  SHA512:
6
- metadata.gz: 73267b211f9944de80b673e8387a83320378b691a6af9b17803fad1aa8a15a87e59c9caea8732d4d1b23440165f57094c085b3ada36ea46fb01f1572c46eef21
7
- data.tar.gz: 00abd832c2f0e895b88473aa0e4d422c232d52d74821bdeaea2e940c8bcc6fd05d3909ff2d3624185de044242c8c1546b6c8d64fe1d56c04e42c5c14381733f1
6
+ metadata.gz: 5d5ffcbb104c5b277f4196328cafc70392606541b6c840493f1896b0a35436e2338e049e4811da19f13daca8071b7a60b0b0d7a3192397096ace769fa05cb960
7
+ data.tar.gz: 13191a7d05cf3bd1cb8e0ef1d4e3fa005c4485b23233b080be73e1ae9481fda68ac262b761edc795d31039ec6c70d2605b96a4b8295a6ea040c3722e544ee663
@@ -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.3'
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
 
@@ -12,7 +12,7 @@ module CoinsPaid
12
12
  class Response < Dry::Struct
13
13
  attribute :external_id, Types::Integer
14
14
  attribute :address, Types::String
15
- attribute :tag, Types::String.optional
15
+ attribute :tag, Types::Coercible::String.optional
16
16
  end
17
17
 
18
18
  PATH = 'addresses/take'
@@ -9,6 +9,7 @@ module CoinsPaid
9
9
  attribute :currency, Types::String
10
10
  attribute :convert_to, Types::String
11
11
  attribute :address, Types::String
12
+ attribute? :tag, Types::String
12
13
  end
13
14
 
14
15
  class Response < Dry::Struct
@@ -42,11 +42,8 @@ module CoinsPaid
42
42
  )
43
43
  end
44
44
 
45
- def withdraw(foreign_id:, amount:, currency:, convert_to:, address:)
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
@@ -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
@@ -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
@@ -15,7 +15,7 @@ describe CoinsPaid::API, '.take_address' do
15
15
  {
16
16
  external_id: 1,
17
17
  address: '12983h13ro1hrt24it432t',
18
- tag: 'tag-123'
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' => 'tag-123',
30
+ 'tag' => 123,
31
31
  'foreign_id' => 'user-id:2048'
32
32
  }
33
33
  }
@@ -2,15 +2,9 @@
2
2
 
3
3
  require_relative './request_examples'
4
4
 
5
- describe CoinsPaid::API, '.withdraw' do
5
+ RSpec.shared_examples 'CoinsPaid API withdrawal' do |request_data:|
6
6
  endpoint = 'https://app.coinspaid.com/api/v2/withdrawal/crypto'
7
- request_data = {
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.3
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: 2020-04-14 00:00:00.000000000 Z
12
+ date: 2021-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-struct