routific 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/routific/options.rb +49 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80f461bbd6a8c76891619ef0e6eac1a430eb5aa7
|
4
|
+
data.tar.gz: 659b39f98fcd1b8d45d93cbde3b99f59eb8e0a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10a6414354f038e953e4ca3366b8e6322777c92a16c7656b2f02873f49efa80a8499fffe52bc686154bfb39da91cf1b011326845560553db09910c2c7d9d038
|
7
|
+
data.tar.gz: 50130e568b9c6fd4c5a3bab8212968698b938ca699953d7aaaedbeb84578434fb6bf21606f56a93cbf36ea66cc398342a83a01534e693826bc4f7ce1ee863362
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module RoutificApi
|
2
|
+
# This class represents a set of options for the request
|
3
|
+
class Options
|
4
|
+
VALID_PARAMS = %w{ traffic min_visits_per_vehicle balance min_vehicles shortest_distance }
|
5
|
+
|
6
|
+
attr_reader *VALID_PARAMS
|
7
|
+
|
8
|
+
def initialize(params)
|
9
|
+
# Validates the provided parameters
|
10
|
+
validate(params)
|
11
|
+
|
12
|
+
@traffic = params["traffic"]
|
13
|
+
@min_visits_per_vehicle = params["min_visits_per_vehicle"]
|
14
|
+
@balance = params["balance"]
|
15
|
+
@min_vehicles = params["min_vehicles"]
|
16
|
+
@shortest_distance = params["shortest_distance"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json(options)
|
20
|
+
as_json(options).to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the JSON representation of this object
|
24
|
+
# def to_json(options = nil)
|
25
|
+
def as_json(options = nil)
|
26
|
+
jsonData = {}
|
27
|
+
jsonData["traffic"] = self.traffic if self.traffic
|
28
|
+
jsonData["min_visits_per_vehicle"] = self.min_visits_per_vehicle if self.min_visits_per_vehicle
|
29
|
+
jsonData["balance"] = self.balance if self.balance
|
30
|
+
jsonData["shortest_distance"] = self.shortest_distance if self.shortest_distance
|
31
|
+
jsonData["min_vehicles"] = self.min_vehicles if self.min_vehicles
|
32
|
+
|
33
|
+
jsonData
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
# Validates the parameters being provided
|
38
|
+
# Raises an ArgumentError if any of the provided params is not supported
|
39
|
+
# Supported params are traffic, min_visits_per_vehicle, and balance
|
40
|
+
def validate(params)
|
41
|
+
invalid = params.keys.reject { |k| VALID_PARAMS.include?(k) }
|
42
|
+
|
43
|
+
if invalid.any?
|
44
|
+
invalid = invalid.join(",")
|
45
|
+
raise ArgumentError, "#{invalid} parameter is not supported"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routific
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Kuo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -85,16 +85,16 @@ description: Gem to use Routific API
|
|
85
85
|
email: asoesilo@live.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
|
-
extra_rdoc_files:
|
89
|
-
- README.md
|
88
|
+
extra_rdoc_files: []
|
90
89
|
files:
|
91
|
-
- "./lib/routific.rb"
|
92
|
-
- "./lib/routific/location.rb"
|
93
|
-
- "./lib/routific/route.rb"
|
94
|
-
- "./lib/routific/vehicle.rb"
|
95
|
-
- "./lib/routific/visit.rb"
|
96
|
-
- "./lib/routific/way_point.rb"
|
97
90
|
- README.md
|
91
|
+
- lib/routific.rb
|
92
|
+
- lib/routific/location.rb
|
93
|
+
- lib/routific/options.rb
|
94
|
+
- lib/routific/route.rb
|
95
|
+
- lib/routific/vehicle.rb
|
96
|
+
- lib/routific/visit.rb
|
97
|
+
- lib/routific/way_point.rb
|
98
98
|
homepage: https://routific.com/
|
99
99
|
licenses:
|
100
100
|
- MIT
|