fipe_api 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0358ab75e6e72f7ebf6faf032da9838f267f535
4
- data.tar.gz: c644953ebe9061facce589f862170674a91a5edf
3
+ metadata.gz: fd6b1b6001408f2676c045cbe0924be8cf72b725
4
+ data.tar.gz: daffad8b5e88daa3b001296f649859321ee4d893
5
5
  SHA512:
6
- metadata.gz: d5268b71775cde9e86251d46c07e6fc0d216b2370e1057d802b4ae86d6d190b4028889025dfaff5587c8c0dc8d0fb36cb6cfb67600b337c4ac10c8c183c1b3ab
7
- data.tar.gz: 169fcb47a9b622a8a7b61a2f25e0f914cd33fb7fcd573ab1a45f9d6e54dcbf69a6ab736cfa77b7c6f1ed2eea299d62a41e744714e22423ac26276df07f2b2436
6
+ metadata.gz: ef2e5d438a4383d64cff3ed9699e5b72f04456972f3e534a093b0548bd6c32097ab1bb8011e97fef8d71757e4d0f219a22181eace7146ba7a2b75e1172a9ef42
7
+ data.tar.gz: 8ec1b21584254165fcc544fa9be87fe4dc52f41848bf587cb9e0aa422e8844bd8bd3fe5f32decbbd1ce40443d24c3c310b69bef598859124fdfe0a97f230be6f
data/README.md CHANGED
@@ -47,26 +47,26 @@ vehicles.first.name => Car
47
47
  or you can initialize an specific Vehicle type, let`s say a CAR, with:
48
48
 
49
49
  ```ruby
50
- vehicle = FipeApi::Vehicle.new(Vehicle::CAR, "Car")
50
+ vehicle = FipeApi::Vehicle.new(FipeApi::Vehicle::CAR, "Car")
51
51
  ```
52
52
 
53
53
  Given a vehicle you can get all of its tables. A Table is generated each month with updated values for some vehicles. So, to get all tables you may do:
54
54
 
55
55
  ```ruby
56
- tables = vehicle.get_tables
56
+ tables = vehicle.get_tables
57
57
  ```
58
58
 
59
59
  Frequently you will be using the latest table generated, i.e. that was generated for the current month and year, to get the vehicles data. It`s possible to
60
60
  retrieve the latest table for an specific vehicle with:
61
61
 
62
62
  ```ruby
63
- latest_table = Table.latest(vehicle)
63
+ latest_table = FipeApi::Table.latest(vehicle)
64
64
  ```
65
65
 
66
66
  or you can get a table for an specific month and year:
67
67
 
68
68
  ```ruby
69
- table = Table.find_by_month_and_year(vehicle, 3, 2015) # Table from March/2015
69
+ table = FipeApi::Table.find_by_month_and_year(vehicle, 3, 2015) # Table from March/2015
70
70
  ```
71
71
 
72
72
  Once you have a vehicle and a given table, you can get all of the vehicle`s Brands(Ford, Fiat, GM/Chevrolet, BMW, etc...), like so:
@@ -87,7 +87,7 @@ You can get the years with:
87
87
 
88
88
  ```ruby
89
89
  years = model.get_years(table) #If you don`t pass a table, it will use the latest table for the vehicle.
90
- ```
90
+ ```
91
91
 
92
92
  Finally, once you have an specific year for a vehicle, it`s possible to get its price like the following:
93
93
 
data/lib/fipe_api/base.rb CHANGED
@@ -4,6 +4,6 @@ require "fipe_api/utils"
4
4
 
5
5
  module FipeApi
6
6
  class Base
7
-
7
+ HEADERS = { "Referer" => "http://veiculos.fipe.org.br/", "Host" => "veiculos.fipe.org.br" }
8
8
  end
9
9
  end
@@ -18,6 +18,7 @@ module FipeApi
18
18
  end
19
19
 
20
20
  response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarModelos",
21
+ headers: HEADERS,
21
22
  params: {
22
23
  codigoTabelaReferencia: table.id,
23
24
  codigoTipoVeiculo: self.vehicle.id,
@@ -18,9 +18,9 @@ module FipeApi
18
18
 
19
19
  #http://www.fipe.org.br/pt-br/indices/veiculos/carro/ford/7-2015/003376-6/32000/g/g1gj386ctbp
20
20
  def url
21
- "http://www.fipe.org.br/pt-br/indices/veiculos/#{year.model.brand.vehicle.name_id}/" +
21
+ "http://uat.fipe.org.br?#{year.model.brand.vehicle.name_id}/" +
22
22
  "#{year.model.brand.name.downcase}/#{year.model.brand.table.month}-#{year.model.brand.table.year}/" +
23
- "#{self.id}/#{self.year.id}/g/#{self.authentication}"
23
+ "#{self.id}/#{self.year.id}/#{self.fuel.downcase.chars.first}/#{self.authentication}"
24
24
  end
25
25
  end
26
26
  end
@@ -16,6 +16,7 @@ module FipeApi
16
16
  end
17
17
 
18
18
  response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarAnoModelo",
19
+ headers: HEADERS,
19
20
  params: {
20
21
  codigoTabelaReferencia: table.id,
21
22
  codigoTipoVeiculo: self.brand.vehicle.id,
@@ -16,7 +16,7 @@ module FipeApi
16
16
  def self.all(vehicle)
17
17
  return [] if vehicle.nil?
18
18
  tables = []
19
- response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", body: {}.to_json).to_s
19
+ response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", headers: HEADERS, body: {}.to_json).to_s
20
20
  tables_hash = JSON.parse(response)
21
21
  tables_hash.each do |table|
22
22
  if table["Mes"] != ""
@@ -32,7 +32,7 @@ module FipeApi
32
32
  def self.latest(vehicle)
33
33
  return nil if vehicle.nil? || !vehicle.kind_of?(FipeApi::Vehicle)
34
34
  table = nil
35
- response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", body: {}.to_json).to_s
35
+ response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarTabelaDeReferencia", headers: HEADERS, body: {}.to_json).to_s
36
36
  table = JSON.parse(response).first
37
37
  # first_option = doc.css("#selectTabelaReferencia#{vehicle.name_id} option").first
38
38
  if table["Mes"] != ""
@@ -27,7 +27,7 @@ module FipeApi
27
27
  table = Table.latest(self)
28
28
  end
29
29
 
30
- response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarMarcas", params: { codigoTabelaReferencia: table.id, codigoTipoVeiculo: self.id }, body: {}.to_json).to_s
30
+ response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarMarcas", headers: HEADERS, 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|
@@ -18,6 +18,7 @@ module FipeApi
18
18
  end
19
19
 
20
20
  response = HTTP.post("http://veiculos.fipe.org.br/api/veiculos/ConsultarValorComTodosParametros",
21
+ headers: HEADERS,
21
22
  params: {
22
23
  codigoTabelaReferencia: table.id,
23
24
  codigoTipoVeiculo: self.model.brand.vehicle.id,
@@ -1,3 +1,3 @@
1
1
  module FipeApi
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fipe_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Teixeira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '5.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.6'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: http
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
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
96
  version: '2.0'
97
97
  description: This application is a ruby client to the Tabela Fipe Api - http://veiculos.fipe.org.br/.
@@ -103,9 +103,9 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - ".gitignore"
107
- - ".rspec"
108
- - ".travis.yml"
106
+ - .gitignore
107
+ - .rspec
108
+ - .travis.yml
109
109
  - CODE_OF_CONDUCT.md
110
110
  - Gemfile
111
111
  - LICENSE.txt
@@ -134,19 +134,18 @@ require_paths:
134
134
  - lib
135
135
  required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - '>='
138
138
  - !ruby/object:Gem::Version
139
139
  version: '2.0'
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - ">="
142
+ - - '>='
143
143
  - !ruby/object:Gem::Version
144
144
  version: 1.3.5
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.5.1
147
+ rubygems_version: 2.4.8
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: A ruby client to consume Tabela Fipe api data - http://veiculos.fipe.org.br/
151
151
  test_files: []
152
- has_rdoc: