Class: Onfleet::Workers
- Inherits:
-
Object
- Object
- Onfleet::Workers
- Defined in:
- lib/resources/workers.rb
Overview
Workers (also known as drivers in the dashboard) are the members of an organization who perform actions via the Onfleet mobile applications.
Instance Method Summary collapse
- #create(config, body) ⇒ Object
- #delete(config, id) ⇒ Object
- #get(config, id = nil, query_parameters_hash = nil) ⇒ Object
-
#get_by_location(config, longitude, latitude, radius = 1000) ⇒ Object
ACTION: still needs to be tested.
- #get_delivery_manifest(config, body, google_api_key = nil, query_parameters_hash = nil) ⇒ Object
- #get_schedule(config, id) ⇒ Object
- #get_tasks(config, id) ⇒ Object
-
#insert_task(config, worker_id, body) ⇒ Object
ACTION: still needs to be tested.
-
#match_metadata(config, body) ⇒ Object
ACTION: still needs to be tested.
- #set_schedule(config, id, body) ⇒ Object
- #update(config, id, body) ⇒ Object
Instance Method Details
#create(config, body) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/resources/workers.rb', line 9 def create(config, body) method = 'post' path = 'workers' Onfleet.request(config, method.to_sym, path, body.to_json) end |
#delete(config, id) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/resources/workers.rb', line 40 def delete(config, id) method = 'delete' path = "workers/#{id}" Onfleet.request(config, method.to_sym, path) end |
#get(config, id = nil, query_parameters_hash = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/resources/workers.rb', line 16 def get(config, id = nil, query_parameters_hash = nil) method = 'get' query_parameters = nil if query_parameters_hash query_parameters = URI.encode_www_form(query_parameters_hash) end if id path = "workers/#{id}?#{query_parameters}" else path = "workers?#{query_parameters}" end Onfleet.request(config, method.to_sym, path) end |
#get_by_location(config, longitude, latitude, radius = 1000) ⇒ Object
ACTION: still needs to be tested
55 56 57 58 59 60 |
# File 'lib/resources/workers.rb', line 55 def get_by_location(config, longitude, latitude, radius = 1000) method = 'get' path = "workers/location?longitude=#{longitude}&latitude=#{latitude}&radius=#{radius}" Onfleet.request(config, method.to_sym, path) end |
#get_delivery_manifest(config, body, google_api_key = nil, query_parameters_hash = nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/resources/workers.rb', line 76 def get_delivery_manifest(config, body, google_api_key = nil, query_parameters_hash = nil) method = 'post' query_parameters = nil if google_api_key config.headers['X-Api-Key'] = "Google #{google_api_key}" end if query_parameters_hash query_parameters = URI.encode_www_form(query_parameters_hash) end path = "integrations/marketplace?#{query_parameters}" Onfleet.request(config, method.to_sym, path, body.to_json) end |
#get_schedule(config, id) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/resources/workers.rb', line 62 def get_schedule(config, id) method = 'get' path = "workers/#{id}/schedule" Onfleet.request(config, method.to_sym, path) end |
#get_tasks(config, id) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/resources/workers.rb', line 47 def get_tasks(config, id) method = 'get' path = "workers/#{id}/tasks" Onfleet.request(config, method.to_sym, path) end |
#insert_task(config, worker_id, body) ⇒ Object
ACTION: still needs to be tested
93 94 95 96 97 98 |
# File 'lib/resources/workers.rb', line 93 def insert_task(config, worker_id, body) method = 'put' path = "containers/workers/#{worker_id}" Onfleet.request(config, method.to_sym, path, body.to_json) end |
#match_metadata(config, body) ⇒ Object
ACTION: still needs to be tested
101 102 103 104 105 106 |
# File 'lib/resources/workers.rb', line 101 def (config, body) method = 'post' path = 'workers/metadata' Onfleet.request(config, method.to_sym, path, body.to_json) end |