coins_paid_api 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dab68a09a9d71508b881664e7a83e9647511525afd6bbf6069cd1ff642aa3261
4
- data.tar.gz: 7e24f02f8e4e68a3ba2af738edd6d381bae82a898c0f594421314ba4aa66ca60
3
+ metadata.gz: f347724eaccb1361f9082352da01fdcdcf6becc50ba56e98f4826cac56f92e87
4
+ data.tar.gz: f018f55ad92352b0d10fe4ff5358876e8df68a5505f0fc7c49f7600f4c292fb6
5
5
  SHA512:
6
- metadata.gz: b84b692b3bc06816ee23fbb39d0d879f9138be28b96e79746e05e8935ca6fdec48a67104a1759cfb75fd483f0e1173310258db92c9ddc11522acb0bc4711c037
7
- data.tar.gz: ebb4f45a348407d17dc6eba3b5f3fb19d59a8d7bfc1ed485c0c356905b27e64287cd717e3a0dd006f469f9b598e1e1216365235f468b6da3af135bdbc630bc55
6
+ metadata.gz: 37fdf652b56173c030c62a01fed2eb7fccded736e441da735bf60aa7ab0ea9a577072333f663ff4572db7775e6784f9656f2505992c4639ea8d8037e1a7ca5f4
7
+ data.tar.gz: 1cbc72a4c4b5c45125c84a6b825a2cebe033a36ae4307608ae1bdf201847c555eb8385040624269908ceac14947059045ae83f52ba40ff1cef28cf6ed1cd1d78
@@ -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'
4
+ s.version = '1.0.5'
5
5
  s.files = `git ls-files`.split("\n")
6
6
  s.summary = 'Coins Paid Integration'
7
7
  s.license = 'MIT'
@@ -12,7 +12,7 @@ module CoinsPaid
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
 
@@ -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
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
4
+ version: 1.0.5
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-15 00:00:00.000000000 Z
12
+ date: 2020-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-struct