yandex_market_api_client 0.0.3 → 0.0.4

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: 3db6965d41da0cadb9aea2474f1fab8a4e80ebb7
4
- data.tar.gz: f3109c0be041d2f2798b4d7947a2b6c99cab2578
3
+ metadata.gz: f4cd935f7ccace7a9c68f6f45544a96d537702f0
4
+ data.tar.gz: 715af7884b0ddeb45bb4058ee7b5f0f400186a6d
5
5
  SHA512:
6
- metadata.gz: b1cc8712ecf54cff4ae5472c7f4f4d5cc749e558fde60f27c29fa91a6956c267b3e163ff989b96bc7eff216cb961bffea773756f67a612e3445f88698310d1a6
7
- data.tar.gz: d33b8e2c66c66a45a4feae503558baa27d9e608081bde77f8e809acd89120e179d96e2ebec9c5997cb60ba0ed494ed8d651fb1994ee36e7b43c7d9d3e75fa24f
6
+ metadata.gz: 33154cd574de978d964bd9f16905af43181113ec341a6b2e8bdefe475d61fcc8d672c02480ab0ead9572f08492cb8470cee706883a2fe936795aff91f93ac03a
7
+ data.tar.gz: 1ffae31095a2ab4006348b97ddbfcae52770745073ec7d9f1bce09c9534991d7f1c551f9bb3377b0be885f0f7169ea4633367a6f3dbcdffe36d330a096eae956
@@ -26,6 +26,17 @@ module YandexMarketApiClient
26
26
  resource.required :geo_id
27
27
  end
28
28
 
29
+ get :category_children, "/v#{config.api_version}/category/{category_id}/children.#{format}" do |resource|
30
+ resource.optional :page, :count, :sort, :type
31
+ resource.required :geo_id
32
+ end
33
+
34
+ get :category_models, "/v#{config.api_version}/category/{category_id}/models.#{format}" do |resource|
35
+ resource.optional :page, :count, :sort,
36
+ :vendor_id, :how # how - asc или desc для сортировки
37
+ resource.required :geo_id
38
+ end
39
+
29
40
  get :regions, "/v#{config.api_version}/georegion.#{format}" do |resource|
30
41
  resource.optional :page, :count
31
42
  end
@@ -1,3 +1,3 @@
1
1
  module YandexMarketApiClient
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "categories": {
3
3
  "items": [
4
+
4
5
  {
5
6
  "id": 7877999,
6
7
  "name": "Одежда, обувь и аксессуары",
@@ -11,6 +12,7 @@
11
12
  "visual": true,
12
13
  "type": "nonguru"
13
14
  },
15
+
14
16
  {
15
17
  "id": 90829,
16
18
  "name": "Книги",
@@ -21,6 +23,7 @@
21
23
  "visual": false,
22
24
  "type": "nonguru"
23
25
  },
26
+
24
27
  {
25
28
  "id": 91597,
26
29
  "name": "Строительство и ремонт",
@@ -31,6 +34,7 @@
31
34
  "visual": false,
32
35
  "type": "nonguru"
33
36
  },
37
+
34
38
  {
35
39
  "id": 90666,
36
40
  "name": "Все для дома и дачи",
@@ -41,6 +45,7 @@
41
45
  "visual": false,
42
46
  "type": "nonguru"
43
47
  },
48
+
44
49
  {
45
50
  "id": 91009,
46
51
  "name": "Компьютеры",
@@ -51,6 +56,7 @@
51
56
  "visual": false,
52
57
  "type": "nonguru"
53
58
  },
59
+
54
60
  {
55
61
  "id": 90402,
56
62
  "name": "Авто, мото",
@@ -61,6 +67,7 @@
61
67
  "visual": false,
62
68
  "type": "nonguru"
63
69
  },
70
+
64
71
  {
65
72
  "id": 91282,
66
73
  "name": "Подарки, сувениры, цветы",
@@ -71,6 +78,7 @@
71
78
  "visual": false,
72
79
  "type": "guru"
73
80
  },
81
+
74
82
  {
75
83
  "id": 91763,
76
84
  "name": "Оборудование",
@@ -81,6 +89,7 @@
81
89
  "visual": false,
82
90
  "type": "nonguru"
83
91
  },
92
+
84
93
  {
85
94
  "id": 6179129,
86
95
  "name": "Мебель",
@@ -91,6 +100,7 @@
91
100
  "visual": false,
92
101
  "type": "nonguru"
93
102
  },
103
+
94
104
  {
95
105
  "id": 90722,
96
106
  "name": "Все для офиса",
@@ -101,333 +111,7 @@
101
111
  "visual": false,
102
112
  "type": "nonguru"
103
113
  }
104
- ],
105
- "total": 22,
106
- "count": 10,
107
- "page": 1
108
- }
109
- }
110
- {
111
- "categories": {
112
- "items": [
113
- {
114
- "id": 7877999,
115
- "name": "Одежда, обувь и аксессуары",
116
- "parentId": 90401,
117
- "childrenCount": 6,
118
- "offersNum": 3473424,
119
- "modelsNum": 0,
120
- "visual": true,
121
- "type": "nonguru"
122
- },
123
- {
124
- "id": 90829,
125
- "name": "Книги",
126
- "parentId": 90401,
127
- "childrenCount": 17,
128
- "offersNum": 3425134,
129
- "modelsNum": 0,
130
- "visual": false,
131
- "type": "nonguru"
132
- },
133
- {
134
- "id": 91597,
135
- "name": "Строительство и ремонт",
136
- "parentId": 90401,
137
- "childrenCount": 19,
138
- "offersNum": 1117378,
139
- "modelsNum": 80740,
140
- "visual": false,
141
- "type": "nonguru"
142
- },
143
- {
144
- "id": 90666,
145
- "name": "Все для дома и дачи",
146
- "parentId": 90401,
147
- "childrenCount": 12,
148
- "offersNum": 987600,
149
- "modelsNum": 4116,
150
- "visual": false,
151
- "type": "nonguru"
152
- },
153
- {
154
- "id": 91009,
155
- "name": "Компьютеры",
156
- "parentId": 90401,
157
- "childrenCount": 23,
158
- "offersNum": 912104,
159
- "modelsNum": 72591,
160
- "visual": false,
161
- "type": "nonguru"
162
- },
163
- {
164
- "id": 90402,
165
- "name": "Авто, мото",
166
- "parentId": 90401,
167
- "childrenCount": 18,
168
- "offersNum": 744796,
169
- "modelsNum": 115748,
170
- "visual": false,
171
- "type": "nonguru"
172
- },
173
- {
174
- "id": 91282,
175
- "name": "Подарки, сувениры, цветы",
176
- "parentId": 90401,
177
- "childrenCount": 31,
178
- "offersNum": 476554,
179
- "modelsNum": 94055,
180
- "visual": false,
181
- "type": "guru"
182
- },
183
- {
184
- "id": 91763,
185
- "name": "Оборудование",
186
- "parentId": 90401,
187
- "childrenCount": 24,
188
- "offersNum": 398142,
189
- "modelsNum": 0,
190
- "visual": false,
191
- "type": "nonguru"
192
- },
193
- {
194
- "id": 6179129,
195
- "name": "Мебель",
196
- "parentId": 90401,
197
- "childrenCount": 12,
198
- "offersNum": 375792,
199
- "modelsNum": 1200,
200
- "visual": false,
201
- "type": "nonguru"
202
- },
203
- {
204
- "id": 90722,
205
- "name": "Все для офиса",
206
- "parentId": 90401,
207
- "childrenCount": 5,
208
- "offersNum": 310415,
209
- "modelsNum": 2642,
210
- "visual": false,
211
- "type": "nonguru"
212
- }
213
- ],
214
- "total": 22,
215
- "count": 10,
216
- "page": 1
217
- }
218
- }
219
- {
220
- "categories": {
221
- "items": [
222
- {
223
- "id": 7877999,
224
- "name": "Одежда, обувь и аксессуары",
225
- "parentId": 90401,
226
- "childrenCount": 6,
227
- "offersNum": 3473424,
228
- "modelsNum": 0,
229
- "visual": true,
230
- "type": "nonguru"
231
- },
232
- {
233
- "id": 90829,
234
- "name": "Книги",
235
- "parentId": 90401,
236
- "childrenCount": 17,
237
- "offersNum": 3425134,
238
- "modelsNum": 0,
239
- "visual": false,
240
- "type": "nonguru"
241
- },
242
- {
243
- "id": 91597,
244
- "name": "Строительство и ремонт",
245
- "parentId": 90401,
246
- "childrenCount": 19,
247
- "offersNum": 1117378,
248
- "modelsNum": 80740,
249
- "visual": false,
250
- "type": "nonguru"
251
- },
252
- {
253
- "id": 90666,
254
- "name": "Все для дома и дачи",
255
- "parentId": 90401,
256
- "childrenCount": 12,
257
- "offersNum": 987600,
258
- "modelsNum": 4116,
259
- "visual": false,
260
- "type": "nonguru"
261
- },
262
- {
263
- "id": 91009,
264
- "name": "Компьютеры",
265
- "parentId": 90401,
266
- "childrenCount": 23,
267
- "offersNum": 912104,
268
- "modelsNum": 72591,
269
- "visual": false,
270
- "type": "nonguru"
271
- },
272
- {
273
- "id": 90402,
274
- "name": "Авто, мото",
275
- "parentId": 90401,
276
- "childrenCount": 18,
277
- "offersNum": 744796,
278
- "modelsNum": 115748,
279
- "visual": false,
280
- "type": "nonguru"
281
- },
282
- {
283
- "id": 91282,
284
- "name": "Подарки, сувениры, цветы",
285
- "parentId": 90401,
286
- "childrenCount": 31,
287
- "offersNum": 476554,
288
- "modelsNum": 94055,
289
- "visual": false,
290
- "type": "guru"
291
- },
292
- {
293
- "id": 91763,
294
- "name": "Оборудование",
295
- "parentId": 90401,
296
- "childrenCount": 24,
297
- "offersNum": 398142,
298
- "modelsNum": 0,
299
- "visual": false,
300
- "type": "nonguru"
301
- },
302
- {
303
- "id": 6179129,
304
- "name": "Мебель",
305
- "parentId": 90401,
306
- "childrenCount": 12,
307
- "offersNum": 375792,
308
- "modelsNum": 1200,
309
- "visual": false,
310
- "type": "nonguru"
311
- },
312
- {
313
- "id": 90722,
314
- "name": "Все для офиса",
315
- "parentId": 90401,
316
- "childrenCount": 5,
317
- "offersNum": 310415,
318
- "modelsNum": 2642,
319
- "visual": false,
320
- "type": "nonguru"
321
- }
322
- ],
323
- "total": 22,
324
- "count": 10,
325
- "page": 1
326
- }
327
- }
328
- {
329
- "categories": {
330
- "items": [
331
- {
332
- "id": 7877999,
333
- "name": "Одежда, обувь и аксессуары",
334
- "parentId": 90401,
335
- "childrenCount": 6,
336
- "offersNum": 3473424,
337
- "modelsNum": 0,
338
- "visual": true,
339
- "type": "nonguru"
340
- },
341
- {
342
- "id": 90829,
343
- "name": "Книги",
344
- "parentId": 90401,
345
- "childrenCount": 17,
346
- "offersNum": 3425134,
347
- "modelsNum": 0,
348
- "visual": false,
349
- "type": "nonguru"
350
- },
351
- {
352
- "id": 91597,
353
- "name": "Строительство и ремонт",
354
- "parentId": 90401,
355
- "childrenCount": 19,
356
- "offersNum": 1117378,
357
- "modelsNum": 80740,
358
- "visual": false,
359
- "type": "nonguru"
360
- },
361
- {
362
- "id": 90666,
363
- "name": "Все для дома и дачи",
364
- "parentId": 90401,
365
- "childrenCount": 12,
366
- "offersNum": 987600,
367
- "modelsNum": 4116,
368
- "visual": false,
369
- "type": "nonguru"
370
- },
371
- {
372
- "id": 91009,
373
- "name": "Компьютеры",
374
- "parentId": 90401,
375
- "childrenCount": 23,
376
- "offersNum": 912104,
377
- "modelsNum": 72591,
378
- "visual": false,
379
- "type": "nonguru"
380
- },
381
- {
382
- "id": 90402,
383
- "name": "Авто, мото",
384
- "parentId": 90401,
385
- "childrenCount": 18,
386
- "offersNum": 744796,
387
- "modelsNum": 115748,
388
- "visual": false,
389
- "type": "nonguru"
390
- },
391
- {
392
- "id": 91282,
393
- "name": "Подарки, сувениры, цветы",
394
- "parentId": 90401,
395
- "childrenCount": 31,
396
- "offersNum": 476554,
397
- "modelsNum": 94055,
398
- "visual": false,
399
- "type": "guru"
400
- },
401
- {
402
- "id": 91763,
403
- "name": "Оборудование",
404
- "parentId": 90401,
405
- "childrenCount": 24,
406
- "offersNum": 398142,
407
- "modelsNum": 0,
408
- "visual": false,
409
- "type": "nonguru"
410
- },
411
- {
412
- "id": 6179129,
413
- "name": "Мебель",
414
- "parentId": 90401,
415
- "childrenCount": 12,
416
- "offersNum": 375792,
417
- "modelsNum": 1200,
418
- "visual": false,
419
- "type": "nonguru"
420
- },
421
- {
422
- "id": 90722,
423
- "name": "Все для офиса",
424
- "parentId": 90401,
425
- "childrenCount": 5,
426
- "offersNum": 310415,
427
- "modelsNum": 2642,
428
- "visual": false,
429
- "type": "nonguru"
430
- }
114
+
431
115
  ],
432
116
  "total": 22,
433
117
  "count": 10,
@@ -0,0 +1,12 @@
1
+ {
2
+ "category": {
3
+ "id": 7877999,
4
+ "name": "Одежда, обувь и аксессуары",
5
+ "parentId": 90401,
6
+ "childrenCount": 6,
7
+ "offersNum": 3473424,
8
+ "modelsNum": 0,
9
+ "visual": true,
10
+ "type": "nonguru"
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "georegion":
3
+ {
4
+ "id":225,
5
+ "name":"Россия",
6
+ "parentId":10001,
7
+ "childrenCount":10,
8
+ "type":"COUNTRY"
9
+ }
10
+ }
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ class CategoryResourceTest < TestCase
4
+
5
+ def setup
6
+ standard_configuration
7
+ @client = YandexMarketApiClient.get_client
8
+
9
+ @return = { headers: {
10
+ 'Authorization' => YandexMarketApiClient.config.auth_key,
11
+ "content-type" => "application/json; charset=utf-8"
12
+ } }
13
+ @categories_url = YandexMarketApiClient.config.host + "/v1/%s"
14
+ @category_url = @categories_url % 'category/%s'
15
+ end
16
+
17
+ def test_getting_all_categories
18
+ stub = stub_request(:get, @categories_url % "category" + ".json").
19
+ with(query: { geo_id: 1, page: 1, count: 1 }).
20
+ to_return(@return.merge(body: load_fixture('categories.json')))
21
+
22
+ @client.categories(geo_id: 1, page: 1, count: 1).perform.parse
23
+
24
+ assert_requested stub
25
+ end
26
+
27
+ def test_getting_all_categories
28
+ stub = stub_request(:get, @category_url % "1" + ".json").
29
+ with(query: { geo_id: 1 }).
30
+ to_return(@return.merge(body: load_fixture('category.json')))
31
+
32
+ @client.category(geo_id: 1, category_id: 1).perform.parse
33
+
34
+ assert_requested stub
35
+ end
36
+ end
@@ -21,4 +21,14 @@ class GeoregionResourceTest < TestCase
21
21
 
22
22
  assert_requested stub
23
23
  end
24
+
25
+ def test_getting_one_georegion
26
+ stub = stub_request(:get, @georegions_url % "georegion/1" + ".json").
27
+ to_return(@return.merge(body: load_fixture('georegion.json')))
28
+
29
+ @client.region(geo_id: 1).perform.parse
30
+
31
+ assert_requested stub
32
+ end
33
+
24
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex_market_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kuznetsov
@@ -56,9 +56,12 @@ files:
56
56
  - lib/yandex_market_api_client/config.rb
57
57
  - lib/yandex_market_api_client/version.rb
58
58
  - test/fixtures/categories.json
59
+ - test/fixtures/category.json
60
+ - test/fixtures/georegion.json
59
61
  - test/fixtures/georegions.json
60
62
  - test/helpers/configuration_helper.rb
61
63
  - test/helpers/fixtures_helper.rb
64
+ - test/lib/yandex_market_api_client/category_resource_test.rb
62
65
  - test/lib/yandex_market_api_client/client_test.rb
63
66
  - test/lib/yandex_market_api_client/georegion_resource_test.rb
64
67
  - test/test_helper.rb
@@ -89,9 +92,12 @@ summary: It's a wrapper for YandexMarket Api calls written in Ruby. Useful for c
89
92
  having authoriztion key from Yandex.
90
93
  test_files:
91
94
  - test/fixtures/categories.json
95
+ - test/fixtures/category.json
96
+ - test/fixtures/georegion.json
92
97
  - test/fixtures/georegions.json
93
98
  - test/helpers/configuration_helper.rb
94
99
  - test/helpers/fixtures_helper.rb
100
+ - test/lib/yandex_market_api_client/category_resource_test.rb
95
101
  - test/lib/yandex_market_api_client/client_test.rb
96
102
  - test/lib/yandex_market_api_client/georegion_resource_test.rb
97
103
  - test/test_helper.rb