fipe_api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +8 -8
- data/fipe_api.gemspec +4 -4
- data/lib/fipe_api.rb +1 -0
- data/lib/fipe_api/resources/brand.rb +1 -1
- data/lib/fipe_api/resources/model.rb +1 -1
- data/lib/fipe_api/resources/table.rb +13 -10
- data/lib/fipe_api/resources/vehicle.rb +1 -1
- data/lib/fipe_api/resources/year.rb +1 -1
- data/lib/fipe_api/version.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0358ab75e6e72f7ebf6faf032da9838f267f535
|
4
|
+
data.tar.gz: c644953ebe9061facce589f862170674a91a5edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5268b71775cde9e86251d46c07e6fc0d216b2370e1057d802b4ae86d6d190b4028889025dfaff5587c8c0dc8d0fb36cb6cfb67600b337c4ac10c8c183c1b3ab
|
7
|
+
data.tar.gz: 169fcb47a9b622a8a7b61a2f25e0f914cd33fb7fcd573ab1a45f9d6e54dcbf69a6ab736cfa77b7c6f1ed2eea299d62a41e744714e22423ac26276df07f2b2436
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# FipeApi
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
![Gem Version](http://img.shields.io/gem/v/fipe_api.svg)
|
4
|
+
![Build Status](http://img.shields.io/travis/caiofct/fipe_api.svg)
|
5
|
+
![Dependency Status](http://img.shields.io/gemnasium/caiofct/fipe_api.svg)
|
6
|
+
![Code Climate](http://img.shields.io/codeclimate/github/caiofct/fipe_api.svg)
|
7
7
|
|
8
|
-
This application is a ruby client to the Tabela Fipe Api - http://www.fipe.org.br/pt-br/indices/veiculos/. It makes use the excellent http gem to make http requests and nokogiri to parse the response
|
8
|
+
This application is a ruby client to the Tabela Fipe Api - http://www.fipe.org.br/pt-br/indices/veiculos/. It makes use of the excellent http gem to make http requests and nokogiri to parse the response
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -27,9 +27,9 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
The base class to use is a FipeApi::Vehicle. The Fipe data makes use of three Vehicles types wich are mapped to a FipeApi::Vehicle constant. The constants are:
|
29
29
|
|
30
|
-
FipeApi::Vehicle::CAR
|
31
|
-
FipeApi::Vehicle::MOTORCYCLE
|
32
|
-
FipeApi::Vehicle::TRUCK
|
30
|
+
* `FipeApi::Vehicle::CAR`
|
31
|
+
* `FipeApi::Vehicle::MOTORCYCLE`
|
32
|
+
* `FipeApi::Vehicle::TRUCK`
|
33
33
|
|
34
34
|
You can get all Vehicles types with:
|
35
35
|
|
data/fipe_api.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Caio Teixeira"]
|
10
10
|
spec.email = ["caiofct@ifce.edu.br"]
|
11
11
|
|
12
|
-
spec.summary = %q{A ruby client to consume Tabela Fipe api data - http://
|
13
|
-
spec.description = %q{This application is a ruby client to the Tabela Fipe Api - http://
|
12
|
+
spec.summary = %q{A ruby client to consume Tabela Fipe api data - http://veiculos.fipe.org.br/}
|
13
|
+
spec.description = %q{This application is a ruby client to the Tabela Fipe Api - http://veiculos.fipe.org.br/. It makes use of the excellent http gem to make http requests and nokogiri to parse the responses.}
|
14
14
|
spec.homepage = "https://github.com/caiofct/fipe_api"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "byebug", "~> 5.0"
|
26
26
|
|
27
27
|
spec.add_dependency 'nokogiri', '~> 1.6'
|
28
|
-
spec.add_dependency 'http', '~> 0
|
28
|
+
spec.add_dependency 'http', '~> 2.0'
|
29
29
|
|
30
|
-
spec.required_ruby_version = '>=
|
30
|
+
spec.required_ruby_version = '>= 2.0'
|
31
31
|
spec.required_rubygems_version = '>= 1.3.5'
|
32
32
|
end
|
data/lib/fipe_api.rb
CHANGED
@@ -17,7 +17,7 @@ module FipeApi
|
|
17
17
|
table = Table.latest(self.vehicle)
|
18
18
|
end
|
19
19
|
|
20
|
-
response = HTTP.post("http://
|
20
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarModelos",
|
21
21
|
params: {
|
22
22
|
codigoTabelaReferencia: table.id,
|
23
23
|
codigoTipoVeiculo: self.vehicle.id,
|
@@ -15,7 +15,7 @@ module FipeApi
|
|
15
15
|
table = Table.latest(self.brand.vehicle)
|
16
16
|
end
|
17
17
|
|
18
|
-
response = HTTP.post("http://
|
18
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarAnoModelo",
|
19
19
|
params: {
|
20
20
|
codigoTabelaReferencia: table.id,
|
21
21
|
codigoTipoVeiculo: self.brand.vehicle.id,
|
@@ -16,11 +16,12 @@ module FipeApi
|
|
16
16
|
def self.all(vehicle)
|
17
17
|
return [] if vehicle.nil?
|
18
18
|
tables = []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", body: {}.to_json).to_s
|
20
|
+
tables_hash = JSON.parse(response)
|
21
|
+
tables_hash.each do |table|
|
22
|
+
if table["Mes"] != ""
|
23
|
+
parts = table["Mes"].strip.split("/")
|
24
|
+
tables << Table.new(table["Codigo"], Utils.month_name_to_int(parts[0]), parts[1].to_i)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -31,11 +32,12 @@ module FipeApi
|
|
31
32
|
def self.latest(vehicle)
|
32
33
|
return nil if vehicle.nil? || !vehicle.kind_of?(FipeApi::Vehicle)
|
33
34
|
table = nil
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", body: {}.to_json).to_s
|
36
|
+
table = JSON.parse(response).first
|
37
|
+
# first_option = doc.css("#selectTabelaReferencia#{vehicle.name_id} option").first
|
38
|
+
if table["Mes"] != ""
|
39
|
+
parts = table["Mes"].strip.split("/")
|
40
|
+
table = Table.new(table["Codigo"], Utils.month_name_to_int(parts[0]), parts[1].to_i)
|
39
41
|
end
|
40
42
|
table
|
41
43
|
end
|
@@ -45,6 +47,7 @@ module FipeApi
|
|
45
47
|
return nil if vehicle.nil? || !vehicle.kind_of?(FipeApi::Vehicle)
|
46
48
|
result = nil
|
47
49
|
tables = self.all(vehicle)
|
50
|
+
|
48
51
|
tables.each do |table|
|
49
52
|
if table.month == month && table.year == year
|
50
53
|
result = table
|
@@ -27,7 +27,7 @@ module FipeApi
|
|
27
27
|
table = Table.latest(self)
|
28
28
|
end
|
29
29
|
|
30
|
-
response = HTTP.post("http://
|
30
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarMarcas", params: { codigoTabelaReferencia: table.id, codigoTipoVeiculo: self.id }, body: {}.to_json).to_s
|
31
31
|
brands_hash = JSON.parse(response)
|
32
32
|
brands_result = []
|
33
33
|
brands_hash.each do |brand|
|
@@ -17,7 +17,7 @@ module FipeApi
|
|
17
17
|
table = Table.latest(self.model.brand.vehicle)
|
18
18
|
end
|
19
19
|
|
20
|
-
response = HTTP.post("http://
|
20
|
+
response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarValorComTodosParametros",
|
21
21
|
params: {
|
22
22
|
codigoTabelaReferencia: table.id,
|
23
23
|
codigoTipoVeiculo: self.model.brand.vehicle.id,
|
data/lib/fipe_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fipe_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Teixeira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,17 +86,17 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
89
|
+
version: '2.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
97
|
-
description: This application is a ruby client to the Tabela Fipe Api - http://
|
98
|
-
It makes use the excellent http gem to make http requests and nokogiri to parse
|
99
|
-
the
|
96
|
+
version: '2.0'
|
97
|
+
description: This application is a ruby client to the Tabela Fipe Api - http://veiculos.fipe.org.br/.
|
98
|
+
It makes use of the excellent http gem to make http requests and nokogiri to parse
|
99
|
+
the responses.
|
100
100
|
email:
|
101
101
|
- caiofct@ifce.edu.br
|
102
102
|
executables: []
|
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: '2.0'
|
140
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - ">="
|
@@ -144,8 +144,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: 1.3.5
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.5.1
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
|
-
summary: A ruby client to consume Tabela Fipe api data - http://
|
150
|
+
summary: A ruby client to consume Tabela Fipe api data - http://veiculos.fipe.org.br/
|
151
151
|
test_files: []
|
152
|
+
has_rdoc:
|