vng 3.1.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44bfc4eff4a138fc21a6058eb634d08e8be4bca032b43807c15fea355dfa5fe1
4
- data.tar.gz: 414e83652f42d05171fc1413c17d9a817ab02bcd49d340164338e682b886d028
3
+ metadata.gz: d0040674685e7d8090bd5872e705ce17dd4fae6c16a4390522039719da756c39
4
+ data.tar.gz: e78eeca80c62145b6e2c9f737b78b1cf971c6597d21fbce910a3981bb89a90c7
5
5
  SHA512:
6
- metadata.gz: c64946b9ea2609929eb2b89b241dc93fa221df17c081e3548357eb94187d3d58215c59a6522a27d248c53c9009c5df7ec2fe64047b53367748be71988e653d60
7
- data.tar.gz: 917f9edb608a9488bd95896fad8e11803494f5598236f8271abc08853159b5a6821c328d99c4db5c9f5fcb138fb4632c99fa5349569e87355edc2a09f013d45f
6
+ metadata.gz: 1235ebc7d60b12babbfe060ead7aa92905423d87939b48de7996567317ff4c3dbd16b218e803de22522a963fe52e1e22a186f99fe997998001ffb6b8dd778dce
7
+ data.tar.gz: cf02b625c67a97bb01e670ff08f8026a7395531825db98bd958466d95a8736f23c16aa8cf7cd61122e3326e5d1a647a467484cf7a8925b37a11b8dbc43af45ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [3.3.0] - 2025-01-15
2
+
3
+ - Add SystemObject.find_by(name:)
4
+
5
+ ## [3.2.0] - 2025-01-15
6
+
7
+ - Add Lead#notes
8
+
1
9
  ## [3.1.0] - 2025-01-11
2
10
 
3
11
  - Add Client.find(id)
data/lib/vng/lead.rb CHANGED
@@ -5,16 +5,17 @@ module Vng
5
5
  class Lead < Resource
6
6
  PATH = '/api/v1/data/Leads/'
7
7
 
8
- attr_reader :id, :name, :email, :phone
8
+ attr_reader :id, :name, :email, :phone, :notes
9
9
 
10
- def initialize(id:, name:, email:, phone:)
10
+ def initialize(id:, name:, email:, phone:, notes:)
11
11
  @id = id
12
12
  @name = name
13
13
  @email = email
14
14
  @phone = phone
15
+ @notes = notes
15
16
  end
16
17
 
17
- def self.create(name:, email:, phone:)
18
+ def self.create(name:, email:, phone:, notes: nil, campaign_option_id: nil)
18
19
  body = {
19
20
  method: '3',
20
21
  Fields: [
@@ -25,14 +26,18 @@ module Vng
25
26
  ]
26
27
  }
27
28
 
29
+ body[:Fields] << { fieldID: 108, fieldValue: notes } if notes
30
+ body[:Fields] << { fieldID: 795, optionID: campaign_option_id } if campaign_option_id
31
+
28
32
  data = request path: PATH, body: body
29
33
 
30
34
  id = data['Client']['objectID']
31
35
  name = value_for_field data, 127
32
36
  email = value_for_field data, 238
33
37
  phone = value_for_field data, 1024
38
+ notes = value_for_field data, 108
34
39
 
35
- new id: id, name: name, email: email, phone: phone
40
+ new id: id, name: name, email: email, phone: phone, notes: notes
36
41
  end
37
42
  end
38
43
  end
@@ -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
@@ -118,6 +133,7 @@ module Vng
118
133
  { "fieldID"=>126, "fieldValue"=>"Vng Example" },
119
134
  { "fieldID"=>238, "fieldValue"=>"vng@example.com" },
120
135
  { "fieldID"=>1024, "fieldValue"=>"8648648640" },
136
+ { "fieldID"=>108, "fieldValue"=>"Lead notes" },
121
137
  ] }
122
138
  end
123
139
  when '/api/v1/data/Contacts/'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Vng
2
- VERSION = '3.1.0'
2
+ VERSION = '3.3.0'
3
3
  end
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.1.0
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-11 00:00:00.000000000 Z
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