Skip to content

Commit

Permalink
edit zebpay url (coingecko#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjieyek authored and wongy91 committed Mar 1, 2019
1 parent 125f156 commit 515a938
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/cryptoexchange/exchanges/zebpay/market.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Cryptoexchange::Exchanges
module Zebpay
class Market < Cryptoexchange::Models::Market
NAME = 'zebpay'
API_URL = 'https://www.zebapi.com/api/v1'
API_URL = 'https://www.zebapi.com/pro/v1'
end
end
end
24 changes: 18 additions & 6 deletions lib/cryptoexchange/exchanges/zebpay/services/market.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@ module Services
class Market < Cryptoexchange::Services::Market
class << self
def supports_individual_ticker_query?
true
false
end
end

def fetch(market_pair)
output = super(ticker_url(market_pair))
adapt(output, market_pair)
def fetch
output = super(ticker_url)
adapt_all(output)
end

def ticker_url(market_pair)
"#{Cryptoexchange::Exchanges::Zebpay::Market::API_URL}/market/ticker-new/#{market_pair.base}/#{market_pair.target}"
def ticker_url
"#{Cryptoexchange::Exchanges::Zebpay::Market::API_URL}/market"
end

def adapt_all(output)
output.map do |output|
base, target = output['pair'].split('-')
market_pair = Cryptoexchange::Models::MarketPair.new(
base: base,
target: target,
market: Zebpay::Market::NAME
)
adapt(output, market_pair)
end
end

def adapt(output, market_pair)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions spec/exchanges/zebpay/integration/market_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Zebpay integration specs' do
let(:client) { Cryptoexchange::Client.new }
let(:btc_usdt_pair) { Cryptoexchange::Models::MarketPair.new(base: 'BTC', target: 'INR', market: 'zebpay') }
let(:btc_eur_pair) { Cryptoexchange::Models::MarketPair.new(base: 'BTC', target: 'EUR', market: 'zebpay') }

it 'fetch pairs' do
pairs = client.pairs('zebpay')
Expand All @@ -15,10 +15,10 @@
end

it 'fetch ticker' do
ticker = client.ticker(btc_usdt_pair)
ticker = client.ticker(btc_eur_pair)

expect(ticker.base).to eq 'BTC'
expect(ticker.target).to eq 'INR'
expect(ticker.target).to eq 'EUR'
expect(ticker.market).to eq 'zebpay'
expect(ticker.last).to be_a Numeric
expect(ticker.ask).to be_a Numeric
Expand Down
2 changes: 1 addition & 1 deletion spec/exchanges/zebpay/market_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

RSpec.describe Cryptoexchange::Exchanges::Zebpay::Market do
it { expect(described_class::NAME).to eq 'zebpay' }
it { expect(described_class::API_URL).to eq 'https://www.zebapi.com/api/v1' }
it { expect(described_class::API_URL).to eq 'https://www.zebapi.com/pro/v1' }
end

0 comments on commit 515a938

Please sign in to comment.