contentful-management 0.5.0 → 0.6.0

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: 3ae13b9bb15ea88eab394450ef29325340fe48e8
4
- data.tar.gz: 67bcdac156d68a6d35da893472bc3aa0f4d0f4b7
3
+ metadata.gz: b6df21aeaccae009003052b0d621c6aebf5be57c
4
+ data.tar.gz: d0de855068614ce2b6943d3875f60c6695bac976
5
5
  SHA512:
6
- metadata.gz: 41d3ca3acf06a94f24a08be3e773734b75d90c7f4cd41aa14341aa4ae90252ad749ec97f4fdfb234d29614cf205f44cd4785162fe762fd1e894f3e70d2800393
7
- data.tar.gz: b2e8e16655c8ddbab2e187b7332e8ebf5cfbb5e38d72a1d21fc349214363c6490a738d7d3cb4d3ca46ea0f3f8ceca2c4373b412c307f2c1ab4d1c5b6726262cc
6
+ metadata.gz: c70079bbf7f64d9038af87d0ad0be7790824cd5185a4cf2245104adf655808f30af72086f6d4d3e36a227eacbedc3f4106b263f45fd78dc46c2632eedee27f05
7
+ data.tar.gz: ee42998b120b306b3f795d917763b94f86cbc3c3fd755092b710d47a1ec913d7d2fd31b427e49ad1289ddc71f53f34242fdcb62a4e99bf0291efea466bce1ef4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.6.0
4
+ ### Added
5
+ * Access request and response from Contentful::Management:Error [#46](https://github.com/contentful/contentful-management.rb/pull/46)
6
+ ### Fixed
7
+ * Handle 429 responses as errors [#46](https://github.com/contentful/contentful-management.rb/pull/46)
8
+
3
9
  ## 0.5.0
4
10
  ### Added
5
11
  * Allow setting a default locale when creating a space [#43](https://github.com/contentful/contentful-management.rb/pull/43)
@@ -1,17 +1,22 @@
1
1
  module Contentful
2
2
  module Management
3
- # All errors raised by the contentful gem are either instances of Contentful::Error
4
- # or inherit from Contentful::Error
3
+ # All errors raised by the contentful gem are either instances of Contentful::Management::Error
4
+ # or inherit from Contentful::Management::Error
5
5
  class Error < StandardError
6
- attr_reader :response
6
+ attr_reader :response, :error
7
7
 
8
8
  def initialize(response)
9
9
  @response = response
10
+ @error = {
11
+ url: response.request.endpoint,
12
+ message: response.error_message,
13
+ details: response.raw.body.instance_variable_get(:@contents)
14
+ }
10
15
  super @response.error_message
11
16
  end
12
17
 
13
18
  # Shortcut for creating specialized error classes
14
- # USAGE rescue Contentful::Error[404]
19
+ # USAGE rescue Contentful::Management::Error[404]
15
20
  def self.[](error_status_code)
16
21
  case error_status_code
17
22
  when 404
@@ -26,6 +31,8 @@ module Contentful
26
31
  Unauthorized
27
32
  when 422
28
33
  UnprocessableEntity
34
+ when 429
35
+ RateLimitExceeded
29
36
  when 500
30
37
  ServerError
31
38
  when 503
@@ -55,11 +62,15 @@ module Contentful
55
62
  # 409
56
63
  class Conflict < Error
57
64
  end
58
-
65
+
59
66
  # 422
60
67
  class UnprocessableEntity < Error
61
68
  end
62
69
 
70
+ # 429
71
+ class RateLimitExceeded < Error
72
+ end
73
+
63
74
  # 500
64
75
  class ServerError < Error
65
76
  end
@@ -72,7 +83,7 @@ module Contentful
72
83
  class UnparsableJson < Error
73
84
  end
74
85
 
75
- # Raised when response is not parsable as a Contentful::Resource
86
+ # Raised when response is not parsable as a Contentful::Management::Resource
76
87
  class UnparsableResource < Error
77
88
  end
78
89
  end
@@ -4,7 +4,7 @@ module Contentful
4
4
  # with domain specific logic. The client later uses the Request's #url and #query methods
5
5
  # to execute the HTTP request.
6
6
  class Request
7
- attr_reader :client, :type, :query, :id
7
+ attr_reader :client, :type, :query, :id, :endpoint
8
8
 
9
9
  def initialize(endpoint, query = {}, id = nil, header = {})
10
10
  @header = header
@@ -61,7 +61,7 @@ module Contentful
61
61
  end
62
62
 
63
63
  def resource_error?
64
- [400, 404, 422].include?(raw.status)
64
+ [400, 404, 422, 429].include?(raw.status)
65
65
  end
66
66
 
67
67
  def no_content_response?
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Management
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -0,0 +1,732 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/286arvy86ry9
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.5.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Host:
19
+ - api.contentful.com
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Accept-Ranges:
26
+ - bytes
27
+ Access-Control-Allow-Headers:
28
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
29
+ Access-Control-Allow-Methods:
30
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Access-Control-Expose-Headers:
34
+ - Etag
35
+ Access-Control-Max-Age:
36
+ - '1728000'
37
+ Cache-Control:
38
+ - max-age=0
39
+ Content-Type:
40
+ - application/vnd.contentful.management.v1+json
41
+ Date:
42
+ - Thu, 18 Dec 2014 12:21:23 GMT
43
+ Etag:
44
+ - '"91d2291b87bce2aa62bc5aeadb61793a"'
45
+ Server:
46
+ - nginx
47
+ Status:
48
+ - 200 OK
49
+ X-Contentful-Request-Id:
50
+ - f1c-653450314
51
+ Content-Length:
52
+ - '453'
53
+ Connection:
54
+ - keep-alive
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ {
59
+ "sys":{
60
+ "type":"Space",
61
+ "id":"286arvy86ry9",
62
+ "version":1,
63
+ "createdBy":{
64
+ "sys":{
65
+ "type":"Link",
66
+ "linkType":"User",
67
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
68
+ }
69
+ },
70
+ "createdAt":"2014-12-15T08:12:42Z",
71
+ "updatedBy":{
72
+ "sys":{
73
+ "type":"Link",
74
+ "linkType":"User",
75
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
76
+ }
77
+ },
78
+ "updatedAt":"2014-12-15T08:12:42Z"
79
+ },
80
+ "name":"TestingRspec"}
81
+ http_version:
82
+ recorded_at: Thu, 18 Dec 2014 12:21:23 GMT
83
+ - request:
84
+ method: get
85
+ uri: https://api.contentful.com/spaces/286arvy86ry9/content_types
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ''
89
+ headers:
90
+ User-Agent:
91
+ - RubyContentfulManagementGem/0.5.0
92
+ Authorization:
93
+ - Bearer <ACCESS_TOKEN>
94
+ Content-Type:
95
+ - application/vnd.contentful.management.v1+json
96
+ Content-Length:
97
+ - '0'
98
+ Host:
99
+ - api.contentful.com
100
+ response:
101
+ status:
102
+ code: 200
103
+ message: OK
104
+ headers:
105
+ Access-Control-Allow-Headers:
106
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
107
+ Access-Control-Allow-Methods:
108
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
109
+ Access-Control-Allow-Origin:
110
+ - "*"
111
+ Access-Control-Expose-Headers:
112
+ - Etag
113
+ Access-Control-Max-Age:
114
+ - '1728000'
115
+ Cf-Space-Id:
116
+ - 286arvy86ry9
117
+ Content-Type:
118
+ - application/vnd.contentful.management.v1+json
119
+ Date:
120
+ - Thu, 18 Dec 2014 12:21:23 GMT
121
+ Etag:
122
+ - '"0042a1083a298261f6f010e5e28a8f1f"'
123
+ Server:
124
+ - nginx
125
+ X-Powered-By:
126
+ - Express
127
+ Content-Length:
128
+ - '4644'
129
+ Connection:
130
+ - keep-alive
131
+ body:
132
+ encoding: UTF-8
133
+ string: |
134
+ {
135
+ "sys": {
136
+ "type": "Array"
137
+ },
138
+ "total": 3,
139
+ "skip": 0,
140
+ "limit": 100,
141
+ "items": [
142
+ {
143
+ "fields": [
144
+ {
145
+ "name": "text",
146
+ "id": "text",
147
+ "type": "Text"
148
+ },
149
+ {
150
+ "name": "number2",
151
+ "id": "number2",
152
+ "type": "Integer"
153
+ },
154
+ {
155
+ "name": "entry2",
156
+ "id": "entry2",
157
+ "type": "Link",
158
+ "linkType": "Entry"
159
+ }
160
+ ],
161
+ "name": "Test2",
162
+ "sys": {
163
+ "id": "4dsDWisVl6WAAYuk60E4QC",
164
+ "type": "ContentType",
165
+ "createdAt": "2014-12-15T08:13:47.342Z",
166
+ "createdBy": {
167
+ "sys": {
168
+ "type": "Link",
169
+ "linkType": "User",
170
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
171
+ }
172
+ },
173
+ "space": {
174
+ "sys": {
175
+ "type": "Link",
176
+ "linkType": "Space",
177
+ "id": "286arvy86ry9"
178
+ }
179
+ },
180
+ "firstPublishedAt": "2014-12-15T08:14:20.807Z",
181
+ "publishedCounter": 1,
182
+ "publishedAt": "2014-12-15T08:14:20.807Z",
183
+ "publishedBy": {
184
+ "sys": {
185
+ "type": "Link",
186
+ "linkType": "User",
187
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
188
+ }
189
+ },
190
+ "publishedVersion": 39,
191
+ "version": 40,
192
+ "updatedAt": "2014-12-15T08:14:20.852Z",
193
+ "updatedBy": {
194
+ "sys": {
195
+ "type": "Link",
196
+ "linkType": "User",
197
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
198
+ }
199
+ }
200
+ },
201
+ "description": "test",
202
+ "displayField": "text"
203
+ },
204
+ {
205
+ "fields": [
206
+ {
207
+ "name": "name",
208
+ "id": "name",
209
+ "type": "Text"
210
+ },
211
+ {
212
+ "name": "number",
213
+ "id": "number",
214
+ "type": "Integer"
215
+ },
216
+ {
217
+ "name": "entry",
218
+ "id": "entry",
219
+ "type": "Link",
220
+ "linkType": "Entry",
221
+ "validations": [
222
+ {
223
+ "linkContentType": [
224
+ "4dsDWisVl6WAAYuk60E4QC"
225
+ ]
226
+ }
227
+ ]
228
+ }
229
+ ],
230
+ "name": "Test1",
231
+ "sys": {
232
+ "id": "5lIEiXrCIoKoIKaSW2C8aa",
233
+ "type": "ContentType",
234
+ "createdAt": "2014-12-15T08:13:15.767Z",
235
+ "createdBy": {
236
+ "sys": {
237
+ "type": "Link",
238
+ "linkType": "User",
239
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
240
+ }
241
+ },
242
+ "space": {
243
+ "sys": {
244
+ "type": "Link",
245
+ "linkType": "Space",
246
+ "id": "286arvy86ry9"
247
+ }
248
+ },
249
+ "firstPublishedAt": "2014-12-15T08:13:43.070Z",
250
+ "publishedCounter": 2,
251
+ "publishedAt": "2014-12-18T12:02:02.366Z",
252
+ "publishedBy": {
253
+ "sys": {
254
+ "type": "Link",
255
+ "linkType": "User",
256
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
257
+ }
258
+ },
259
+ "publishedVersion": 30,
260
+ "version": 31,
261
+ "updatedAt": "2014-12-18T12:02:02.409Z",
262
+ "updatedBy": {
263
+ "sys": {
264
+ "type": "Link",
265
+ "linkType": "User",
266
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
267
+ }
268
+ }
269
+ },
270
+ "description": "test1",
271
+ "displayField": "name"
272
+ },
273
+ {
274
+ "fields": [
275
+ {
276
+ "name": "name",
277
+ "id": "name",
278
+ "type": "Text",
279
+ "validations": [
280
+ {
281
+ "size": {
282
+ "min": 1,
283
+ "max": 2
284
+ }
285
+ }
286
+ ]
287
+ }
288
+ ],
289
+ "name": "Test3",
290
+ "sys": {
291
+ "id": "2PqKsSmwKASkM6sWiqMuqi",
292
+ "type": "ContentType",
293
+ "createdAt": "2014-12-18T12:01:49.830Z",
294
+ "createdBy": {
295
+ "sys": {
296
+ "type": "Link",
297
+ "linkType": "User",
298
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
299
+ }
300
+ },
301
+ "space": {
302
+ "sys": {
303
+ "type": "Link",
304
+ "linkType": "Space",
305
+ "id": "286arvy86ry9"
306
+ }
307
+ },
308
+ "firstPublishedAt": "2014-12-18T12:01:59.077Z",
309
+ "publishedCounter": 2,
310
+ "publishedAt": "2014-12-18T12:16:31.529Z",
311
+ "publishedBy": {
312
+ "sys": {
313
+ "type": "Link",
314
+ "linkType": "User",
315
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
316
+ }
317
+ },
318
+ "publishedVersion": 14,
319
+ "version": 15,
320
+ "updatedAt": "2014-12-18T12:16:31.576Z",
321
+ "updatedBy": {
322
+ "sys": {
323
+ "type": "Link",
324
+ "linkType": "User",
325
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
326
+ }
327
+ }
328
+ },
329
+ "displayField": "name"
330
+ }
331
+ ]
332
+ }
333
+ http_version:
334
+ recorded_at: Thu, 18 Dec 2014 12:21:23 GMT
335
+ - request:
336
+ method: get
337
+ uri: https://api.contentful.com/spaces/286arvy86ry9/entries/1YNepnMpXGiMWikaKC4GG0
338
+ body:
339
+ encoding: US-ASCII
340
+ string: ''
341
+ headers:
342
+ User-Agent:
343
+ - RubyContentfulManagementGem/0.5.0
344
+ Authorization:
345
+ - Bearer <ACCESS_TOKEN>
346
+ Content-Type:
347
+ - application/vnd.contentful.management.v1+json
348
+ Content-Length:
349
+ - '0'
350
+ Host:
351
+ - api.contentful.com
352
+ response:
353
+ status:
354
+ code: 200
355
+ message: OK
356
+ headers:
357
+ Access-Control-Allow-Headers:
358
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
359
+ Access-Control-Allow-Methods:
360
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
361
+ Access-Control-Allow-Origin:
362
+ - "*"
363
+ Access-Control-Expose-Headers:
364
+ - Etag
365
+ Access-Control-Max-Age:
366
+ - '1728000'
367
+ Cf-Space-Id:
368
+ - 286arvy86ry9
369
+ Content-Type:
370
+ - application/vnd.contentful.management.v1+json
371
+ Date:
372
+ - Thu, 18 Dec 2014 12:21:24 GMT
373
+ Etag:
374
+ - '"9458b849a96cdf2ff9d50bffce2300ee"'
375
+ Server:
376
+ - nginx
377
+ X-Powered-By:
378
+ - Express
379
+ Content-Length:
380
+ - '1105'
381
+ Connection:
382
+ - keep-alive
383
+ body:
384
+ encoding: UTF-8
385
+ string: |
386
+ {
387
+ "sys": {
388
+ "id": "1YNepnMpXGiMWikaKC4GG0",
389
+ "type": "Entry",
390
+ "createdAt": "2014-12-18T12:02:39.207Z",
391
+ "createdBy": {
392
+ "sys": {
393
+ "type": "Link",
394
+ "linkType": "User",
395
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
396
+ }
397
+ },
398
+ "space": {
399
+ "sys": {
400
+ "type": "Link",
401
+ "linkType": "Space",
402
+ "id": "286arvy86ry9"
403
+ }
404
+ },
405
+ "contentType": {
406
+ "sys": {
407
+ "type": "Link",
408
+ "linkType": "ContentType",
409
+ "id": "2PqKsSmwKASkM6sWiqMuqi"
410
+ }
411
+ },
412
+ "firstPublishedAt": "2014-12-18T12:02:49.757Z",
413
+ "publishedCounter": 1,
414
+ "publishedAt": "2014-12-18T12:02:49.757Z",
415
+ "publishedBy": {
416
+ "sys": {
417
+ "type": "Link",
418
+ "linkType": "User",
419
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
420
+ }
421
+ },
422
+ "publishedVersion": 18,
423
+ "version": 19,
424
+ "updatedAt": "2014-12-18T12:02:49.806Z",
425
+ "updatedBy": {
426
+ "sys": {
427
+ "type": "Link",
428
+ "linkType": "User",
429
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
430
+ }
431
+ }
432
+ },
433
+ "fields": {
434
+ "name": {
435
+ "en-US": "Entry Test 3"
436
+ }
437
+ }
438
+ }
439
+ http_version:
440
+ recorded_at: Thu, 18 Dec 2014 12:21:24 GMT
441
+ - request:
442
+ method: get
443
+ uri: https://api.contentful.com/spaces/286arvy86ry9/content_types/5lIEiXrCIoKoIKaSW2C8aa
444
+ body:
445
+ encoding: US-ASCII
446
+ string: ''
447
+ headers:
448
+ User-Agent:
449
+ - RubyContentfulManagementGem/0.5.0
450
+ Authorization:
451
+ - Bearer <ACCESS_TOKEN>
452
+ Content-Type:
453
+ - application/vnd.contentful.management.v1+json
454
+ Content-Length:
455
+ - '0'
456
+ Host:
457
+ - api.contentful.com
458
+ response:
459
+ status:
460
+ code: 200
461
+ message: OK
462
+ headers:
463
+ Access-Control-Allow-Headers:
464
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
465
+ Access-Control-Allow-Methods:
466
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
467
+ Access-Control-Allow-Origin:
468
+ - "*"
469
+ Access-Control-Expose-Headers:
470
+ - Etag
471
+ Access-Control-Max-Age:
472
+ - '1728000'
473
+ Cf-Space-Id:
474
+ - 286arvy86ry9
475
+ Content-Type:
476
+ - application/vnd.contentful.management.v1+json
477
+ Date:
478
+ - Thu, 18 Dec 2014 12:21:24 GMT
479
+ Etag:
480
+ - '"bf0d1213c4389c275fe7d30e0e84631a"'
481
+ Server:
482
+ - nginx
483
+ X-Powered-By:
484
+ - Express
485
+ Content-Length:
486
+ - '1378'
487
+ Connection:
488
+ - keep-alive
489
+ body:
490
+ encoding: UTF-8
491
+ string: |
492
+ {
493
+ "fields": [
494
+ {
495
+ "name": "name",
496
+ "id": "name",
497
+ "type": "Text"
498
+ },
499
+ {
500
+ "name": "number",
501
+ "id": "number",
502
+ "type": "Integer"
503
+ },
504
+ {
505
+ "name": "entry",
506
+ "id": "entry",
507
+ "type": "Link",
508
+ "linkType": "Entry",
509
+ "validations": [
510
+ {
511
+ "linkContentType": [
512
+ "4dsDWisVl6WAAYuk60E4QC"
513
+ ]
514
+ }
515
+ ]
516
+ }
517
+ ],
518
+ "name": "Test1",
519
+ "sys": {
520
+ "id": "5lIEiXrCIoKoIKaSW2C8aa",
521
+ "type": "ContentType",
522
+ "createdAt": "2014-12-15T08:13:15.767Z",
523
+ "createdBy": {
524
+ "sys": {
525
+ "type": "Link",
526
+ "linkType": "User",
527
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
528
+ }
529
+ },
530
+ "space": {
531
+ "sys": {
532
+ "type": "Link",
533
+ "linkType": "Space",
534
+ "id": "286arvy86ry9"
535
+ }
536
+ },
537
+ "firstPublishedAt": "2014-12-15T08:13:43.070Z",
538
+ "publishedCounter": 2,
539
+ "publishedAt": "2014-12-18T12:02:02.366Z",
540
+ "publishedBy": {
541
+ "sys": {
542
+ "type": "Link",
543
+ "linkType": "User",
544
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
545
+ }
546
+ },
547
+ "publishedVersion": 30,
548
+ "version": 31,
549
+ "updatedAt": "2014-12-18T12:02:02.409Z",
550
+ "updatedBy": {
551
+ "sys": {
552
+ "type": "Link",
553
+ "linkType": "User",
554
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
555
+ }
556
+ }
557
+ },
558
+ "description": "test1",
559
+ "displayField": "name"
560
+ }
561
+ http_version:
562
+ recorded_at: Thu, 18 Dec 2014 12:21:25 GMT
563
+ - request:
564
+ method: post
565
+ uri: https://api.contentful.com/spaces/286arvy86ry9/entries/
566
+ body:
567
+ encoding: UTF-8
568
+ string: '{"fields":{"name":{"en-US":"Create test"},"entry":{"en-US":{"sys":{"type":"Link","linkType":"Entry","id":"1YNepnMpXGiMWikaKC4GG0"}}}}}'
569
+ headers:
570
+ User-Agent:
571
+ - RubyContentfulManagementGem/0.5.0
572
+ Authorization:
573
+ - Bearer <ACCESS_TOKEN>
574
+ Content-Type:
575
+ - application/vnd.contentful.management.v1+json
576
+ X-Contentful-Content-Type:
577
+ - 5lIEiXrCIoKoIKaSW2C8aa
578
+ Host:
579
+ - api.contentful.com
580
+ response:
581
+ status:
582
+ code: 201
583
+ message: Created
584
+ headers:
585
+ Access-Control-Allow-Headers:
586
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
587
+ Access-Control-Allow-Methods:
588
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
589
+ Access-Control-Allow-Origin:
590
+ - "*"
591
+ Access-Control-Expose-Headers:
592
+ - Etag
593
+ Access-Control-Max-Age:
594
+ - '1728000'
595
+ Cf-Space-Id:
596
+ - 286arvy86ry9
597
+ Content-Type:
598
+ - application/vnd.contentful.management.v1+json
599
+ Date:
600
+ - Thu, 18 Dec 2014 12:21:26 GMT
601
+ Etag:
602
+ - '"50fcfbbef32b283c8528932f23a158ec"'
603
+ Server:
604
+ - nginx
605
+ X-Powered-By:
606
+ - Express
607
+ Content-Length:
608
+ - '979'
609
+ Connection:
610
+ - keep-alive
611
+ body:
612
+ encoding: UTF-8
613
+ string: |
614
+ {
615
+ "fields": {
616
+ "name": {
617
+ "en-US": "Create test"
618
+ },
619
+ "entry": {
620
+ "en-US": {
621
+ "sys": {
622
+ "type": "Link",
623
+ "linkType": "Entry",
624
+ "id": "1YNepnMpXGiMWikaKC4GG0"
625
+ }
626
+ }
627
+ }
628
+ },
629
+ "sys": {
630
+ "id": "7cMVEy1toAWaMKUYsSAmC4",
631
+ "type": "Entry",
632
+ "version": 1,
633
+ "createdAt": "2014-12-18T12:21:26.306Z",
634
+ "createdBy": {
635
+ "sys": {
636
+ "type": "Link",
637
+ "linkType": "User",
638
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
639
+ }
640
+ },
641
+ "space": {
642
+ "sys": {
643
+ "type": "Link",
644
+ "linkType": "Space",
645
+ "id": "286arvy86ry9"
646
+ }
647
+ },
648
+ "contentType": {
649
+ "sys": {
650
+ "type": "Link",
651
+ "linkType": "ContentType",
652
+ "id": "5lIEiXrCIoKoIKaSW2C8aa"
653
+ }
654
+ },
655
+ "updatedAt": "2014-12-18T12:21:26.306Z",
656
+ "updatedBy": {
657
+ "sys": {
658
+ "type": "Link",
659
+ "linkType": "User",
660
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
661
+ }
662
+ }
663
+ }
664
+ }
665
+ http_version:
666
+ recorded_at: Thu, 18 Dec 2014 12:21:26 GMT
667
+ - request:
668
+ method: put
669
+ uri: https://api.contentful.com/spaces/286arvy86ry9/entries/7cMVEy1toAWaMKUYsSAmC4/published
670
+ body:
671
+ encoding: US-ASCII
672
+ string: ''
673
+ headers:
674
+ User-Agent:
675
+ - RubyContentfulManagementGem/0.5.0
676
+ Authorization:
677
+ - Bearer <ACCESS_TOKEN>
678
+ Content-Type:
679
+ - application/vnd.contentful.management.v1+json
680
+ X-Contentful-Version:
681
+ - '1'
682
+ Content-Length:
683
+ - '0'
684
+ Host:
685
+ - api.contentful.com
686
+ response:
687
+ status:
688
+ code: 429
689
+ message: Rate Limit Exceeded
690
+ headers:
691
+ Access-Control-Allow-Headers:
692
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation
693
+ Access-Control-Allow-Methods:
694
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
695
+ Access-Control-Allow-Origin:
696
+ - "*"
697
+ Access-Control-Expose-Headers:
698
+ - Etag
699
+ Access-Control-Max-Age:
700
+ - '1728000'
701
+ Content-Type:
702
+ - application/vnd.contentful.management.v1+json
703
+ Date:
704
+ - Thu, 18 Dec 2014 12:21:27 GMT
705
+ Server:
706
+ - nginx
707
+ X-Powered-By:
708
+ - Express
709
+ Content-Length:
710
+ - '609'
711
+ Connection:
712
+ - keep-alive
713
+ body:
714
+ encoding: UTF-8
715
+ string: |
716
+ {
717
+ "sys": {
718
+ "type": "Error",
719
+ "id": "RateLimitExceeded"
720
+ },
721
+ "message": "You have exceeded the rate limit of the Organization this Space belongs to by making too many API requests within a short timespan. Please wait a moment before trying the request again.",
722
+ "details": {
723
+ "errors": [
724
+ {
725
+ "details": "You have exceeded the rate limit of the Organization this Space belongs to by making too many API requests within a short timespan. Please wait a moment before trying the request again."
726
+ }
727
+ ]
728
+ }
729
+ }
730
+ http_version:
731
+ recorded_at: Thu, 18 Dec 2014 12:21:27 GMT
732
+ recorded_with: VCR 2.9.3
@@ -104,6 +104,9 @@ module Contentful
104
104
  result = subject.find(space_id, entry_id).unpublish
105
105
  expect(result).to be_kind_of Contentful::Management::BadRequest
106
106
  expect(result.message).to eq 'Not published'
107
+ expect(result.error[:message]).to eq 'Not published'
108
+ expect(result.error[:url]).to eq '/yr5m0jky5hsh/entries/4Rouux8SoUCKwkyCq2I0E0/published'
109
+ expect(result.error[:details]).to eq "{\n \"sys\": {\n \"type\": \"Error\",\n \"id\": \"BadRequest\"\n },\n \"message\": \"Not published\"\n}\n"
107
110
  end
108
111
  end
109
112
  end
@@ -319,6 +322,18 @@ module Contentful
319
322
  expect(entry.name).to eq 'Create test'
320
323
  end
321
324
  end
325
+
326
+ it 'too many requests' do
327
+ vcr('entry/too_many_requests') do
328
+ space = Contentful::Management::Space.find('286arvy86ry9')
329
+ invalid_entry = space.entries.find('1YNepnMpXGiMWikaKC4GG0')
330
+ ct = space.content_types.find('5lIEiXrCIoKoIKaSW2C8aa')
331
+ entry = ct.entries.create(name: 'Create test', entry: invalid_entry)
332
+ publish = entry.publish
333
+ expect(publish).to be_a RateLimitExceeded
334
+ expect(publish.error[:message]).to eq 'You have exceeded the rate limit of the Organization this Space belongs to by making too many API requests within a short timespan. Please wait a moment before trying the request again.'
335
+ end
336
+ end
322
337
  end
323
338
 
324
339
  describe '#update' do
@@ -576,8 +591,6 @@ module Contentful
576
591
  location.lat = 22.44
577
592
  location.lon = 33.33
578
593
  end
579
- # file = Asset.find('ene4qtp2sh7u', '2oNoT3vSAs82SOIQmKe0KG')
580
- # entry_att = Entry.find('ene4qtp2sh7u', '60zYC7nY9GcKGiCYwAs4wm')
581
594
 
582
595
  attributes = {
583
596
  name: 'Test name',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-management
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Protas
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-04 00:00:00.000000000 Z
13
+ date: 2015-01-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -358,6 +358,7 @@ files:
358
358
  - spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml
359
359
  - spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml
360
360
  - spec/fixtures/vcr_cassettes/entry/service_unavailable.yml
361
+ - spec/fixtures/vcr_cassettes/entry/too_many_requests.yml
361
362
  - spec/fixtures/vcr_cassettes/entry/unarchive.yml
362
363
  - spec/fixtures/vcr_cassettes/entry/unarchive_already_unarchived.yml
363
364
  - spec/fixtures/vcr_cassettes/entry/unpublish.yml
@@ -589,6 +590,7 @@ test_files:
589
590
  - spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml
590
591
  - spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml
591
592
  - spec/fixtures/vcr_cassettes/entry/service_unavailable.yml
593
+ - spec/fixtures/vcr_cassettes/entry/too_many_requests.yml
592
594
  - spec/fixtures/vcr_cassettes/entry/unarchive.yml
593
595
  - spec/fixtures/vcr_cassettes/entry/unarchive_already_unarchived.yml
594
596
  - spec/fixtures/vcr_cassettes/entry/unpublish.yml