Class: MagLoft::ApiCaller
- Inherits:
-
Dialers::Caller
- Object
- Dialers::Caller
- MagLoft::ApiCaller
show all
- Defined in:
- lib/magloft/api_caller.rb
Defined Under Namespace
Classes: ConflictError, UnauthorizedError, ValidationError
Constant Summary
collapse
- MAX_RETRIES =
0
- TIMEOUT_IN_SECONDS =
600
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.api_config ⇒ Object
12
13
14
|
# File 'lib/magloft/api_caller.rb', line 12
def api_config
@api_config ||= File.exist?("magloft-api.yml") ? YAML.load_file("magloft-api.yml") : default_api_config
end
|
.api_url ⇒ Object
16
17
18
|
# File 'lib/magloft/api_caller.rb', line 16
def api_url
api_config["api_url"]
end
|
.cdn_url ⇒ Object
20
21
22
|
# File 'lib/magloft/api_caller.rb', line 20
def cdn_url
api_config["cdn_url"]
end
|
.default_api_config ⇒ Object
8
9
10
|
# File 'lib/magloft/api_caller.rb', line 8
def default_api_config
{ "api_url" => "https://www.magloft.com", "cdn_url" => "https://storage.googleapis.com/cdn.magloft.com" }
end
|
Instance Method Details
#http_call(request_options, current_retries = 0) ⇒ Object
35
36
37
38
|
# File 'lib/magloft/api_caller.rb', line 35
def http_call(request_options, current_retries = 0)
request_options.["X-Magloft-Accesstoken"] = Api.client.token
super
end
|
40
41
42
43
|
# File 'lib/magloft/api_caller.rb', line 40
def transform(response)
self.class.short_circuits.search_for_stops(response)
Transformable.new(response)
end
|