coins_paid_api 1.0.4 → 1.0.5
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 +4 -4
- data/coins_paid_api.gemspec +1 -1
- data/lib/coins_paid/api/callback_data.rb +2 -2
- data/spec/callback_spec.rb +20 -0
- data/spec/support/shared/data.rb +29 -0
- 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: f347724eaccb1361f9082352da01fdcdcf6becc50ba56e98f4826cac56f92e87
         | 
| 4 | 
            +
              data.tar.gz: f018f55ad92352b0d10fe4ff5358876e8df68a5505f0fc7c49f7600f4c292fb6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 37fdf652b56173c030c62a01fed2eb7fccded736e441da735bf60aa7ab0ea9a577072333f663ff4572db7775e6784f9656f2505992c4639ea8d8037e1a7ca5f4
         | 
| 7 | 
            +
              data.tar.gz: 1cbc72a4c4b5c45125c84a6b825a2cebe033a36ae4307608ae1bdf201847c555eb8385040624269908ceac14947059045ae83f52ba40ff1cef28cf6ed1cd1d78
         | 
    
        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.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 |  | 
    
        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
         | 
    
        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.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- | 
| 12 | 
            +
            date: 2020-04-16 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: dry-struct
         |