book-value 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/book-value/client.rb +15 -13
- data/lib/book-value/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: f13ec585d50646d3083b25f0d66fd48a18846260bf43142240ac2900264abfef
|
4
|
+
data.tar.gz: b296783edf3d9a4e8eae476df35a35e7c6df43550125820c1de2c450c275fe6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b01ba337b241e8182df07035e54630cc8faaad0b9dd04393bc2cb95cb4261f984ac2ee9cbd8852413b1293adf7ebb110dae69dfb23b089bd7526b1d2b10f1f48
|
7
|
+
data.tar.gz: 23087867bb8eeb3066fbbd128c395abbef11453f23baeb9db07beac84b55b0f837809db1c77496339f4f33b8f6bbaa140c53dc2a15a9458d218f31cd70fd13ed
|
data/Gemfile.lock
CHANGED
data/lib/book-value/client.rb
CHANGED
@@ -38,33 +38,32 @@ module BookValue
|
|
38
38
|
options
|
39
39
|
end
|
40
40
|
|
41
|
-
# TODO: Fix model to try `-`
|
42
41
|
def car_features(make, model)
|
43
|
-
|
42
|
+
checkbox_options = {}
|
43
|
+
|
44
|
+
process_model(model).each do |model_name|
|
44
45
|
raw_page = authorise_and_send(http_method: :get, command: "calculate/#{make.downcase}/#{model_name}")
|
45
|
-
next if raw_page == {}
|
46
46
|
|
47
47
|
doc = Nokogiri::HTML(raw_page['body'])
|
48
48
|
|
49
|
-
checkbox_options = {}
|
50
|
-
|
51
49
|
doc.css(".list-group li div").each do |checkbox|
|
52
50
|
input_of_child = checkbox.children.find { |child| child.name == 'input' }
|
53
51
|
label_of_child = checkbox.children.find { |child| child.name == 'label' }
|
54
52
|
|
55
53
|
checkbox_options[input_of_child[:name]] = label_of_child.children.first.to_s
|
56
54
|
end
|
57
|
-
|
58
|
-
return checkbox_options
|
59
55
|
end
|
56
|
+
|
57
|
+
checkbox_options
|
60
58
|
end
|
61
59
|
|
62
60
|
# Features are just the list of features
|
63
61
|
# condition_score is between 1-10, 10 is perfect, 1 is bad
|
64
62
|
def get_book_value(make, model, features, mileage, year, condition_score = 10)
|
65
|
-
|
66
|
-
|
63
|
+
output = ''
|
64
|
+
feature_params = ''
|
67
65
|
|
66
|
+
process_model(model).each do |model_name|
|
68
67
|
features.each do |feature_id|
|
69
68
|
feature_params = "#{feature_params}#{feature_id}=on&"
|
70
69
|
end
|
@@ -72,9 +71,8 @@ module BookValue
|
|
72
71
|
feature_params = feature_params[0..-2]
|
73
72
|
|
74
73
|
milage_form_page = authorise_and_send(http_method: :post, payload: feature_params, command: "calculate/#{make.downcase}/#{model_name}")
|
75
|
-
next if milage_form_page == {}
|
76
|
-
|
77
74
|
condition_url = milage_form_page['headers']['location']
|
75
|
+
next unless condition_url
|
78
76
|
|
79
77
|
_condition_page = HTTParty.post(condition_url, body: "mileage=#{mileage}&year=#{year}")
|
80
78
|
|
@@ -82,8 +80,11 @@ module BookValue
|
|
82
80
|
book_value_page = HTTParty.post(book_value_url, body: "condition_score=#{condition_score}")
|
83
81
|
|
84
82
|
doc = Nokogiri::HTML(book_value_page.body)
|
85
|
-
|
83
|
+
|
84
|
+
output = doc.at('h4').text
|
86
85
|
end
|
86
|
+
|
87
|
+
output
|
87
88
|
end
|
88
89
|
|
89
90
|
private
|
@@ -138,7 +139,8 @@ module BookValue
|
|
138
139
|
{
|
139
140
|
'start_time' => start_time,
|
140
141
|
'end_time' => end_time,
|
141
|
-
'total_time' => total_time
|
142
|
+
'total_time' => total_time,
|
143
|
+
'ok' => response.ok?
|
142
144
|
}
|
143
145
|
end
|
144
146
|
|
data/lib/book-value/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: book-value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trex22
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|