auto_ria_api 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82fb4b202b4c2d3edc4257ba2dcb5f8585cd35604651695cb765d8dddfa0c129
4
- data.tar.gz: 02a2b30dc955f38ffef0850c5236d27bc4a0985418eddd8de1ed7ecf8372c9a5
3
+ metadata.gz: 5ad52d92d1b42ebfe2298c8c65d6e1860f88c6ad794fa8fc51dadf2de730422a
4
+ data.tar.gz: 92653049945c86cacf4ea14f83de2d6897d7aaf70663f44fb4d4d67dd31fb480
5
5
  SHA512:
6
- metadata.gz: 41761f22f13c17848022eaba0140b0b8e4e998af840e3809f73356e339195ccf4b4aa8bb7d6faf5a76000202304fe3f5e83582c0a0d2bbceb5ecd03995e16a31
7
- data.tar.gz: '0691a1061b25b5fcdec895daebc778011c8513849d8e2a5094e9ca69173051bc1158e74b65fdc2f964f61e1a92f47469020634622a008fed75413a56b67b824d'
6
+ metadata.gz: c55d7cda985ce3ec8b7a2086a55ec4ba9c50699f09bed831dc0384f63dcf4ed947306f037ad5b47f5beb13a5708b2f0e475cdd360cbe53eccee7a718d5aab8b5
7
+ data.tar.gz: 4037cbeb2ba4f3c93dd2379e149f5f98f4530118d9dd2e5bb4e5d6be5075dd260210110c1102fb929d4b43941e8cc4268c9437d2196f08dce115d4f3a1aa1e8a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- auto_ria_api (0.1.0)
4
+ auto_ria_api (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # AutoRiaApi
1
+ # Auto Ria Api
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/auto_ria_api`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem provides integration with [https://auto.ria.com/](https://auto.ria.com/)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
42
+ ```
43
+ For more detailed documentation follows:
26
44
 
27
- ## Development
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
- 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.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/auto_ria_api.
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, grouped: false, all: false)
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, mark, grouped: false, all: false)
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(*args)
77
- raise 'Not implemented'
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, method = :get_response, params = {})
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)
@@ -1,3 +1,3 @@
1
1
  module AutoRiaApi
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'
3
3
  end
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler