cointrader.net 0.2.4 → 0.3.0
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/lib/cointrader.net/client/order.rb +5 -0
- data/lib/cointrader.net/version.rb +1 -1
- data/spec/client_spec.rb +32 -2
- data/spec/fixtures/vcr_cassettes/cancel.yml +65 -0
- metadata +3 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 27ca2dfd9efedd3c3754818611319f56105cf575
         | 
| 4 | 
            +
              data.tar.gz: e63c3b86e70c434a0753679ea9152d687d4da70f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a756177726711bc4f2189fb50432ebfe4878bd4e7eabc5f9887ddd77064c6263392b144bc6d0a956ceb7ea1e509607f0abcee86ac19b729fedf8dcca17679126
         | 
| 7 | 
            +
              data.tar.gz: e877c2ffb0622addddda20b83d4c604c42653a23d2b7391f1b5f5e41578e5b8befd83063eb179ee0c8ff3e3ff2b56bc5dd0d381b1646d2c217396d01f95fe55b
         | 
| @@ -9,5 +9,10 @@ module Cointrader | |
| 9 9 | 
             
                  params = get_defaults(params)
         | 
| 10 10 | 
             
                  request(:post, "/order/#{params[:currency_pair]}/sell", total_quantity: params[:total_quantity], price: params[:price])
         | 
| 11 11 | 
             
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def cancel params={}
         | 
| 14 | 
            +
                  params = get_defaults(params)
         | 
| 15 | 
            +
                  request(:post, "/order/#{params[:currency_pair]}/cancel")
         | 
| 16 | 
            +
                end
         | 
| 12 17 | 
             
              end
         | 
| 13 18 | 
             
            end
         | 
    
        data/spec/client_spec.rb
    CHANGED
    
    | @@ -1,6 +1,22 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe Cointrader::Client do
         | 
| 4 | 
            +
              def limit_buy 
         | 
| 5 | 
            +
                subject.limit_buy(total_quantity: 1, price: 10)
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def limit_sell
         | 
| 9 | 
            +
                subject.limit_sell(total_quantity: 1, price: 10)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def safe_limit_buy
         | 
| 13 | 
            +
                VCR.use_cassette('limit_buy', &method(:limit_buy))
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def safe_limit_sell
         | 
| 17 | 
            +
                VCR.use_cassette('limit_sell', &method(:limit_sell))
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 4 20 | 
             
              describe 'stats' do
         | 
| 5 21 | 
             
                describe '#symbol' do
         | 
| 6 22 | 
             
                  it 'returns supported currencies' do
         | 
| @@ -61,7 +77,7 @@ describe Cointrader::Client do | |
| 61 77 | 
             
                describe '#limit_buy' do
         | 
| 62 78 | 
             
                  it 'returns an order' do
         | 
| 63 79 | 
             
                    VCR.use_cassette('limit_buy') do
         | 
| 64 | 
            -
                      response =  | 
| 80 | 
            +
                      response = limit_buy
         | 
| 65 81 |  | 
| 66 82 | 
             
                      expect_success(response)
         | 
| 67 83 | 
             
                      expect(response['data']['id']).not_to be_nil
         | 
| @@ -72,10 +88,24 @@ describe Cointrader::Client do | |
| 72 88 | 
             
                describe '#limit_sell' do
         | 
| 73 89 | 
             
                  it 'returns an order' do
         | 
| 74 90 | 
             
                    VCR.use_cassette('limit_sell') do
         | 
| 75 | 
            -
                      response =  | 
| 91 | 
            +
                      response = limit_sell
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                      expect_success(response)
         | 
| 94 | 
            +
                      expect(response['data']['id']).not_to be_nil
         | 
| 95 | 
            +
                    end
         | 
| 96 | 
            +
                  end
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                describe '#cancel' do
         | 
| 100 | 
            +
                  let(:order) { safe_limit_buy }
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  it 'cancels and order' do
         | 
| 103 | 
            +
                    VCR.use_cassette('cancel') do
         | 
| 104 | 
            +
                      response = subject.cancel(id: order['data']['id'])
         | 
| 76 105 |  | 
| 77 106 | 
             
                      expect_success(response)
         | 
| 78 107 | 
             
                      expect(response['data']['id']).not_to be_nil
         | 
| 108 | 
            +
                      expect(response['data']['currency_pair']).not_to be_nil
         | 
| 79 109 | 
             
                    end
         | 
| 80 110 | 
             
                  end
         | 
| 81 111 | 
             
                end
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: post
         | 
| 5 | 
            +
                uri: https://private-anon-e01e290b7-cointrader.apiary-mock.com/api4/order/BTCUSD/cancel
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: UTF-8
         | 
| 8 | 
            +
                  string: '{"secret":"l33lpBPqrNazDz5bgOpQkaerFtpOBqw8wjLTK3sbEcSK","t":"1432487211197"}'
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  Accept:
         | 
| 11 | 
            +
                  - "*/*; q=0.5, application/xml"
         | 
| 12 | 
            +
                  Accept-Encoding:
         | 
| 13 | 
            +
                  - gzip, deflate
         | 
| 14 | 
            +
                  Content-Type:
         | 
| 15 | 
            +
                  - application/json
         | 
| 16 | 
            +
                  X-Auth:
         | 
| 17 | 
            +
                  - hCkVvzR4Nuc6dbuN0biMFSqMqSfc1f1grhXqoaQAlq1y
         | 
| 18 | 
            +
                  X-Auth-Hash:
         | 
| 19 | 
            +
                  - 7b4dd8cb2dd2a1a4c95e3d4c1a9b3c981f7bd55f6889c33128bab7a05bd23cf8
         | 
| 20 | 
            +
                  Content-Length:
         | 
| 21 | 
            +
                  - '77'
         | 
| 22 | 
            +
                  User-Agent:
         | 
| 23 | 
            +
                  - Ruby
         | 
| 24 | 
            +
              response:
         | 
| 25 | 
            +
                status:
         | 
| 26 | 
            +
                  code: 200
         | 
| 27 | 
            +
                  message: OK
         | 
| 28 | 
            +
                headers:
         | 
| 29 | 
            +
                  Server:
         | 
| 30 | 
            +
                  - Cowboy
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  X-Apiary-Ratelimit-Limit:
         | 
| 34 | 
            +
                  - '120'
         | 
| 35 | 
            +
                  X-Apiary-Ratelimit-Remaining:
         | 
| 36 | 
            +
                  - '119'
         | 
| 37 | 
            +
                  Access-Control-Allow-Origin:
         | 
| 38 | 
            +
                  - "*"
         | 
| 39 | 
            +
                  Access-Control-Allow-Methods:
         | 
| 40 | 
            +
                  - OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,CONNECT
         | 
| 41 | 
            +
                  Access-Control-Max-Age:
         | 
| 42 | 
            +
                  - '10'
         | 
| 43 | 
            +
                  X-Apiary-Transaction-Id:
         | 
| 44 | 
            +
                  - 5562047865401d0300ea875b
         | 
| 45 | 
            +
                  Date:
         | 
| 46 | 
            +
                  - Sun, 24 May 2015 17:03:52 GMT
         | 
| 47 | 
            +
                  Transfer-Encoding:
         | 
| 48 | 
            +
                  - chunked
         | 
| 49 | 
            +
                  Via:
         | 
| 50 | 
            +
                  - 1.1 vegur
         | 
| 51 | 
            +
                body:
         | 
| 52 | 
            +
                  encoding: UTF-8
         | 
| 53 | 
            +
                  string: |-
         | 
| 54 | 
            +
                    {
         | 
| 55 | 
            +
                        "success":true,
         | 
| 56 | 
            +
                        "message":"BTCCAD Order Canceled",
         | 
| 57 | 
            +
                        "data":
         | 
| 58 | 
            +
                        {
         | 
| 59 | 
            +
                            "id":"85",
         | 
| 60 | 
            +
                            "currency_pair":"BTCAD"
         | 
| 61 | 
            +
                        }
         | 
| 62 | 
            +
                    }
         | 
| 63 | 
            +
                http_version: 
         | 
| 64 | 
            +
              recorded_at: Sun, 24 May 2015 17:06:52 GMT
         | 
| 65 | 
            +
            recorded_with: VCR 2.9.3
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cointrader.net
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Maros Hluska
         | 
| @@ -102,6 +102,7 @@ files: | |
| 102 102 | 
             
            - lib/cointrader.net/version.rb
         | 
| 103 103 | 
             
            - spec/client_spec.rb
         | 
| 104 104 | 
             
            - spec/fixtures/vcr_cassettes/balance.yml
         | 
| 105 | 
            +
            - spec/fixtures/vcr_cassettes/cancel.yml
         | 
| 105 106 | 
             
            - spec/fixtures/vcr_cassettes/limit_buy.yml
         | 
| 106 107 | 
             
            - spec/fixtures/vcr_cassettes/limit_sell.yml
         | 
| 107 108 | 
             
            - spec/fixtures/vcr_cassettes/orders.yml
         | 
| @@ -136,6 +137,7 @@ summary: Cointrader.net API wrapper | |
| 136 137 | 
             
            test_files:
         | 
| 137 138 | 
             
            - spec/client_spec.rb
         | 
| 138 139 | 
             
            - spec/fixtures/vcr_cassettes/balance.yml
         | 
| 140 | 
            +
            - spec/fixtures/vcr_cassettes/cancel.yml
         | 
| 139 141 | 
             
            - spec/fixtures/vcr_cassettes/limit_buy.yml
         | 
| 140 142 | 
             
            - spec/fixtures/vcr_cassettes/limit_sell.yml
         | 
| 141 143 | 
             
            - spec/fixtures/vcr_cassettes/orders.yml
         |