Class: BTCJammer::Users
- Inherits:
-
Object
- Object
- BTCJammer::Users
- Defined in:
- lib/btcjammer/users.rb
Overview
Contains user authenticated API calls btcjam.com/faq/api
Class Method Summary collapse
- .addr_checks(access_token) ⇒ Object
- .automatic_plans(access_token) ⇒ Object
- .create(email, password) ⇒ Object
- .credit_checks(access_token) ⇒ Object
- .identity_checks(access_token) ⇒ Object
- .invest(access_token, listing_id, amount) ⇒ Object
- .open_listings(access_token) ⇒ Object
- .payables(access_token) ⇒ Object
- .profile(access_token) ⇒ Object
- .receivables(access_token) ⇒ Object
Class Method Details
.addr_checks(access_token) ⇒ Object
42 43 44 45 46 |
# File 'lib/btcjammer/users.rb', line 42 def self.addr_checks(access_token) BTCJammer.api_call(access_token, :addr_checks, :object).addr_checks.collect do |i| OpenStruct.new i end end |
.automatic_plans(access_token) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/btcjammer/users.rb', line 64 def self.automatic_plans(access_token) BTCJammer.api_call(access_token, :automatic_plans, :object) .automatic_plans.collect do |i| OpenStruct.new i end end |
.create(email, password) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/btcjammer/users.rb', line 9 def self.create(email, password) url = "#{API_URL}/" url += "users.json?appid=#{BTCJammer.client_id}&" url += "secret=#{BTCJammer.client_secret}" response = Faraday.post(url, email: email, password: password) JSON.parse(response.body) end |
.credit_checks(access_token) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/btcjammer/users.rb', line 48 def self.credit_checks(access_token) BTCJammer.api_call(access_token, :credit_checks, :object) .credit_checks.collect do |i| OpenStruct.new i end end |
.identity_checks(access_token) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/btcjammer/users.rb', line 35 def self.identity_checks(access_token) BTCJammer.api_call(access_token, :identity_checks, :object) .identity_checks.collect do |i| OpenStruct.new i end end |
.invest(access_token, listing_id, amount) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/btcjammer/users.rb', line 55 def self.invest(access_token, listing_id, amount) token = BTCJammer.get_client access_token response = token.post("#{API_URL}/investments.json", body: { listing_id: listing_id, amount: amount }) investment = OpenStruct.new(JSON.parse(response.body)).listing_investment OpenStruct.new investment end |
.open_listings(access_token) ⇒ Object
23 24 25 |
# File 'lib/btcjammer/users.rb', line 23 def self.open_listings(access_token) BTCJammer.api_call(access_token, :my_open_listings, :array) end |
.payables(access_token) ⇒ Object
31 32 33 |
# File 'lib/btcjammer/users.rb', line 31 def self.payables(access_token) OpenStruct.new BTCJammer.api_call(access_token, :my_payables, :object).user end |