adf_builder 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -4
- data/Gemfile.lock +1 -1
- data/README.md +126 -11
- data/lib/adf_builder.rb +57 -16
- data/lib/adf_builder/{base.rb → base/base.rb} +0 -2
- data/lib/adf_builder/base/prospect.rb +10 -0
- data/lib/adf_builder/customer/customer.rb +27 -0
- data/lib/adf_builder/shared/contact.rb +50 -0
- data/lib/adf_builder/{id.rb → shared/id.rb} +0 -0
- data/lib/adf_builder/vehicles/colorcombinations.rb +31 -0
- data/lib/adf_builder/vehicles/vehicles.rb +71 -41
- data/lib/adf_builder/vendor/vendor.rb +34 -0
- data/lib/adf_builder/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b6904f4a4346718e3a08189a1da210b0c6a8305679d49f00d552854abb36db2
|
4
|
+
data.tar.gz: becdc5415db73468da3508f93f9d8d6a7a094a80e19f2b5bcf872e248d3520df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0798101309032835894eb10965dfbcbcc97b7481f1e1aefda8f617b4a1219c469eb505df14c7344c2be80c0ce39d2bf347aa33f63106d893fcd1010d52775d0f'
|
7
|
+
data.tar.gz: 15d466aa189bf14ba7a7b79fa807a596f9d6d789ab06c68e40692d4b9e81336195b9581c1243fea22f12fa87b5059d7d453282de1c2455d89811d6f48f11bbae
|
data/CHANGELOG.md
CHANGED
@@ -8,14 +8,31 @@
|
|
8
8
|
- price
|
9
9
|
- option
|
10
10
|
- finance
|
11
|
-
|
11
|
+
- Expand Structures for all parameters
|
12
|
+
- Customer
|
13
|
+
- Vehicle
|
14
|
+
- Contact
|
15
|
+
|
12
16
|
### In many moons
|
13
|
-
- Add Vendor structure
|
14
|
-
- Add Customer structure
|
15
17
|
- Add Provider structure
|
16
|
-
- Add Contact structure
|
17
18
|
- Add Price structure
|
18
19
|
|
20
|
+
## [0.0.7] - 2021-08-08
|
21
|
+
- Much refactoring so that we can reuse functions
|
22
|
+
- Added more functionality to the Vehicle structure including all free text, all same level tags with params, and Color Combination and ImageTag
|
23
|
+
|
24
|
+
|
25
|
+
## [0.0.6] - 2021-08-08
|
26
|
+
- minimal_lead function will remove all previous adf nodes
|
27
|
+
- Created ability to reset doc
|
28
|
+
|
29
|
+
## [0.0.5] - 2021-08-08
|
30
|
+
- Fixed bug that kept us from using the library
|
31
|
+
|
32
|
+
## [0.0.4] - 2021-08-08
|
33
|
+
- Added Customer, Contact, Vendor basic structure
|
34
|
+
|
35
|
+
|
19
36
|
## [0.0.3] - 2021-08-04
|
20
37
|
- Added ability to add simple vehicle structures
|
21
38
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# AdfBuilder
|
2
|
-
Hopefully this will help with development in the ADF format. The goal is to intuitively create
|
2
|
+
Hopefully this will help with development in the ADF format. The goal is to intuitively create and update an ADF XML file that can easily be added to an email or saved to a file.
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
|
@@ -49,7 +49,7 @@ Outputs
|
|
49
49
|
Update Requestdate value
|
50
50
|
```ruby
|
51
51
|
builder = AdfBuilder::Builder.new
|
52
|
-
builder.
|
52
|
+
builder.prospect.request_date.update_val(Date.new(2021,12,12))
|
53
53
|
```
|
54
54
|
Outputs
|
55
55
|
|
@@ -68,7 +68,7 @@ Outputs
|
|
68
68
|
Add ID tag to Prospect
|
69
69
|
```ruby
|
70
70
|
builder = AdfBuilder::Builder.new
|
71
|
-
builder.
|
71
|
+
builder.prospect.add_id('howdy', 'Ag')
|
72
72
|
```
|
73
73
|
|
74
74
|
Outputs
|
@@ -88,7 +88,7 @@ Add Vehicle
|
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
builder = AdfBuilder::Builder.new
|
91
|
-
builder.
|
91
|
+
builder.prospect.vehicles.add(2021, 'Ford', 'Raptor')
|
92
92
|
```
|
93
93
|
|
94
94
|
Outputs
|
@@ -108,15 +108,28 @@ Outputs
|
|
108
108
|
</prospect>
|
109
109
|
</adf>
|
110
110
|
```
|
111
|
-
|
111
|
+
|
112
|
+
Vehicle with different operations
|
112
113
|
|
113
114
|
```ruby
|
114
115
|
builder = AdfBuilder::Builder.new
|
115
|
-
builder.
|
116
|
-
interest: :sell,
|
116
|
+
builder.prospect.vehicles.add(2021, 'Toyota', 'Prius', {
|
117
117
|
status: :used,
|
118
|
-
vin: 'XXXXXXXXXX',
|
119
118
|
})
|
119
|
+
builder.prospect.vehicles.update_tags_with_free_text(0, {
|
120
|
+
bodystyle: 'howdy',
|
121
|
+
year: '2000'
|
122
|
+
})
|
123
|
+
builder.prospect.vehicles.update_odometer(0, 9000, {
|
124
|
+
units: 'km'
|
125
|
+
})
|
126
|
+
builder.prospect.vehicles.update_condition(0, 'ffff')
|
127
|
+
builder.prospect.vehicles.update_imagetag(0, 'http://adfxml.info/adf_spec.pdf', {
|
128
|
+
width: 400,
|
129
|
+
height: 500,
|
130
|
+
alttext: 'Howdy'
|
131
|
+
})
|
132
|
+
puts builder.to_xml
|
120
133
|
```
|
121
134
|
|
122
135
|
Outputs
|
@@ -127,18 +140,120 @@ Outputs
|
|
127
140
|
<?xml version="1.0"?>
|
128
141
|
<adf>
|
129
142
|
<prospect status="new">
|
130
|
-
<requestdate>2021-08-
|
131
|
-
<
|
143
|
+
<requestdate>2021-08-09T00:53:59+04:00</requestdate>
|
144
|
+
<customer/>
|
145
|
+
<vendor/>
|
146
|
+
<vehicle status="used">
|
147
|
+
<year>2000</year>
|
148
|
+
<make>Toyota</make>
|
149
|
+
<model>Prius</model>
|
150
|
+
<bodystyle>howdy</bodystyle>
|
151
|
+
<odometer units="km">9000</odometer>
|
152
|
+
<imagetag width="400" height="500" alttext="Howdy">http://adfxml.info/adf_spec.pdf</imagetag>
|
153
|
+
</vehicle>
|
154
|
+
</prospect>
|
155
|
+
</adf>
|
156
|
+
```
|
157
|
+
|
158
|
+
Color Combination
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
builder = AdfBuilder::Builder.new
|
162
|
+
builder.prospect.vehicles.add(2021, 'Toyota', 'Prius', {
|
163
|
+
status: :used,
|
164
|
+
})
|
165
|
+
builder.prospect.vehicles.add_color_combination(0, 'black', 'yellow', 1)
|
166
|
+
puts builder.to_xml
|
167
|
+
```
|
168
|
+
|
169
|
+
Outputs
|
170
|
+
|
171
|
+
```xml
|
172
|
+
<?ADF version="1.0"?>
|
173
|
+
|
174
|
+
<?xml version="1.0"?>
|
175
|
+
<adf>
|
176
|
+
<prospect status="new">
|
177
|
+
<requestdate>2021-08-09T00:56:07+04:00</requestdate>
|
178
|
+
<customer/>
|
179
|
+
<vendor/>
|
180
|
+
<vehicle status="used">
|
132
181
|
<year>2021</year>
|
133
182
|
<make>Toyota</make>
|
134
183
|
<model>Prius</model>
|
135
|
-
<
|
184
|
+
<colorcombination>
|
185
|
+
<interiorcolor>black</interiorcolor>
|
186
|
+
<exteriorcolor>yellow</exteriorcolor>
|
187
|
+
<preference>1</preference>
|
188
|
+
</colorcombination>
|
136
189
|
</vehicle>
|
137
190
|
</prospect>
|
138
191
|
</adf>
|
192
|
+
```
|
193
|
+
|
194
|
+
Add Vendor
|
139
195
|
|
196
|
+
```ruby
|
197
|
+
builder = AdfBuilder::Builder.new
|
198
|
+
builder.prospect.vendor.add('Dealer One', 'Manager Name', {
|
199
|
+
part: 'full',
|
200
|
+
type: 'individual'
|
201
|
+
}) # options for customer object that is required in vendor
|
140
202
|
```
|
141
203
|
|
204
|
+
Outputs
|
205
|
+
|
206
|
+
```xml
|
207
|
+
<?ADF version="1.0"?>
|
208
|
+
|
209
|
+
<?xml version="1.0"?>
|
210
|
+
<adf>
|
211
|
+
<prospect status="new">
|
212
|
+
<requestdate>2021-08-08T18:43:02+04:00</requestdate>
|
213
|
+
<customer/>
|
214
|
+
<vendor>
|
215
|
+
<vendorname>Dealer One</vendorname>
|
216
|
+
<contact>
|
217
|
+
<name part="full" type="individual">Manager Name</name>
|
218
|
+
</contact>
|
219
|
+
</vendor>
|
220
|
+
</prospect>
|
221
|
+
</adf>
|
222
|
+
```
|
223
|
+
|
224
|
+
Add Contact with phone
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
builder = AdfBuilder::Builder.new
|
228
|
+
builder.prospect.customer.add('New Guy', {
|
229
|
+
part: 'full',
|
230
|
+
type: 'individual'
|
231
|
+
})
|
232
|
+
builder.prospect.customer.contact.add_phone('(555)-444-3333')
|
233
|
+
```
|
234
|
+
|
235
|
+
Outputs
|
236
|
+
|
237
|
+
```xml
|
238
|
+
<?ADF version="1.0"?>
|
239
|
+
|
240
|
+
<?xml version="1.0"?>
|
241
|
+
<adf>
|
242
|
+
<prospect status="new">
|
243
|
+
<requestdate>2021-08-08T18:44:45+04:00</requestdate>
|
244
|
+
<customer>
|
245
|
+
<contact>
|
246
|
+
<name part="full" type="individual">New Guy</name>
|
247
|
+
<phone>(555)-444-3333</phone>
|
248
|
+
</contact>
|
249
|
+
</customer>
|
250
|
+
<vendor/>
|
251
|
+
</prospect>
|
252
|
+
</adf>
|
253
|
+
```
|
254
|
+
|
255
|
+
Different Vehicle operations
|
256
|
+
|
142
257
|
## Development
|
143
258
|
|
144
259
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/adf_builder.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ox'
|
3
4
|
require_relative "adf_builder/version"
|
4
|
-
|
5
|
-
|
5
|
+
|
6
|
+
# CUSTOMER
|
7
|
+
require_relative 'adf_builder/customer/customer'
|
6
8
|
|
7
9
|
# BASE
|
10
|
+
require_relative 'adf_builder/base/base'
|
8
11
|
require_relative 'adf_builder/base/prospect'
|
9
12
|
require_relative 'adf_builder/base/request_date'
|
10
13
|
|
14
|
+
# SHARED
|
15
|
+
require_relative 'adf_builder/shared/id'
|
16
|
+
require_relative 'adf_builder/shared/contact'
|
17
|
+
|
11
18
|
# VEHICLES
|
12
19
|
require_relative 'adf_builder/vehicles/vehicles'
|
20
|
+
require_relative 'adf_builder/vehicles/colorcombinations'
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
require 'ox'
|
22
|
+
# VENDOR
|
23
|
+
require_relative 'adf_builder/vendor/vendor'
|
17
24
|
|
18
25
|
module AdfBuilder
|
19
26
|
class Error < StandardError; end
|
@@ -23,8 +30,8 @@ module AdfBuilder
|
|
23
30
|
@base = Base.new(@doc)
|
24
31
|
end
|
25
32
|
|
26
|
-
def
|
27
|
-
@base
|
33
|
+
def prospect
|
34
|
+
@base.prospect
|
28
35
|
end
|
29
36
|
|
30
37
|
# output the XML
|
@@ -34,8 +41,6 @@ module AdfBuilder
|
|
34
41
|
|
35
42
|
# def an example of minimal XML taken from ADF spec file http://adfxml.info/adf_spec.pdf
|
36
43
|
def minimal_lead
|
37
|
-
adf = Ox::Element.new("adf")
|
38
|
-
|
39
44
|
prospect = Ox::Element.new("prospect")
|
40
45
|
|
41
46
|
request_date = Ox::Element.new("requestdate")
|
@@ -78,16 +83,15 @@ module AdfBuilder
|
|
78
83
|
vendor << contact
|
79
84
|
|
80
85
|
prospect << request_date << vehicle << customer << vendor
|
81
|
-
adf
|
82
|
-
@doc <<
|
86
|
+
@doc.remove_children_by_path("adf/prospect")
|
87
|
+
@doc.adf << prospect
|
83
88
|
Ox.dump(@doc, {})
|
84
89
|
end
|
85
90
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
# go back to the initial structure
|
92
|
+
def reset_doc
|
93
|
+
@doc.adf.prospect.remove_children_by_path("*")
|
94
|
+
end
|
91
95
|
|
92
96
|
# all the files will start with this same header
|
93
97
|
def init_doc
|
@@ -103,5 +107,42 @@ module AdfBuilder
|
|
103
107
|
doc << adf
|
104
108
|
doc
|
105
109
|
end
|
110
|
+
|
111
|
+
# we will either create a new node with the value or replace the one if it is available
|
112
|
+
def self.update_node(parent_node, key, value, params={})
|
113
|
+
key = key.to_s
|
114
|
+
value = value.to_s
|
115
|
+
if parent_node.locate(key).size > 0
|
116
|
+
node = parent_node.locate(key).first
|
117
|
+
node.replace_text(value)
|
118
|
+
else
|
119
|
+
node = (Ox::Element.new(key) << value)
|
120
|
+
parent_node << node
|
121
|
+
end
|
122
|
+
|
123
|
+
AdfBuilder::Builder.update_params(node, key, params)
|
124
|
+
end
|
125
|
+
|
126
|
+
# update the params by first checking if they are valid params and then checking if the values are valid if necessary
|
127
|
+
def self.update_params(node, key, params)
|
128
|
+
return true if params.empty?
|
129
|
+
key = key.to_sym
|
130
|
+
valid_values = params[:valid_values]
|
131
|
+
valid_parameters = params[:valid_parameters]
|
132
|
+
_params = AdfBuilder::Builder.whitelabel_params(params,valid_parameters, key)
|
133
|
+
_params.each do |k,v|
|
134
|
+
node[k] = v if valid_values[key][k] == true or valid_values[key][k].include? v.to_s
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# clear out the opts that don't match valid keys
|
139
|
+
def self.whitelabel_params(opts, valid_parameters, key)
|
140
|
+
opts.slice(*valid_parameters[key])
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.valid_child?(parent, tag_name, index)
|
144
|
+
child = parent.locate(tag_name)[index]
|
145
|
+
return !child.nil?,child
|
146
|
+
end
|
106
147
|
end
|
107
148
|
end
|
@@ -14,6 +14,8 @@ module AdfBuilder
|
|
14
14
|
|
15
15
|
@request_date = RequestDate.new(@prospect)
|
16
16
|
@vehicles = Vehicles.new(@prospect)
|
17
|
+
@customer = Customer.new(@prospect)
|
18
|
+
@vendor = Vendor.new(@prospect)
|
17
19
|
end
|
18
20
|
|
19
21
|
def request_date
|
@@ -24,6 +26,14 @@ module AdfBuilder
|
|
24
26
|
@vehicles
|
25
27
|
end
|
26
28
|
|
29
|
+
def customer
|
30
|
+
@customer
|
31
|
+
end
|
32
|
+
|
33
|
+
def vendor
|
34
|
+
@vendor
|
35
|
+
end
|
36
|
+
|
27
37
|
# set status to renew
|
28
38
|
def set_renew
|
29
39
|
@prospect[:status] = STATUSES[:resend]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class Customer
|
3
|
+
def initialize(prospect)
|
4
|
+
@customer = Ox::Element.new('customer')
|
5
|
+
@contact = nil
|
6
|
+
|
7
|
+
prospect << @customer
|
8
|
+
end
|
9
|
+
|
10
|
+
def contact
|
11
|
+
@contact
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(name, opts={})
|
15
|
+
@contact = Contact.new(@customer, name, opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_id(index, value, source=nil, sequence=1)
|
19
|
+
if @prospect.locate("customer").empty?
|
20
|
+
false
|
21
|
+
else
|
22
|
+
Id.new.add(@prospect.customer(index), value, source, sequence)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class Contact
|
3
|
+
VALID_PARAMETERS = {
|
4
|
+
name: [:part, :type, :primarycontact],
|
5
|
+
email: [:preferredcontact],
|
6
|
+
phone: [:type, :time, :preferredcontact]
|
7
|
+
}
|
8
|
+
|
9
|
+
PHONE_TYPES = [:phone, :fax, :cellphone, :pager]
|
10
|
+
|
11
|
+
def initialize(parent_node, name, opts={})
|
12
|
+
@contact = Ox::Element.new('contact') << (Ox::Element.new('name') << name)
|
13
|
+
parent_node << @contact
|
14
|
+
|
15
|
+
opts = whitelabel_opts(opts, :name)
|
16
|
+
|
17
|
+
if opts[:primary_contact]
|
18
|
+
@contact[:primarycontact] = opts[:primary_contact].to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.each do |k,v|
|
22
|
+
@contact.locate("name")[0][k] = v.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_email(email, opts={})
|
28
|
+
@contact << (Ox::Element.new('email') << email)
|
29
|
+
opts = whitelabel_opts(opts, :phone)
|
30
|
+
|
31
|
+
opts.each do |k,v|
|
32
|
+
@contact.email[k] = v.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_phone(phone, opts={})
|
37
|
+
@contact << (Ox::Element.new('phone') << phone)
|
38
|
+
opts = whitelabel_opts(opts, :phone)
|
39
|
+
|
40
|
+
opts.each do |k,v|
|
41
|
+
@contact.phone[k] = v.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# clear out the opts that don't match valid keys
|
46
|
+
def whitelabel_opts(opts, key)
|
47
|
+
opts.slice(*VALID_PARAMETERS[key])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class ColorCombinations
|
3
|
+
|
4
|
+
FREE_TEXT_OPTIONAL_TAGS = [:interiorcolor, :exteriorcolor, :preference]
|
5
|
+
|
6
|
+
def initialize(vehicle)
|
7
|
+
@vehicle = vehicle
|
8
|
+
@color_combination = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(interior_color, exterior_color, preference)
|
12
|
+
@color_combination = Ox::Element.new('colorcombination')
|
13
|
+
@color_combination <<
|
14
|
+
(Ox::Element.new('interiorcolor') << interior_color) <<
|
15
|
+
(Ox::Element.new('exteriorcolor') << exterior_color) <<
|
16
|
+
(Ox::Element.new('preference') << preference.to_s)
|
17
|
+
@vehicle << @color_combination
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_tags(index, tags)
|
21
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@vehicle,'colorcombination', index)
|
22
|
+
if valid
|
23
|
+
tags.each do |key, value|
|
24
|
+
if FREE_TEXT_OPTIONAL_TAGS.include? key.to_sym
|
25
|
+
AdfBuilder::Builder.update_node(vehicle, key, value)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,64 +1,95 @@
|
|
1
1
|
module AdfBuilder
|
2
2
|
class Vehicles
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
trade_in: 'trade-in',
|
8
|
-
test_drive: 'test-drive'
|
3
|
+
VALID_PARAMETERS = {
|
4
|
+
vehicle: [:interest, :status],
|
5
|
+
odometer: [:status, :units],
|
6
|
+
imagetag: [:width, :height, :alttext],
|
9
7
|
}
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
VALID_VALUES = {
|
10
|
+
vehicle: {
|
11
|
+
interest: %w[buy lease sell trade-in test-drive],
|
12
|
+
status: %w[new used]
|
13
|
+
},
|
14
|
+
odometer: {
|
15
|
+
status: %w[unknown rolledover replaced original],
|
16
|
+
units: %w[km mi]
|
17
|
+
},
|
18
|
+
imagetag: {
|
19
|
+
width: true,
|
20
|
+
height: true,
|
21
|
+
alttext: true
|
22
|
+
}
|
14
23
|
}
|
15
24
|
|
16
|
-
FREE_TEXT_OPTIONAL_TAGS =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
doors: :doors,
|
21
|
-
bodystyle: :bodystyle,
|
22
|
-
transmission: :transmission,
|
23
|
-
pricecomments: :pricecomments,
|
24
|
-
comments: :comments
|
25
|
-
}
|
25
|
+
FREE_TEXT_OPTIONAL_TAGS = [:year, :make, :model, :vin, :stock,
|
26
|
+
:trim, :doors, :bodystyle, :transmission, :pricecomments, :comments]
|
27
|
+
|
28
|
+
CONDITIONS = %w[excellent good fair poor unknown]
|
26
29
|
|
27
30
|
def initialize(prospect)
|
28
31
|
@prospect = prospect
|
32
|
+
@color_combinations = []
|
29
33
|
end
|
30
34
|
|
31
|
-
def
|
32
|
-
vehicle =
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
else
|
38
|
-
interest = INTEREST_VALUES[:buy]
|
35
|
+
def add_color_combination(v_index, interior_color, exterior_color, preference)
|
36
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@prospect,'vehicle', v_index)
|
37
|
+
if valid
|
38
|
+
cc = ColorCombinations.new(vehicle)
|
39
|
+
cc.add(interior_color, exterior_color, preference)
|
40
|
+
@color_combinations.push(cc)
|
39
41
|
end
|
42
|
+
end
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def color_combinations
|
45
|
+
@color_combinations
|
46
|
+
end
|
47
|
+
|
48
|
+
def add(year, make, model, params={})
|
49
|
+
vehicle = Ox::Element.new('vehicle')
|
47
50
|
|
48
|
-
|
49
|
-
vehicle
|
51
|
+
params.merge!({valid_values: VALID_VALUES, valid_parameters: VALID_PARAMETERS})
|
52
|
+
AdfBuilder::Builder.update_params(vehicle, :vehicle, params)
|
50
53
|
|
51
54
|
vehicle << (Ox::Element.new('year') << year.to_s)
|
52
55
|
vehicle << (Ox::Element.new('make') << make)
|
53
56
|
vehicle << (Ox::Element.new('model') << model)
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
@prospect << vehicle
|
59
|
+
end
|
60
|
+
|
61
|
+
def update_odometer(index, value, params={})
|
62
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@prospect,'vehicle', index)
|
63
|
+
if valid
|
64
|
+
params.merge!({valid_values: VALID_VALUES, valid_parameters: VALID_PARAMETERS})
|
65
|
+
AdfBuilder::Builder.update_node(vehicle, 'odometer', value, params)
|
59
66
|
end
|
67
|
+
end
|
60
68
|
|
61
|
-
|
69
|
+
def update_condition(index, value)
|
70
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@prospect,'vehicle', index)
|
71
|
+
if valid and CONDITIONS.include? value
|
72
|
+
AdfBuilder::Builder.update_node(vehicle, 'condition', value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_imagetag(index, value, params={})
|
77
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@prospect,'vehicle', index)
|
78
|
+
if valid
|
79
|
+
params.merge!({valid_values: VALID_VALUES, valid_parameters: VALID_PARAMETERS})
|
80
|
+
AdfBuilder::Builder.update_node(vehicle, 'imagetag', value, params)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def update_tags_with_free_text(index, tags)
|
85
|
+
valid, vehicle = AdfBuilder::Builder.valid_child?(@prospect,'vehicle', index)
|
86
|
+
if valid
|
87
|
+
tags.each do |key, value|
|
88
|
+
if FREE_TEXT_OPTIONAL_TAGS.include? key.to_sym
|
89
|
+
AdfBuilder::Builder.update_node(vehicle, key, value)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
62
93
|
end
|
63
94
|
|
64
95
|
def add_id(index, value, source=nil, sequence=1)
|
@@ -68,6 +99,5 @@ module AdfBuilder
|
|
68
99
|
Id.new.add(@prospect.vehicle(index), value, source, sequence)
|
69
100
|
end
|
70
101
|
end
|
71
|
-
|
72
102
|
end
|
73
103
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module AdfBuilder
|
2
|
+
class Vendor
|
3
|
+
def initialize(prospect)
|
4
|
+
@vendor = Ox::Element.new('vendor')
|
5
|
+
@contact = nil
|
6
|
+
prospect << @vendor
|
7
|
+
end
|
8
|
+
|
9
|
+
def contact
|
10
|
+
@contact
|
11
|
+
end
|
12
|
+
|
13
|
+
def add(name, contact_name, opts={})
|
14
|
+
@vendor << (Ox::Element.new('vendorname') << name)
|
15
|
+
@contact = Contact.new(@vendor, contact_name, opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_url(url)
|
19
|
+
if @vendor.locate("url").size > 0
|
20
|
+
@vendor.remove_children(@vendor.url)
|
21
|
+
end
|
22
|
+
@vendor << (Ox::Element.new('url') << url)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_id(index, value, source=nil, sequence=1)
|
26
|
+
if @prospect.locate("vendor").empty?
|
27
|
+
false
|
28
|
+
else
|
29
|
+
Id.new.add(@prospect.vendor(index), value, source, sequence)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/adf_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adf_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marcus.salinas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|
@@ -45,11 +45,15 @@ files:
|
|
45
45
|
- bin/console
|
46
46
|
- bin/setup
|
47
47
|
- lib/adf_builder.rb
|
48
|
-
- lib/adf_builder/base.rb
|
48
|
+
- lib/adf_builder/base/base.rb
|
49
49
|
- lib/adf_builder/base/prospect.rb
|
50
50
|
- lib/adf_builder/base/request_date.rb
|
51
|
-
- lib/adf_builder/
|
51
|
+
- lib/adf_builder/customer/customer.rb
|
52
|
+
- lib/adf_builder/shared/contact.rb
|
53
|
+
- lib/adf_builder/shared/id.rb
|
54
|
+
- lib/adf_builder/vehicles/colorcombinations.rb
|
52
55
|
- lib/adf_builder/vehicles/vehicles.rb
|
56
|
+
- lib/adf_builder/vendor/vendor.rb
|
53
57
|
- lib/adf_builder/version.rb
|
54
58
|
homepage: https://github.com/jippylong12/adf_builder
|
55
59
|
licenses:
|