localbitcoins 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +2 -0
- data/Gemfile.lock +16 -19
- data/README.md +319 -35
- data/Rakefile +1 -1
- data/lib/localbitcoins/client/ads.rb +45 -9
- data/lib/localbitcoins/client/contacts.rb +66 -0
- data/lib/localbitcoins/client/escrows.rb +8 -12
- data/lib/localbitcoins/client/markets.rb +27 -0
- data/lib/localbitcoins/client/public.rb +78 -0
- data/lib/localbitcoins/client/users.rb +16 -0
- data/lib/localbitcoins/client/wallet.rb +28 -0
- data/lib/localbitcoins/client.rb +13 -1
- data/lib/localbitcoins/request.rb +11 -15
- data/lib/localbitcoins/version.rb +1 -1
- data/localbitcoins.gemspec +3 -3
- data/spec/client_spec.rb +397 -8
- data/spec/fixtures/account_info.json +14 -0
- data/spec/fixtures/ad_create.json +5 -0
- data/spec/fixtures/ad_list.json +103 -0
- data/spec/fixtures/ad_single.json +55 -0
- data/spec/fixtures/ad_update.json +5 -0
- data/spec/fixtures/ads.json +103 -0
- data/spec/fixtures/contact_message.json +5 -0
- data/spec/fixtures/contacts.json +52 -0
- data/spec/fixtures/contacts_active.json +165 -0
- data/spec/fixtures/contacts_active_buyers.json +60 -0
- data/spec/fixtures/contacts_active_sellers.json +111 -0
- data/spec/fixtures/contacts_cancel.json +5 -0
- data/spec/fixtures/contacts_canceled_contacts.json +162 -0
- data/spec/fixtures/contacts_closed_contacts.json +109 -0
- data/spec/fixtures/contacts_contact_info.json +52 -0
- data/spec/fixtures/contacts_contacts_info.json +111 -0
- data/spec/fixtures/contacts_create.json +10 -0
- data/spec/fixtures/contacts_messages.json +43 -0
- data/spec/fixtures/contacts_released_contacts.json +60 -0
- data/spec/fixtures/currencies.json +505 -0
- data/spec/fixtures/currency_ticker.json +236 -0
- data/spec/fixtures/escrow_release.json +5 -0
- data/spec/fixtures/escrows.json +24 -22
- data/spec/fixtures/local_buy_ads.json +93 -0
- data/spec/fixtures/local_sell_ads.json +93 -0
- data/spec/fixtures/logout.json +0 -0
- data/spec/fixtures/myself.json +14 -0
- data/spec/fixtures/online_buy_ads.json +637 -0
- data/spec/fixtures/online_sell_ads.json +2160 -0
- data/spec/fixtures/orderbook.json +1739 -0
- data/spec/fixtures/payment_methods.json +95 -0
- data/spec/fixtures/places.json +15 -0
- data/spec/fixtures/ticker.json +254 -0
- data/spec/fixtures/trades.json +3002 -0
- data/spec/fixtures/wallet.json +34 -0
- data/spec/fixtures/wallet_addr.json +6 -0
- data/spec/fixtures/wallet_balance.json +16 -0
- data/spec/fixtures/wallet_send.json +5 -0
- data/spec/spec_helper.rb +26 -29
- metadata +51 -7
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTcyMzNjNTJjYWU2OTM0YmJhNjZlNGViM2RiYmM5ODk4ZjkxZTQ5OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTA5Mzk3ZGQ3MTdmYTg0ZGYxNmM2ZTU2OTYyMDI1Mjk5MDgwZjY4Ng==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzI4ZWZhMWI4YWFiNTdlYzk2Y2UwMDcxYWE4Nzc1MmE5N2NhYTU2M2Y4NTEx
|
10
|
+
MTQ4YjIyNThiNzVjMzY5OTFmYzFhNjM4NzBjYjBiODE1YmYxNWJhOWFiNTQ5
|
11
|
+
NTNjY2VhMjExYzU2MWJhMDYwZGQyNzVjZWZkOTViOTgwYTAxNWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzYzODlmZWUyY2U3Mjg2MWFlMmI4ODRmMzE0NjhhNzc1OTRmZjMyMmE0NGVi
|
14
|
+
MmU0MjQyM2IxNzYzODhhZDU3YWU2ZmI2ZWEwNGE1Y2UzNGVjMTEwNGMwODc0
|
15
|
+
ZTU0MmJmMmIwOWYzYzgyNzM3NDdhYmIyOTdjOTc4ZTNiNDgzMjk=
|
data/Gemfile.lock
CHANGED
@@ -5,36 +5,33 @@ PATH
|
|
5
5
|
activesupport (~> 3)
|
6
6
|
hashie (~> 2.0.2)
|
7
7
|
json (~> 1.8.0)
|
8
|
-
oauth2 (~> 0.9.
|
8
|
+
oauth2 (~> 0.9.4)
|
9
9
|
rest-client (~> 1.6)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (3.2.
|
15
|
-
i18n (
|
14
|
+
activesupport (3.2.18)
|
15
|
+
i18n (~> 0.6, >= 0.6.4)
|
16
16
|
multi_json (~> 1.0)
|
17
17
|
addressable (2.3.5)
|
18
18
|
crack (0.4.0)
|
19
19
|
safe_yaml (~> 0.9.0)
|
20
20
|
diff-lcs (1.2.4)
|
21
|
-
faraday (0.
|
22
|
-
multipart-post (
|
21
|
+
faraday (0.9.0)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
23
|
hashie (2.0.5)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
httpauth (~> 0.2)
|
36
|
-
jwt (~> 0.1.4)
|
37
|
-
multi_json (~> 1.0)
|
24
|
+
i18n (0.6.9)
|
25
|
+
json (1.8.1)
|
26
|
+
jwt (1.0.0)
|
27
|
+
mime-types (2.3)
|
28
|
+
multi_json (1.10.1)
|
29
|
+
multi_xml (0.5.5)
|
30
|
+
multipart-post (2.0.0)
|
31
|
+
oauth2 (0.9.4)
|
32
|
+
faraday (>= 0.8, < 0.10)
|
33
|
+
jwt (~> 1.0)
|
34
|
+
multi_json (~> 1.3)
|
38
35
|
multi_xml (~> 0.5)
|
39
36
|
rack (~> 1.2)
|
40
37
|
rack (1.5.2)
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# LocalBitcoins API Gem 0.0
|
1
|
+
# LocalBitcoins API Gem 1.0.0
|
2
2
|
|
3
3
|
This gem provides a simple, extensible Ruby wrapper to access the [LocalBitcoins API](https://localbitcoins.com/api-docs/).
|
4
4
|
|
5
|
-
## Installation
|
5
|
+
## Installation & Setup
|
6
6
|
|
7
7
|
Install the gem:
|
8
8
|
```
|
@@ -11,22 +11,36 @@ gem install localbitcoins
|
|
11
11
|
|
12
12
|
Or include it in your Gemfile:
|
13
13
|
```
|
14
|
-
gem '
|
14
|
+
gem 'localbitcoins'
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
You can use the gem with or without OAuth2 for authentication. Without authentication the API only allows access to the public endpoints documented [here (Ad Listings)](https://localbitcoins.com/api-docs/public/) and [here (Market Data)](https://localbitcoins.com/api-docs/#toc7)
|
18
18
|
|
19
|
-
|
19
|
+
### Setting Up The Client
|
20
20
|
|
21
|
-
There are a number of ways to implement
|
21
|
+
For authenticated requests to the LocalBitcoins API, you must [register your application](https://localbitcoins.com/accounts/api/) and get your API credentials. Use the Client ID and Client Secret to receive an access token via OAuth2. There are a number of ways to implement OAuth2, and it is largely left up to you to decide how to do it. If you've never used OAuth2 before, reading [this tutorial](http://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified) is a good place to start!
|
22
22
|
|
23
|
-
Once you have your token, you can
|
23
|
+
Once you have your token, you can get to setting up the LocalBitcoins client.
|
24
24
|
|
25
25
|
``` ruby
|
26
|
+
# Authenticated
|
27
|
+
|
26
28
|
# long version
|
27
|
-
client = LocalBitcoins::Client.new(
|
28
|
-
|
29
|
-
|
29
|
+
client = LocalBitcoins::Client.new(
|
30
|
+
client_id: 'CLIENT_ID',
|
31
|
+
client_secret: 'CLIENT_SECRET',
|
32
|
+
oauth_token: 'OAUTH_TOKEN'
|
33
|
+
)
|
34
|
+
# slightly shorter version
|
35
|
+
client = LocalBitcoins.new(
|
36
|
+
client_id: 'CLIENT_ID',
|
37
|
+
client_secret: 'CLIENT_SECRET',
|
38
|
+
oauth_token: 'OAUTH_TOKEN'
|
39
|
+
)
|
40
|
+
|
41
|
+
# Unauthenticated
|
42
|
+
client = LocalBitcoins.new
|
43
|
+
|
30
44
|
```
|
31
45
|
|
32
46
|
### Global Configuration
|
@@ -36,12 +50,12 @@ To make things easier, you can define your client credentials at a global level:
|
|
36
50
|
``` ruby
|
37
51
|
# Set the configuration
|
38
52
|
LocalBitcoins.configure(
|
39
|
-
client_id: '
|
40
|
-
client_secret: '
|
53
|
+
client_id: 'CLIENT_ID',
|
54
|
+
client_secret: 'CLIENT_SECRET'
|
41
55
|
)
|
42
56
|
|
43
57
|
# Get the configuration
|
44
|
-
LocalBitcoins.configuration # => { client_id => '
|
58
|
+
LocalBitcoins.configuration # => { client_id => 'CLIENT_ID', client_secret => 'CLIENT_SECRET' }
|
45
59
|
|
46
60
|
# Reset the configuration
|
47
61
|
LocalBitcoins.reset_configuration
|
@@ -55,47 +69,317 @@ There are several ways to solve the problem of keeping your credentials secret.
|
|
55
69
|
|
56
70
|
## Usage
|
57
71
|
|
58
|
-
|
72
|
+
Nearly every endpoint found in both the [logged in](https://localbitcoins.com/api-docs) and [public](https://localbitcoins.com/api-docs/public/) documentation is supported by this gem.
|
73
|
+
|
74
|
+
### Ads
|
59
75
|
|
60
|
-
|
76
|
+
Return a list of the token owner's ads with the following method:
|
61
77
|
|
62
78
|
``` ruby
|
63
|
-
|
79
|
+
ads = client.ads
|
64
80
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
e.actions.release_url # => url to release to escrow
|
81
|
+
ads.ad_list.each do |a|
|
82
|
+
a.data.visible # => boolean value of the ad's visibility
|
83
|
+
a.data.email # => valid e-mail string or null
|
84
|
+
a.data.location_string # => human-readable location
|
85
|
+
# and many more pieces of data!
|
71
86
|
end
|
72
87
|
```
|
88
|
+
Create a new ad for the token owner:
|
89
|
+
|
90
|
+
``` ruby
|
91
|
+
# - Required fields -
|
92
|
+
# min_amount - minimum amount for sale in fiat [string]
|
93
|
+
# max_amount - maximum amount for sale in fiat [string]
|
94
|
+
# price_equation - price using price equation operators [string]
|
95
|
+
# lat - latitude of location [float]
|
96
|
+
# lon - longitude of location [float]
|
97
|
+
# city - city of listing [string]
|
98
|
+
# location_string - text representation of location [string]
|
99
|
+
# countrycode - two letter countrycode [string]
|
100
|
+
# account_info - [string]
|
101
|
+
# bank_name - [string]
|
102
|
+
# sms_verification_required - only receive contacts with verified phone numbers [boolean]
|
103
|
+
# track_max_amount - decrease max sell amount in relation to liquidity [boolean]
|
104
|
+
# trusted_required - only allow trusted contacts [boolean]
|
105
|
+
# currency - three letter fiat representation [string]
|
106
|
+
#
|
107
|
+
# pass a hash of the above fields
|
108
|
+
# returns a message on success
|
109
|
+
client.create_ad(params)
|
110
|
+
```
|
73
111
|
|
74
|
-
|
112
|
+
Update existing ad for the token owner.
|
75
113
|
|
76
|
-
|
114
|
+
``` ruby
|
115
|
+
# - Required Fields -
|
116
|
+
# id - id of the ad you want to update
|
117
|
+
# visibility - the ad's visibility [boolean]
|
118
|
+
# price_equation - equation to calculate price [string]
|
119
|
+
#
|
120
|
+
# NOTE 1: Setting min_amount or max_amount to nil will unset them.
|
121
|
+
# NOTE 2: "Floating price" must be false in you ad's edit form for price_equation to go through
|
122
|
+
#
|
123
|
+
# pass a hash of the above fields, plus any other editable fields
|
124
|
+
# returns a message on success
|
125
|
+
client.update_ad(id,params)
|
126
|
+
```
|
127
|
+
|
128
|
+
List of ads from a comma separated string of ids
|
129
|
+
``` ruby
|
130
|
+
# pass a comma separated string of ids
|
131
|
+
ads = client.ad_list("12345,123456,1234567")
|
132
|
+
```
|
133
|
+
Gets a single ad from its id
|
134
|
+
|
135
|
+
``` ruby
|
136
|
+
ad = client.ad(12345)
|
137
|
+
```
|
138
|
+
### Escrows
|
139
|
+
|
140
|
+
View token owner's releasable escrows
|
141
|
+
NOTE: This endpoint is not documented by LocalBitcoins and may or may not work.
|
142
|
+
``` ruby
|
143
|
+
escrows = client.escrows
|
144
|
+
# escrows are listed in escrows.escrow_list
|
145
|
+
```
|
146
|
+
Release an escrow
|
77
147
|
|
78
148
|
``` ruby
|
149
|
+
# pass the id of the contact which the escrow is associated with
|
79
150
|
# returns a complimentary message if the escrow successfully released
|
80
|
-
release = client.escrow_release(
|
151
|
+
release = client.escrow_release(contact_id)
|
81
152
|
```
|
82
153
|
|
83
|
-
###
|
154
|
+
### Contacts
|
84
155
|
|
85
|
-
|
156
|
+
List of active contacts
|
157
|
+
``` ruby
|
158
|
+
# This method can filter contacts by contact_type, which can be "buyer" or "seller"
|
159
|
+
#
|
160
|
+
# buyers and sellers
|
161
|
+
contacts = client.active_contacts
|
162
|
+
# buyers only
|
163
|
+
contacts = client.active_contacts('buyer')
|
164
|
+
# sellers only
|
165
|
+
contacts = client.active_contacts('seller')
|
166
|
+
```
|
86
167
|
|
168
|
+
Released, canceled, and closed contacts have their own methods as well, which can be filtered the same as above.
|
87
169
|
``` ruby
|
88
|
-
|
170
|
+
released = client.released_contacts
|
171
|
+
closed = client.closed_contacts
|
172
|
+
canceled = client.canceled_contacts
|
173
|
+
```
|
89
174
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
175
|
+
Get a contact based on the id
|
176
|
+
``` ruby
|
177
|
+
released = client.released_contacts
|
178
|
+
closed = client.closed_contacts
|
179
|
+
canceled = client.canceled_contacts
|
180
|
+
```
|
181
|
+
|
182
|
+
Get a contact based on the id
|
183
|
+
``` ruby
|
184
|
+
contact = client.contact_info(1234)
|
185
|
+
```
|
186
|
+
|
187
|
+
Get a list of contacts from a comma separated string of ids
|
188
|
+
``` ruby
|
189
|
+
contacts = client.contacts_info("1234,12345,1234567")
|
190
|
+
# access list at contacts.contact_list
|
96
191
|
```
|
97
192
|
|
98
|
-
|
193
|
+
Create a new contact for the token owner
|
194
|
+
``` ruby
|
195
|
+
client.create_contact(ad_id, amount, message)
|
196
|
+
```
|
197
|
+
|
198
|
+
Fund an active contact for the token owner
|
199
|
+
``` ruby
|
200
|
+
client.fund_contact(contact_id)
|
201
|
+
```
|
202
|
+
|
203
|
+
Cancel an active contact for the token owner
|
204
|
+
``` ruby
|
205
|
+
client.cancel_contact(contact_id)
|
206
|
+
```
|
207
|
+
|
208
|
+
Initiate a dispute with on a contact for the token owner
|
209
|
+
``` ruby
|
210
|
+
client.dispute_contact(contact_id)
|
211
|
+
```
|
212
|
+
|
213
|
+
Send a message to a contact for the token owner
|
214
|
+
``` ruby
|
215
|
+
client.message_contact(contact_id, message)
|
216
|
+
```
|
217
|
+
|
218
|
+
Return all messages from a contact
|
219
|
+
``` ruby
|
220
|
+
messages = client.messages_from_contact(contact_id)
|
221
|
+
```
|
222
|
+
|
223
|
+
Mark a contact as paid for the token owner
|
224
|
+
``` ruby
|
225
|
+
client.mark_contact_as_paid(contact_id)
|
226
|
+
```
|
227
|
+
|
228
|
+
### Users
|
229
|
+
|
230
|
+
Return info on the token owner
|
231
|
+
``` ruby
|
232
|
+
myself = client.myself
|
233
|
+
```
|
234
|
+
|
235
|
+
Return an account based on the username.
|
236
|
+
``` ruby
|
237
|
+
user = client.account_info(username)
|
238
|
+
```
|
239
|
+
|
240
|
+
Immediately expire the currently authorized access_token.
|
241
|
+
NOTE: This method may not work. We're looking into it.
|
242
|
+
``` ruby
|
243
|
+
client.logout
|
244
|
+
```
|
245
|
+
|
246
|
+
### Wallet
|
247
|
+
|
248
|
+
Return info on the token owner's wallet
|
249
|
+
``` ruby
|
250
|
+
wallet = client.wallet
|
251
|
+
```
|
252
|
+
|
253
|
+
Return the token owner's wallet balance
|
254
|
+
``` ruby
|
255
|
+
balance = client.wallet_balance
|
256
|
+
```
|
257
|
+
|
258
|
+
Return the address of the token owner's wallet
|
259
|
+
``` ruby
|
260
|
+
address = client.wallet_addr
|
261
|
+
```
|
262
|
+
|
263
|
+
Send bitcoin from the token owner's wallet
|
264
|
+
``` ruby
|
265
|
+
# returns message on success
|
266
|
+
client.wallet_send(address, amount)
|
267
|
+
```
|
268
|
+
NOTE: The LocalBitcoins documentation does not specify where pins can be acquired, though use of a pin requires the 'money_pin' token scope.
|
269
|
+
|
270
|
+
Send bitcoin from token owner's wallet using pin code
|
271
|
+
``` ruby
|
272
|
+
#returns message no success
|
273
|
+
client.wallet_pin_send(address, amount, pin)
|
274
|
+
```
|
275
|
+
|
276
|
+
Check if a pin is valid
|
277
|
+
``` ruby
|
278
|
+
client.valid_pin?(pin)
|
279
|
+
```
|
280
|
+
|
281
|
+
## Public API
|
282
|
+
|
283
|
+
### Markets
|
284
|
+
Return a ticker of bitcoin prices in various currencies.
|
285
|
+
``` ruby
|
286
|
+
ticker = client.ticker
|
287
|
+
```
|
288
|
+
|
289
|
+
Return a batch of 500 trades in the specifed currency
|
290
|
+
``` ruby
|
291
|
+
# currency is the 3 letter currency code
|
292
|
+
trades = client.trades(currency)
|
293
|
+
|
294
|
+
# since is an optional trade id - will return the next 500 trades after the specifed id
|
295
|
+
trades = client.trades(currency, 12345)
|
296
|
+
```
|
297
|
+
|
298
|
+
Return the LocalBitcoins online orderbook ( Bids and Asks ) in a specified currency
|
299
|
+
``` ruby
|
300
|
+
# currency is the 3 letter currency code
|
301
|
+
orderbook = client.orderbook(currency)
|
302
|
+
```
|
303
|
+
|
304
|
+
### Ad Listings
|
305
|
+
|
306
|
+
Return a list of online buy ads pertaining to specified parameters
|
307
|
+
``` ruby
|
308
|
+
# Accepts a hash of parameters, with a valid subset of the following keys: countrycode, currency, country_name, payment_method
|
309
|
+
#
|
310
|
+
# Valid API endpoints include:
|
311
|
+
# /buy-bitcoins-online/{countrycode}/{country_name}/{payment_method}/.json
|
312
|
+
# /buy-bitcoins-online/{countrycode}/{country_name}/.json
|
313
|
+
# /buy-bitcoins-online/{currency}/{payment_method}/.json
|
314
|
+
# /buy-bitcoins-online/{currency}/.json
|
315
|
+
# /buy-bitcoins-online/{payment_method}/.json
|
316
|
+
# /buy-bitcoins-online/.json
|
317
|
+
#
|
318
|
+
# NOTE: countrycode must be 2 characters and currency must be 3 characters
|
319
|
+
online_buy_ads_lookup = client.online_buy_ads_lookup(params)
|
320
|
+
```
|
321
|
+
|
322
|
+
Return a list of online sell ads pertaining to specified parameters
|
323
|
+
``` ruby
|
324
|
+
# Accepts a hash of parameters, with a valid subset of the following keys: countrycode, currency, country_name, payment_method
|
325
|
+
#
|
326
|
+
# NOTE: see valid API endpoints in online_buy_ads_lookup method above
|
327
|
+
online_sell_ads_lookup = client.online_sell_ads_lookup(params)
|
328
|
+
```
|
329
|
+
|
330
|
+
Returns a list of local buy ads in a certain place
|
331
|
+
``` ruby
|
332
|
+
# - Required fields -
|
333
|
+
# location_id - id for location found using places method
|
334
|
+
# location_slug - slug name for location found using places method
|
335
|
+
#
|
336
|
+
# - Optional fields -
|
337
|
+
# lat - latitude of location [float]
|
338
|
+
# lon - longitude of location [float]
|
339
|
+
#
|
340
|
+
# pass a hash of the above fields
|
341
|
+
local_buy_ad = client.local_buy_ad(params)
|
342
|
+
```
|
343
|
+
|
344
|
+
Return a list of local sell ads in a certain place
|
345
|
+
``` ruby
|
346
|
+
# pass a hash with the same fields as local_buy_ad
|
347
|
+
local_sell_ad = client.local_sell_ad(params)
|
348
|
+
```
|
349
|
+
|
350
|
+
### Additional Public Methods
|
351
|
+
|
352
|
+
Return all payment methods accepted on LocalBitcoins, with an option to limit the search to a specific country
|
353
|
+
``` ruby
|
354
|
+
# countrycode is the 2 character countrycode
|
355
|
+
payment_methods = client.payment_methods(countrycode)
|
356
|
+
```
|
357
|
+
|
358
|
+
Return all currencies accepted by the LocalBitcoins platform
|
359
|
+
``` ruby
|
360
|
+
currencies = client.currencies
|
361
|
+
```
|
362
|
+
|
363
|
+
Return information about the place at or near a specified latitude and longitude
|
364
|
+
``` ruby
|
365
|
+
# - Required fields -
|
366
|
+
# lat - latitude of location [float]
|
367
|
+
# lon - longitude of location [float]
|
368
|
+
#
|
369
|
+
# - Optional fields -
|
370
|
+
# countrycode - 2 letter countrycode
|
371
|
+
# location_string - location name in string form
|
372
|
+
#
|
373
|
+
# pass a hash of the above fields
|
374
|
+
places = client.places(params)
|
375
|
+
```
|
376
|
+
|
377
|
+
## Contributors
|
378
|
+
|
379
|
+
* [John Shutt](http://shutt.in)
|
380
|
+
* [Will Newman](http://willnewman.me)
|
381
|
+
* [Albert Brown](https://www.linkedin.com/pub/albert-brown/36/515/a2)
|
382
|
+
* [Coincove](https://coincove.co)
|
99
383
|
|
100
384
|
## License
|
101
385
|
|
data/Rakefile
CHANGED
@@ -1,24 +1,60 @@
|
|
1
1
|
module LocalBitcoins
|
2
2
|
module Ads
|
3
3
|
# Get a list of the token owner's ads
|
4
|
-
|
5
|
-
|
6
|
-
data = oauth_request(:get, '/api/ads')
|
7
|
-
Hashie::Mash.new(data['ad_list'])
|
4
|
+
def ads
|
5
|
+
oauth_request(:get, '/api/ads/').data
|
8
6
|
end
|
9
7
|
|
10
8
|
# Update one of the token owner's ads
|
11
9
|
#
|
12
10
|
# id - id of the ad you want to update
|
13
11
|
# visibility - the ad's visibility [boolean]
|
14
|
-
# min_amount - minimum selling price [string
|
15
|
-
# max_amount - maximum buying price [string
|
12
|
+
# min_amount - minimum selling price [string]
|
13
|
+
# max_amount - maximum buying price [string]
|
16
14
|
# price_equation - equation to calculate price [string]
|
17
15
|
#
|
18
|
-
# NOTE:
|
16
|
+
# NOTE 1: Setting min_amount or max_amount to nil will unset them.
|
17
|
+
# NOTE 2: "Floating price" must be false in you ad's edit form for price_equation to go through
|
18
|
+
#
|
19
|
+
def update_ad(id, params={})
|
20
|
+
old_ad = ad(id).data
|
21
|
+
updated_params = {
|
22
|
+
:min_amount => old_ad.min_amount,
|
23
|
+
:max_amount => old_ad.max_amount,
|
24
|
+
:visible => old_ad.visible
|
25
|
+
}.merge(params)
|
26
|
+
oauth_request(:post, "/api/ad/#{id}/", updated_params).data
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a new ad for the token owner
|
30
|
+
#
|
31
|
+
# - Required fields -
|
32
|
+
# min_amount - minimum amount for sale in fiat [string]
|
33
|
+
# max_amount - maximum amount for sale in fiat [string]
|
34
|
+
# price_equation - price using price equation operators [string]
|
35
|
+
# lat - latitude of location [float]
|
36
|
+
# lon - longitude of location [float]
|
37
|
+
# city - city of listing [string]
|
38
|
+
# location_string - text representation of location [string]
|
39
|
+
# countrycode - two letter countrycode [string]
|
40
|
+
# account_info - [string]
|
41
|
+
# bank_name - [string]
|
42
|
+
# sms_verification_required - only receive contacts with verified phone numbers [boolean]
|
43
|
+
# track_max_amount - decrease max sell amount in relation to liquidity [boolean]
|
44
|
+
# trusted_required - only allow trusted contacts [boolean]
|
45
|
+
# currency - three letter fiat representation [string]
|
19
46
|
#
|
20
|
-
def
|
21
|
-
|
47
|
+
def create_ad(params={})
|
48
|
+
oauth_request(:post, '/api/ad-create/', params).data
|
49
|
+
end
|
50
|
+
|
51
|
+
# ads - comma separated list of ad ids [string]
|
52
|
+
def ad_list(ads)
|
53
|
+
oauth_request(:get, "/api/ad-get/", {:ads=>ads}).data
|
54
|
+
end
|
55
|
+
|
56
|
+
def ad(ad_id)
|
57
|
+
oauth_request(:get, "/api/ad-get/#{ad_id}/").data.ad_list[0]
|
22
58
|
end
|
23
59
|
end
|
24
60
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module LocalBitcoins
|
2
|
+
module Contacts
|
3
|
+
# Contact interaction endpoints
|
4
|
+
# contact_id - id number associated with the contact
|
5
|
+
|
6
|
+
def mark_contact_as_paid(contact_id)
|
7
|
+
oauth_request(:post, "/api/contact_mark_as_paid/#{contact_id}/")
|
8
|
+
end
|
9
|
+
|
10
|
+
def messages_from_contact(contact_id)
|
11
|
+
oauth_request(:get, "/api/contact_messages/#{contact_id}/").data
|
12
|
+
end
|
13
|
+
|
14
|
+
def message_contact(contact_id, msg)
|
15
|
+
oauth_request(:post, "/api/contact_message_post/#{contact_id}/", {:msg=>msg}).data
|
16
|
+
end
|
17
|
+
|
18
|
+
def dispute_contact(contact_id)
|
19
|
+
oauth_request(:post, "/api/contact_dispute/#{contact_id}/")
|
20
|
+
end
|
21
|
+
|
22
|
+
def cancel_contact(contact_id)
|
23
|
+
oauth_request(:post, "/api/contact_cancel/#{contact_id}/").data
|
24
|
+
end
|
25
|
+
|
26
|
+
def fund_contact(contact_id)
|
27
|
+
oauth_request(:post, "/api/contact_fund/#{contact_id}/")
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_contact(ad_id, amount, message=nil)
|
31
|
+
oauth_request(:post, "/api/contact_create/#{ad_id}/", {:amount=>amount, :message=>message})
|
32
|
+
end
|
33
|
+
|
34
|
+
def contact_info(contact_id)
|
35
|
+
oauth_request(:get, "/api/contact_info/#{contact_id}/")
|
36
|
+
end
|
37
|
+
|
38
|
+
# contacts - comma separated list of contact ids [string]
|
39
|
+
def contacts_info(contacts)
|
40
|
+
oauth_request(:get, '/api/contact_info/', {:contacts=>contacts}).data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Dashboard contact endpoints
|
44
|
+
# contact_type - optional filter 'buyer' or 'seller' [string]
|
45
|
+
#
|
46
|
+
def active_contacts(contact_type = nil)
|
47
|
+
contact_type<<'/' unless contact_type.nil?
|
48
|
+
oauth_request(:get, "/api/dashboard/#{contact_type}").data
|
49
|
+
end
|
50
|
+
|
51
|
+
def released_contacts(contact_type = nil)
|
52
|
+
contact_type<<'/' unless contact_type.nil?
|
53
|
+
oauth_request(:get, "/api/dashboard/released/#{contact_type}").data
|
54
|
+
end
|
55
|
+
|
56
|
+
def canceled_contacts(contact_type = nil)
|
57
|
+
contact_type<<'/' unless contact_type.nil?
|
58
|
+
oauth_request(:get, "/api/dashboard/canceled/#{contact_type}").data
|
59
|
+
end
|
60
|
+
|
61
|
+
def closed_contacts(contact_type = nil)
|
62
|
+
contact_type<<'/' unless contact_type.nil?
|
63
|
+
oauth_request(:get, "/api/dashboard/closed/#{contact_type}").data
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
module LocalBitcoins
|
2
2
|
module Escrows
|
3
3
|
# Get a list of the token owner's releaseable escrows
|
4
|
-
#
|
5
|
-
def escrows
|
6
|
-
|
7
|
-
Hashie::Mash.new(data)
|
4
|
+
# NOTE: This endpoint is not documented so it may or may not work
|
5
|
+
def escrows
|
6
|
+
oauth_request(:get, '/api/escrows/').data
|
8
7
|
end
|
9
8
|
|
10
9
|
# Release an escrow
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
def escrow_release(release_url)
|
17
|
-
data = oauth_request(:post, release_url)
|
18
|
-
data['data']['message']
|
10
|
+
# id - the contact number
|
11
|
+
# NOTE: LocalBitcoins documentation calls this the "escrow_id",
|
12
|
+
# it is actually just the contact number the escrow is associated with
|
13
|
+
def escrow_release(id)
|
14
|
+
oauth_request(:post, "/api/escrow_release/#{id}/").data
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|