vng 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/vng/contact.rb +23 -3
- data/lib/vng/mock_request.rb +22 -7
- data/lib/vng/resource.rb +13 -1
- data/lib/vng/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf5c18372847d998d4e0d4c25e7bfe79ce17a11df1e573c66771cd963b3cb0a
|
4
|
+
data.tar.gz: 3cb76db925bd75bc8568607e3375ee18c6ed41f1c689b0624e2fc6de642e4be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 527b1ced6a89489422f020b7745b6b38026d8b8187c9f3fd36abd9b55fffc21f9247a7af492c957419fe48bef126a0a3bc2894304fc23ebdb77e950446de9109
|
7
|
+
data.tar.gz: 86024f32fa8d9c432225d7b0a655336e5894e0ebfc13c11b4f39f18ce5cb9df2836ca06cb056135a86f7e52253f096cc2a0607a305d38241e4992799d87e6a00
|
data/CHANGELOG.md
CHANGED
data/lib/vng/contact.rb
CHANGED
@@ -5,14 +5,34 @@ module Vng
|
|
5
5
|
class Contact < Resource
|
6
6
|
PATH = '/api/v1/data/Contacts/'
|
7
7
|
|
8
|
-
attr_reader :id, :first_name, :last_name, :email, :phone
|
8
|
+
attr_reader :id, :first_name, :last_name, :email, :phone, :client_id
|
9
9
|
|
10
|
-
def initialize(id:, first_name:, last_name:, email:, phone:)
|
10
|
+
def initialize(id:, first_name:, last_name:, email:, phone:, client_id:)
|
11
11
|
@id = id
|
12
12
|
@first_name = first_name
|
13
13
|
@last_name = last_name
|
14
14
|
@email = email
|
15
15
|
@phone = phone
|
16
|
+
@client_id = client_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.all # TODO: add (edited_after: param)
|
20
|
+
body = { isCompleteObject: 'true' }
|
21
|
+
|
22
|
+
data = request path: PATH, body: body, returning: 'Contacts'
|
23
|
+
|
24
|
+
data.filter_map do |body|
|
25
|
+
next unless body['isActive']
|
26
|
+
|
27
|
+
id = body['objectID']
|
28
|
+
first_name = value_for_field body, 127
|
29
|
+
last_name = value_for_field body, 128
|
30
|
+
email = value_for_field body, 97
|
31
|
+
phone = value_for_field body, 96
|
32
|
+
client_id = value_for_relation body, 'client'
|
33
|
+
|
34
|
+
new id: id, first_name: first_name, last_name: last_name, email: email, phone: phone, client_id: client_id
|
35
|
+
end
|
16
36
|
end
|
17
37
|
|
18
38
|
def self.create(first_name:, last_name:, email:, phone:, client_id:)
|
@@ -35,7 +55,7 @@ module Vng
|
|
35
55
|
email = value_for_field data, 97
|
36
56
|
phone = value_for_field data, 96
|
37
57
|
|
38
|
-
new id: id, first_name: first_name, last_name: last_name, email: email, phone: phone
|
58
|
+
new id: id, first_name: first_name, last_name: last_name, email: email, phone: phone, client_id: client_id
|
39
59
|
end
|
40
60
|
end
|
41
61
|
end
|
data/lib/vng/mock_request.rb
CHANGED
@@ -121,12 +121,27 @@ module Vng
|
|
121
121
|
] }
|
122
122
|
end
|
123
123
|
when '/api/v1/data/Contacts/'
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
124
|
+
if @body[:pageNo].eql? 1
|
125
|
+
{"Contacts" => [
|
126
|
+
{"objectID" => "2201007", "isActive" => "true", "Fields" => [
|
127
|
+
{"fieldID"=>127, "fieldValue"=>"Vng" },
|
128
|
+
{"fieldID"=>128, "fieldValue"=>"Example" },
|
129
|
+
{"fieldID"=>97, "fieldValue"=>"vng@example.com" },
|
130
|
+
{"fieldID"=>96, "fieldValue"=>"8648648640" },
|
131
|
+
], "Relations" => [
|
132
|
+
{"objectID" => 915738, "relationType" => "client", "isActive" => "true"},
|
133
|
+
]}
|
134
|
+
]}
|
135
|
+
elsif @body[:pageNo].nil?
|
136
|
+
{ "Contact"=>{ "objectID"=>"2201007" }, "Fields"=> [
|
137
|
+
{ "fieldID"=>127, "fieldValue"=>"Vng" },
|
138
|
+
{ "fieldID"=>128, "fieldValue"=>"Example" },
|
139
|
+
{ "fieldID"=>97, "fieldValue"=>"vng@example.com" },
|
140
|
+
{ "fieldID"=>96, "fieldValue"=>"8648648640" },
|
141
|
+
] }
|
142
|
+
else
|
143
|
+
{ }
|
144
|
+
end
|
130
145
|
when '/api/v1/data/Locations/'
|
131
146
|
{ "Location"=>{ "objectID"=>995681 } }
|
132
147
|
when '/api/v1/data/Assets/'
|
@@ -224,7 +239,7 @@ module Vng
|
|
224
239
|
{"routeID" => 3, "routeName" => "Route 3 (Inactive)", "isActive" => false},
|
225
240
|
]}
|
226
241
|
when '/api/v1/data/WorkOrders/'
|
227
|
-
if @body[:
|
242
|
+
if @body[:pageNo].eql? 1
|
228
243
|
{"WorkOrders" => [
|
229
244
|
{"objectID" => "4139754", "isActive" => "true", "Fields" => [
|
230
245
|
{"fieldID" => 185, "fieldValue" => "1736445600"},
|
data/lib/vng/resource.rb
CHANGED
@@ -10,10 +10,14 @@ module Vng
|
|
10
10
|
body = body.merge securityToken: Vng.configuration.security_token
|
11
11
|
end
|
12
12
|
|
13
|
+
# TODO: I have to redo the pagination as a yield block for each page
|
14
|
+
|
13
15
|
if returning
|
14
16
|
[].tap do |response|
|
15
17
|
1.step do |page_number|
|
16
|
-
|
18
|
+
# ORDER BY edited ASC
|
19
|
+
body = body.merge pageSize: 500, pageNo: page_number, sortMode: 3, sortDirection: 0
|
20
|
+
|
17
21
|
batch = response_for(path:, body:, query:).fetch(returning, [])
|
18
22
|
break if batch.empty? || page_number > 20
|
19
23
|
response.concat batch
|
@@ -35,6 +39,14 @@ module Vng
|
|
35
39
|
field['fieldValue'] if field
|
36
40
|
end
|
37
41
|
|
42
|
+
def self.value_for_relation(data, relation_type)
|
43
|
+
relation = data['Relations'].find do |relation|
|
44
|
+
relation['relationType'] == relation_type &&
|
45
|
+
relation['isActive'] == 'true'
|
46
|
+
end
|
47
|
+
relation['objectID'] if relation
|
48
|
+
end
|
49
|
+
|
38
50
|
# @return [String] the Vonigo API host.
|
39
51
|
def self.host
|
40
52
|
Vng.configuration.host
|
data/lib/vng/version.rb
CHANGED
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: 2.
|
4
|
+
version: 2.4.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-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: simplecov
|