contentful-management 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -29
  3. data/.rubocop_todo.yml +24 -0
  4. data/.travis.yml +1 -1
  5. data/.yardopts +4 -0
  6. data/CHANGELOG.md +12 -0
  7. data/Gemfile +1 -0
  8. data/Guardfile +39 -34
  9. data/README.md +42 -1
  10. data/Rakefile +2 -0
  11. data/contentful-management.gemspec +2 -1
  12. data/lib/contentful/management/api_key.rb +65 -0
  13. data/lib/contentful/management/array.rb +3 -2
  14. data/lib/contentful/management/asset.rb +124 -58
  15. data/lib/contentful/management/client.rb +60 -19
  16. data/lib/contentful/management/content_type.rb +104 -49
  17. data/lib/contentful/management/content_type_entry_methods_factory.rb +21 -0
  18. data/lib/contentful/management/dynamic_entry.rb +22 -18
  19. data/lib/contentful/management/entry.rb +138 -80
  20. data/lib/contentful/management/error.rb +23 -23
  21. data/lib/contentful/management/field.rb +16 -13
  22. data/lib/contentful/management/http_client.rb +29 -0
  23. data/lib/contentful/management/link.rb +3 -3
  24. data/lib/contentful/management/locale.rb +55 -26
  25. data/lib/contentful/management/location.rb +1 -1
  26. data/lib/contentful/management/request.rb +11 -12
  27. data/lib/contentful/management/resource.rb +27 -12
  28. data/lib/contentful/management/resource/array_like.rb +1 -1
  29. data/lib/contentful/management/resource/asset_fields.rb +1 -0
  30. data/lib/contentful/management/resource/entry_fields.rb +2 -0
  31. data/lib/contentful/management/resource/field_aware.rb +16 -5
  32. data/lib/contentful/management/resource/fields.rb +16 -8
  33. data/lib/contentful/management/resource/refresher.rb +1 -0
  34. data/lib/contentful/management/resource/system_properties.rb +13 -6
  35. data/lib/contentful/management/resource_builder.rb +43 -40
  36. data/lib/contentful/management/space.rb +67 -28
  37. data/lib/contentful/management/space_api_key_methods_factory.rb +15 -0
  38. data/lib/contentful/management/space_asset_methods_factory.rb +4 -0
  39. data/lib/contentful/management/space_association_all_published_method_factory.rb +11 -0
  40. data/lib/contentful/management/space_association_methods_factory.rb +4 -2
  41. data/lib/contentful/management/space_content_type_methods_factory.rb +4 -0
  42. data/lib/contentful/management/space_entry_methods_factory.rb +4 -0
  43. data/lib/contentful/management/space_locale_methods_factory.rb +2 -0
  44. data/lib/contentful/management/space_webhook_methods_factory.rb +2 -0
  45. data/lib/contentful/management/validation.rb +3 -2
  46. data/lib/contentful/management/version.rb +4 -1
  47. data/lib/contentful/management/webhook.rb +42 -21
  48. data/spec/fixtures/vcr_cassettes/api_key/all_for_space.yml +194 -0
  49. data/spec/fixtures/vcr_cassettes/api_key/create_for_space.yml +113 -0
  50. data/spec/fixtures/vcr_cassettes/api_key/find.yml +113 -0
  51. data/spec/fixtures/vcr_cassettes/api_key/find_for_space_not_found.yml +71 -0
  52. data/spec/fixtures/vcr_cassettes/asset/all_public.yml +112 -0
  53. data/spec/fixtures/vcr_cassettes/content_type/all_public.yml +106 -0
  54. data/spec/fixtures/vcr_cassettes/entry/all_public.yml +102 -0
  55. data/spec/fixtures/vcr_cassettes/locale/destroy.yml +330 -0
  56. data/spec/fixtures/vcr_cassettes/locale/update_both.yml +306 -0
  57. data/spec/fixtures/vcr_cassettes/locale/update_code.yml +306 -0
  58. data/spec/fixtures/vcr_cassettes/locale/update_name.yml +306 -0
  59. data/spec/fixtures/vcr_cassettes/space/api_key/all.yml +410 -0
  60. data/spec/fixtures/vcr_cassettes/space/api_key/create.yml +329 -0
  61. data/spec/fixtures/vcr_cassettes/space/api_key/find.yml +329 -0
  62. data/spec/fixtures/vcr_cassettes/space/asset/all_public.yml +328 -0
  63. data/spec/fixtures/vcr_cassettes/space/content_type/all_public.yml +322 -0
  64. data/spec/fixtures/vcr_cassettes/space/entry/all_public.yml +318 -0
  65. data/spec/lib/contentful/management/api_key_spec.rb +55 -0
  66. data/spec/lib/contentful/management/asset_spec.rb +10 -0
  67. data/spec/lib/contentful/management/content_type_spec.rb +10 -0
  68. data/spec/lib/contentful/management/entry_spec.rb +10 -0
  69. data/spec/lib/contentful/management/locale_spec.rb +58 -0
  70. data/spec/lib/contentful/management/space_spec.rb +53 -0
  71. metadata +58 -9
@@ -0,0 +1,113 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.contentful.com/spaces/bjwq7b86vgmm/api_keys
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"testLocalCreate","description":"bg"}'
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.8.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.contentful.com
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
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
+ - Tue, 26 Jan 2016 13:11:04 GMT
43
+ Etag:
44
+ - '"b6d05819f9e0fe1e9b62da6f27ef43df"'
45
+ Location:
46
+ - https://api.contentful.com/spaces/bjwq7b86vgmm/api_keys/1nlVhF1rbb6iLWCdm72QVi
47
+ Server:
48
+ - nginx
49
+ Status:
50
+ - 201 Created
51
+ Strict-Transport-Security:
52
+ - max-age=15768000
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Contentful-Request-Id:
56
+ - 0b5-177692491
57
+ Content-Length:
58
+ - '911'
59
+ Connection:
60
+ - Close
61
+ body:
62
+ encoding: UTF-8
63
+ string: |+
64
+ {
65
+ "sys":{
66
+ "type":"ApiKey",
67
+ "id":"1nlVhF1rbb6iLWCdm72QVi",
68
+ "version":0,
69
+ "space":{
70
+ "sys":{
71
+ "type":"Link",
72
+ "linkType":"Space",
73
+ "id":"bjwq7b86vgmm"
74
+ }
75
+ },
76
+ "createdBy":{
77
+ "sys":{
78
+ "type":"Link",
79
+ "linkType":"User",
80
+ "id":"4SejVrWT96dvL9IV4Nb7sQ"
81
+ }
82
+ },
83
+ "createdAt":"2016-01-26T13:11:03Z",
84
+ "updatedBy":{
85
+ "sys":{
86
+ "type":"Link",
87
+ "linkType":"User",
88
+ "id":"4SejVrWT96dvL9IV4Nb7sQ"
89
+ }
90
+ },
91
+ "updatedAt":"2016-01-26T13:11:03Z"
92
+ },
93
+ "name":"testLocalCreate",
94
+ "description":"bg",
95
+ "accessToken":"b8d6f1bfac699f3eeceb9ee61711d9e1011e7fcbaf6836961e706c3cd49d7751",
96
+ "policies":[
97
+ {
98
+ "effect":"allow",
99
+ "actions":"all"
100
+ }
101
+ ],
102
+ "preview_api_key":{
103
+ "sys":{
104
+ "type":"Link",
105
+ "linkType":"PreviewApiKey",
106
+ "id":"1nnt6zK7H3ePdUZkO3NRII"
107
+ }
108
+ }
109
+ }
110
+
111
+ http_version:
112
+ recorded_at: Tue, 26 Jan 2016 13:11:04 GMT
113
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,113 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/bjwq7b86vgmm/api_keys/6vbW35TjBTc8FyRTAuXZZe
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.8.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - api.contentful.com
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Accept-Ranges:
28
+ - bytes
29
+ Access-Control-Allow-Headers:
30
+ - 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
31
+ Access-Control-Allow-Methods:
32
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Expose-Headers:
36
+ - Etag
37
+ Access-Control-Max-Age:
38
+ - '1728000'
39
+ Cache-Control:
40
+ - max-age=0
41
+ Content-Type:
42
+ - application/vnd.contentful.management.v1+json
43
+ Date:
44
+ - Tue, 26 Jan 2016 13:11:05 GMT
45
+ Etag:
46
+ - '"b2f774265427beffe1f5927d01069f0f"'
47
+ Server:
48
+ - nginx
49
+ Status:
50
+ - 200 OK
51
+ Strict-Transport-Security:
52
+ - max-age=15768000
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Contentful-Request-Id:
56
+ - 0b5-177692512
57
+ Content-Length:
58
+ - '903'
59
+ Connection:
60
+ - Close
61
+ body:
62
+ encoding: UTF-8
63
+ string: |+
64
+ {
65
+ "sys":{
66
+ "type":"ApiKey",
67
+ "id":"6vbW35TjBTc8FyRTAuXZZe",
68
+ "version":0,
69
+ "space":{
70
+ "sys":{
71
+ "type":"Link",
72
+ "linkType":"Space",
73
+ "id":"bjwq7b86vgmm"
74
+ }
75
+ },
76
+ "createdBy":{
77
+ "sys":{
78
+ "type":"Link",
79
+ "linkType":"User",
80
+ "id":"4SejVrWT96dvL9IV4Nb7sQ"
81
+ }
82
+ },
83
+ "createdAt":"2016-01-26T02:31:31Z",
84
+ "updatedBy":{
85
+ "sys":{
86
+ "type":"Link",
87
+ "linkType":"User",
88
+ "id":"4SejVrWT96dvL9IV4Nb7sQ"
89
+ }
90
+ },
91
+ "updatedAt":"2016-01-26T02:31:31Z"
92
+ },
93
+ "name":"testKey",
94
+ "description":null,
95
+ "accessToken":"833ea085204398499ea424c8ad832f1ae1cac4d64e2cc56db774aff87ef20b33",
96
+ "policies":[
97
+ {
98
+ "effect":"allow",
99
+ "actions":"all"
100
+ }
101
+ ],
102
+ "preview_api_key":{
103
+ "sys":{
104
+ "type":"Link",
105
+ "linkType":"PreviewApiKey",
106
+ "id":"6veHm0b2CK8lszllc91rCE"
107
+ }
108
+ }
109
+ }
110
+
111
+ http_version:
112
+ recorded_at: Tue, 26 Jan 2016 13:11:05 GMT
113
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/bjwq7b86vgmm/api_keys/not_exist
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.8.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - api.contentful.com
22
+ response:
23
+ status:
24
+ code: 404
25
+ message: Not Found
26
+ headers:
27
+ Accept-Ranges:
28
+ - bytes
29
+ Access-Control-Allow-Headers:
30
+ - 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
31
+ Access-Control-Allow-Methods:
32
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Expose-Headers:
36
+ - Etag
37
+ Access-Control-Max-Age:
38
+ - '1728000'
39
+ Cache-Control:
40
+ - max-age=0
41
+ Content-Type:
42
+ - application/vnd.contentful.management.v1+json
43
+ Date:
44
+ - Tue, 26 Jan 2016 13:11:04 GMT
45
+ Server:
46
+ - nginx
47
+ Status:
48
+ - 404 Not Found
49
+ X-Contentful-Request-Id:
50
+ - 9e1-668687226
51
+ X-Ua-Compatible:
52
+ - IE=Edge,chrome=1
53
+ Content-Length:
54
+ - '138'
55
+ Connection:
56
+ - Close
57
+ body:
58
+ encoding: UTF-8
59
+ string: |+
60
+ {
61
+ "sys":{
62
+ "type":"Error",
63
+ "id":"NotFound"
64
+ },
65
+ "requestId":"9e1-668687226",
66
+ "message":"The resource could not be found."
67
+ }
68
+
69
+ http_version:
70
+ recorded_at: Tue, 26 Jan 2016 13:11:04 GMT
71
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,112 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/bjwq7b86vgmm/public/assets
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.8.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - api.contentful.com
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
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
+ Cf-Space-Id:
38
+ - bjwq7b86vgmm
39
+ Content-Type:
40
+ - application/vnd.contentful.management.v1+json
41
+ Date:
42
+ - Tue, 26 Jan 2016 21:14:33 GMT
43
+ Etag:
44
+ - '"ce8850c48d118084925339ea2d9abc11"'
45
+ Server:
46
+ - nginx
47
+ Strict-Transport-Security:
48
+ - max-age=15768000
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ X-Contentful-Request-Id:
52
+ - content-api:2ILknGLeQ828OG0yUsGsuK
53
+ X-Powered-By:
54
+ - Express
55
+ Content-Length:
56
+ - '1084'
57
+ Connection:
58
+ - Close
59
+ body:
60
+ encoding: UTF-8
61
+ string: |
62
+ {
63
+ "sys": {
64
+ "type": "Array"
65
+ },
66
+ "total": 1,
67
+ "skip": 0,
68
+ "limit": 100,
69
+ "items": [
70
+ {
71
+ "fields": {
72
+ "title": {
73
+ "en-US": "nyancat"
74
+ },
75
+ "description": {
76
+ "en-US": null
77
+ },
78
+ "file": {
79
+ "en-US": {
80
+ "fileName": "Nyan_cat_250px_frame.PNG",
81
+ "contentType": "image/png",
82
+ "details": {
83
+ "image": {
84
+ "width": 250,
85
+ "height": 250
86
+ },
87
+ "size": 12273
88
+ },
89
+ "url": "//images.contentful.com/bjwq7b86vgmm/3QnoGVq1viESsUw22kiAC6/4a32575e07f8da2ea820eb76424dfd74/Nyan_cat_250px_frame.PNG"
90
+ }
91
+ }
92
+ },
93
+ "sys": {
94
+ "space": {
95
+ "sys": {
96
+ "type": "Link",
97
+ "linkType": "Space",
98
+ "id": "bjwq7b86vgmm"
99
+ }
100
+ },
101
+ "type": "Asset",
102
+ "id": "3QnoGVq1viESsUw22kiAC6",
103
+ "revision": 63,
104
+ "createdAt": "2016-01-25T16:29:20.850Z",
105
+ "updatedAt": "2016-01-26T21:05:57.798Z"
106
+ }
107
+ }
108
+ ]
109
+ }
110
+ http_version:
111
+ recorded_at: Tue, 26 Jan 2016 21:14:33 GMT
112
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,106 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/bjwq7b86vgmm/public/content_types
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.8.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - api.contentful.com
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
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
+ Cf-Space-Id:
38
+ - bjwq7b86vgmm
39
+ Content-Type:
40
+ - application/vnd.contentful.management.v1+json
41
+ Date:
42
+ - Tue, 26 Jan 2016 21:12:12 GMT
43
+ Etag:
44
+ - '"67f7d7ea590afed67e5d873f69fd71a4"'
45
+ Server:
46
+ - nginx
47
+ Strict-Transport-Security:
48
+ - max-age=15768000
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ X-Contentful-Request-Id:
52
+ - content-api:2o8Ojxhp1iQwsSE6gAWiK4
53
+ X-Powered-By:
54
+ - Express
55
+ Content-Length:
56
+ - '836'
57
+ Connection:
58
+ - Close
59
+ body:
60
+ encoding: UTF-8
61
+ string: |
62
+ {
63
+ "sys": {
64
+ "type": "Array"
65
+ },
66
+ "total": 1,
67
+ "skip": 0,
68
+ "limit": 100,
69
+ "items": [
70
+ {
71
+ "displayField": "name",
72
+ "name": "TestCT",
73
+ "description": "",
74
+ "fields": [
75
+ {
76
+ "id": "name",
77
+ "name": "name",
78
+ "type": "Symbol",
79
+ "linkType": null,
80
+ "items": null,
81
+ "required": null,
82
+ "localized": null,
83
+ "validations": [],
84
+ "disabled": null
85
+ }
86
+ ],
87
+ "sys": {
88
+ "space": {
89
+ "sys": {
90
+ "type": "Link",
91
+ "linkType": "Space",
92
+ "id": "bjwq7b86vgmm"
93
+ }
94
+ },
95
+ "type": "ContentType",
96
+ "id": "testCt",
97
+ "revision": 73,
98
+ "createdAt": "2016-01-21T13:22:51.140Z",
99
+ "updatedAt": "2016-01-26T21:03:35.369Z"
100
+ }
101
+ }
102
+ ]
103
+ }
104
+ http_version:
105
+ recorded_at: Tue, 26 Jan 2016 21:12:12 GMT
106
+ recorded_with: VCR 2.9.3