Project

btcjammer

0.0
No commit activity in last 3 years
No release in over 3 years
A simple wrapper for BTCJam API calls with support for user authenticated API calls.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 5.8
~> 10.0
~> 0.34
~> 2.9
~> 1.21

Runtime

~> 0.9
~> 1.8
~> 1.0
 Project Readme

btcjammer

Gem Version Build Status

A Ruby interface to the BTCJam API.

Disclaimer

Note, investing with BTCJam involves risk. This API is not production ready; use at your own risk.

Installation

Add this line to your application's Gemfile:

gem 'btcjammer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install btcjammer

Usage

After installation and without further configuration you can use the following API methods:

require 'btcjammer'

# returns an array of currencies
BTCJammer::Currencies.all

# returns an array of employment types
BTCJammer::EmploymentTypes.all

# returns an array of national ID types
BTCJammer::NationalIDTypes.all

# returns an array of payment types
BTCJammer::PaymentTypes.all

# returns an array of automatic plan templates
BTCJammer::AutomaticPlanTemplates.all

If you want to ask more interesting things, then you'll need a BCTJam account and need to register an app with BTCJam. Finally, grab your Application ID and Secret:

require 'btcjammer'

BTCJammer.configure do |config|
	config.client_id     = "<YOUR APPLICATION ID>"
	config.client_secret = "<YOUR SECRET>"
end

# returns an array of listings (not sure yet if it is paginated and if so how)
BTCJammer::Listings.all

# creates a new user (not very well tested currently)
BTCJammer::Users.create "bilbo.baggins@shire.com", "Elevensies11"

Lastly, the following API methods require an authenticated user:

require 'btcjammer'
BTCJammer.configure do |config|
	config.client_id     = "<YOUR APPLICATION ID>"
	config.client_secret = "<YOUR SECRET>"
	config.scopes				 = [:basic_profile, :extended_profile, :make_loan,
													:identity_information, :address_information, :income_information,
													:invest, :trade, :withdraw, :submit_documents, :manage_references]
	config.redirect_uri  = "<YOUR REGISTERED CALLBACK URL>"
end

# send the user here to authorize
auth = BTCJammer::OAuth.new

url = auth.authorization_url

# assuming you get a code back
code = "<CODE YOU RECEIVED IN CALLBACK>"
access_token = auth.get_access_token(code)

# or if you have a saved token
access_token = BTCJammer::OAuth.from_token token

# retrieve the auth'd user's profile
BTCJammer::Users.profile access_token.token

# retrieve the auth'd user's payables
BTCJammer::Users.payables access_token.token

# retrieve the auth'd user's receivables
BTCJammer::Users.receivables access_token.token

# retrieve the auth'd user's credit checks
BTCJammer::Users.credit_checks access_token.token

# retrieve the auth'd user's addr checks
BTCJammer::Users.addr_checks access_token.token

# retrieve the auth'd user's identity checks
BTCJammer::Users.identity_checks access_token.token

# retrieve the auth'd user's open listings
BTCJammer::Users.open_listings access_token.token

# invest in a listing
BTCJammer::User.invest access_token.token, {:listing_id => 123, :amount => 0.1}

# create a new listing
params = {
  loan_purpose_id: 1,
  currency_id: 2,
  amount: 0.01,
  term_days: 123,
  payment_type_id: 3,
  locale_id: 4,
  title: 'A new listing',
	description: 'Sweet!'
}
BTCJammer::Listings.create access_token.token, params

Contributing

If you would like ideas on what to work on, then please send me a line. There are plenty of opportunities to refactor code and extend the current functionality.

  1. Fork it ( https://github.com/cacciatc/btcjammer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write tests
  4. Run rubocop
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create a new Pull Request