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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82efc2a53c1701fc7eb085e9288eb19f5aad31bd8c6b53a741b7df6f7f3614fb
4
- data.tar.gz: ce64e32bef02da3d05f0bb2abe617d43fb3e6a88e5f9ef17b7513d7436de0be6
3
+ metadata.gz: 77c224107919eb31f903b177076f19139b24287cee093d03280bb856e0873636
4
+ data.tar.gz: ae7664b9509ad5186586c163ea706e90e8d4f4bfca6ed6ebbc6f9dd2e990a57e
5
5
  SHA512:
6
- metadata.gz: 6d0ea75c0ed1a0597ceeaead6523c2cc1e398127bf6bf52a738f82ccbeb92fe7d1dcc8821beee09716a20976878f2b62c0797e225742215b39aba2ef4237f824
7
- data.tar.gz: a483291bb5db42d991b3574dca10786f617dd6f7c263142430d926bd9c2cd3a238f01e72ddc655c0c3fdfa70c59f834ccbf8ad4d901b1dec61c3150a8d271cb5
6
+ metadata.gz: 3e9115a5876e0cf0775ed992f6b38325e353f678e30c77bded350f59f32ef4280757b524589f10b61aad4d32b32debe4e81fa4166a277d22c97f6da1ce837c68
7
+ data.tar.gz: 0ea0c1d2e3fc576cb3e14510e0f3b5c1ee8b67159d114cbe70210ffb41daa18ad78e905269133bc1f2ae0e6edd96f8d0b12e0160f6e2b459ce7fc702be6550ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [3.5.0] - 2025-01-22
2
+
3
+ - Add Asset.for_client_id
4
+
5
+ ## [3.4.1] - 2025-01-22
6
+
7
+ - Fix mock for WorkOrder#route_id
8
+
1
9
  ## [3.4.0] - 2025-01-22
2
10
 
3
11
  - Add WorkOrder#route_id
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',
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Vng
2
- VERSION = '3.4.0'
2
+ VERSION = '3.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vng
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob