Module: LocalBitcoins::Ads

Included in:
Client
Defined in:
lib/localbitcoins/client/ads.rb

Instance Method Summary collapse

Instance Method Details

#ad(ad_id) ⇒ Object



56
57
58
# File 'lib/localbitcoins/client/ads.rb', line 56

def ad(ad_id)
  request(:get, "/api/ad-get/#{ad_id}/").data.ad_list[0]
end

#ad_list(ads) ⇒ Object

ads - comma separated list of ad ids [string]



52
53
54
# File 'lib/localbitcoins/client/ads.rb', line 52

def ad_list(ads)
  request(:get, "/api/ad-get/", {:ads=>ads}).data
end

#adsObject

Get a list of the token owner’s ads



4
5
6
# File 'lib/localbitcoins/client/ads.rb', line 4

def ads
  request(:get, '/api/ads/').data
end

#create_ad(params = {}) ⇒ Object

Create a new ad for the token owner

  • Required fields -

min_amount - minimum amount for sale in fiat [string] max_amount - maximum amount for sale in fiat [string] price_equation - price using price equation operators [string] lat - latitude of location [float] lon - longitude of location [float] city - city of listing [string] location_string - text representation of location [string] countrycode - two letter countrycode [string] account_info - [string] bank_name - [string] sms_verification_required - only receive contacts with verified phone numbers [boolean] track_max_amount - decrease max sell amount in relation to liquidity [boolean] trusted_required - only allow trusted contacts [boolean] currency - three letter fiat representation [string]



47
48
49
# File 'lib/localbitcoins/client/ads.rb', line 47

def create_ad(params={})
  request(:post, '/api/ad-create/', params).data
end

#update_ad(id, params = {}) ⇒ Object

Update one of the token owner’s ads

id - id of the ad you want to update visibility - the ad’s visibility [boolean] min_amount - minimum selling price [string] max_amount - maximum buying price [string] price_equation - equation to calculate price [string]

NOTE 1: Setting min_amount or max_amount to nil will unset them. NOTE 2: “Floating price” must be false in you ad’s edit form for price_equation to go through



19
20
21
22
23
24
25
26
27
# File 'lib/localbitcoins/client/ads.rb', line 19

def update_ad(id, params={})
  old_ad = ad(id).data
  updated_params = {
      :min_amount => old_ad.min_amount,
      :max_amount => old_ad.max_amount,
      :visible    => old_ad.visible
  }.merge(params)
  request(:post, "/api/ad/#{id}/", updated_params).data
end