Class: Cartowrap::API
- Inherits:
-
Object
- Object
- Cartowrap::API
- Defined in:
- lib/cartowrap/api.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #check_synchronization(import_id) ⇒ Object
- #create_synchronization(url, interval, sync_options = {}) ⇒ Object
- #delete_synchronization(import_id) ⇒ Object
- #force_synchronization(import_id) ⇒ Object
- #get_synchronization(import_id) ⇒ Object
- #get_synchronizations ⇒ Object
-
#initialize(api_key = nil, account = nil) ⇒ API
constructor
A new instance of API.
- #initialize_options ⇒ Object
- #send_query(query) ⇒ Object
Constructor Details
#initialize(api_key = nil, account = nil) ⇒ API
Returns a new instance of API.
3 4 5 6 7 8 9 10 11 |
# File 'lib/cartowrap/api.rb', line 3 def initialize(api_key = nil, account = nil) @api_key = api_key || Cartowrap.config.api_key @account = account || Cartowrap.config.account @dry_run = Cartowrap.config.dry_run || false @credentials = {} @credentials['api_key'] = @api_key @credentials['account'] = @account @options = OpenStruct.new end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
13 14 15 |
# File 'lib/cartowrap/api.rb', line 13 def account @account end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/cartowrap/api.rb', line 13 def api_key @api_key end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
13 14 15 |
# File 'lib/cartowrap/api.rb', line 13 def credentials @credentials end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/cartowrap/api.rb', line 13 def @options end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/cartowrap/api.rb', line 13 def response @response end |
Instance Method Details
#check_synchronization(import_id) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/cartowrap/api.rb', line 39 def check_synchronization(import_id) .endpoint = "import" .query_string = false .http_method = 'get' .resource_id = "#{import_id}/sync_now" result = make_call() result end |
#create_synchronization(url, interval, sync_options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cartowrap/api.rb', line 57 def create_synchronization(url, interval, ={}) () if .endpoint = "import" .type_guessing = [:type_guessing] .quoted_fields_guessing = [:quoted_fields_guessing] .content_guessing = [:content_guessing] .query_string = false .url = url .interval = interval .http_method = 'post' result = make_call() result end |
#delete_synchronization(import_id) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/cartowrap/api.rb', line 71 def delete_synchronization(import_id) .endpoint = "import" .resource_id = import_id .query_string = false .http_method = 'delete' result = make_call() result end |
#force_synchronization(import_id) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/cartowrap/api.rb', line 48 def force_synchronization(import_id) .endpoint = "import" .query_string = false .http_method = 'put' .resource_id = "#{import_id}/sync_now" result = make_call() result end |
#get_synchronization(import_id) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/cartowrap/api.rb', line 30 def get_synchronization(import_id) .endpoint = "import" .import_id = import_id .query_string = false .http_method = 'get' result = make_call() result end |
#get_synchronizations ⇒ Object
23 24 25 26 27 28 |
# File 'lib/cartowrap/api.rb', line 23 def get_synchronizations .endpoint = "import" .query_string = false result = make_call() result end |
#initialize_options ⇒ Object
80 81 82 |
# File 'lib/cartowrap/api.rb', line 80 def @options = OpenStruct.new end |
#send_query(query) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cartowrap/api.rb', line 15 def send_query(query) .endpoint = "sql" .query_string = true .q = query result = make_call() result end |