vng 3.4.0 → 3.5.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 +8 -0
- data/lib/vng/asset.rb +22 -10
- data/lib/vng/mock_request.rb +10 -1
- data/lib/vng/resource.rb +5 -0
- data/lib/vng/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77c224107919eb31f903b177076f19139b24287cee093d03280bb856e0873636
|
4
|
+
data.tar.gz: ae7664b9509ad5186586c163ea706e90e8d4f4bfca6ed6ebbc6f9dd2e990a57e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9115a5876e0cf0775ed992f6b38325e353f678e30c77bded350f59f32ef4280757b524589f10b61aad4d32b32debe4e81fa4166a277d22c97f6da1ce837c68
|
7
|
+
data.tar.gz: 0ea0c1d2e3fc576cb3e14510e0f3b5c1ee8b67159d114cbe70210ffb41daa18ad78e905269133bc1f2ae0e6edd96f8d0b12e0160f6e2b459ce7fc702be6550ac
|
data/CHANGELOG.md
CHANGED
data/lib/vng/asset.rb
CHANGED
@@ -5,10 +5,13 @@ module Vng
|
|
5
5
|
class Asset < Resource
|
6
6
|
PATH = '/api/v1/data/Assets/'
|
7
7
|
|
8
|
-
attr_reader :id
|
8
|
+
attr_reader :id, :name, :weight, :breed_option_id
|
9
9
|
|
10
|
-
def initialize(id:)
|
10
|
+
def initialize(id:, name: nil, weight: nil, breed_option_id: nil)
|
11
11
|
@id = id
|
12
|
+
@name = name
|
13
|
+
@weight = weight
|
14
|
+
@breed_option_id = breed_option_id
|
12
15
|
end
|
13
16
|
|
14
17
|
def self.create(name:, weight:, breed_option_id:, client_id:)
|
@@ -24,17 +27,26 @@ module Vng
|
|
24
27
|
|
25
28
|
data = request path: PATH, body: body
|
26
29
|
|
27
|
-
# curl = 'curl'.tap do |curl|
|
28
|
-
# curl << ' -X POST'
|
29
|
-
# request.each_header{|k, v| curl << %Q{ -H "#{k}: #{v}"}}
|
30
|
-
# curl << %Q{ -d '#{request.body}'} if request.body
|
31
|
-
# curl << %Q{ "#{uri.to_s}"}
|
32
|
-
# end
|
33
|
-
# puts curl
|
34
|
-
|
35
30
|
new id: data['Asset']['objectID']
|
36
31
|
end
|
37
32
|
|
33
|
+
def self.for_client_id(client_id)
|
34
|
+
body = { clientID: client_id, isCompleteObject: 'true' }
|
35
|
+
|
36
|
+
data = request path: PATH, body: body
|
37
|
+
|
38
|
+
data.fetch('Assets', []).map do |asset|
|
39
|
+
next unless active?(asset)
|
40
|
+
|
41
|
+
id = asset['objectID']
|
42
|
+
name = asset['name']
|
43
|
+
breed_option_id = option_for_field asset, 1014
|
44
|
+
weight = value_for_field asset, 1017
|
45
|
+
weight = (Integer weight unless weight.empty?)
|
46
|
+
new id: id, name: name, weight: weight, breed_option_id: breed_option_id
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
38
50
|
def destroy
|
39
51
|
body = {
|
40
52
|
method: '4',
|
data/lib/vng/mock_request.rb
CHANGED
@@ -180,6 +180,13 @@ module Vng
|
|
180
180
|
end
|
181
181
|
elsif @body[:method].eql? '4'
|
182
182
|
{}
|
183
|
+
else
|
184
|
+
{"Assets" => [
|
185
|
+
{"objectID" => "2201008", "name" => "Fluffy", "isActive" => "true", "Fields" => [
|
186
|
+
{"fieldID" => 1014, "fieldValue" => "400", "optionID" => 400},
|
187
|
+
{"fieldID" => 1017, "fieldValue" => "", "optionID" => 0},
|
188
|
+
]},
|
189
|
+
]}
|
183
190
|
end
|
184
191
|
when '/api/v1/resources/priceBlocks/'
|
185
192
|
if @body[:pageNo].eql? 1
|
@@ -276,7 +283,9 @@ module Vng
|
|
276
283
|
{"fieldID" => 810, "fieldValue" => "0.00"},
|
277
284
|
{"fieldID" => 186, "fieldValue" => "30"},
|
278
285
|
{"fieldID" => 9835, "fieldValue" => "135.00"},
|
279
|
-
]
|
286
|
+
], "Relations" => [
|
287
|
+
{"objectID" => 2, "name" => "Route 2", "relationType" => "route", "isActive" => "true"},
|
288
|
+
]},
|
280
289
|
]}
|
281
290
|
else
|
282
291
|
{ "WorkOrder"=>{ "objectID"=>"4138030" } }
|
data/lib/vng/resource.rb
CHANGED
@@ -39,6 +39,11 @@ module Vng
|
|
39
39
|
field['fieldValue'] if field
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.option_for_field(data, field_id)
|
43
|
+
field = data['Fields'].find { |field| field['fieldID'] == field_id }
|
44
|
+
field['optionID'] if field
|
45
|
+
end
|
46
|
+
|
42
47
|
def self.value_for_relation(data, relation_type)
|
43
48
|
relation = data['Relations'].find do |relation|
|
44
49
|
relation['relationType'] == relation_type &&
|
data/lib/vng/version.rb
CHANGED