yandex_market_api_client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +49 -2
- data/lib/yandex_market_api_client/client.rb +6 -0
- data/lib/yandex_market_api_client/version.rb +1 -1
- data/test/fixtures/category_children.json +110 -0
- data/test/fixtures/category_filters.json +30 -0
- data/test/fixtures/category_models.json +62 -0
- data/test/lib/yandex_market_api_client/category_resource_test.rb +31 -1
- data/test/test_helper.rb +7 -1
- metadata +30 -11
- checksums.yaml +0 -7
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: BD08fN1igPDYWXZYN777IUsN3b1tUsDxL
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/igkuz/yandex_market_api_wrapper.png)](https://travis-ci.org/igkuz/yandex_wrapper_api_wrapper)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/igkuz/yandex_market_api_wrapper/badge.png)](https://coveralls.io/r/igkuz/yandex_market_api_wrapper)
|
2
3
|
|
3
4
|
# YandexMarketApiWrapper
|
4
5
|
|
@@ -23,6 +24,11 @@ Or install it yourself as:
|
|
23
24
|
|
24
25
|
## Usage
|
25
26
|
|
27
|
+
### Basic Information
|
28
|
+
|
29
|
+
The structure of the api response will not be provided here in case of large data in it.
|
30
|
+
You can look for it in Yandex docs [here](http://api.yandex.ru/market/content/doc/dg/concepts/about.xml).
|
31
|
+
|
26
32
|
### Configuration
|
27
33
|
|
28
34
|
There are several parameters that can be configured:
|
@@ -44,9 +50,50 @@ end
|
|
44
50
|
If no version or format options are provided, the default values will be
|
45
51
|
seted.
|
46
52
|
|
47
|
-
Default Yandex
|
53
|
+
Default Yandex *api_version* is **1**
|
54
|
+
|
55
|
+
Default *deafult_format* is **json**
|
56
|
+
|
57
|
+
### Client instance
|
58
|
+
|
59
|
+
To get a client instance you have to call `get_client` method:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
client = YandexMarketApiClient.get_client
|
63
|
+
```
|
64
|
+
|
65
|
+
### Category Resource
|
66
|
+
|
67
|
+
The api description is provided [here](http://api.yandex.ru/market/content/doc/dg/reference/categories.xml).
|
68
|
+
List of optinal and required params provided in the docs on the link upper.
|
69
|
+
|
70
|
+
+ To get all categories:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
client.categories(geo_id: 255).perform.parse
|
74
|
+
client.categories(geo_id: 255, page: 1, count: 10, sort: "name").perform.parse
|
75
|
+
```
|
76
|
+
|
77
|
+
+ To get one category info:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
client.category(geo_id: 255, category_id: 1).perform.parse
|
81
|
+
client.category(geo_id: 255, category_id: 1).perform.parse
|
82
|
+
```
|
48
83
|
|
49
|
-
|
84
|
+
+ To get all category children:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
client.category_children(geo_id: 255, category_id: 1).perform.parse
|
88
|
+
client.category_children(geo_id: 255, category_id: 1, page: 1, count: 10, sort: "name", type: "guru").perform.parse
|
89
|
+
```
|
90
|
+
|
91
|
+
+ To get all category models:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
client.category_models(geo_id: 255, category_id: 1).perform.parse
|
95
|
+
client.category_models(geo_id: 255, category_id: 1, page: 1, count: 10, sort: "name", vendor_id: 1, how: "asc").perform.parse
|
96
|
+
```
|
50
97
|
|
51
98
|
## Contributing
|
52
99
|
|
@@ -37,6 +37,12 @@ module YandexMarketApiClient
|
|
37
37
|
resource.required :geo_id
|
38
38
|
end
|
39
39
|
|
40
|
+
get :category_filters, "/v#{config.api_version}/category/{category_id}/filters.#{format}" do |resource|
|
41
|
+
resource.optional :filter_set, # basic, popular, all basic - default
|
42
|
+
:by_popularity #0, 1
|
43
|
+
resource.required :geo_id
|
44
|
+
end
|
45
|
+
|
40
46
|
get :regions, "/v#{config.api_version}/georegion.#{format}" do |resource|
|
41
47
|
resource.optional :page, :count
|
42
48
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
{
|
2
|
+
"categories": {
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"id": 90543,
|
6
|
+
"name": "Аудиотехника",
|
7
|
+
"parentId": 198119,
|
8
|
+
"childrenCount": 13,
|
9
|
+
"offersNum": 100685,
|
10
|
+
"modelsNum": 9549,
|
11
|
+
"visual": false,
|
12
|
+
"type": "nonguru"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id": 90625,
|
16
|
+
"name": "Аксессуары",
|
17
|
+
"parentId": 198119,
|
18
|
+
"childrenCount": 10,
|
19
|
+
"offersNum": 69505,
|
20
|
+
"modelsNum": 3781,
|
21
|
+
"visual": false,
|
22
|
+
"type": "nonguru"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"id": 90607,
|
26
|
+
"name": "Фото",
|
27
|
+
"parentId": 198119,
|
28
|
+
"childrenCount": 11,
|
29
|
+
"offersNum": 47265,
|
30
|
+
"modelsNum": 4493,
|
31
|
+
"visual": false,
|
32
|
+
"type": "nonguru"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": 944108,
|
36
|
+
"name": "Портативная аудиотехника",
|
37
|
+
"parentId": 198119,
|
38
|
+
"childrenCount": 6,
|
39
|
+
"offersNum": 26022,
|
40
|
+
"modelsNum": 7178,
|
41
|
+
"visual": false,
|
42
|
+
"type": "nonguru"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"id": 90639,
|
46
|
+
"name": "Телевизоры и плазменные панели",
|
47
|
+
"parentId": 198119,
|
48
|
+
"childrenCount": 0,
|
49
|
+
"offersNum": 10448,
|
50
|
+
"modelsNum": 6075,
|
51
|
+
"visual": false,
|
52
|
+
"type": "guru"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"id": 4976480,
|
56
|
+
"name": "Оптические приборы",
|
57
|
+
"parentId": 198119,
|
58
|
+
"childrenCount": 6,
|
59
|
+
"offersNum": 9893,
|
60
|
+
"modelsNum": 2079,
|
61
|
+
"visual": false,
|
62
|
+
"type": "nonguru"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"id": 995785,
|
66
|
+
"name": "Навигационное оборудование",
|
67
|
+
"parentId": 198119,
|
68
|
+
"childrenCount": 4,
|
69
|
+
"offersNum": 8118,
|
70
|
+
"modelsNum": 1642,
|
71
|
+
"visual": false,
|
72
|
+
"type": "nonguru"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"id": 91470,
|
76
|
+
"name": "Рации",
|
77
|
+
"parentId": 198119,
|
78
|
+
"childrenCount": 0,
|
79
|
+
"offersNum": 5761,
|
80
|
+
"modelsNum": 442,
|
81
|
+
"visual": false,
|
82
|
+
"type": "guru"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"id": 90635,
|
86
|
+
"name": "Видеокамеры",
|
87
|
+
"parentId": 198119,
|
88
|
+
"childrenCount": 0,
|
89
|
+
"offersNum": 2652,
|
90
|
+
"modelsNum": 593,
|
91
|
+
"visual": false,
|
92
|
+
"type": "guru"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"id": 90633,
|
96
|
+
"name": "DVD и Blu-ray плееры",
|
97
|
+
"parentId": 198119,
|
98
|
+
"childrenCount": 0,
|
99
|
+
"offersNum": 2201,
|
100
|
+
"modelsNum": 1072,
|
101
|
+
"visual": false,
|
102
|
+
"type": "guru"
|
103
|
+
}
|
104
|
+
],
|
105
|
+
"total": 16,
|
106
|
+
"count": 10,
|
107
|
+
"page": 1
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"filters": [
|
3
|
+
{
|
4
|
+
"id": "2140131888",
|
5
|
+
"name": "Минимальная цена",
|
6
|
+
"shortname": "min_price",
|
7
|
+
"type": "NUMERIC",
|
8
|
+
"unit": "руб.",
|
9
|
+
"minValue": "0",
|
10
|
+
"maxValue": "10000000"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"id": "2140131887",
|
14
|
+
"name": "Максимальная цена",
|
15
|
+
"shortname": "max_price",
|
16
|
+
"type": "NUMERIC",
|
17
|
+
"unit": "руб.",
|
18
|
+
"minValue": "0",
|
19
|
+
"maxValue": "10000000"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"id": "2142585907",
|
23
|
+
"name": "Bi-wiring",
|
24
|
+
"shortname": "BiwiringSpeaker",
|
25
|
+
"type": "BOOL",
|
26
|
+
"hasBoolNo": true
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"models": {
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"id": 343488,
|
6
|
+
"name": "NS-555",
|
7
|
+
"description": "тип АС: напольная, пассивная, фазоинверторного типа, назначение: фронтальный громкоговоритель, 100 Вт, 88 дБ, 35-35000 Гц, Bi-wiring, 222x980x345 мм, магнитная защита",
|
8
|
+
"categoryId": 90548,
|
9
|
+
"prices": {
|
10
|
+
"max": "39000",
|
11
|
+
"min": "6900",
|
12
|
+
"avg": "14990",
|
13
|
+
"curCode": "RUR",
|
14
|
+
"curName": "руб."
|
15
|
+
},
|
16
|
+
"mainPhoto": {
|
17
|
+
"url": "http://mdata.yandex.net/i?path=b0129182319_img_id4572006153617451124.jpg",
|
18
|
+
"width": 501,
|
19
|
+
"height": 701
|
20
|
+
},
|
21
|
+
"vendor": "Yamaha",
|
22
|
+
"vendorId": 152866,
|
23
|
+
"offersCount": 19,
|
24
|
+
"isNew": 0,
|
25
|
+
"rating": 4.5,
|
26
|
+
"reviewsCount": 44,
|
27
|
+
"link": "http://market.yandex.ru/model.xml?modelid=343488&hid=90548",
|
28
|
+
"isGroup": false
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": 343489,
|
32
|
+
"name": "NS-777",
|
33
|
+
"description": "тип АС: напольная, пассивная, фазоинверторного типа, назначение: фронтальный громкоговоритель, 100 Вт, 89 дБ, 30-35000 Гц, Bi-wiring, 276x1100x391 мм, магнитная защита",
|
34
|
+
"categoryId": 90548,
|
35
|
+
"prices": {
|
36
|
+
"max": "54700",
|
37
|
+
"min": "9399",
|
38
|
+
"avg": "18900",
|
39
|
+
"curCode": "RUR",
|
40
|
+
"curName": "руб."
|
41
|
+
},
|
42
|
+
"mainPhoto": {
|
43
|
+
"url": "http://mdata.yandex.net/i?path=b1111163301_img_id6879016018058279920.jpg",
|
44
|
+
"width": 370,
|
45
|
+
"height": 500
|
46
|
+
},
|
47
|
+
"vendor": "Yamaha",
|
48
|
+
"vendorId": 152866,
|
49
|
+
"offersCount": 14,
|
50
|
+
"isNew": 0,
|
51
|
+
"rating": 4.5,
|
52
|
+
"reviewsCount": 49,
|
53
|
+
"link": "http://market.yandex.ru/model.xml?modelid=343489&hid=90548",
|
54
|
+
"isGroup": false
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"total": 4612,
|
58
|
+
"count": 2,
|
59
|
+
"page": 1
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
@@ -24,7 +24,7 @@ class CategoryResourceTest < TestCase
|
|
24
24
|
assert_requested stub
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_getting_category_info
|
28
28
|
stub = stub_request(:get, @category_url % "1" + ".json").
|
29
29
|
with(query: { geo_id: 1 }).
|
30
30
|
to_return(@return.merge(body: load_fixture('category.json')))
|
@@ -33,4 +33,34 @@ class CategoryResourceTest < TestCase
|
|
33
33
|
|
34
34
|
assert_requested stub
|
35
35
|
end
|
36
|
+
|
37
|
+
def test_getting_category_children
|
38
|
+
stub = stub_request(:get, @category_url % "1/children" + ".json").
|
39
|
+
with(query: { geo_id: 1 }).
|
40
|
+
to_return(@return.merge(body: load_fixture('category_children.json')))
|
41
|
+
|
42
|
+
@client.category_children(geo_id: 1, category_id: 1).perform.parse
|
43
|
+
|
44
|
+
assert_requested stub
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_getting_category_models
|
48
|
+
stub = stub_request(:get, @category_url % "1/models" + ".json").
|
49
|
+
with(query: { geo_id: 1 }).
|
50
|
+
to_return(@return.merge(body: load_fixture('category_models.json')))
|
51
|
+
|
52
|
+
@client.category_models(geo_id: 1, category_id: 1).perform.parse
|
53
|
+
|
54
|
+
assert_requested stub
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_getting_category_filters
|
58
|
+
stub = stub_request(:get, @category_url % "1/filters" + ".json").
|
59
|
+
with(query: { geo_id: 1, filter_set: "popular" }).
|
60
|
+
to_return(@return.merge(body: load_fixture('category_filters.json')))
|
61
|
+
|
62
|
+
@client.category_filters(geo_id: 1, category_id: 1, filter_set: "popular").perform.parse
|
63
|
+
|
64
|
+
assert_requested stub
|
65
|
+
end
|
36
66
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'bundler/setup'
|
2
|
-
Bundler.require
|
3
2
|
|
4
3
|
require 'minitest/autorun'
|
5
4
|
require 'webmock/minitest'
|
@@ -8,6 +7,13 @@ require 'webmock/minitest'
|
|
8
7
|
require 'minitest/pride'
|
9
8
|
Minitest::PrideIO.pride!
|
10
9
|
|
10
|
+
if ENV["TRAVIS"]
|
11
|
+
require 'coveralls'
|
12
|
+
Coveralls.wear!
|
13
|
+
end
|
14
|
+
|
15
|
+
Bundler.require
|
16
|
+
|
11
17
|
# requiring helpers
|
12
18
|
Dir[ File.join( File.dirname(__FILE__), "helpers/*.rb")].each { |file| require file }
|
13
19
|
|
metadata
CHANGED
@@ -1,41 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_market_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Igor Kuznetsov
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: weary
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
description: YandexMarket API client written in Ruby
|
@@ -45,6 +50,7 @@ executables: []
|
|
45
50
|
extensions: []
|
46
51
|
extra_rdoc_files: []
|
47
52
|
files:
|
53
|
+
- .coveralls.yml
|
48
54
|
- .gitignore
|
49
55
|
- .travis.yml
|
50
56
|
- Gemfile
|
@@ -57,6 +63,9 @@ files:
|
|
57
63
|
- lib/yandex_market_api_client/version.rb
|
58
64
|
- test/fixtures/categories.json
|
59
65
|
- test/fixtures/category.json
|
66
|
+
- test/fixtures/category_children.json
|
67
|
+
- test/fixtures/category_filters.json
|
68
|
+
- test/fixtures/category_models.json
|
60
69
|
- test/fixtures/georegion.json
|
61
70
|
- test/fixtures/georegions.json
|
62
71
|
- test/helpers/configuration_helper.rb
|
@@ -68,31 +77,41 @@ files:
|
|
68
77
|
- yandex_market_api_client.gemspec
|
69
78
|
homepage: ''
|
70
79
|
licenses: []
|
71
|
-
metadata: {}
|
72
80
|
post_install_message:
|
73
81
|
rdoc_options: []
|
74
82
|
require_paths:
|
75
83
|
- lib
|
76
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
77
86
|
requirements:
|
78
|
-
- - '>='
|
87
|
+
- - ! '>='
|
79
88
|
- !ruby/object:Gem::Version
|
80
89
|
version: '0'
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
hash: 2599971410341083809
|
81
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
82
95
|
requirements:
|
83
|
-
- - '>='
|
96
|
+
- - ! '>='
|
84
97
|
- !ruby/object:Gem::Version
|
85
98
|
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: 2599971410341083809
|
86
102
|
requirements: []
|
87
103
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
104
|
+
rubygems_version: 1.8.24
|
89
105
|
signing_key:
|
90
|
-
specification_version:
|
106
|
+
specification_version: 3
|
91
107
|
summary: It's a wrapper for YandexMarket Api calls written in Ruby. Useful for clients
|
92
108
|
having authoriztion key from Yandex.
|
93
109
|
test_files:
|
94
110
|
- test/fixtures/categories.json
|
95
111
|
- test/fixtures/category.json
|
112
|
+
- test/fixtures/category_children.json
|
113
|
+
- test/fixtures/category_filters.json
|
114
|
+
- test/fixtures/category_models.json
|
96
115
|
- test/fixtures/georegion.json
|
97
116
|
- test/fixtures/georegions.json
|
98
117
|
- test/helpers/configuration_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: f4cd935f7ccace7a9c68f6f45544a96d537702f0
|
4
|
-
data.tar.gz: 715af7884b0ddeb45bb4058ee7b5f0f400186a6d
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 33154cd574de978d964bd9f16905af43181113ec341a6b2e8bdefe475d61fcc8d672c02480ab0ead9572f08492cb8470cee706883a2fe936795aff91f93ac03a
|
7
|
-
data.tar.gz: 1ffae31095a2ab4006348b97ddbfcae52770745073ec7d9f1bce09c9534991d7f1c551f9bb3377b0be885f0f7169ea4633367a6f3dbcdffe36d330a096eae956
|