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
3 4 5 6 7 8 9 10 |
# 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 @credentials = {} @credentials['api_key'] = @api_key @credentials['account'] = @account = OpenStruct.new end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
12 13 14 |
# File 'lib/cartowrap/api.rb', line 12 def account @account end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/cartowrap/api.rb', line 12 def api_key @api_key end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
12 13 14 |
# File 'lib/cartowrap/api.rb', line 12 def credentials @credentials end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/cartowrap/api.rb', line 12 def end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/cartowrap/api.rb', line 12 def response @response end |
Instance Method Details
#check_synchronization(import_id) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/cartowrap/api.rb', line 38 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
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cartowrap/api.rb', line 56 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
70 71 72 73 74 75 76 77 |
# File 'lib/cartowrap/api.rb', line 70 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
47 48 49 50 51 52 53 54 |
# File 'lib/cartowrap/api.rb', line 47 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
29 30 31 32 33 34 35 36 |
# File 'lib/cartowrap/api.rb', line 29 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
22 23 24 25 26 27 |
# File 'lib/cartowrap/api.rb', line 22 def get_synchronizations .endpoint = "import" .query_string = false result = make_call() result end |
#initialize_options ⇒ Object
79 80 81 |
# File 'lib/cartowrap/api.rb', line 79 def = OpenStruct.new end |
#send_query(query) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cartowrap/api.rb', line 14 def send_query(query) .endpoint = "sql" .query_string = true .q = query result = make_call() result end |