vng 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/vng/lead.rb +2 -1
- data/lib/vng/mock_request.rb +15 -0
- 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: d0040674685e7d8090bd5872e705ce17dd4fae6c16a4390522039719da756c39
|
4
|
+
data.tar.gz: e78eeca80c62145b6e2c9f737b78b1cf971c6597d21fbce910a3981bb89a90c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1235ebc7d60b12babbfe060ead7aa92905423d87939b48de7996567317ff4c3dbd16b218e803de22522a963fe52e1e22a186f99fe997998001ffb6b8dd778dce
|
7
|
+
data.tar.gz: cf02b625c67a97bb01e670ff08f8026a7395531825db98bd958466d95a8736f23c16aa8cf7cd61122e3326e5d1a647a467484cf7a8925b37a11b8dbc43af45ab
|
data/CHANGELOG.md
CHANGED
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
|
@@ -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.0
|
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-16 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
|