work_surfer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/work_surfer/api/approved_plans.rb +3 -3
- data/lib/work_surfer/api/base.rb +29 -0
- data/lib/work_surfer/api/territories.rb +2 -2
- data/lib/work_surfer/api/time_of_arrival.rb +4 -4
- data/lib/work_surfer/api.rb +2 -5
- data/lib/work_surfer/client.rb +16 -3
- data/lib/work_surfer.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c456764defdde3b3827c67ae0666f72a8a500780
|
4
|
+
data.tar.gz: 35e2173c4f097597631d3a9b86636a419d6eba7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1eb2b9e3cbaf0a72e8545871ff30c295112023ee8b83f2f1adb910a5df4815be2bf557ecaab204fb0f6b64472e63b55376a4bc647c78bfad9c3b57089fa5332
|
7
|
+
data.tar.gz: d201a387bdbb4eff926f96d84c831e415d74656be2de4bdba7d1c6238c9f2e4d295d1b88cc1728c1424439856dcb14476b6a5da4e7fd90378b95025aa01fafcf
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module WorkSurfer
|
4
4
|
module API
|
5
|
-
class ApprovedPlans
|
5
|
+
class ApprovedPlans < Base
|
6
6
|
class << self
|
7
7
|
def get(route_id, territory_id: WorkSurfer::Client.default_territory_id)
|
8
|
-
|
8
|
+
client.get("territories/#{territory_id}/approved/routes/#{route_id}")
|
9
9
|
end
|
10
10
|
|
11
11
|
def list(date: "today", territory_id: WorkSurfer::Client.default_territory_id)
|
12
|
-
|
12
|
+
client.get("territories/#{territory_id}/approved/routes?date=#{formatted_date(date)}")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WorkSurfer
|
4
|
+
module API
|
5
|
+
class Base
|
6
|
+
class << self
|
7
|
+
protected
|
8
|
+
|
9
|
+
def client
|
10
|
+
Client.default_client
|
11
|
+
end
|
12
|
+
|
13
|
+
def formatted_date(date = nil)
|
14
|
+
return date if date.to_s == "today"
|
15
|
+
return nil if date.to_s.strip.length <= 0
|
16
|
+
|
17
|
+
date = date.respond_to?(:to_date)
|
18
|
+
if date.respond_to?(:to_date)
|
19
|
+
date.to_date
|
20
|
+
else
|
21
|
+
Date.parse(date.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
date.strftime("%Y%m%d")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
module WorkSurfer
|
4
4
|
module API
|
5
|
-
class TimeOfArrival
|
5
|
+
class TimeOfArrival < Base
|
6
6
|
class << self
|
7
7
|
def get(route_id, territory_id: WorkSurfer::Client.default_territory_id)
|
8
|
-
|
8
|
+
client.get("territories/#{territory_id}/toa/routes/#{route_id}")
|
9
9
|
end
|
10
10
|
|
11
11
|
def list(date: nil, territory_id: WorkSurfer::Client.default_territory_id, vehicle_id: nil)
|
12
|
-
|
13
|
-
date: date,
|
12
|
+
client.get("territories/#{territory_id}/toa/routes", { params: {
|
13
|
+
date: formatted_date(date),
|
14
14
|
territory_id: territory_id,
|
15
15
|
vehicle: vehicle_id,
|
16
16
|
}.reject { |k, v| v.nil? } })
|
data/lib/work_surfer/api.rb
CHANGED
@@ -2,14 +2,11 @@
|
|
2
2
|
|
3
3
|
module WorkSurfer
|
4
4
|
module API
|
5
|
-
class << self
|
6
|
-
def client
|
7
|
-
Client.default_client
|
8
|
-
end
|
9
|
-
end
|
10
5
|
end
|
11
6
|
end
|
12
7
|
|
8
|
+
require "work_surfer/api/base"
|
9
|
+
|
13
10
|
require "work_surfer/api/approved_plans"
|
14
11
|
require "work_surfer/api/territories"
|
15
12
|
require "work_surfer/api/time_of_arrival"
|
data/lib/work_surfer/client.rb
CHANGED
@@ -12,14 +12,27 @@ module WorkSurfer
|
|
12
12
|
].freeze
|
13
13
|
|
14
14
|
OPTIONS_WITH_CLASS_DEFAULT.each do |option|
|
15
|
-
|
16
|
-
|
15
|
+
define_singleton_method(option) do
|
16
|
+
instance_variable_get("@#{option}")
|
17
|
+
end
|
18
|
+
|
19
|
+
define_singleton_method("#{option}=") do |*args|
|
20
|
+
instance_variable_set("@#{option}", *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
define_method(option) do
|
24
|
+
instance_variable_get("@#{option}")
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method("#{option}=") do |*args|
|
28
|
+
instance_variable_set("@#{option}", *args)
|
29
|
+
end
|
17
30
|
end
|
18
31
|
|
19
32
|
self.connection_builder = ->(builder) {
|
20
33
|
builder.adapter Faraday.default_adapter
|
21
34
|
builder.request :url_encoded
|
22
|
-
builder.response :
|
35
|
+
builder.response :json
|
23
36
|
}
|
24
37
|
|
25
38
|
self.connection_options = {}
|
data/lib/work_surfer.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: work_surfer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niels Ganser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/work_surfer.rb
|
54
54
|
- lib/work_surfer/api.rb
|
55
55
|
- lib/work_surfer/api/approved_plans.rb
|
56
|
+
- lib/work_surfer/api/base.rb
|
56
57
|
- lib/work_surfer/api/territories.rb
|
57
58
|
- lib/work_surfer/api/time_of_arrival.rb
|
58
59
|
- lib/work_surfer/client.rb
|