vng 1.6.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc73ebb5c56c095dd0605b32f41dcb6b75560f84a7b2b8ffcdfed0bc574a54ff
4
- data.tar.gz: e64616624354c33d07c9bfe8ffb6c4494008d5dfbd3ce10c8f994015cf483fad
3
+ metadata.gz: 2ba9ded97747e245e2102d52fc515f78a6b836b5e5a19709c40413d6c135f62b
4
+ data.tar.gz: 356ecdbc427ba9f6d1977972bafa3b81a4afa3122bc66ed11bbc9d69cfa1e6f9
5
5
  SHA512:
6
- metadata.gz: 7d5df6061ebbe9f818cac377456caf130bedb8c9864d3e984c8d32c1339aef9267006d545fc276e624559f489fb36be2c69118d4730a3c384ec9babe915d33b1
7
- data.tar.gz: 2df311c7ae9c712e71f4c8f950ef3bc085888d9ea74d71b2acc989e324f9c6a467e506c267ff78383f8885d97ec01773e78b7722870062ef8ed33c253c1953d0
6
+ metadata.gz: 1547625c3428ba7727be689119387e1c29b3a931037a01ac6cd03e8df0a9f80a21bf5486d17d23bb5428b902b4d7620696f997fad59e53ec101a8f62c8441f6f
7
+ data.tar.gz: 0646cbea6e388d76db71cf24505862ec92d808901e1c465b3c2796383c24ba93c1bdea676bcab98968e79b79004030133cce0e2c9f533346371ce1b930df595b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [2.0.0] - 2024-12-26
2
+
3
+ ** Breaking changes**
4
+
5
+ - Remove ServiceType.all and ServiceType.where(zip:)
6
+
7
+ ## [1.7.0] - 2024-12-26
8
+
9
+ - Adds PriceItem.for_price_list_id
10
+ - Adds PriceList.all
11
+ - Adds PriceBlock.for_price_list_id
12
+
1
13
  ## [1.6.0] - 2024-12-24
2
14
 
3
15
  - Adds Zip.find_by(zip:)
@@ -133,33 +133,71 @@ module Vng
133
133
  elsif @body[:method].eql? '4'
134
134
  {}
135
135
  end
136
+ when '/api/v1/resources/priceBlocks/'
137
+ if @body[:pageNo].eql? 1
138
+ { "PriceBlocks" => [
139
+ {"priceBlockID"=>329, "priceListID"=>455, "priceBlock"=>"Affenpinscher", "sequence"=>1, "isActive"=>true},
140
+ {"priceBlockID"=>331, "priceListID"=>455, "priceBlock"=>"Afghan", "sequence"=>2, "isActive"=>false},
141
+ {"priceBlockID"=>332, "priceListID"=>455, "priceBlock"=>"Airedale Terrier", "sequence"=>3, "isActive"=>true},
142
+ {"priceBlockID"=>333, "priceListID"=>455, "priceBlock"=>"Persian", "sequence"=>4, "isActive"=>true},
143
+ ]}
144
+ else
145
+ { }
146
+ end
147
+ when '/api/v1/resources/priceLists/'
148
+ { "PriceLists" => [
149
+ { "priceListID" => 145, "priceList": "Pet Grooming Default", "serviceTypeID" => 14, "isActive" => true },
150
+ { "priceListID" => 146, "priceList": "Pet Grooming Special", "serviceTypeID" => 14, "isActive" => true },
151
+ { "priceListID" => 147, "priceList": "Pet Grooming Old", "serviceTypeID" => 14, "isActive" => false },
152
+ ]}
153
+ when '/api/v1/resources/priceItems/'
154
+ if @body[:pageNo].eql? 1
155
+ { "PriceItems"=>[
156
+ { "priceItemID"=>275111, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>1, "priceItem"=>"Bulldog American - 15 Step SPA Grooming Service", "value"=>85.0, "taxID"=>256, "durationPerUnit"=>45.0, "serviceBadge"=>"Required", "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
157
+ { "priceItemID"=>275112, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>2, "priceItem"=>"Bulldog American - 15 Step SPA Super Grooming Service", "value"=>105.0, "taxID"=>256, "durationPerUnit"=>75.0, "serviceBadge"=>nil, "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
158
+
159
+ { "priceItemID"=>275300, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>3, "priceItem"=>"Bulldog American - Shave Down", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Not Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
160
+ { "priceItemID"=>275301, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>4, "priceItem"=>"Bulldog American - Puppy Cut", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
161
+
162
+ { "priceItemID"=>275302, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>5, "priceItem"=>"De-Shedding Treatment inactive", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>false },
163
+ { "priceItemID"=>275303, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>6, "priceItem"=>"De-Shedding Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
164
+ { "priceItemID"=>275304, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>7, "priceItem"=>"De-Shedding Treatment 60 - 100 lbs", "value"=>30.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
165
+ { "priceItemID"=>275305, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>8, "priceItem"=>"De-shedding Treatment - 101 lbs and over", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
166
+
167
+ { "priceItemID"=>275306, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>9, "priceItem"=>"Hot Aloe SPA Re- Moisturizing Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
168
+ { "priceItemID"=>275307, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>10, "priceItem"=>"Aches & Pains Package", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
169
+ { "priceItemID"=>275308, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>11, "priceItem"=>"Old Add On", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Not Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
170
+ ] }
171
+ else
172
+ { }
173
+ end
136
174
  when '/api/v1/data/priceLists/'
137
- if @body[:assetID].eql? "2201008"
175
+ if @body[:assetID].eql?("2201008")
138
176
  { "PriceItems"=>[
139
- { "priceItemID"=>275111, "priceItem"=>"Bulldog American - 15 Step SPA Grooming Service", "value"=>85.0, "taxID"=>256, "durationPerUnit"=>45.0, "serviceBadge"=>"Required", "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
140
- { "priceItemID"=>275112, "priceItem"=>"Bulldog American - 15 Step SPA Super Grooming Service", "value"=>105.0, "taxID"=>256, "durationPerUnit"=>75.0, "serviceBadge"=>nil, "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
177
+ { "priceItemID"=>275111, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>1, "priceItem"=>"Bulldog American - 15 Step SPA Grooming Service", "value"=>85.0, "taxID"=>256, "durationPerUnit"=>45.0, "serviceBadge"=>"Required", "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
178
+ { "priceItemID"=>275112, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>2, "priceItem"=>"Bulldog American - 15 Step SPA Super Grooming Service", "value"=>105.0, "taxID"=>256, "durationPerUnit"=>75.0, "serviceBadge"=>nil, "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
141
179
 
142
- { "priceItemID"=>275300, "priceItem"=>"Bulldog American - Shave Down", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Not Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
143
- { "priceItemID"=>275301, "priceItem"=>"Bulldog American - Puppy Cut", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
180
+ { "priceItemID"=>275300, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>3, "priceItem"=>"Bulldog American - Shave Down", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Not Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
181
+ { "priceItemID"=>275301, "priceBlockID"=>329, "descriptionHelp"=>"A price item", "sequence"=>4, "priceItem"=>"Bulldog American - Puppy Cut", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
144
182
 
145
- { "priceItemID"=>275302, "priceItem"=>"De-Shedding Treatment inactive", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>false },
146
- { "priceItemID"=>275303, "priceItem"=>"De-Shedding Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
147
- { "priceItemID"=>275304, "priceItem"=>"De-Shedding Treatment 60 - 100 lbs", "value"=>30.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
148
- { "priceItemID"=>275305, "priceItem"=>"De-shedding Treatment - 101 lbs and over", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
183
+ { "priceItemID"=>275302, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>5, "priceItem"=>"De-Shedding Treatment inactive", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>false },
184
+ { "priceItemID"=>275303, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>6, "priceItem"=>"De-Shedding Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
185
+ { "priceItemID"=>275304, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>7, "priceItem"=>"De-Shedding Treatment 60 - 100 lbs", "value"=>30.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
186
+ { "priceItemID"=>275305, "priceBlockID"=>331, "descriptionHelp"=>"A price item", "sequence"=>8, "priceItem"=>"De-shedding Treatment - 101 lbs and over", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>true },
149
187
 
150
- { "priceItemID"=>275306, "priceItem"=>"Hot Aloe SPA Re- Moisturizing Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
151
- { "priceItemID"=>275307, "priceItem"=>"Aches & Pains Package", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
152
- { "priceItemID"=>275308, "priceItem"=>"Old Add On", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Not Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
188
+ { "priceItemID"=>275306, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>9, "priceItem"=>"Hot Aloe SPA Re- Moisturizing Treatment 0-30 lbs", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>20.0, "serviceBadge"=>nil, "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
189
+ { "priceItemID"=>275307, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>10, "priceItem"=>"Aches & Pains Package", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
190
+ { "priceItemID"=>275308, "priceBlockID"=>332, "descriptionHelp"=>"A price item", "sequence"=>11, "priceItem"=>"Old Add On", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Not Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
153
191
  ] }
154
192
  elsif @body[:assetID].eql? "2201009"
155
193
  { "PriceItems"=>[
156
- { "priceItemID"=>276111, "priceItem"=>"Cat Short Hair - 15 Step SPA Grooming Service", "value"=>65.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Recommended", "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
194
+ { "priceItemID"=>276111, "priceBlockID"=>333, "descriptionHelp"=>"A price item", "sequence"=>21, "priceItem"=>"Cat Short Hair - 15 Step SPA Grooming Service", "value"=>65.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Recommended", "serviceCategory"=>"15 Step Spa", "isOnline"=>true, "isActive"=>true },
157
195
 
158
- { "priceItemID"=>276111, "priceItem"=>"Cat Short Hair - Lion Cut", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
159
- { "priceItemID"=>276111, "priceItem"=>"Cat Short Hair - Shave Down", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
196
+ { "priceItemID"=>276111, "priceBlockID"=>333, "descriptionHelp"=>"A price item", "sequence"=>22, "priceItem"=>"Cat Short Hair - Lion Cut", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
197
+ { "priceItemID"=>276111, "priceBlockID"=>333, "descriptionHelp"=>"A price item", "sequence"=>23, "priceItem"=>"Cat Short Hair - Shave Down", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
160
198
 
161
- { "priceItemID"=>276111, "priceItem"=>"De-Matting - Light", "value"=>15.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
162
- { "priceItemID"=>276111, "priceItem"=>"De-Matting - Moderate", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
199
+ { "priceItemID"=>276111, "priceBlockID"=>333, "descriptionHelp"=>"A price item", "sequence"=>24, "priceItem"=>"De-Matting - Light", "value"=>15.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
200
+ { "priceItemID"=>276111, "priceBlockID"=>333, "descriptionHelp"=>"A price item", "sequence"=>25, "priceItem"=>"De-Matting - Moderate", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
163
201
  ] }
164
202
  end
165
203
  when '/api/v1/resources/serviceTypes/'
@@ -0,0 +1,33 @@
1
+ require 'vng/resource'
2
+ require 'vng/price_list'
3
+
4
+ module Vng
5
+ # Provides methods to interact with Vonigo price blocks.
6
+ class PriceBlock < Resource
7
+ PATH = '/api/v1/resources/priceBlocks/'
8
+
9
+ attr_reader :id, :name, :index
10
+
11
+ def initialize(id:, name:, index:)
12
+ @id = id
13
+ @name = name
14
+ @index = index
15
+ end
16
+
17
+ def self.for_price_list_id(price_list_id)
18
+ body = { priceListID: price_list_id }
19
+
20
+ data = request path: PATH, body: body, returning: 'PriceBlocks'
21
+
22
+ data.filter_map do |body|
23
+ next unless body['isActive']
24
+
25
+ id = body['priceBlockID']
26
+ name = body['priceBlock']
27
+ index = body['sequence']
28
+
29
+ new id: id, name: name, index: index
30
+ end
31
+ end
32
+ end
33
+ end
@@ -5,16 +5,45 @@ module Vng
5
5
  class PriceItem < Resource
6
6
  PATH = '/api/v1/data/priceLists/'
7
7
 
8
- attr_reader :id, :price_item, :value, :tax_id, :duration_per_unit, :service_badge, :service_category
8
+ attr_reader :id, :price_item, :index, :description, :value, :tax_id, :duration_per_unit, :service_badge, :service_category, :price_block_id
9
9
 
10
- def initialize(id:, price_item:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:)
10
+ def initialize(id:, price_item:, index:, description:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:, price_block_id:)
11
11
  @id = id
12
12
  @price_item = price_item
13
+ @index = index
14
+ @description = description
13
15
  @value = value
14
16
  @tax_id = tax_id
15
17
  @duration_per_unit = duration_per_unit
16
18
  @service_badge = service_badge
17
19
  @service_category = service_category
20
+ @price_block_id = price_block_id
21
+ end
22
+
23
+ def self.for_price_list_id(price_list_id)
24
+ body = {
25
+ method: '1',
26
+ priceListID: price_list_id,
27
+ }
28
+
29
+ data = request path: '/api/v1/resources/priceItems/', body: body, returning: 'PriceItems'
30
+
31
+ data.filter_map do |body|
32
+ next unless body['isOnline'] && body['isActive']
33
+
34
+ id = body['priceItemID']
35
+ price_item = body['priceItem']
36
+ index = body['sequence']
37
+ description = body['descriptionHelp']
38
+ value = body['value']
39
+ tax_id = body['taxID']
40
+ duration_per_unit = body['durationPerUnit']
41
+ service_badge = body['serviceBadge']
42
+ service_category = body['serviceCategory']
43
+ price_block_id = body['priceBlockID']
44
+
45
+ new id: id, price_item: price_item, index: index, description: description, value: value, tax_id: tax_id, duration_per_unit: duration_per_unit, service_badge: service_badge, service_category: service_category, price_block_id: price_block_id
46
+ end
18
47
  end
19
48
 
20
49
  def self.where(location_id:, asset_id:)
@@ -32,13 +61,16 @@ module Vng
32
61
  end.map do |body|
33
62
  id = body['priceItemID']
34
63
  price_item = body['priceItem']
64
+ index = body['sequence']
65
+ description = body['descriptionHelp']
35
66
  value = body['value']
36
67
  tax_id = body['taxID']
37
68
  duration_per_unit = body['durationPerUnit']
38
69
  service_badge = body['serviceBadge']
39
70
  service_category = body['serviceCategory']
71
+ price_block_id = body['priceBlockID']
40
72
 
41
- new id: id, price_item: price_item, value: value, tax_id: tax_id, duration_per_unit: duration_per_unit, service_badge: service_badge, service_category: service_category
73
+ new id: id, price_item: price_item, index: index, description: description, value: value, tax_id: tax_id, duration_per_unit: duration_per_unit, service_badge: service_badge, service_category: service_category, price_block_id: price_block_id
42
74
  end
43
75
  end
44
76
  end
@@ -0,0 +1,29 @@
1
+ require 'vng/resource'
2
+
3
+ module Vng
4
+ # Provides methods to interact with Vonigo price lists.
5
+ class PriceList < Resource
6
+ PATH = '/api/v1/resources/priceLists/'
7
+
8
+ attr_reader :id, :name
9
+
10
+ def initialize(id:, name:)
11
+ @id = id
12
+ @name = name
13
+ end
14
+
15
+ def self.all
16
+ data = request path: PATH
17
+
18
+ data['PriceLists'].filter_map do |price_list|
19
+ next unless price_list['isActive']
20
+ next unless price_list['serviceTypeID'].eql?(14)
21
+
22
+ id = price_list['priceListID']
23
+ name = price_list['priceList']
24
+
25
+ new id: id, name: name
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/vng/resource.rb CHANGED
@@ -5,11 +5,26 @@ module Vng
5
5
  class Resource
6
6
  private
7
7
 
8
- def self.request(path:, body: {}, query: {}, include_security_token: true)
8
+ def self.request(path:, body: {}, query: {}, include_security_token: true, returning: nil)
9
9
  if query.none? && include_security_token
10
10
  body = body.merge securityToken: Vng.configuration.security_token
11
11
  end
12
12
 
13
+ if returning
14
+ [].tap do |response|
15
+ 1.step do |page_number|
16
+ body = body.merge pageSize: 500, pageNo: page_number
17
+ batch = response_for(path:, body:, query:).fetch(returning, [])
18
+ break if batch.empty? || page_number > 20
19
+ response.concat batch
20
+ end
21
+ end
22
+ else
23
+ response_for path:, body:, query:
24
+ end
25
+ end
26
+
27
+ def self.response_for(path:, body: {}, query: {})
13
28
  instrument do |data|
14
29
  Request.new(host: host, path: path, query: query, body: body).run
15
30
  end
@@ -5,42 +5,13 @@ module Vng
5
5
  class ServiceType < Resource
6
6
  PATH = '/api/v1/resources/serviceTypes/'
7
7
 
8
- attr_reader :id, :type, :duration
8
+ attr_reader :id, :type, :duration, :price_list_id
9
9
 
10
- def initialize(id:, type:, duration:)
10
+ def initialize(id:, type:, duration:, price_list_id:)
11
11
  @id = id
12
12
  @type = type
13
13
  @duration = duration
14
- end
15
-
16
- def self.all
17
- data = request path: PATH
18
-
19
- data['ServiceTypes'].map do |body|
20
- id = body['serviceTypeID']
21
- type = body['serviceType']
22
- duration = body['duration']
23
-
24
- new id: id, type: type, duration: duration
25
- end
26
- end
27
-
28
- def self.where(zip:)
29
- body = {
30
- zip: zip,
31
- }
32
-
33
- data = request path: PATH, body: body
34
-
35
- data.fetch('ServiceTypes', []).filter do |body|
36
- body['isActive']
37
- end.map do |body|
38
- id = body['serviceTypeID']
39
- type = body['serviceType']
40
- duration = body['duration']
41
-
42
- new id: id, type: type, duration: duration
43
- end
14
+ @price_list_id = price_list_id
44
15
  end
45
16
  end
46
17
  end
data/lib/vng/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vng
2
- VERSION = '1.6.0'
2
+ VERSION = '2.0.0'
3
3
  end
data/lib/vng/zip.rb CHANGED
@@ -20,6 +20,7 @@ module Vng
20
20
  data = request path: PATH
21
21
 
22
22
  data['Zips'].reject do |franchise|
23
+ # TODO: add "Owned - Not In Service"
23
24
  franchise['zipStatus'].eql? 'Owned – Deactivated'
24
25
  end.map do |body|
25
26
  zip = body['zip']
@@ -39,12 +40,15 @@ module Vng
39
40
  data = request path: PATH, body: body
40
41
  zip_data = data['Zip']
41
42
 
43
+ # TODO: Remove ServiceType class, store duration and price_list_id
44
+ # inside Zip itself
42
45
  unless zip_data['zipCodeID'] == '0'
43
46
  service_types = data['ServiceTypes'].map do |body|
44
47
  id = body['serviceTypeID']
45
48
  type = body['serviceType']
46
49
  duration = body['duration']
47
- ServiceType.new id: id, type: type, duration: duration
50
+ price_list_id = body['priceID']
51
+ ServiceType.new id: id, type: type, duration: duration, price_list_id: price_list_id
48
52
  end
49
53
 
50
54
  new zip: zip_data['zipCode'], state: zip_data['provinceAbbr'], zone_name: zip_data['zoneName'], city: zip_data['defaultCity'], service_types: service_types
data/lib/vng.rb CHANGED
@@ -14,6 +14,7 @@ require_relative 'vng/franchise'
14
14
  require_relative 'vng/lead'
15
15
  require_relative 'vng/location'
16
16
  require_relative 'vng/lock'
17
+ require_relative 'vng/price_block'
17
18
  require_relative 'vng/price_item'
18
19
  require_relative 'vng/route'
19
20
  require_relative 'vng/security_token'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vng
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-25 00:00:00.000000000 Z
11
+ date: 2024-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -81,7 +81,9 @@ files:
81
81
  - lib/vng/location.rb
82
82
  - lib/vng/lock.rb
83
83
  - lib/vng/mock_request.rb
84
+ - lib/vng/price_block.rb
84
85
  - lib/vng/price_item.rb
86
+ - lib/vng/price_list.rb
85
87
  - lib/vng/resource.rb
86
88
  - lib/vng/route.rb
87
89
  - lib/vng/security_token.rb