vng 1.5.0 → 1.7.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 +10 -0
- data/lib/vng/mock_request.rb +64 -19
- data/lib/vng/price_block.rb +33 -0
- data/lib/vng/price_item.rb +35 -3
- data/lib/vng/price_list.rb +29 -0
- data/lib/vng/resource.rb +16 -1
- data/lib/vng/version.rb +1 -1
- data/lib/vng/zip.rb +26 -2
- data/lib/vng.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec68041442659731246003b523c47c70f41ac3127190c3f966a0c774274f9a2e
|
4
|
+
data.tar.gz: b34853bfd235358cb485ff8fbe84a090dd4104e01f6f01065d6269b20f7f9fbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c9cb81c4ec152b7e98800ee01ba68b05617e5b5f85d6dee04607e9c3347faa402f0d3e8109d9579e3683bd7e8d234c5c209ef3e67e8e7d6dd8277e08930dd7
|
7
|
+
data.tar.gz: 91abf7c0f28cd38e7cd9151797eb3312ea6046db8c07af63ba53861b00cf6603f0b2e17c5a585bba9b75623fe2a58aa17c89df739437ee8de027893a25836d32
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## [1.7.0] - 2024-12-26
|
2
|
+
|
3
|
+
- Adds PriceItem.for_price_list_id
|
4
|
+
- Adds PriceList.all
|
5
|
+
- Adds PriceBlock.for_price_list_id
|
6
|
+
|
7
|
+
## [1.6.0] - 2024-12-24
|
8
|
+
|
9
|
+
- Adds Zip.find_by(zip:)
|
10
|
+
|
1
11
|
## [1.5.0] - 2024-12-20
|
2
12
|
|
3
13
|
- Allow Case to be created without client_id
|
data/lib/vng/mock_request.rb
CHANGED
@@ -48,7 +48,14 @@ module Vng
|
|
48
48
|
{}
|
49
49
|
end
|
50
50
|
when '/api/v1/resources/zips/'
|
51
|
-
|
51
|
+
if @body[:method] == '1'
|
52
|
+
# TODO: The response already includes the ServiceTypes so there
|
53
|
+
# is no need to ask for those in a separate API request:
|
54
|
+
{ "Zip"=>{"zipCodeID"=>"1", "zipCode"=>"21765", "zoneName"=>"Brentwood", "defaultCity"=>"Los Angeles", "provinceAbbr"=>"CA", "franchiseID"=>"105"},
|
55
|
+
"ServiceTypes"=>[{"serviceTypeID"=>14, "serviceType"=>"Pet Grooming", "duration" => 45}]}
|
56
|
+
else
|
57
|
+
{ "Zips"=>[{ "zip"=>"21765", "zoneName"=>"Brentwood", "state"=>"MD" }] }
|
58
|
+
end
|
52
59
|
when '/api/v1/resources/franchises/'
|
53
60
|
if @body.key?(:objectID)
|
54
61
|
{ "Franchise"=>{ "objectID"=>"2201007" }, "Fields"=>[
|
@@ -126,33 +133,71 @@ module Vng
|
|
126
133
|
elsif @body[:method].eql? '4'
|
127
134
|
{}
|
128
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
|
129
174
|
when '/api/v1/data/priceLists/'
|
130
|
-
if @body[:assetID].eql?
|
175
|
+
if @body[:assetID].eql?("2201008")
|
131
176
|
{ "PriceItems"=>[
|
132
|
-
{ "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 },
|
133
|
-
{ "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 },
|
134
179
|
|
135
|
-
{ "priceItemID"=>275300, "priceItem"=>"Bulldog American - Shave Down", "value"=>40.0, "taxID"=>256, "durationPerUnit"=>30.0, "serviceBadge"=>"Not Recommended", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
|
136
|
-
{ "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 },
|
137
182
|
|
138
|
-
{ "priceItemID"=>275302, "priceItem"=>"De-Shedding Treatment inactive", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>nil, "serviceCategory"=>"De-Shed", "isOnline"=>true, "isActive"=>false },
|
139
|
-
{ "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 },
|
140
|
-
{ "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 },
|
141
|
-
{ "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 },
|
142
187
|
|
143
|
-
{ "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 },
|
144
|
-
{ "priceItemID"=>275307, "priceItem"=>"Aches & Pains Package", "value"=>0.0, "taxID"=>256, "durationPerUnit"=>60.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
|
145
|
-
{ "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 },
|
146
191
|
] }
|
147
|
-
elsif @body[:assetID].eql? 2201009
|
192
|
+
elsif @body[:assetID].eql? "2201009"
|
148
193
|
{ "PriceItems"=>[
|
149
|
-
{ "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 },
|
150
195
|
|
151
|
-
{ "priceItemID"=>276111, "priceItem"=>"Cat Short Hair - Lion Cut", "value"=>20.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Cut", "isOnline"=>true, "isActive"=>true },
|
152
|
-
{ "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 },
|
153
198
|
|
154
|
-
{ "priceItemID"=>276111, "priceItem"=>"De-Matting - Light", "value"=>15.0, "taxID"=>256, "durationPerUnit"=>15.0, "serviceBadge"=>"Offered", "serviceCategory"=>"Add Ons", "isOnline"=>true, "isActive"=>true },
|
155
|
-
{ "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 },
|
156
201
|
] }
|
157
202
|
end
|
158
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
|
data/lib/vng/price_item.rb
CHANGED
@@ -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
|
data/lib/vng/version.rb
CHANGED
data/lib/vng/zip.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'vng/resource'
|
2
|
+
require 'vng/service_type'
|
2
3
|
|
3
4
|
module Vng
|
4
5
|
# Provides methods to interact with Vonigo ZIP codes.
|
5
6
|
class Zip < Resource
|
6
7
|
PATH = '/api/v1/resources/zips/'
|
7
8
|
|
8
|
-
attr_reader :zip, :state, :zone_name
|
9
|
+
attr_reader :zip, :state, :zone_name, :city, :service_types
|
9
10
|
|
10
|
-
def initialize(zip:, state:, zone_name:)
|
11
|
+
def initialize(zip:, state:, zone_name:, city: nil, service_types: [])
|
11
12
|
@zip = zip
|
12
13
|
@state = state
|
13
14
|
@zone_name = zone_name
|
15
|
+
@city = city
|
16
|
+
@service_types = service_types
|
14
17
|
end
|
15
18
|
|
16
19
|
def self.all
|
@@ -26,5 +29,26 @@ module Vng
|
|
26
29
|
new zip: zip, state: state, zone_name: zone_name
|
27
30
|
end
|
28
31
|
end
|
32
|
+
|
33
|
+
def self.find_by(zip:)
|
34
|
+
body = {
|
35
|
+
method: '1',
|
36
|
+
zip: zip,
|
37
|
+
}
|
38
|
+
|
39
|
+
data = request path: PATH, body: body
|
40
|
+
zip_data = data['Zip']
|
41
|
+
|
42
|
+
unless zip_data['zipCodeID'] == '0'
|
43
|
+
service_types = data['ServiceTypes'].map do |body|
|
44
|
+
id = body['serviceTypeID']
|
45
|
+
type = body['serviceType']
|
46
|
+
duration = body['duration']
|
47
|
+
ServiceType.new id: id, type: type, duration: duration
|
48
|
+
end
|
49
|
+
|
50
|
+
new zip: zip_data['zipCode'], state: zip_data['provinceAbbr'], zone_name: zip_data['zoneName'], city: zip_data['defaultCity'], service_types: service_types
|
51
|
+
end
|
52
|
+
end
|
29
53
|
end
|
30
54
|
end
|
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.
|
4
|
+
version: 1.7.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-
|
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
|