vng 3.2.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -0
- data/lib/vng/lead.rb +2 -1
- data/lib/vng/mock_request.rb +18 -3
- data/lib/vng/route.rb +5 -3
- data/lib/vng/system_field.rb +26 -0
- data/lib/vng/system_object.rb +26 -0
- data/lib/vng/system_option.rb +21 -0
- data/lib/vng/version.rb +1 -1
- data/lib/vng.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c12edbb4518fc769872a46bb3060e6e88d8850c18e0c0eec6b9aea157bfcaa8
|
4
|
+
data.tar.gz: 1bb1e134d2bf6b1ab736fd9c342f594fd826b1de7b116f114113f383fc33d157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61b780b5a55aa0c4cc87ee51ca4c9c9b1d850e4fb68bfae22939d95d4c5aef7315a79775c1be3ce37121ffbaff4400166693ec433eedd7a4ef6346d14766d120
|
7
|
+
data.tar.gz: 6f87f2b80d1d52c9aa7711556bc1ae211f2b330b2e612cff7d2f450b803dc21838c1880cbc255609f94ecf4bed1f63df8f783d5a0c5f18ab56be43fc8f1707ea
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,8 @@ Vng::ServiceType.where zip:
|
|
19
19
|
Vng::SecurityToken.create host:, usename:, password:
|
20
20
|
Vng::Lead.create email:, phone:, name: full_name
|
21
21
|
Vng::Contact.create first_name:, last_name:, email:, phone:, client_id:
|
22
|
+
Vng::Contact.edited_since timestamp
|
23
|
+
Vng::Client.find contact_id
|
22
24
|
Vng::Location.create address:, city:, zip:, state: state, client_id:
|
23
25
|
Vng::Breed.all
|
24
26
|
Vng::Asset.create name:, weight:, breed_option_id:, client_id:
|
data/lib/vng/lead.rb
CHANGED
@@ -15,7 +15,7 @@ module Vng
|
|
15
15
|
@notes = notes
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.create(name:, email:, phone:, notes: nil)
|
18
|
+
def self.create(name:, email:, phone:, notes: nil, campaign_option_id: nil)
|
19
19
|
body = {
|
20
20
|
method: '3',
|
21
21
|
Fields: [
|
@@ -27,6 +27,7 @@ module Vng
|
|
27
27
|
}
|
28
28
|
|
29
29
|
body[:Fields] << { fieldID: 108, fieldValue: notes } if notes
|
30
|
+
body[:Fields] << { fieldID: 795, optionID: campaign_option_id } if campaign_option_id
|
30
31
|
|
31
32
|
data = request path: PATH, body: body
|
32
33
|
|
data/lib/vng/mock_request.rb
CHANGED
@@ -47,6 +47,21 @@ module Vng
|
|
47
47
|
@@logged_out = true
|
48
48
|
{}
|
49
49
|
end
|
50
|
+
when '/api/v1/system/objects/'
|
51
|
+
if @body[:method] == '1'
|
52
|
+
{ "Fields" => [
|
53
|
+
{ "fieldID" => 795, "field" => "Marketing Campaign" },
|
54
|
+
{ "fieldID" => 830, "field" => "Primary Contact" },
|
55
|
+
], "Options" => [
|
56
|
+
{"optionID" => 15840, "name" => "Referral", "fieldID" => 795, "objectTypeID" => 28, "isActive" => false},
|
57
|
+
{"optionID" => 15841, "name" => "Website", "fieldID" => 795, "objectTypeID" => 28, "isActive" => true},
|
58
|
+
] }
|
59
|
+
else
|
60
|
+
{ "Objects"=>[
|
61
|
+
{ "objectTypeID" => 15, "name" => "User" },
|
62
|
+
{ "objectTypeID" => 28, "name" => "Lead" },
|
63
|
+
] }
|
64
|
+
end
|
50
65
|
when '/api/v1/resources/zips/'
|
51
66
|
if @body[:method] == '1'
|
52
67
|
# TODO: The response already includes the ServiceTypes so there
|
@@ -246,9 +261,9 @@ module Vng
|
|
246
261
|
end
|
247
262
|
when '/api/v1/resources/Routes/'
|
248
263
|
{"Routes" => [
|
249
|
-
{"routeID" => AVAILABLE_ROUTE_ID, "routeName" => "Route 1", "isActive" => true},
|
250
|
-
{"routeID" => 2, "routeName" => "Route 2", "isActive" => true},
|
251
|
-
{"routeID" => 3, "routeName" => "Route 3 (Inactive)", "isActive" => false},
|
264
|
+
{"routeID" => AVAILABLE_ROUTE_ID, "routeName" => "Route 1", "isActive" => true, "routeTypeID" => 106},
|
265
|
+
{"routeID" => 2, "routeName" => "Route 2", "isActive" => true, "routeTypeID" => 107},
|
266
|
+
{"routeID" => 3, "routeName" => "Route 3 (Inactive)", "isActive" => false, "routeTypeID" => 1},
|
252
267
|
]}
|
253
268
|
when '/api/v1/data/WorkOrders/'
|
254
269
|
if @body[:pageNo].eql? 1
|
data/lib/vng/route.rb
CHANGED
@@ -5,11 +5,12 @@ module Vng
|
|
5
5
|
class Route < Resource
|
6
6
|
PATH = '/api/v1/resources/Routes/'
|
7
7
|
|
8
|
-
attr_reader :id, :name
|
8
|
+
attr_reader :id, :name, :type_id
|
9
9
|
|
10
|
-
def initialize(id:, name:)
|
10
|
+
def initialize(id:, name:, type_id:)
|
11
11
|
@id = id
|
12
12
|
@name = name
|
13
|
+
@type_id = type_id
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.all
|
@@ -20,8 +21,9 @@ module Vng
|
|
20
21
|
end.map do |body|
|
21
22
|
id = body['routeID']
|
22
23
|
name = body['routeName']
|
24
|
+
type_id = body['routeTypeID']
|
23
25
|
|
24
|
-
new id: id, name: name
|
26
|
+
new id: id, name: name, type_id: type_id
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'vng/system_option'
|
2
|
+
|
3
|
+
module Vng
|
4
|
+
# Provides methods to interact with Vonigo system fields.
|
5
|
+
class SystemField < Resource
|
6
|
+
PATH = '/api/v1/system/objects/'
|
7
|
+
|
8
|
+
attr_reader :id, :name, :options
|
9
|
+
|
10
|
+
def initialize(id:, name:, options:)
|
11
|
+
@id = id
|
12
|
+
@name = name
|
13
|
+
@options = options
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.for_system_object_id(system_object_id)
|
17
|
+
body = { objectID: system_object_id, method: '1' }
|
18
|
+
data = request path: PATH, body: body
|
19
|
+
|
20
|
+
data['Fields'].lazy.map do |field|
|
21
|
+
options = SystemOption.for_system_field_id field['fieldID'], data['Options']
|
22
|
+
new id: field['fieldID'], name: field['field'], options: options
|
23
|
+
end # TODO: make this thing respond to find_by(name:)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'vng/system_field'
|
2
|
+
|
3
|
+
module Vng
|
4
|
+
# Provides methods to interact with Vonigo system objects.
|
5
|
+
class SystemObject < Resource
|
6
|
+
PATH = '/api/v1/system/objects/'
|
7
|
+
|
8
|
+
attr_reader :id, :name, :fields
|
9
|
+
|
10
|
+
def initialize(id:, name:, fields:)
|
11
|
+
@id = id
|
12
|
+
@name = name
|
13
|
+
@fields = fields
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find_by(name:)
|
17
|
+
data = request path: PATH
|
18
|
+
object = data['Objects'].find{|object| object['name'].eql? name}
|
19
|
+
|
20
|
+
if object
|
21
|
+
fields = SystemField.for_system_object_id object['objectTypeID']
|
22
|
+
new id: object['objectTypeID'], name: name, fields: fields
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo system fields’ options.
|
3
|
+
class SystemOption
|
4
|
+
attr_reader :id, :name
|
5
|
+
|
6
|
+
def initialize(id:, name:)
|
7
|
+
@id = id
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.for_system_field_id(system_field_id, options = {})
|
12
|
+
options.lazy.filter_map do |option|
|
13
|
+
next unless option['isActive']
|
14
|
+
|
15
|
+
if option['fieldID'].eql? system_field_id
|
16
|
+
new id: option['optionID'], name: option['name']
|
17
|
+
end
|
18
|
+
end # TODO: make this thing respond to find_by(name:)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/vng/version.rb
CHANGED
data/lib/vng.rb
CHANGED
@@ -21,6 +21,7 @@ require_relative 'vng/price_item'
|
|
21
21
|
require_relative 'vng/route'
|
22
22
|
require_relative 'vng/security_token'
|
23
23
|
require_relative 'vng/service_type'
|
24
|
+
require_relative 'vng/system_object'
|
24
25
|
require_relative 'vng/version'
|
25
26
|
require_relative 'vng/work_order'
|
26
27
|
require_relative 'vng/zip'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- claudiob
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: simplecov
|
@@ -89,6 +89,9 @@ files:
|
|
89
89
|
- lib/vng/route.rb
|
90
90
|
- lib/vng/security_token.rb
|
91
91
|
- lib/vng/service_type.rb
|
92
|
+
- lib/vng/system_field.rb
|
93
|
+
- lib/vng/system_object.rb
|
94
|
+
- lib/vng/system_option.rb
|
92
95
|
- lib/vng/version.rb
|
93
96
|
- lib/vng/work_order.rb
|
94
97
|
- lib/vng/zip.rb
|