Class: BTCJammer::Listings
- Inherits:
-
Object
- Object
- BTCJammer::Listings
- Defined in:
- lib/btcjammer/listings.rb
Overview
Class Method Summary collapse
Class Method Details
.all ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/btcjammer/listings.rb', line 8 def self.all url = "#{API_URL}/" url += "listings.json?appid=#{BTCJammer.client_id}&" url += "secret=#{BTCJammer.client_secret}" response = Faraday.get(url) JSON.parse(response.body).collect do |c| listing = OpenStruct.new c['listing'] listing.user = OpenStruct.new listing.user listing end end |
.create(access_token, params) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/btcjammer/listings.rb', line 23 def self.create(access_token, params) token = BTCJammer.get_client access_token response = token.post("#{API_URL}/listings.json", body: { listing: params.to_json }) result = OpenStruct.new JSON.parse(response.body) OpenStruct.new(result.listing) end |
.create_lead(access_token, params) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/btcjammer/listings.rb', line 31 def self.create_lead(access_token, params) token = BTCJammer.get_client access_token response = token.post("#{API_URL}/lead_listings.json", body: { lead_listing: params.to_json }) result = OpenStruct.new JSON.parse(response.body) OpenStruct.new(result.lead_listing) end |