onfleet-ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -7
- data/lib/onfleet-ruby.rb +4 -1
- data/lib/onfleet-ruby/actions/query_metadata.rb +17 -0
- data/lib/onfleet-ruby/admin.rb +1 -1
- data/lib/onfleet-ruby/destination.rb +1 -1
- data/lib/onfleet-ruby/onfleet_object.rb +1 -1
- data/lib/onfleet-ruby/recipient.rb +1 -0
- data/lib/onfleet-ruby/task.rb +1 -1
- data/lib/onfleet-ruby/worker.rb +1 -1
- data/onfleet-ruby.gemspec +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d19ee4307f4f027c05f2581baae87b5a52c1d0
|
4
|
+
data.tar.gz: a88178b746ab81416c9919b3df3c914cc7dca388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a6f0b564028363c31263ec927caf5e84777bec52f3aee8c830e786cca80283bc01ed0004970ffbaf138fd65ae7789ed7b002e75c71ef52c0b146bfd0a9d478b
|
7
|
+
data.tar.gz: 721408e9ac056dc81ae3acdf62bbbf3c20530dc56c36c5f9aaa8a63f6d7b1b45aae8a5191ac65b735718640b69e1ce2fbc838c91388c398205c2511ddf79c2b4
|
data/README.md
CHANGED
@@ -61,6 +61,7 @@ delegatee.country # => "US"
|
|
61
61
|
| name | string | The administrator’s complete name. |
|
62
62
|
| email | string | The administrator’s email address. |
|
63
63
|
| phone | string | (Optional) The administrator's E.164-formatted phone number. |
|
64
|
+
| metadata | array | (Optional) Any associated metadata |
|
64
65
|
|
65
66
|
**Create**
|
66
67
|
|
@@ -95,7 +96,8 @@ Worker
|
|
95
96
|
| name | string | The workers complete name. |
|
96
97
|
| phone | string | The worker's phone number. |
|
97
98
|
| teams | string Array | One or more team IDs of which the worker is a member.|
|
98
|
-
| vehicle |
|
99
|
+
| vehicle | object | (Optional) The worker’s vehicle, providing no vehicle details is interpreted as the worker being on foot. |
|
100
|
+
| metadata | array | (Optional) Any associated metadata |
|
99
101
|
|
100
102
|
Vehicle
|
101
103
|
|
@@ -164,6 +166,7 @@ Destination
|
|
164
166
|
| address | object | The destination’s street address details. |
|
165
167
|
| location | array | (Optional) The `[ longitude, latitude ]` geographic coordinates. If missing, the API will geocode based on the `address` details provided. Note that geocoding may slightly modify the format of the address properties. |
|
166
168
|
| notes | string | (Optional) Notes for the destination |
|
169
|
+
| metadata | array | (Optional) Any associated metadata |
|
167
170
|
|
168
171
|
Address
|
169
172
|
|
@@ -181,7 +184,6 @@ Address
|
|
181
184
|
|
182
185
|
|
183
186
|
|
184
|
-
|
185
187
|
**Create**
|
186
188
|
```ruby
|
187
189
|
destination = Onfleet::Destination.create({address: {unparsed: '200 12th st, 94103, ca'} })
|
@@ -204,6 +206,7 @@ Onfleet::Destination('DEST_ID')
|
|
204
206
|
| notes | string | (Optional) Notes for the recipient. |
|
205
207
|
| skip_sms_notifications | boolean | (Optional) To disable sms notification. Defaults to `false` |
|
206
208
|
| skip_phone_number_verificaton | boolean | (Optional) Whether to skip validation of the phone number. |
|
209
|
+
| metadata | array | (Optional) Any associated metadata |
|
207
210
|
|
208
211
|
**Create**
|
209
212
|
```ruby
|
@@ -239,11 +242,11 @@ rec.name = "John Doe"
|
|
239
242
|
rec = Onfleet::Recipient.find('phone', '4155556789')
|
240
243
|
```
|
241
244
|
|
242
|
-
##Tasks
|
245
|
+
## Tasks
|
243
246
|
| Name | Type | Description |
|
244
247
|
| ----------- |--------| --------------|
|
245
|
-
| destination | string | `ID` of the destination
|
246
|
-
| recipients | string
|
248
|
+
| destination | string or hash | `ID` of the destination, or the Destination data itself |
|
249
|
+
| recipients | array of string or hash | An array containing zero or one IDs of the task's recipients; alternately, an array containing Recipient data as entries |
|
247
250
|
| merchant | string | (Optional) `ID` of merchant organization. |
|
248
251
|
| executor | string | (Optional) `ID` of the executor organization. |
|
249
252
|
| complete_after | number | (Optional) A timestamp for the earliest time the task should be completed. |
|
@@ -252,12 +255,29 @@ rec = Onfleet::Recipient.find('phone', '4155556789')
|
|
252
255
|
| dependencies | string array | (Optional) One or more IDs of tasks which must be completed prior to this task. |
|
253
256
|
| notes | notes | (Optional) Notes for the task. |
|
254
257
|
| auto_assign | object | (Optional) The automatic assignment options for the newly created task. See above for exact object structure and allowed values. |
|
258
|
+
| metadata | array | (Optional) Any associated metadata |
|
255
259
|
|
256
260
|
**Create**
|
257
261
|
```ruby
|
258
262
|
# First Create a destination and Recipient
|
259
263
|
# Then create the task
|
260
|
-
task = Onfleet::Task.create({
|
264
|
+
task = Onfleet::Task.create({recipients: ['REC_ID'], destination: 'DEC_ID' })
|
265
|
+
|
266
|
+
# Alternatively, create the Destination and Recipient in a single call to Onfleet
|
267
|
+
# If a recipient exists for the phone number, it will be updated with the new information
|
268
|
+
another_task = Onfleet::Task.create(
|
269
|
+
destination: {
|
270
|
+
address: {
|
271
|
+
unparsed: "123 Smith St"
|
272
|
+
},
|
273
|
+
notes: "Some destination notes"
|
274
|
+
},
|
275
|
+
recipients: [{
|
276
|
+
name: "Foo Bar",
|
277
|
+
phone: "987-654-3210",
|
278
|
+
notes: "Some recipient notes"
|
279
|
+
}]
|
280
|
+
)
|
261
281
|
```
|
262
282
|
|
263
283
|
**Update**
|
@@ -288,7 +308,21 @@ Onfleet::Task.list({state: 0}) # => returns all tasks with state 0, see official
|
|
288
308
|
Currently not supported
|
289
309
|
|
290
310
|
|
291
|
-
##
|
311
|
+
## Metadata
|
312
|
+
| Name | Type | Description |
|
313
|
+
| ----------- |--------| --------------|
|
314
|
+
| name | string | the name of the property |
|
315
|
+
| type | string | The type of the property. Must be one of [ ‘boolean’, ‘number’, ‘string’, ‘object’, ‘array’ ] |
|
316
|
+
| subtype | string | (Optional) Required only for entries of type array, used for future visualization purposes. Must be one of [ ‘boolean’, ‘number’, ‘string’, ‘object’ ]. |
|
317
|
+
| value | string | The value of the property. The JSON type must match the type (and subtype) provided for the entry. |
|
318
|
+
|
319
|
+
```ruby
|
320
|
+
# Returns an array with entities matching the metadata query
|
321
|
+
# Any entity supporting metadata can be queried (eg: Admins, Workers, Tasks, Destinations, Recipients)
|
322
|
+
tasks = Onfleet::Task.query_by_metadata([{name: "property", type: "string", value: "abc"}])
|
323
|
+
```
|
324
|
+
|
325
|
+
## Error Handling
|
292
326
|
```ruby
|
293
327
|
begin
|
294
328
|
# perform onfleet api requests
|
data/lib/onfleet-ruby.rb
CHANGED
@@ -20,7 +20,10 @@ require 'onfleet-ruby/actions/update'
|
|
20
20
|
require 'onfleet-ruby/actions/get'
|
21
21
|
require 'onfleet-ruby/actions/list'
|
22
22
|
require 'onfleet-ruby/actions/delete'
|
23
|
-
|
23
|
+
<<<<<<< HEAD
|
24
|
+
=======
|
25
|
+
require 'onfleet-ruby/actions/query_metadata'
|
26
|
+
>>>>>>> 5c063de65d354e63cb5ac4f7589fbb9c1ae99c5a
|
24
27
|
|
25
28
|
# Resources
|
26
29
|
require 'onfleet-ruby/onfleet_object'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Onfleet
|
2
|
+
module Actions
|
3
|
+
module QueryMetadata
|
4
|
+
module ClassMethods
|
5
|
+
def query_by_metadata metadata
|
6
|
+
api_url = "#{self.api_url}/metadata"
|
7
|
+
response = Onfleet.request(api_url, :post, metadata)
|
8
|
+
response.map { |item| Util.constantize("#{self}").new(item) } if response.is_a? Array
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included base
|
13
|
+
base.extend(ClassMethods)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/onfleet-ruby/admin.rb
CHANGED
@@ -57,7 +57,7 @@ module Onfleet
|
|
57
57
|
|
58
58
|
def parse_onfleet_obj obj
|
59
59
|
if obj.is_a?(OnfleetObject)
|
60
|
-
if obj.is_a?(Destination) || obj.is_a?(Recipient) || obj.is_a?(Task)
|
60
|
+
if obj.respond_to?('id') && obj.id && (obj.is_a?(Destination) || obj.is_a?(Recipient) || obj.is_a?(Task))
|
61
61
|
obj.id
|
62
62
|
else
|
63
63
|
obj.attributes
|
data/lib/onfleet-ruby/task.rb
CHANGED
data/lib/onfleet-ruby/worker.rb
CHANGED
data/onfleet-ruby.gemspec
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'onfleet'
|
2
|
-
require File.expand_path('
|
1
|
+
require 'onfleet-ruby'
|
2
|
+
require File.expand_path('../test_data', __FILE__)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onfleet-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Wargnier
|
@@ -14,34 +14,34 @@ dependencies:
|
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.3.0
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 3.0.0
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - ~>
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 3.3.0
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 3.0.0
|
47
47
|
description: To interact with Onfleet's API
|
@@ -50,8 +50,8 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rspec
|
53
|
+
- ".gitignore"
|
54
|
+
- ".rspec"
|
55
55
|
- Gemfile
|
56
56
|
- README.md
|
57
57
|
- lib/onfleet-ruby.rb
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/onfleet-ruby/actions/find.rb
|
61
61
|
- lib/onfleet-ruby/actions/get.rb
|
62
62
|
- lib/onfleet-ruby/actions/list.rb
|
63
|
+
- lib/onfleet-ruby/actions/query_metadata.rb
|
63
64
|
- lib/onfleet-ruby/actions/save.rb
|
64
65
|
- lib/onfleet-ruby/actions/update.rb
|
65
66
|
- lib/onfleet-ruby/address.rb
|
@@ -91,17 +92,17 @@ require_paths:
|
|
91
92
|
- lib
|
92
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- -
|
95
|
+
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
99
|
requirements:
|
99
|
-
- -
|
100
|
+
- - ">="
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: '0'
|
102
103
|
requirements: []
|
103
104
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.4.
|
105
|
+
rubygems_version: 2.4.8
|
105
106
|
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: Onfleet ruby api
|