hypertrack 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 497161ee6c7532a5d8905a0f5be8659007905b89
4
- data.tar.gz: 6c0618355dda776262082d2c88b6beec75468e45
3
+ metadata.gz: 84303e29979cffc3077bef07b0cdc047c191510a
4
+ data.tar.gz: d3165cb9c2e75557e1c4eb4f67ab67b63d294ec4
5
5
  SHA512:
6
- metadata.gz: 3599e44c50219ae6d9e4a4f3dfeb5841f39e9a723054deb9efc1718eab767a11eec6b93e0c2654ec2730d79743fcb182616abfcb4fd2e0d93b18f9e91e84da0c
7
- data.tar.gz: 56236254eeb03d089563e775b229e1cc78115b50a1aa74250c3f220a95a868b2ecdad9350dfcf6a3b8a2f2812eae568800596cdd8fe8d1d0a49002f2c8193eb9
6
+ metadata.gz: e709f5dc1937115e97a1148a386ec28231847abdb4f63366ca9d21b6a7c9889b4abfeaebe1d39e69b945f607a6b6fc1937781d2d289ebb1d7c568713fa36dd09
7
+ data.tar.gz: ca4f1411f10b913c58cc4a078c1573288b7a14ad567f3bf46a4a7e55e399f9a4ba1e8655f8c14c8d3b03de0d2927c70a58527211ed5d34c29b72cbdb13a42c2e
@@ -12,11 +12,8 @@ require_relative "hypertrack/api_operations/common/create"
12
12
  require_relative "hypertrack/api_operations/common/retrieve"
13
13
  require_relative "hypertrack/api_operations/common/list"
14
14
  require_relative "hypertrack/api_operations/common/update"
15
- require_relative "hypertrack/api_operations/driver_api"
16
- require_relative "hypertrack/api_operations/task_api"
17
- require_relative "hypertrack/api_operations/trip_api"
18
- require_relative "hypertrack/api_operations/shift_api"
19
- require_relative "hypertrack/api_operations/gps_log_api"
15
+ require_relative "hypertrack/api_operations/user_api"
16
+ require_relative "hypertrack/api_operations/action_api"
20
17
 
21
18
  # All HTTP calls made here
22
19
  require_relative "hypertrack/api_client"
@@ -25,17 +22,8 @@ require_relative "hypertrack/api_client"
25
22
  require_relative "hypertrack/shared_resource"
26
23
 
27
24
  # Resources
28
- require_relative "hypertrack/resources/driver"
29
- require_relative "hypertrack/resources/customer"
30
- require_relative "hypertrack/resources/destination"
31
- require_relative "hypertrack/resources/task"
32
- require_relative "hypertrack/resources/trip"
33
- require_relative "hypertrack/resources/neighbourhood"
34
- require_relative "hypertrack/resources/fleet"
35
- require_relative "hypertrack/resources/hub"
36
- require_relative "hypertrack/resources/shift"
37
- require_relative "hypertrack/resources/event"
38
- require_relative "hypertrack/resources/gps_log"
25
+ require_relative "hypertrack/resources/user"
26
+ require_relative "hypertrack/resources/action"
39
27
 
40
28
  module HyperTrack
41
29
 
@@ -1,7 +1,7 @@
1
1
  module HyperTrack
2
2
  class ApiClient
3
3
 
4
- BASE_URL = "https://app.hypertrack.io/api"
4
+ BASE_URL = "https://api.hypertrack.com/api"
5
5
  API_VERSION = "v1"
6
6
 
7
7
  VERB_MAP = {
@@ -0,0 +1,17 @@
1
+ module HyperTrack
2
+ module ApiOperations
3
+ module ActionAPI
4
+
5
+ def complete(params={})
6
+ path = "complete/"
7
+ self.update(path, params, [:completion_location])
8
+ end
9
+
10
+ def cancel(params={})
11
+ path = "cancel/"
12
+ self.update(path, params)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -10,7 +10,7 @@ module HyperTrack
10
10
  api_result['results'][idx] = get_class_name.new(opts['id'], opts)
11
11
  end
12
12
 
13
- api_result
13
+ api_result['results']
14
14
  end
15
15
 
16
16
  end
@@ -0,0 +1,12 @@
1
+ module HyperTrack
2
+ module ApiOperations
3
+ module UserAPI
4
+
5
+ def assign_actions(params)
6
+ path = "assign_actions/"
7
+ self.update(path, params, [:action_ids])
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -15,7 +15,9 @@ module HyperTrack
15
15
  410 => HyperTrack::ResourceRemovedFromServer,
16
16
  429 => HyperTrack::RateLimitExceeded,
17
17
  500 => HyperTrack::InternalServerError,
18
- 503 => HyperTrack::ServiceTemporarilyUnavailable
18
+ 502 => HyperTrack::BadGateway,
19
+ 503 => HyperTrack::ServiceTemporarilyUnavailable,
20
+ 504 => HyperTrack::GatewayTimeout
19
21
  }
20
22
  end
21
23
 
@@ -56,9 +58,15 @@ module HyperTrack
56
58
  # Raised when - There was an error on the server and we have been notified. Try again later.
57
59
  class InternalServerError < Error; end
58
60
 
59
- # Raised when - We are temporarily offline for maintenance. Please try again later.
61
+ # Raised when - load balancer throws 502
62
+ class BadGateway < Error; end
63
+
64
+ # Raised when - service throws 500
60
65
  class ServiceTemporarilyUnavailable < Error; end
61
66
 
67
+ # Raised when - load balancer throws 504
68
+ class GatewayTimeout < Error; end
69
+
62
70
  # Raised when - We get an unknown response code from the API
63
71
  class UnknownError < Error; end
64
72
 
@@ -0,0 +1,20 @@
1
+ module HyperTrack
2
+ class Action < HyperTrack::SharedResource
3
+ include HyperTrack::ApiOperations::ActionAPI
4
+
5
+ API_BASE_PATH = "actions/"
6
+ REQUIRED_FIELDS = []
7
+
8
+ VALID_ATTRIBUTE_VALUES = {
9
+ type: {
10
+ allowed: [:pickup, :delivery, :dropoff, :visit, :stoppver, :task],
11
+ allow_nil: true
12
+ },
13
+ vehicle_type: {
14
+ allowed: HyperTrack::SharedResource::VALID_VEHICLE_TYPES,
15
+ allow_nil: true
16
+ }
17
+ }
18
+
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module HyperTrack
2
+ class User < HyperTrack::SharedResource
3
+ include HyperTrack::ApiOperations::UserAPI
4
+
5
+ API_BASE_PATH = "users/"
6
+ REQUIRED_FIELDS = [:name]
7
+
8
+ VALID_ATTRIBUTE_VALUES = {
9
+ vehicle_type: {
10
+ allowed: HyperTrack::SharedResource::VALID_VEHICLE_TYPES
11
+ }
12
+ }
13
+
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypertrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Utsav Kesharwani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2017-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
- description: Ruby wrapper around HyperTrack's API. Refer http://docs.hypertrack.io/
27
+ description: Ruby wrapper around HyperTrack's API. Refer http://docs.hypertrack.com/
28
28
  for more information.
29
29
  email: utsav.kesharwani@gmail.com
30
30
  executables: []
@@ -33,28 +33,16 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - lib/hypertrack.rb
35
35
  - lib/hypertrack/api_client.rb
36
+ - lib/hypertrack/api_operations/action_api.rb
36
37
  - lib/hypertrack/api_operations/common/create.rb
37
38
  - lib/hypertrack/api_operations/common/list.rb
38
39
  - lib/hypertrack/api_operations/common/retrieve.rb
39
40
  - lib/hypertrack/api_operations/common/update.rb
40
- - lib/hypertrack/api_operations/driver_api.rb
41
- - lib/hypertrack/api_operations/gps_log_api.rb
42
- - lib/hypertrack/api_operations/shift_api.rb
43
- - lib/hypertrack/api_operations/task_api.rb
44
- - lib/hypertrack/api_operations/trip_api.rb
41
+ - lib/hypertrack/api_operations/user_api.rb
45
42
  - lib/hypertrack/errors/hypertrack_errors.rb
46
43
  - lib/hypertrack/params_validator.rb
47
- - lib/hypertrack/resources/customer.rb
48
- - lib/hypertrack/resources/destination.rb
49
- - lib/hypertrack/resources/driver.rb
50
- - lib/hypertrack/resources/event.rb
51
- - lib/hypertrack/resources/fleet.rb
52
- - lib/hypertrack/resources/gps_log.rb
53
- - lib/hypertrack/resources/hub.rb
54
- - lib/hypertrack/resources/neighbourhood.rb
55
- - lib/hypertrack/resources/shift.rb
56
- - lib/hypertrack/resources/task.rb
57
- - lib/hypertrack/resources/trip.rb
44
+ - lib/hypertrack/resources/action.rb
45
+ - lib/hypertrack/resources/user.rb
58
46
  - lib/hypertrack/shared_resource.rb
59
47
  - lib/util.rb
60
48
  homepage: http://rubygems.org/gems/hypertrack
@@ -77,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
65
  version: '0'
78
66
  requirements: []
79
67
  rubyforge_project:
80
- rubygems_version: 2.6.6
68
+ rubygems_version: 2.5.1
81
69
  signing_key:
82
70
  specification_version: 4
83
71
  summary: Ruby bindings for the HyperTrack API!
@@ -1,25 +0,0 @@
1
- module HyperTrack
2
- module ApiOperations
3
- module DriverAPI
4
-
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
-
11
- def map_list(filter_params={})
12
- map_list_path = "#{HyperTrack::Driver::API_BASE_PATH}map_list/"
13
- HyperTrack::ApiClient.fetch(map_list_path, filter_params)
14
- end
15
-
16
- end
17
-
18
- def overview(filter_params={})
19
- driver_overview_path = "#{HyperTrack::Driver::API_BASE_PATH}#{self.id}/overview/"
20
- HyperTrack::ApiClient.fetch(driver_overview_path, filter_params)
21
- end
22
-
23
- end
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- module HyperTrack
2
- module ApiOperations
3
- module GPSLogAPI
4
-
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
-
11
- def filtered_list(params)
12
- if HyperTrack::ParamsValidator.valid_args?(params, [:driver_id], HyperTrack::GPSLog::VALID_ATTRIBUTE_VALUES)
13
- HyperTrack::GPSLog.list(params.merge(filtered: true))
14
- end
15
- end
16
-
17
- end
18
- end
19
- end
20
- end
@@ -1,13 +0,0 @@
1
- module HyperTrack
2
- module ApiOperations
3
- module ShiftAPI
4
-
5
- # Don't want to name this method as 'end'. Its a reserved keyword in Ruby.
6
- def end_shift(params)
7
- path = "end/"
8
- self.update(path, params, [:end_location])
9
- end
10
-
11
- end
12
- end
13
- end
@@ -1,34 +0,0 @@
1
- module HyperTrack
2
- module ApiOperations
3
- module TaskAPI
4
-
5
- def editable_url(params)
6
- if HyperTrack::ParamsValidator.valid_args?(params, [:editable], self.class::VALID_ATTRIBUTE_VALUES)
7
- api_path = "#{self.class::API_BASE_PATH}#{self.id}/editable_url/"
8
- HyperTrack::ApiClient.update(api_path, params)
9
- end
10
- end
11
-
12
- def start(params)
13
- path = "start/"
14
- self.update(path, params, [:start_location, :start_time])
15
- end
16
-
17
- def complete(params)
18
- path = "completed/"
19
- self.update(path, params, [:completion_location])
20
- end
21
-
22
- def cancel(params={})
23
- path = "canceled/"
24
- self.update(path, params)
25
- end
26
-
27
- def update_destination(params)
28
- path = "update_destination/"
29
- self.update(path, params, [:location])
30
- end
31
-
32
- end
33
- end
34
- end
@@ -1,43 +0,0 @@
1
- module HyperTrack
2
- module ApiOperations
3
- module TripAPI
4
-
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
-
11
- def sending_eta(params)
12
- if HyperTrack::ParamsValidator.valid_args?(params, [:driver, :destination], HyperTrack::Trip::VALID_ATTRIBUTE_VALUES)
13
- eta_path = "#{HyperTrack::Trip::API_BASE_PATH}lite/"
14
- HyperTrack::ApiClient.update(eta_path, params)
15
- end
16
- end
17
-
18
- end
19
-
20
- # Don't want to name this method as 'end'. Its a reserved keyword in Ruby.
21
- def end_trip(params)
22
- path = "end/"
23
- self.update(path, params, [])
24
- end
25
-
26
- def add_task(params)
27
- path = 'add_task/'
28
- self.update(path, params, [:task_id])
29
- end
30
-
31
- def remove_task(params)
32
- path = 'remove_task/'
33
- self.update(path, params, [:task_id])
34
- end
35
-
36
- def change_task_order(params)
37
- path = 'change_task_order/'
38
- self.update(path, params, [:task_order])
39
- end
40
-
41
- end
42
- end
43
- end
@@ -1,10 +0,0 @@
1
- module HyperTrack
2
- class Customer < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "customers/"
5
- REQUIRED_FIELDS = [:name]
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- module HyperTrack
2
- class Destination < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "destinations/"
5
- REQUIRED_FIELDS = [:customer_id]
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- module HyperTrack
2
- class Driver < HyperTrack::SharedResource
3
- include HyperTrack::ApiOperations::DriverAPI
4
-
5
- API_BASE_PATH = "drivers/"
6
- REQUIRED_FIELDS = [:name, :vehicle_type]
7
-
8
- VALID_ATTRIBUTE_VALUES = {
9
- vehicle_type: {
10
- allowed: HyperTrack::SharedResource::VALID_VEHICLE_TYPES
11
- }
12
- }
13
-
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- module HyperTrack
2
- class Event < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "events/"
5
- REQUIRED_FIELDS = []
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- def self.create(params={})
10
- raise HyperTrack::MethodNotAllowed.new("Create not allowed on HyperTrack::Event class")
11
- end
12
-
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- module HyperTrack
2
- class Fleet < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "fleets/"
5
- REQUIRED_FIELDS = [:name]
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- end
10
- end
@@ -1,31 +0,0 @@
1
- module HyperTrack
2
- class GPSLog < HyperTrack::SharedResource
3
- include HyperTrack::ApiOperations::GPSLogAPI
4
-
5
- API_BASE_PATH = "gps/"
6
- REQUIRED_FIELDS = [:driver_id, :location, :speed, :bearing, :altitude, :recorded_at]
7
-
8
- VALID_ATTRIBUTE_VALUES = {
9
- activities: {
10
- allowed: [:stationary, :walking, :running, :automotive, :cycling, :unknown]
11
- },
12
- activity_confidence: {
13
- allowed: (0..100).to_a
14
- }
15
- }
16
-
17
- def self.create(params={})
18
- raise HyperTrack::MethodNotAllowed.new("Create not allowed on HyperTrack::GPSLog class")
19
- end
20
-
21
- def self.list(params={})
22
- if params.is_a?(Hash)
23
- params[:filtered] ? params.delete(:raw) : params[:raw] = true
24
- end
25
- params.delete(:filtered)
26
-
27
- super(params)
28
- end
29
-
30
- end
31
- end
@@ -1,10 +0,0 @@
1
- module HyperTrack
2
- class Hub < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "hubs/"
5
- REQUIRED_FIELDS = [:name]
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- module HyperTrack
2
- class Neighbourhood < HyperTrack::SharedResource
3
-
4
- API_BASE_PATH = "neighborhoods/"
5
- REQUIRED_FIELDS = []
6
-
7
- VALID_ATTRIBUTE_VALUES = {}
8
-
9
- def self.create(params={})
10
- raise HyperTrack::MethodNotAllowed.new("Create not allowed on HyperTrack::Neighbourhood class")
11
- end
12
-
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- module HyperTrack
2
- class Shift < HyperTrack::SharedResource
3
- include HyperTrack::ApiOperations::ShiftAPI
4
-
5
- API_BASE_PATH = "shifts/"
6
- REQUIRED_FIELDS = [:driver_id, :start_location]
7
-
8
- VALID_ATTRIBUTE_VALUES = {}
9
-
10
- end
11
- end
@@ -1,22 +0,0 @@
1
- module HyperTrack
2
- class Task < HyperTrack::SharedResource
3
- include HyperTrack::ApiOperations::TaskAPI
4
-
5
- API_BASE_PATH = "tasks/"
6
- REQUIRED_FIELDS = []
7
-
8
- VALID_ATTRIBUTE_VALUES = {
9
- action: {
10
- allowed: [:pickup, :delivery, :visit, :task],
11
- allow_nil: true
12
- },
13
- editable: {
14
- allowed: [:'not editable', :once, :multiple]
15
- },
16
- vehicle_type: {
17
- allowed: HyperTrack::SharedResource::VALID_VEHICLE_TYPES
18
- }
19
- }
20
-
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- module HyperTrack
2
- class Trip < HyperTrack::SharedResource
3
- include HyperTrack::ApiOperations::TripAPI
4
-
5
- API_BASE_PATH = "trips/"
6
- REQUIRED_FIELDS = [:driver_id]
7
-
8
- VALID_ATTRIBUTE_VALUES = {
9
- vehicle_type: {
10
- allowed: HyperTrack::SharedResource::VALID_VEHICLE_TYPES
11
- },
12
- has_ordered_tasks: {
13
- allowed: [true, false]
14
- }
15
- }
16
-
17
- end
18
- end