diff --git a/CHANGELOG b/CHANGELOG index 6c6ea58..690acbc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +2.0.0 +- Removes rest/v2 pulse functions +- Fixes rest/v2 margin & funding info functions +- Fixes rest/v2 offers function + 1.1.0 - Bump dependencies for ruby 3.x - Replace faraday_adapter_socks with custom class diff --git a/bitfinex-rb.gemspec b/bitfinex-rb.gemspec index 6167ac4..9cbffd0 100644 --- a/bitfinex-rb.gemspec +++ b/bitfinex-rb.gemspec @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |spec| spec.name = 'bitfinex-rb' - spec.version = '1.1.0' + spec.version = '2.0.0' spec.authors = ['Bitfinex'] spec.email = ['developers@bitfinex.com'] spec.summary = %q{Bitfinex API Wrapper} @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.homepage = 'https://www.bitfinex.com/' spec.license = 'MIT' - spec.files = Dir['lib/**/*'] + spec.files = Dir['lib/**/*'] spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] diff --git a/docs/events.md b/docs/events.md index 492355a..6ceef1b 100644 --- a/docs/events.md +++ b/docs/events.md @@ -46,7 +46,7 @@ * `:wallet_snapshot` * `:wallet_update` * `:balance_update` -* `:marign_info_update` +* `:margin_info_update` * `:funding_info_update` * `:funding_trade_entry` * `:funding_trade_update` diff --git a/examples/rest/v2/pulse.rb b/examples/rest/v2/pulse.rb deleted file mode 100644 index db6546b..0000000 --- a/examples/rest/v2/pulse.rb +++ /dev/null @@ -1,47 +0,0 @@ -require_relative '../../../lib/bitfinex.rb' - -client = Bitfinex::RESTv2.new({ - :url => ENV['REST_URL'], - :api_key => ENV['API_KEY'], - :api_secret => ENV['API_SECRET'] -}) - -# Get pulse profile -p client.get_pulse_profile('Bitfinex') - -# Get public pulse history -p client.get_public_pulse_history({ :limit => 5 }) - -# Submit new Pulse message -pulse = client.submit_pulse({ - :title => '1234 5678 Foo Bar Baz Qux TITLE', - :content => '1234 5678 Foo Bar Baz Qux Content', - :isPublic => 0, - :isPin => 1 -}) -p pulse - -# Delete Pulse message -p "About to delete pulse: #{pulse[:id]}" -p client.delete_pulse(pulse[:id]) - -# Get private pulse history -p client.get_private_pulse_history() - -# Submit Pulse message comment -# 1 - create pulse message -pulse2 = client.submit_pulse({ - :title => '2 1234 5678 Foo Bar Baz Qux TITLE', - :content => '2 1234 5678 Foo Bar Baz Qux Content', - :isPublic => 0, - :isPin => 1 -}) - -# 2 - submit comment for above pulse message -p client.submit_pulse_comment({ - :parent => pulse2[:id], - :title => 'comment 2 1234 5678 Foo Bar Baz Qux TITLE', - :content => 'comment 2 1234 5678 Foo Bar Baz Qux Content', - :isPublic => 0, - :isPin => 1 -}) diff --git a/lib/bitfinex.rb b/lib/bitfinex.rb index 9ca9924..7cd4399 100644 --- a/lib/bitfinex.rb +++ b/lib/bitfinex.rb @@ -37,5 +37,3 @@ require_relative './models/trading_ticker' require_relative './models/user_info' require_relative './models/wallet' -require_relative './models/pulse_profile' -require_relative './models/pulse' diff --git a/lib/models/pulse.rb b/lib/models/pulse.rb deleted file mode 100644 index 567225e..0000000 --- a/lib/models/pulse.rb +++ /dev/null @@ -1,37 +0,0 @@ -require_relative './model' - -module Bitfinex - module Models - class Pulse < Model - BOOL_FIELDS = [] - FIELDS = { - :id => 0, - :mts_create => 1, - :pulse_user_id => 3, - :title => 5, - :content => 6, - :is_pin => 9, - :is_public => 10, - :comments_disabled => 11, - :tags => 12, - :attachments => 13, - :meta => 14, - :likes => 15, - :profile => 18, - :comments => 19 - } - - FIELDS.each do |key, index| - attr_accessor key - end - - def initialize (data) - super(data, FIELDS, BOOL_FIELDS) - end - - def self.unserialize (data) - Model.unserialize(data, FIELDS, BOOL_FIELDS) - end - end - end -end diff --git a/lib/models/pulse_profile.rb b/lib/models/pulse_profile.rb deleted file mode 100644 index d3bb7a2..0000000 --- a/lib/models/pulse_profile.rb +++ /dev/null @@ -1,31 +0,0 @@ -require_relative './model' - -module Bitfinex - module Models - class PulseProfile < Model - BOOL_FIELDS = [] - FIELDS = { - :id => 0, - :mts_create => 1, - :nickname => 3, - :picture => 5, - :text => 6, - :twitter_handle => 9, - :followers => 11, - :following => 12 - } - - FIELDS.each do |key, index| - attr_accessor key - end - - def initialize (data) - super(data, FIELDS, BOOL_FIELDS) - end - - def self.unserialize (data) - return Model.unserialize(data, FIELDS, BOOL_FIELDS) - end - end - end -end diff --git a/lib/rest/v2.rb b/lib/rest/v2.rb index 8b03c50..ff0f2be 100644 --- a/lib/rest/v2.rb +++ b/lib/rest/v2.rb @@ -9,7 +9,6 @@ require_relative './v2/wallet' require_relative './v2/funding' require_relative './v2/positions' -require_relative './v2/pulse' module Bitfinex class RESTv2 @@ -28,7 +27,6 @@ class RESTv2 include Bitfinex::RESTv2Wallet include Bitfinex::RESTv2Funding include Bitfinex::RESTv2Positions - include Bitfinex::RESTv2Pulse def initialize(args = {}) self.api_endpoint = args[:url] ? "#{args[:url]}/v2/" : "https://api.bitfinex.com/v2/" diff --git a/lib/rest/v2/margin.rb b/lib/rest/v2/margin.rb index 7a03602..2f6cc81 100644 --- a/lib/rest/v2/margin.rb +++ b/lib/rest/v2/margin.rb @@ -6,7 +6,7 @@ module RESTv2Margin # @example: # client.offers def offers - authenticated_post("auth/r/offers").body + authenticated_post("auth/r/funding/offers").body end # Get account margin info @@ -17,7 +17,7 @@ def offers # @example: # client.margin_info("tBTCUSD") def margin_info(symbol = "base") - authenticated_post("auth/r/margin/#{symbol}").body + authenticated_post("auth/r/info/margin/#{symbol}").body end # Get account funding info @@ -27,7 +27,7 @@ def margin_info(symbol = "base") # @example: # client.funding_info def funding_info(symbol = "fUSD") - authenticated_post("auth/r/funding/#{symbol}").body + authenticated_post("auth/r/info/funding/#{symbol}").body end end end diff --git a/lib/rest/v2/pulse.rb b/lib/rest/v2/pulse.rb deleted file mode 100644 index 4dfba89..0000000 --- a/lib/rest/v2/pulse.rb +++ /dev/null @@ -1,105 +0,0 @@ -module Bitfinex - module RESTv2Pulse - ### - # Get Pulse Profile - # - # @param [string] nickname Nickname of pulse profile - # - # @return [Hash] the Pulse Profile - # - # @see https://docs.bitfinex.com/reference#rest-public-pulse-profile - ### - def get_pulse_profile(nickname) - resp = get("pulse/profile/#{nickname}").body - Bitfinex::Models::PulseProfile.unserialize(resp) - end - - ### - # Get Public Pulse History - # - # @param [int] end (optional) Return only the entries after this timestamp - # @param [int] limit (optional) Limit the number of entries to return. Default is 25. - # - # @return [Array] public pulse message - # - # @see https://docs.bitfinex.com/reference#rest-public-pulse-hist - ### - def get_public_pulse_history(params = {}) - pulses = get("pulse/hist", params).body - pulses.map { |p| deserialize_pulse_with_profile(p) } - end - - ### - # Get Private Pulse History - # - # @param [int] isPublic allows to receive the public pulse history with the UID_LIKED field - # - # @return [Array] private pulse message - # - # @see https://docs.bitfinex.com/reference#rest-auth-pulse-hist - ### - def get_private_pulse_history(params = {}) - pulses = authenticated_post("auth/r/pulse/hist", params).body - pulses.map { |p| deserialize_pulse_with_profile(p) } - end - - ### - # Submit new Pulse message - # - # @param [Hash] pulse - # - # @return [Hash] pulse - # - # @see https://docs.bitfinex.com/reference#rest-auth-pulse-add - ### - def submit_pulse(pulse) - resp = authenticated_post("auth/w/pulse/add", params: pulse).body - Bitfinex::Models::Pulse.unserialize(resp) - end - - ### - # Submit Pulse message comment, requires :parent (pulse id) to - # be present in request payload - # - # @param [Hash] pulse - # - # @return [Hash] pulse - # - # @see https://docs.bitfinex.com/reference#rest-auth-pulse-add - ### - def submit_pulse_comment(pulse) - if pulse[:parent].to_s.strip.empty? - raise ":parent (pulse id value) is required for comments" - end - resp = authenticated_post("auth/w/pulse/add", params: pulse).body - Bitfinex::Models::Pulse.unserialize(resp) - end - - ### - # Delete Pulse message - # - # @param [string] id pulse id - # - # @return [boolean] true if success, false if error - # - # @see https://docs.bitfinex.com/reference#rest-auth-pulse-del - ### - def delete_pulse(id) - resp = authenticated_post("auth/w/pulse/del", params: { :pid => id }).body - if resp[0] == 1 - return true - end - return false - end - - private - - def deserialize_pulse_with_profile(payload) - pulse = Bitfinex::Models::Pulse.unserialize(payload) - if pulse[:profile].any? - pulse[:profile] = Bitfinex::Models::PulseProfile.unserialize(pulse[:profile][0]) - end - pulse - end - end -end