Class: Pickpoint::Client
- Inherits:
-
Object
- Object
- Pickpoint::Client
- Defined in:
- lib/pickpoint/client.rb
Overview
Unified public-api client (geocoding, address, routing, devices). This gem does not include realtime tracking.
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#geocoding ⇒ Object
readonly
Returns the value of attribute geocoding.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
Instance Method Summary collapse
- #elevation(body) ⇒ Object
-
#forward(query) ⇒ Object
Flat shortcuts.
- #forward_batch(queries) ⇒ Object
-
#initialize(cfg) ⇒ Client
constructor
A new instance of Client.
- #locate(body) ⇒ Object
- #lookup(query) ⇒ Object
- #lookup_batch(queries) ⇒ Object
- #matrix(body) ⇒ Object
- #optimized_route(body) ⇒ Object
- #reverse(query) ⇒ Object
- #reverse_batch(queries) ⇒ Object
- #route(body) ⇒ Object
- #search(query) ⇒ Object
Constructor Details
#initialize(cfg) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pickpoint/client.rb', line 9 def initialize(cfg) base = Transport.trim_slash(cfg.base_url || DEFAULT_BASE_URL) timeout = cfg.timeout && cfg.timeout.positive? ? cfg.timeout : DEFAULT_TIMEOUT http = Http.new(timeout: timeout, adapter: cfg.http_adapter) max_retries = cfg.max_retries && cfg.max_retries.positive? ? cfg.max_retries : DEFAULT_MAX_RETRIES retry_base = cfg.retry_base && cfg.retry_base.positive? ? cfg.retry_base : DEFAULT_RETRY_BASE retry_base = [retry_base, MIN_RETRY_BASE].max concurrency = cfg.concurrency && cfg.concurrency.positive? ? cfg.concurrency : DEFAULT_CONCURRENCY concurrency = [concurrency, MAX_CONCURRENCY].min auth = Auth.resolve(cfg, base, http) transport = Transport::Client.new( base_url: base, http: http, auth: auth, max_retries: max_retries, retry_base: retry_base ) @concurrency = concurrency @geocoding = GeocodingService.new(transport, concurrency) @address = AddressService.new(transport) @routing = RoutingService.new(transport) @devices = DevicesService.new(transport) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/pickpoint/client.rb', line 7 def address @address end |
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
7 8 9 |
# File 'lib/pickpoint/client.rb', line 7 def concurrency @concurrency end |
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
7 8 9 |
# File 'lib/pickpoint/client.rb', line 7 def devices @devices end |
#geocoding ⇒ Object (readonly)
Returns the value of attribute geocoding.
7 8 9 |
# File 'lib/pickpoint/client.rb', line 7 def geocoding @geocoding end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing.
7 8 9 |
# File 'lib/pickpoint/client.rb', line 7 def routing @routing end |
Instance Method Details
#elevation(body) ⇒ Object
48 |
# File 'lib/pickpoint/client.rb', line 48 def elevation(body) = routing.elevation(body) |
#forward(query) ⇒ Object
Flat shortcuts
37 |
# File 'lib/pickpoint/client.rb', line 37 def forward(query) = geocoding.forward(query) |
#forward_batch(queries) ⇒ Object
40 |
# File 'lib/pickpoint/client.rb', line 40 def forward_batch(queries) = geocoding.forward_batch(queries) |
#locate(body) ⇒ Object
47 |
# File 'lib/pickpoint/client.rb', line 47 def locate(body) = routing.locate(body) |
#lookup(query) ⇒ Object
39 |
# File 'lib/pickpoint/client.rb', line 39 def lookup(query) = geocoding.lookup(query) |
#lookup_batch(queries) ⇒ Object
42 |
# File 'lib/pickpoint/client.rb', line 42 def lookup_batch(queries) = geocoding.lookup_batch(queries) |
#matrix(body) ⇒ Object
46 |
# File 'lib/pickpoint/client.rb', line 46 def matrix(body) = routing.matrix(body) |
#optimized_route(body) ⇒ Object
45 |
# File 'lib/pickpoint/client.rb', line 45 def optimized_route(body) = routing.optimized(body) |
#reverse(query) ⇒ Object
38 |
# File 'lib/pickpoint/client.rb', line 38 def reverse(query) = geocoding.reverse(query) |
#reverse_batch(queries) ⇒ Object
41 |
# File 'lib/pickpoint/client.rb', line 41 def reverse_batch(queries) = geocoding.reverse_batch(queries) |
#route(body) ⇒ Object
44 |
# File 'lib/pickpoint/client.rb', line 44 def route(body) = routing.route(body) |
#search(query) ⇒ Object
43 |
# File 'lib/pickpoint/client.rb', line 43 def search(query) = address.search(query) |