Module: LocalBitcoins::Public
- Included in:
- Client
- Defined in:
- lib/localbitcoins/client/public.rb
Constant Summary collapse
- ROOT =
'https://localbitcoins.com'
Instance Method Summary collapse
- #currencies ⇒ Object
-
#local_buy_ad(params = {}) ⇒ Object
-
Required fields - location_id - id for location found using places method location_slug - slug name for location found using places method.
-
-
#local_sell_ad(params = {}) ⇒ Object
NOTE: Same format as local_buy_ad, but buy is replaced with sell.
-
#online_buy_ads_lookup(params = {}) ⇒ Object
Valid API endpoints include: /buy-bitcoins-online/countrycode:2/country_name/payment_method/.json /buy-bitcoins-online/countrycode:2/country_name/.json /buy-bitcoins-online/currency:3/payment_method/.json /buy-bitcoins-online/currency:3/.json /buy-bitcoins-online/payment_method/.json /buy-bitcoins-online/.json.
-
#online_sell_ads_lookup(params = {}) ⇒ Object
NOTE: Same format as online_buy_ads_lookup, but buy is replaced with sell.
- #payment_methods(countrycode = nil) ⇒ Object
-
#places(params = {}) ⇒ Object
-
Required fields - lat - latitude of location [float] lon - longitude of location [float].
-
Instance Method Details
#currencies ⇒ Object
60 61 62 63 |
# File 'lib/localbitcoins/client/public.rb', line 60 def currencies currencies_uri = open("#{ROOT}/api/currencies/") Hashie::Mash.new(JSON.parse(currencies_uri.read)).data if currencies_uri.status.first=='200' end |
#local_buy_ad(params = {}) ⇒ Object
-
Required fields -
location_id - id for location found using places method location_slug - slug name for location found using places method
-
Optional fields -
lat - latitude of location [float] lon - longitude of location [float]
42 43 44 45 |
# File 'lib/localbitcoins/client/public.rb', line 42 def local_buy_ad(params={}) local_buy_ad_uri = open("#{ROOT}/buy-bitcoins-with-cash/#{params[:location_id]}/#{params[:location_slug].downcase}/.json?lat=#{params[:lat]}&lon=#{params[:lon]}") Hashie::Mash.new(JSON.parse(local_buy_ad_uri.read)) if local_buy_ad_uri.status.first=='200' end |
#local_sell_ad(params = {}) ⇒ Object
NOTE: Same format as local_buy_ad, but buy is replaced with sell
49 50 51 52 |
# File 'lib/localbitcoins/client/public.rb', line 49 def local_sell_ad(params={}) local_sell_ad_uri = open("#{ROOT}/sell-bitcoins-with-cash/#{params[:location_id]}/#{params[:location_slug].downcase}/.json?lat=#{params[:lat]}&lon=#{params[:lon]}") Hashie::Mash.new(JSON.parse(local_sell_ad_uri.read)) if local_sell_ad_uri.status.first=='200' end |
#online_buy_ads_lookup(params = {}) ⇒ Object
Valid API endpoints include: /buy-bitcoins-online/countrycode:2/country_name/payment_method/.json /buy-bitcoins-online/countrycode:2/country_name/.json /buy-bitcoins-online/currency:3/payment_method/.json /buy-bitcoins-online/currency:3/.json /buy-bitcoins-online/payment_method/.json /buy-bitcoins-online/.json
NOTE: countrycode must be 2 characters and currency must be 3 characters
16 17 18 19 20 21 22 |
# File 'lib/localbitcoins/client/public.rb', line 16 def online_buy_ads_lookup(params={}) params.each_key do |k| params[k]<<'/' end online_buy_ads_uri = open("#{ROOT}/buy-bitcoins-online/#{params[:countrycode]}#{params[:currency]}#{params[:country_name]}#{params[:payment_method]}.json") Hashie::Mash.new(JSON.parse(online_buy_ads_uri.read)) if online_buy_ads_uri.status.first=='200' end |
#online_sell_ads_lookup(params = {}) ⇒ Object
NOTE: Same format as online_buy_ads_lookup, but buy is replaced with sell
26 27 28 29 30 31 32 |
# File 'lib/localbitcoins/client/public.rb', line 26 def online_sell_ads_lookup(params={}) params.each do |k,v| params[k]=v<<'/' unless v.nil? end online_sell_ads_uri = open("#{ROOT}/sell-bitcoins-online/#{params[:countrycode]}#{params[:currency]}#{params[:country_name]}#{params[:payment_method]}.json") Hashie::Mash.new(JSON.parse(online_sell_ads_uri.read)) if online_sell_ads_uri.status.first=='200' end |
#payment_methods(countrycode = nil) ⇒ Object
54 55 56 57 58 |
# File 'lib/localbitcoins/client/public.rb', line 54 def payment_methods(countrycode=nil) countrycode<<'/' unless countrycode.nil? payment_methods_uri = open("#{ROOT}/api/payment_methods/#{countrycode}") Hashie::Mash.new(JSON.parse(payment_methods_uri.read)).data if payment_methods_uri.status.first=='200' end |
#places(params = {}) ⇒ Object
-
Required fields -
lat - latitude of location [float] lon - longitude of location [float]
-
Optional fields -
countrycode - 2 letter countrycode location_string - location name in string form
73 74 75 76 |
# File 'lib/localbitcoins/client/public.rb', line 73 def places(params={}) places_uri = open("#{ROOT}/api/places/?#{params.to_query}") Hashie::Mash.new(JSON.parse(places_uri.read)).data if places_uri.status.first=='200' end |