yandex_market_api_client 0.0.2 → 0.0.3

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: da51acba1ff223d1f47bc00a6f36a0d1b6d31fba
4
- data.tar.gz: e67e452371aa4adb2d43d7589bab649dcf461ad0
3
+ metadata.gz: 3db6965d41da0cadb9aea2474f1fab8a4e80ebb7
4
+ data.tar.gz: f3109c0be041d2f2798b4d7947a2b6c99cab2578
5
5
  SHA512:
6
- metadata.gz: c956c9d1fd008ad7737f28f55051947e2f021c9c3f104f5ce21cb721d2d756d1dd904df78b1dc606f611e2af143e14fc72ef53d904443764a13b4b400eda8439
7
- data.tar.gz: c9e39f57f6c18d42f12aa2c1f8c72da7b116e45f4b9a981faf639b2663698deb09e68fcdd8242f7dfc913f04254b53435f77ecb4ad54ffb8af2f21ffb972cfd5
6
+ metadata.gz: b1cc8712ecf54cff4ae5472c7f4f4d5cc749e558fde60f27c29fa91a6956c267b3e163ff989b96bc7eff216cb961bffea773756f67a612e3445f88698310d1a6
7
+ data.tar.gz: d33b8e2c66c66a45a4feae503558baa27d9e608081bde77f8e809acd89120e179d96e2ebec9c5997cb60ba0ed494ed8d651fb1994ee36e7b43c7d9d3e75fa24f
@@ -18,10 +18,20 @@ module YandexMarketApiClient
18
18
 
19
19
  get :categories, "/v#{config.api_version}/category.#{format}" do |resource|
20
20
  resource.optional :page, :count, :sort
21
+ resource.required :geo_id
21
22
  end
22
23
 
23
24
  get :category, "/v#{config.api_version}/category/{category_id}.#{format}" do |resource|
24
25
  resource.optional :page, :count, :sort
26
+ resource.required :geo_id
27
+ end
28
+
29
+ get :regions, "/v#{config.api_version}/georegion.#{format}" do |resource|
30
+ resource.optional :page, :count
31
+ end
32
+
33
+ get :region, "/v#{config.api_version}/georegion/{geo_id}.#{format}" do |resource|
34
+ resource.optional :page, :count
25
35
  end
26
36
  end
27
37
  end
@@ -1,6 +1,7 @@
1
1
  module YandexMarketApiClient
2
2
  class Config
3
- attr_accessor :auth_key, :api_version, :default_format
3
+ # `host` accessor for tests only
4
+ attr_accessor :auth_key, :api_version, :default_format, :host
4
5
 
5
6
  def api_version
6
7
  @api_version ||= "1"
@@ -1,3 +1,3 @@
1
1
  module YandexMarketApiClient
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,436 @@
1
+ {
2
+ "categories": {
3
+ "items": [
4
+ {
5
+ "id": 7877999,
6
+ "name": "Одежда, обувь и аксессуары",
7
+ "parentId": 90401,
8
+ "childrenCount": 6,
9
+ "offersNum": 3473424,
10
+ "modelsNum": 0,
11
+ "visual": true,
12
+ "type": "nonguru"
13
+ },
14
+ {
15
+ "id": 90829,
16
+ "name": "Книги",
17
+ "parentId": 90401,
18
+ "childrenCount": 17,
19
+ "offersNum": 3425134,
20
+ "modelsNum": 0,
21
+ "visual": false,
22
+ "type": "nonguru"
23
+ },
24
+ {
25
+ "id": 91597,
26
+ "name": "Строительство и ремонт",
27
+ "parentId": 90401,
28
+ "childrenCount": 19,
29
+ "offersNum": 1117378,
30
+ "modelsNum": 80740,
31
+ "visual": false,
32
+ "type": "nonguru"
33
+ },
34
+ {
35
+ "id": 90666,
36
+ "name": "Все для дома и дачи",
37
+ "parentId": 90401,
38
+ "childrenCount": 12,
39
+ "offersNum": 987600,
40
+ "modelsNum": 4116,
41
+ "visual": false,
42
+ "type": "nonguru"
43
+ },
44
+ {
45
+ "id": 91009,
46
+ "name": "Компьютеры",
47
+ "parentId": 90401,
48
+ "childrenCount": 23,
49
+ "offersNum": 912104,
50
+ "modelsNum": 72591,
51
+ "visual": false,
52
+ "type": "nonguru"
53
+ },
54
+ {
55
+ "id": 90402,
56
+ "name": "Авто, мото",
57
+ "parentId": 90401,
58
+ "childrenCount": 18,
59
+ "offersNum": 744796,
60
+ "modelsNum": 115748,
61
+ "visual": false,
62
+ "type": "nonguru"
63
+ },
64
+ {
65
+ "id": 91282,
66
+ "name": "Подарки, сувениры, цветы",
67
+ "parentId": 90401,
68
+ "childrenCount": 31,
69
+ "offersNum": 476554,
70
+ "modelsNum": 94055,
71
+ "visual": false,
72
+ "type": "guru"
73
+ },
74
+ {
75
+ "id": 91763,
76
+ "name": "Оборудование",
77
+ "parentId": 90401,
78
+ "childrenCount": 24,
79
+ "offersNum": 398142,
80
+ "modelsNum": 0,
81
+ "visual": false,
82
+ "type": "nonguru"
83
+ },
84
+ {
85
+ "id": 6179129,
86
+ "name": "Мебель",
87
+ "parentId": 90401,
88
+ "childrenCount": 12,
89
+ "offersNum": 375792,
90
+ "modelsNum": 1200,
91
+ "visual": false,
92
+ "type": "nonguru"
93
+ },
94
+ {
95
+ "id": 90722,
96
+ "name": "Все для офиса",
97
+ "parentId": 90401,
98
+ "childrenCount": 5,
99
+ "offersNum": 310415,
100
+ "modelsNum": 2642,
101
+ "visual": false,
102
+ "type": "nonguru"
103
+ }
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
+ }
431
+ ],
432
+ "total": 22,
433
+ "count": 10,
434
+ "page": 1
435
+ }
436
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "georegions": {
3
+ "page": 1,
4
+ "count": 4,
5
+ "total": 4,
6
+ "items": [
7
+ {
8
+ "id": 225,
9
+ "name": "Россия",
10
+ "parentId": 10001,
11
+ "childrenCount": 10,
12
+ "type": "COUNTRY"
13
+ },
14
+ {
15
+ "id": 187,
16
+ "name": "Украина",
17
+ "parentId": 166,
18
+ "childrenCount": 8,
19
+ "type": "COUNTRY"
20
+ },
21
+ {
22
+ "id": 159,
23
+ "name": "Казахстан",
24
+ "parentId": 166,
25
+ "childrenCount": 16,
26
+ "type": "COUNTRY"
27
+ },
28
+ {
29
+ "id": 149,
30
+ "name": "Беларусь",
31
+ "parentId": 166,
32
+ "childrenCount": 8,
33
+ "type": "COUNTRY"
34
+ }
35
+ ]
36
+ }
37
+ }
@@ -0,0 +1,10 @@
1
+ module ConfigurationHelper
2
+
3
+ def standard_configuration
4
+ YandexMarketApiClient.configure do |config|
5
+ config.auth_key = "123"
6
+ config.api_version = "1"
7
+ config.host = "http://test.com"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module FixturesHelper
2
+
3
+ def load_fixture(filename)
4
+ File.read(File.dirname(__FILE__) + "/../" + "fixtures/#{filename}")
5
+ end
6
+ end
@@ -3,10 +3,7 @@ require 'test_helper'
3
3
  class ClientTest < TestCase
4
4
 
5
5
  def setup
6
- YandexMarketApiClient.configure do |config|
7
- config.auth_key = "123"
8
- config.api_version = "1"
9
- end
6
+ standard_configuration
10
7
  end
11
8
 
12
9
  def test_should_get_instance
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class GeoregionResourceTest < 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
+ @georegions_url = YandexMarketApiClient.config.host + "/v1/%s"
14
+ end
15
+
16
+ def test_getting_all_georegions
17
+ stub = stub_request(:get, @georegions_url % "georegion" + ".json").
18
+ to_return(@return.merge(body: load_fixture('georegions.json')))
19
+
20
+ @client.regions.perform.parse
21
+
22
+ assert_requested stub
23
+ end
24
+ end
data/test/test_helper.rb CHANGED
@@ -3,9 +3,17 @@ Bundler.require
3
3
 
4
4
  require 'minitest/autorun'
5
5
  require 'webmock/minitest'
6
+
7
+ # colorize test output
6
8
  require 'minitest/pride'
7
9
  Minitest::PrideIO.pride!
8
10
 
11
+ # requiring helpers
12
+ Dir[ File.join( File.dirname(__FILE__), "helpers/*.rb")].each { |file| require file }
13
+
9
14
  class TestCase < Minitest::Test
10
15
 
16
+ include ConfigurationHelper
17
+ include FixturesHelper
18
+
11
19
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kuznetsov
@@ -55,7 +55,12 @@ files:
55
55
  - lib/yandex_market_api_client/client.rb
56
56
  - lib/yandex_market_api_client/config.rb
57
57
  - lib/yandex_market_api_client/version.rb
58
+ - test/fixtures/categories.json
59
+ - test/fixtures/georegions.json
60
+ - test/helpers/configuration_helper.rb
61
+ - test/helpers/fixtures_helper.rb
58
62
  - test/lib/yandex_market_api_client/client_test.rb
63
+ - test/lib/yandex_market_api_client/georegion_resource_test.rb
59
64
  - test/test_helper.rb
60
65
  - yandex_market_api_client.gemspec
61
66
  homepage: ''
@@ -83,5 +88,10 @@ specification_version: 4
83
88
  summary: It's a wrapper for YandexMarket Api calls written in Ruby. Useful for clients
84
89
  having authoriztion key from Yandex.
85
90
  test_files:
91
+ - test/fixtures/categories.json
92
+ - test/fixtures/georegions.json
93
+ - test/helpers/configuration_helper.rb
94
+ - test/helpers/fixtures_helper.rb
86
95
  - test/lib/yandex_market_api_client/client_test.rb
96
+ - test/lib/yandex_market_api_client/georegion_resource_test.rb
87
97
  - test/test_helper.rb