contentful-management 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.rubocop_todo.yml +3 -3
  4. data/.travis.yml +4 -3
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +0 -8
  7. data/Guardfile +3 -54
  8. data/README.md +45 -0
  9. data/Rakefile +0 -5
  10. data/contentful-management.gemspec +8 -5
  11. data/lib/contentful/management/client.rb +44 -14
  12. data/lib/contentful/management/client_upload_methods_factory.rb +19 -0
  13. data/lib/contentful/management/content_type.rb +19 -19
  14. data/lib/contentful/management/dynamic_entry.rb +1 -1
  15. data/lib/contentful/management/entry.rb +57 -50
  16. data/lib/contentful/management/http_client.rb +7 -1
  17. data/lib/contentful/management/request.rb +14 -9
  18. data/lib/contentful/management/resource.rb +7 -7
  19. data/lib/contentful/management/resource/array_like.rb +2 -2
  20. data/lib/contentful/management/resource/system_properties.rb +2 -1
  21. data/lib/contentful/management/resource_builder.rb +6 -3
  22. data/lib/contentful/management/resource_requester.rb +3 -3
  23. data/lib/contentful/management/support.rb +1 -1
  24. data/lib/contentful/management/upload.rb +42 -0
  25. data/lib/contentful/management/version.rb +1 -1
  26. data/spec/fixtures/pixel.jpg +0 -0
  27. data/spec/fixtures/vcr_cassettes/upload/associate_with_asset.yml +426 -0
  28. data/spec/fixtures/vcr_cassettes/upload/create_file.yml +85 -0
  29. data/spec/fixtures/vcr_cassettes/upload/create_path.yml +85 -0
  30. data/spec/fixtures/vcr_cassettes/upload/destroy.yml +133 -0
  31. data/spec/fixtures/vcr_cassettes/upload/find.yml +82 -0
  32. data/spec/fixtures/vcr_cassettes/upload/find_not_found.yml +66 -0
  33. data/spec/lib/contentful/management/client_spec.rb +25 -0
  34. data/spec/lib/contentful/management/upload_spec.rb +92 -0
  35. data/spec/spec_helper.rb +9 -1
  36. metadata +91 -11
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////
10
+ ////////////////////////////////////////////////////////////
11
+ 2wBDAf//////////////////////////////////////////////////////
12
+ ////////////////////////////////wAARCAABAAEDASIAAhEBAxEB/8QA
13
+ FQABAQAAAAAAAAAAAAAAAAAAAAP/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QA
14
+ FAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAM
15
+ AwEAAhEDEQA/AJgA/9k=
16
+ headers:
17
+ User-Agent:
18
+ - RubyContentfulManagementGem/1.6.0
19
+ Authorization:
20
+ - Bearer <ACCESS_TOKEN>
21
+ Content-Type:
22
+ - application/octet-stream
23
+ Connection:
24
+ - close
25
+ Host:
26
+ - upload.contentful.com
27
+ response:
28
+ status:
29
+ code: 201
30
+ message: Created
31
+ headers:
32
+ Access-Control-Allow-Headers:
33
+ - 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,X-Contentful-User-Agent
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Expose-Headers:
37
+ - Etag
38
+ Cache-Control:
39
+ - no-cache
40
+ Content-Type:
41
+ - application/vnd.contentful.management.v1+json
42
+ Date:
43
+ - Tue, 25 Apr 2017 14:01:08 GMT
44
+ Server:
45
+ - Contentful
46
+ Strict-Transport-Security:
47
+ - max-age=15768000
48
+ Vary:
49
+ - accept-encoding
50
+ X-Content-Type-Options:
51
+ - nosniff
52
+ X-Contentful-Request-Id:
53
+ - 55f47fb1a4e472e127ce1c5a766f18fa
54
+ Content-Length:
55
+ - '432'
56
+ Connection:
57
+ - Close
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: |-
61
+ {
62
+ "sys": {
63
+ "id": "6ltsWxSmH0uelLeX6GL7nV",
64
+ "type": "Upload",
65
+ "createdAt": "2017-04-25T14:01:09.000Z",
66
+ "expiresAt": "2017-04-27T00:00:00.000Z",
67
+ "space": {
68
+ "sys": {
69
+ "type": "Link",
70
+ "linkType": "Space",
71
+ "id": "facgnwwgj5fe"
72
+ }
73
+ },
74
+ "createdBy": {
75
+ "sys": {
76
+ "type": "Link",
77
+ "linkType": "User",
78
+ "id": "4SejVrWT96dvL9IV4Nb7sQ"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ http_version:
84
+ recorded_at: Tue, 25 Apr 2017 14:01:09 GMT
85
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////
10
+ ////////////////////////////////////////////////////////////
11
+ 2wBDAf//////////////////////////////////////////////////////
12
+ ////////////////////////////////wAARCAABAAEDASIAAhEBAxEB/8QA
13
+ FQABAQAAAAAAAAAAAAAAAAAAAAP/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QA
14
+ FAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAM
15
+ AwEAAhEDEQA/AJgA/9k=
16
+ headers:
17
+ User-Agent:
18
+ - RubyContentfulManagementGem/1.6.0
19
+ Authorization:
20
+ - Bearer <ACCESS_TOKEN>
21
+ Content-Type:
22
+ - application/octet-stream
23
+ Connection:
24
+ - close
25
+ Host:
26
+ - upload.contentful.com
27
+ response:
28
+ status:
29
+ code: 201
30
+ message: Created
31
+ headers:
32
+ Access-Control-Allow-Headers:
33
+ - 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,X-Contentful-User-Agent
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Expose-Headers:
37
+ - Etag
38
+ Cache-Control:
39
+ - no-cache
40
+ Content-Type:
41
+ - application/vnd.contentful.management.v1+json
42
+ Date:
43
+ - Tue, 25 Apr 2017 14:01:09 GMT
44
+ Server:
45
+ - Contentful
46
+ Strict-Transport-Security:
47
+ - max-age=15768000
48
+ Vary:
49
+ - accept-encoding
50
+ X-Content-Type-Options:
51
+ - nosniff
52
+ X-Contentful-Request-Id:
53
+ - 47d19da405d23feab565da42bf4f1b99
54
+ Content-Length:
55
+ - '432'
56
+ Connection:
57
+ - Close
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: |-
61
+ {
62
+ "sys": {
63
+ "id": "5U7s6EZ3CE9D7ZS25Rkayk",
64
+ "type": "Upload",
65
+ "createdAt": "2017-04-25T14:01:10.000Z",
66
+ "expiresAt": "2017-04-27T00:00:00.000Z",
67
+ "space": {
68
+ "sys": {
69
+ "type": "Link",
70
+ "linkType": "Space",
71
+ "id": "facgnwwgj5fe"
72
+ }
73
+ },
74
+ "createdBy": {
75
+ "sys": {
76
+ "type": "Link",
77
+ "linkType": "User",
78
+ "id": "4SejVrWT96dvL9IV4Nb7sQ"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ http_version:
84
+ recorded_at: Tue, 25 Apr 2017 14:01:10 GMT
85
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,133 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads/IUMb6WLjk9fjQ0WZfG971
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/1.5.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
+ - upload.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,X-Contentful-User-Agent
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Access-Control-Expose-Headers:
34
+ - Etag
35
+ Cache-Control:
36
+ - no-cache
37
+ Content-Type:
38
+ - application/vnd.contentful.management.v1+json
39
+ Date:
40
+ - Fri, 21 Apr 2017 19:32:39 GMT
41
+ Server:
42
+ - Contentful
43
+ Strict-Transport-Security:
44
+ - max-age=15768000
45
+ Vary:
46
+ - accept-encoding
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - 91e58e8c0b1f53a9e9c41c1669822cdd
51
+ Content-Length:
52
+ - '431'
53
+ Connection:
54
+ - Close
55
+ body:
56
+ encoding: ASCII-8BIT
57
+ string: |-
58
+ {
59
+ "sys": {
60
+ "id": "IUMb6WLjk9fjQ0WZfG971",
61
+ "type": "Upload",
62
+ "createdAt": "2017-04-21T19:24:01.000Z",
63
+ "expiresAt": "2017-04-23T00:00:00.000Z",
64
+ "space": {
65
+ "sys": {
66
+ "type": "Link",
67
+ "linkType": "Space",
68
+ "id": "facgnwwgj5fe"
69
+ }
70
+ },
71
+ "createdBy": {
72
+ "sys": {
73
+ "type": "Link",
74
+ "linkType": "User",
75
+ "id": "4SejVrWT96dvL9IV4Nb7sQ"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ http_version:
81
+ recorded_at: Fri, 21 Apr 2017 19:32:39 GMT
82
+ - request:
83
+ method: delete
84
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads/IUMb6WLjk9fjQ0WZfG971
85
+ body:
86
+ encoding: US-ASCII
87
+ string: ''
88
+ headers:
89
+ User-Agent:
90
+ - RubyContentfulManagementGem/1.5.0
91
+ Authorization:
92
+ - Bearer <ACCESS_TOKEN>
93
+ Content-Type:
94
+ - application/vnd.contentful.management.v1+json
95
+ Content-Length:
96
+ - '0'
97
+ Connection:
98
+ - close
99
+ Host:
100
+ - upload.contentful.com
101
+ response:
102
+ status:
103
+ code: 204
104
+ message: No Content
105
+ headers:
106
+ Access-Control-Allow-Headers:
107
+ - 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,X-Contentful-User-Agent
108
+ Access-Control-Allow-Origin:
109
+ - "*"
110
+ Access-Control-Expose-Headers:
111
+ - Etag
112
+ Cache-Control:
113
+ - no-cache
114
+ Content-Type:
115
+ - application/octet-stream
116
+ Date:
117
+ - Fri, 21 Apr 2017 19:32:40 GMT
118
+ Server:
119
+ - Contentful
120
+ Strict-Transport-Security:
121
+ - max-age=15768000
122
+ X-Content-Type-Options:
123
+ - nosniff
124
+ X-Contentful-Request-Id:
125
+ - 8f9c196947be6175b05ea6c34743d5ef
126
+ Connection:
127
+ - Close
128
+ body:
129
+ encoding: ASCII-8BIT
130
+ string: ''
131
+ http_version:
132
+ recorded_at: Fri, 21 Apr 2017 19:32:40 GMT
133
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,82 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads/IUMb6WLjk9fjQ0WZfG971
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/1.5.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
+ - upload.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,X-Contentful-User-Agent
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Access-Control-Expose-Headers:
34
+ - Etag
35
+ Cache-Control:
36
+ - no-cache
37
+ Content-Type:
38
+ - application/vnd.contentful.management.v1+json
39
+ Date:
40
+ - Fri, 21 Apr 2017 19:32:04 GMT
41
+ Server:
42
+ - Contentful
43
+ Strict-Transport-Security:
44
+ - max-age=15768000
45
+ Vary:
46
+ - accept-encoding
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - ae625a4c50deb387dcf74541abf01785
51
+ Content-Length:
52
+ - '431'
53
+ Connection:
54
+ - Close
55
+ body:
56
+ encoding: ASCII-8BIT
57
+ string: |-
58
+ {
59
+ "sys": {
60
+ "id": "IUMb6WLjk9fjQ0WZfG971",
61
+ "type": "Upload",
62
+ "createdAt": "2017-04-21T19:24:01.000Z",
63
+ "expiresAt": "2017-04-23T00:00:00.000Z",
64
+ "space": {
65
+ "sys": {
66
+ "type": "Link",
67
+ "linkType": "Space",
68
+ "id": "facgnwwgj5fe"
69
+ }
70
+ },
71
+ "createdBy": {
72
+ "sys": {
73
+ "type": "Link",
74
+ "linkType": "User",
75
+ "id": "4SejVrWT96dvL9IV4Nb7sQ"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ http_version:
81
+ recorded_at: Fri, 21 Apr 2017 19:32:04 GMT
82
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://upload.contentful.com/spaces/facgnwwgj5fe/uploads/not_exist
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/1.5.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
+ - upload.contentful.com
22
+ response:
23
+ status:
24
+ code: 404
25
+ message: Not Found
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,X-Contentful-User-Agent
29
+ Access-Control-Allow-Origin:
30
+ - "*"
31
+ Access-Control-Expose-Headers:
32
+ - Etag
33
+ Cache-Control:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/vnd.contentful.management.v1+json
37
+ Date:
38
+ - Fri, 21 Apr 2017 19:30:33 GMT
39
+ Server:
40
+ - Contentful
41
+ Strict-Transport-Security:
42
+ - max-age=15768000
43
+ Vary:
44
+ - accept-encoding
45
+ X-Content-Type-Options:
46
+ - nosniff
47
+ X-Contentful-Request-Id:
48
+ - 603120c101ac4f389bb7fdef94f292ff
49
+ Content-Length:
50
+ - '158'
51
+ Connection:
52
+ - Close
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: |-
56
+ {
57
+ "sys": {
58
+ "type": "Error",
59
+ "id": "NotFound"
60
+ },
61
+ "message": "The resource could not be found.",
62
+ "details": "The resource could not be found."
63
+ }
64
+ http_version:
65
+ recorded_at: Fri, 21 Apr 2017 19:30:33 GMT
66
+ recorded_with: VCR 3.0.3