Class: GeoStock::API
- Inherits:
-
Object
- Object
- GeoStock::API
- Defined in:
- lib/geostock/api.rb
Constant Summary collapse
- REQUEST_EXPIRATION_TIME =
10 minutes
10 * 60
- REQUEST_URI_BASE =
'http://geostock.jp/api'
Instance Method Summary collapse
- #collections ⇒ Object
- #create_collection(col_name) ⇒ Object
- #create_collections(*col_names) ⇒ Object
- #delete_collection(col_name) ⇒ Object
- #delete_collections(*col_names) ⇒ Object
- #delete_poi(value) ⇒ Object
- #delete_pois(value) ⇒ Object
- #get_all_pois(col_name) ⇒ Object
- #get_poi(col_name, uid) ⇒ Object
-
#initialize(api_key, api_secret) ⇒ API
constructor
A new instance of API.
- #update_collection(value) ⇒ Object
- #update_collections(value) ⇒ Object
- #update_poi(col_name, value) ⇒ Object
- #update_pois(col_name, value) ⇒ Object
Constructor Details
#initialize(api_key, api_secret) ⇒ API
Returns a new instance of API.
14 15 16 17 18 19 |
# File 'lib/geostock/api.rb', line 14 def initialize(api_key, api_secret) raise "API_KEY must be present." if api_key.nil? raise "API_SECRET must be present." if api_secret.nil? @api_token = api_key @api_secret_token = api_secret end |
Instance Method Details
#collections ⇒ Object
21 22 23 |
# File 'lib/geostock/api.rb', line 21 def collections get :collections, refresh: 1 end |
#create_collection(col_name) ⇒ Object
46 47 48 |
# File 'lib/geostock/api.rb', line 46 def create_collection(col_name) create_collections col_name end |
#create_collections(*col_names) ⇒ Object
49 50 51 52 |
# File 'lib/geostock/api.rb', line 49 def create_collections(*col_names) col_names = [col_names].flatten post(:update_collections, col_names) end |
#delete_collection(col_name) ⇒ Object
59 60 61 |
# File 'lib/geostock/api.rb', line 59 def delete_collection(col_name) delete_collections(col_name) end |
#delete_collections(*col_names) ⇒ Object
62 63 64 65 |
# File 'lib/geostock/api.rb', line 62 def delete_collections(*col_names) col_names = [col_names].flatten post(:delete_collections, col_names) end |
#delete_poi(value) ⇒ Object
32 33 34 |
# File 'lib/geostock/api.rb', line 32 def delete_poi(value) delete_pois(value) end |
#delete_pois(value) ⇒ Object
35 36 37 |
# File 'lib/geostock/api.rb', line 35 def delete_pois(value) post(:update_pois, value) end |
#get_all_pois(col_name) ⇒ Object
42 43 44 |
# File 'lib/geostock/api.rb', line 42 def get_all_pois(col_name) get :get_all, col: col_name end |
#get_poi(col_name, uid) ⇒ Object
39 40 41 |
# File 'lib/geostock/api.rb', line 39 def get_poi(col_name, uid) get :get, col: col_name, id: uid end |
#update_collection(value) ⇒ Object
53 54 55 |
# File 'lib/geostock/api.rb', line 53 def update_collection(value) update_collections(value) end |
#update_collections(value) ⇒ Object
56 57 58 |
# File 'lib/geostock/api.rb', line 56 def update_collections(value) post(:update_collections, value) end |
#update_poi(col_name, value) ⇒ Object
25 26 27 |
# File 'lib/geostock/api.rb', line 25 def update_poi(col_name, value) update_pois col_name, value end |
#update_pois(col_name, value) ⇒ Object
28 29 30 |
# File 'lib/geostock/api.rb', line 28 def update_pois(col_name, value) post(:update_pois, col_name => value) end |