auto_ria_api 0.1.0 → 0.1.1
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/README.md +35 -8
- data/lib/auto_ria_api.rb +10 -9
- data/lib/auto_ria_api/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: 5ad52d92d1b42ebfe2298c8c65d6e1860f88c6ad794fa8fc51dadf2de730422a
|
4
|
+
data.tar.gz: 92653049945c86cacf4ea14f83de2d6897d7aaf70663f44fb4d4d67dd31fb480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55d7cda985ce3ec8b7a2086a55ec4ba9c50699f09bed831dc0384f63dcf4ed947306f037ad5b47f5beb13a5708b2f0e475cdd360cbe53eccee7a718d5aab8b5
|
7
|
+
data.tar.gz: 4037cbeb2ba4f3c93dd2379e149f5f98f4530118d9dd2e5bb4e5d6be5075dd260210110c1102fb929d4b43941e8cc4268c9437d2196f08dce115d4f3a1aa1e8a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Auto Ria Api
|
2
2
|
|
3
|
-
|
3
|
+
This gem provides integration with [https://auto.ria.com/](https://auto.ria.com/)
|
4
4
|
|
5
|
-
|
5
|
+
#### Please NOTE that this is very early version and not all endpoints are implemented.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -21,18 +21,45 @@ Or install it yourself as:
|
|
21
21
|
$ gem install auto_ria_api
|
22
22
|
|
23
23
|
## Usage
|
24
|
+
First of all you need an api_key which you can get at [https://developers.ria.com](https://developers.ria.com)
|
25
|
+
```ruby
|
26
|
+
# create an instance
|
27
|
+
@client = AutoRiaApi::Base.new(api_key: ENV['AUTO_RIA_API_KEY'])
|
28
|
+
|
29
|
+
# Methods:
|
30
|
+
@clien.types
|
31
|
+
@clien.carcasses(type, grouped: false, all: false)
|
32
|
+
@clien.marks(carcasse)
|
33
|
+
@clien.models(carcasse, mark, grouped: false, all: false)
|
34
|
+
@clien.regions
|
35
|
+
@clien.cities(region)
|
36
|
+
@clien.gearboxes(carcasse)
|
37
|
+
@clien.fuels
|
38
|
+
@clien.colors
|
39
|
+
@clien.options(carcasse)
|
40
|
+
# all method arguments assuming ID (Integer)
|
24
41
|
|
25
|
-
|
42
|
+
```
|
43
|
+
For more detailed documentation follows:
|
26
44
|
|
27
|
-
|
45
|
+
[https://github.com/ria-com/auto-ria-rest-api/tree/master/AUTO_RIA_API](https://github.com/ria-com/auto-ria-rest-api/tree/master/AUTO_RIA_API)
|
28
46
|
|
29
|
-
|
47
|
+
[https://api-docs-v2.readthedocs.io/ru/latest/auto_ria/index.html](https://api-docs-v2.readthedocs.io/ru/latest/auto_ria/index.html)
|
30
48
|
|
31
|
-
|
49
|
+
## TODO:
|
50
|
+
1. Get rid of ::Base namespace. I.e instance should be created directly with `AutoRiaApi.new`
|
51
|
+
1. Implement `search`
|
52
|
+
1. Implement `average_price`
|
53
|
+
1. Implement `info` endpoints
|
32
54
|
|
33
55
|
## Contributing
|
34
56
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/drkmen/auto_ria_api.
|
58
|
+
Help is appreciated Feel free to fork and make a difference!
|
59
|
+
|
60
|
+
## Tests
|
61
|
+
|
62
|
+
Provide `ENV['AUTO_RIA_API_KEY']` in your `.env` file or add it to system env: `export AUTO_RIA_API_KEY=your_key` and run `rspec`
|
36
63
|
|
37
64
|
## License
|
38
65
|
|
data/lib/auto_ria_api.rb
CHANGED
@@ -14,19 +14,19 @@ module AutoRiaApi
|
|
14
14
|
request '/auto/categories'
|
15
15
|
end
|
16
16
|
|
17
|
-
def carcasses(type
|
17
|
+
def carcasses(type:, grouped: false, all: false)
|
18
18
|
raise ArgumentError, 'Type should not be empty.' if blank?(type)
|
19
19
|
return request '/auto/bodystyles' if all
|
20
20
|
group = '_group' if grouped
|
21
21
|
request "/auto/categories/#{type}/bodystyles/#{group}"
|
22
22
|
end
|
23
23
|
|
24
|
-
def marks(carcasse)
|
24
|
+
def marks(carcasse:)
|
25
25
|
raise ArgumentError, 'Carcass should not be empty.' if blank?(carcasse)
|
26
26
|
request "/auto/categories/#{carcasse}/marks"
|
27
27
|
end
|
28
28
|
|
29
|
-
def models(carcasse
|
29
|
+
def models(carcasse:, mark:, grouped: false, all: false)
|
30
30
|
raise ArgumentError, 'Carcass should not be empty.' if blank?(carcasse)
|
31
31
|
raise ArgumentError, 'Mark should not be empty.' if blank?(mark)
|
32
32
|
return request '/auto/models' if all
|
@@ -38,12 +38,12 @@ module AutoRiaApi
|
|
38
38
|
request '/auto/states'
|
39
39
|
end
|
40
40
|
|
41
|
-
def cities(region)
|
41
|
+
def cities(region:)
|
42
42
|
raise ArgumentError, 'Region should not be empty.' if blank?(region)
|
43
43
|
request "/auto/states/#{region}/cities"
|
44
44
|
end
|
45
45
|
|
46
|
-
def gearboxes(carcasse)
|
46
|
+
def gearboxes(carcasse:)
|
47
47
|
raise ArgumentError, 'Carcasse should not be empty.' if blank?(carcasse)
|
48
48
|
request "/auto/categories/#{carcasse}/gearboxes"
|
49
49
|
end
|
@@ -60,7 +60,7 @@ module AutoRiaApi
|
|
60
60
|
request '/auto/colors'
|
61
61
|
end
|
62
62
|
|
63
|
-
def options(carcasse)
|
63
|
+
def options(carcasse:)
|
64
64
|
raise ArgumentError, 'Carcasse should not be empty.' if blank?(carcasse)
|
65
65
|
request "/auto/categories/#{carcasse}/auto_options"
|
66
66
|
end
|
@@ -73,13 +73,14 @@ module AutoRiaApi
|
|
73
73
|
raise 'Not implemented'
|
74
74
|
end
|
75
75
|
|
76
|
-
def info(
|
77
|
-
raise '
|
76
|
+
def info(car_id:)
|
77
|
+
raise ArgumentError, 'car_id should not be empty.' if blank?(car_id)
|
78
|
+
request '/auto/info', auto_id: car_id
|
78
79
|
end
|
79
80
|
|
80
81
|
private
|
81
82
|
|
82
|
-
def request(url,
|
83
|
+
def request(url, params = {}, method = :get_response)
|
83
84
|
uri = URI(@default_url + url)
|
84
85
|
uri.query = URI.encode_www_form(params.merge(api_key: @api_key))
|
85
86
|
response = Net::HTTP.public_send(method, uri)
|
data/lib/auto_ria_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_ria_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drkmen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|