vng 3.4.1 → 3.5.1
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 +7 -0
- data/lib/vng/resource.rb +5 -0
- 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: 8b8954a2a0696b9812e24b67ce9aaf0f60bfbd793b620e1c24ef269cb76440d6
|
4
|
+
data.tar.gz: 2d15a0fd5b1b5afa1fd825d192f684b785b0c1ff4d361ecef5c2cb3856bebc55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5f069055b043b77c4ccd953b898fda311c14e4f63bb0ebb1548da7779dda9d7ac01b409fe0a166653325e9b4c3467ce3af5ae0b2335247f0198ba99e043cf6
|
7
|
+
data.tar.gz: 902deb45f9b692663ac2a1fac6b2bc76e8b8ce252676a05066641b0d54562d89a947efb2ff227eac40bfd416708d7aa75cd813a10783a4f5514c40090173e25d
|
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" => 304},
|
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
|
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
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.5.1
|
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-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: simplecov
|