No commit activity in last 3 years
No release in over 3 years
Mountable engine that fetches completed paxful trades.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.3.0
~> 5.2
 Project Readme

PaxfulEngine

A mountable Rails engine that saves completed trades from paxful marketplace and lets you do anything with it.

Installation

Add this line to your application's Gemfile:

gem 'paxful_engine-rails'

And then execute:

$ bundle
$ rails paxful_engine:install:migrations
$ rails db:migrate

Or install it yourself as:

$ gem install paxful_engine-rails

Configuration

Create an initializer in your Rails application:

# config/initializers/paxful_engine-rails.rb

PaxfulEngine.configure do |c|
  c.paxful_key = "your paxful key"
  c.paxful_secret = "your paxful secret"
  c.on_sync_callback = "SyncCallback"
  c.on_failure_callback = "FailureCallback"
end

c.on_sync_callback

An object that responds to call that gets executed after a trade is (re)processed. It accepts a Trade as its only argument.

# example
class SyncCallback

  def self.call(trade)
    # do anything you want with this record
  end

end

c.on_failure_callback

An object that responds to call that gets executed when a trade cannot be created.

It accepts two arguments:

  • exception
  • payload
# example
class FailureCallback

  def self.call(e, payload)
    # log somewhere...
  end

end

Usage

Add this to your scheduler somewhere:

# sidekiq_cron.yml
refresh_paxful_order_book:
  cron: "*/2 * * * * Asia/Singapore" # runs every 2 minutes
  class: "PaxfulEngine::SyncOrderBookJob"

From the host app:

  • Check list of trades at /paxful_engine/trades.
  • Details per trade at /paxful_engine/trades/:id.

Development

$ rails db:create db:migrate db:test:prepare

If you need to re-record cassettes, cp .env{,.local} and edit the values.

Testing

$ bundle exec rspec spec

License

The gem is available as open source under the terms of the MIT License.