contentful-management 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +32 -14
- data/README.md +9 -4
- data/lib/contentful/management/asset.rb +1 -1
- data/lib/contentful/management/error.rb +7 -1
- data/lib/contentful/management/response.rb +3 -3
- data/lib/contentful/management/space.rb +3 -1
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/space/create_with_client_default_locale.yml +187 -0
- data/spec/fixtures/vcr_cassettes/space/create_with_locale.yml +187 -0
- data/spec/lib/contentful/management/space_spec.rb +27 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae13b9bb15ea88eab394450ef29325340fe48e8
|
4
|
+
data.tar.gz: 67bcdac156d68a6d35da893472bc3aa0f4d0f4b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41d3ca3acf06a94f24a08be3e773734b75d90c7f4cd41aa14341aa4ae90252ad749ec97f4fdfb234d29614cf205f44cd4785162fe762fd1e894f3e70d2800393
|
7
|
+
data.tar.gz: b2e8e16655c8ddbab2e187b7332e8ebf5cfbb5e38d72a1d21fc349214363c6490a738d7d3cb4d3ca46ea0f3f8ceca2c4373b412c307f2c1ab4d1c5b6726262cc
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.5.0
|
4
|
+
### Added
|
5
|
+
* Allow setting a default locale when creating a space [#43](https://github.com/contentful/contentful-management.rb/pull/43)
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
* Handle `UnprocessableEntity` (HTTP 422) as its own error. [#42](https://github.com/contentful/contentful-management.rb/pull/42)
|
9
|
+
|
10
|
+
|
3
11
|
## 0.4.1
|
4
12
|
### Fixed
|
5
13
|
* Handle 409 responses as errors [#39](https://github.com/contentful/contentful-management.rb/pull/39)
|
@@ -9,9 +17,11 @@
|
|
9
17
|
* Return Keep attribute if it's already a hash [#33](https://github.com/contentful/contentful-management.rb/pull/33)
|
10
18
|
* Typo in header [#34](https://github.com/contentful/contentful-management.rb/pull/34)
|
11
19
|
* Items are nil when creating an array field for a content type [#35](https://github.com/contentful/contentful-management.rb/issues/35)
|
20
|
+
|
12
21
|
### Added
|
13
22
|
* `raise_errors` can be enabled, disabled by default [#38](https://github.com/contentful/contentful-management.rb/pull/38)
|
14
23
|
|
24
|
+
|
15
25
|
## 0.3.1
|
16
26
|
### Added
|
17
27
|
* Logging of requests
|
@@ -25,58 +35,66 @@
|
|
25
35
|
* Cleaned the code
|
26
36
|
* Remove encoding strings from the source code files
|
27
37
|
|
38
|
+
|
28
39
|
## 0.2.1
|
29
40
|
### Fixed
|
30
|
-
*
|
41
|
+
* Use array for symbols in entry fields
|
42
|
+
|
31
43
|
|
32
44
|
## 0.2.0
|
33
45
|
### Fixed
|
34
|
-
*
|
35
|
-
*
|
46
|
+
* create entry with multiple locales, skip attributes for not localized fields in content types
|
47
|
+
* reload Assets
|
36
48
|
|
37
49
|
### Added
|
38
50
|
* Add optional gzip encoding
|
39
51
|
|
52
|
+
|
40
53
|
## 0.1.0
|
41
54
|
### Added
|
42
55
|
* Support for web hooks
|
43
56
|
* Image url to asset
|
44
57
|
|
45
58
|
### Fixed
|
46
|
-
*
|
47
|
-
*
|
48
|
-
*
|
59
|
+
* remove implicit processing of assets.
|
60
|
+
* Gem is modifying nil #17
|
61
|
+
* rename asset.process_files to asset.process
|
49
62
|
|
50
63
|
### Other
|
51
64
|
* Cleaning code
|
52
65
|
|
66
|
+
|
53
67
|
## 0.0.3
|
54
68
|
### Added:
|
55
69
|
* More documentation
|
56
70
|
|
57
71
|
### Fixed:
|
58
|
-
*
|
59
|
-
*
|
60
|
-
*
|
61
|
-
*
|
72
|
+
* next_page feature
|
73
|
+
* create entry with specific locale
|
74
|
+
* service unavailable error (503)
|
75
|
+
* reload method on objects
|
76
|
+
|
62
77
|
### Other
|
63
78
|
* Code cleanup
|
64
79
|
|
80
|
+
|
65
81
|
## 0.0.2
|
66
82
|
### Fixed
|
67
83
|
* Fix: Convert an Entry to a DynamicEntry after being created.
|
68
84
|
|
85
|
+
|
69
86
|
## 0.0.1
|
70
87
|
### Added
|
71
|
-
*
|
72
|
-
*
|
88
|
+
* rdoc
|
89
|
+
* filter by content_type id
|
73
90
|
|
74
91
|
### Fixed
|
75
|
-
*
|
76
|
-
*
|
92
|
+
* Headers not properly cleared between requests
|
93
|
+
* Create entries with custom identifier
|
77
94
|
|
78
95
|
### Other
|
79
96
|
* Code cleanup
|
80
97
|
|
98
|
+
|
81
99
|
## 0.0.1-pre
|
82
100
|
* alpha pre-release
|
data/README.md
CHANGED
@@ -69,6 +69,11 @@ or in the context of the organization (if you have multiple organizations within
|
|
69
69
|
blog_space = Contentful::Management::Space.create(name: 'Blog Space', organization_id: 'organization_id')
|
70
70
|
```
|
71
71
|
|
72
|
+
If you want to create a default locale different from `en-US`:
|
73
|
+
```ruby
|
74
|
+
blog_space = Contentful::Management::Space.create(name: 'Blog Space', default_locale: 'de-DE')
|
75
|
+
```
|
76
|
+
|
72
77
|
Updating a space:
|
73
78
|
|
74
79
|
```ruby
|
@@ -314,7 +319,7 @@ entries = blog_space.entries.all
|
|
314
319
|
Retrieving all entries from the space with given content type:
|
315
320
|
|
316
321
|
```ruby
|
317
|
-
entries = blog_space.entries.all(
|
322
|
+
entries = blog_space.entries.all(content_type: content_type.id)
|
318
323
|
```
|
319
324
|
|
320
325
|
or
|
@@ -454,12 +459,12 @@ Takes optional min and max parameters and validates the size of the array (numbe
|
|
454
459
|
```ruby
|
455
460
|
validation_size = Contentful::Management::Validation.new
|
456
461
|
validation_size.size = { min: 10, max: 15 }
|
457
|
-
blog_post_content_type.fields.create(id: 'valid', name: 'Test
|
462
|
+
blog_post_content_type.fields.create(id: 'valid', name: 'Test SIZE', type: 'Text', validations: [validation_size])
|
458
463
|
```
|
459
464
|
|
460
465
|
#### range
|
461
466
|
|
462
|
-
Takes
|
467
|
+
Takes optional min and max parameters and validates the range of a value.
|
463
468
|
|
464
469
|
```ruby
|
465
470
|
validation_range = Contentful::Management::Validation.new
|
@@ -484,7 +489,7 @@ Takes an array of content type ids and validates that the link points to an entr
|
|
484
489
|
```ruby
|
485
490
|
validation_link_content_type = Contentful::Management::Validation.new
|
486
491
|
validation_link_content_type.link_content_type = ['post_content_type_id']
|
487
|
-
blog_post_content_type.fields.create(id: 'entry', name: '
|
492
|
+
blog_post_content_type.fields.create(id: 'entry', name: 'Test linkContentType', type: 'Entry', validations: [validation_link_content_type])
|
488
493
|
```
|
489
494
|
|
490
495
|
#### linkMimetypeGroup
|
@@ -43,7 +43,7 @@ module Contentful
|
|
43
43
|
locale = attributes[:locale]
|
44
44
|
asset = new
|
45
45
|
asset.instance_variable_set(:@fields, attributes[:fields] || {})
|
46
|
-
asset.locale = attributes[:locale]
|
46
|
+
asset.locale = attributes[:locale] || client.default_locale
|
47
47
|
asset.title = attributes[:title] if attributes[:title]
|
48
48
|
asset.description = attributes[:description] if attributes[:description]
|
49
49
|
asset.file = attributes[:file] if attributes[:file]
|
@@ -24,6 +24,8 @@ module Contentful
|
|
24
24
|
Conflict
|
25
25
|
when 401
|
26
26
|
Unauthorized
|
27
|
+
when 422
|
28
|
+
UnprocessableEntity
|
27
29
|
when 500
|
28
30
|
ServerError
|
29
31
|
when 503
|
@@ -49,10 +51,14 @@ module Contentful
|
|
49
51
|
# 401
|
50
52
|
class Unauthorized < Error
|
51
53
|
end
|
52
|
-
|
54
|
+
|
53
55
|
# 409
|
54
56
|
class Conflict < Error
|
55
57
|
end
|
58
|
+
|
59
|
+
# 422
|
60
|
+
class UnprocessableEntity < Error
|
61
|
+
end
|
56
62
|
|
57
63
|
# 500
|
58
64
|
class ServerError < Error
|
@@ -32,7 +32,7 @@ module Contentful
|
|
32
32
|
parse_json!
|
33
33
|
elsif no_content_response?
|
34
34
|
@status = :no_content
|
35
|
-
elsif
|
35
|
+
elsif resource_error?
|
36
36
|
parse_contentful_error
|
37
37
|
else
|
38
38
|
parse_http_error
|
@@ -60,8 +60,8 @@ module Contentful
|
|
60
60
|
@object = Error[raw.status].new(self)
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
[400, 404].include?(raw.status)
|
63
|
+
def resource_error?
|
64
|
+
[400, 404, 422].include?(raw.status)
|
65
65
|
end
|
66
66
|
|
67
67
|
def no_content_response?
|
@@ -21,6 +21,7 @@ module Contentful
|
|
21
21
|
|
22
22
|
property :name, :string
|
23
23
|
property :organization, :string
|
24
|
+
property :default_locale, :string
|
24
25
|
property :locales, Locale
|
25
26
|
|
26
27
|
# Gets a collection of spaces.
|
@@ -50,9 +51,10 @@ module Contentful
|
|
50
51
|
# Takes a hash of attributes with optional organization id if client has more than one organization.
|
51
52
|
# Returns a Contentful::Management::Space.
|
52
53
|
def self.create(attributes)
|
54
|
+
default_locale = attributes[:default_locale] || client.default_locale
|
53
55
|
request = Request.new(
|
54
56
|
'',
|
55
|
-
{'name' => attributes.fetch(:name)},
|
57
|
+
{'name' => attributes.fetch(:name), defaultLocale: default_locale},
|
56
58
|
id = nil,
|
57
59
|
organization_id: attributes[:organization_id]
|
58
60
|
)
|
@@ -0,0 +1,187 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.contentful.com/spaces
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"name":"new space","defaultLocale":"pl-PL"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/0.4.1
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
X-Contentful-Organization:
|
17
|
+
- 1EQPR5IHrPx94UY4AViTYO
|
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
|
+
- Wed, 26 Nov 2014 08:05:56 GMT
|
43
|
+
Etag:
|
44
|
+
- '"990079f8976c99c08d757eb086729c52"'
|
45
|
+
Location:
|
46
|
+
- https://api.contentful.com/spaces/1j2osuxmfs25
|
47
|
+
Server:
|
48
|
+
- nginx
|
49
|
+
Status:
|
50
|
+
- 201 Created
|
51
|
+
X-Contentful-Request-Id:
|
52
|
+
- 71a-1097168226
|
53
|
+
Content-Length:
|
54
|
+
- '450'
|
55
|
+
Connection:
|
56
|
+
- keep-alive
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: |
|
60
|
+
{
|
61
|
+
"sys":{
|
62
|
+
"type":"Space",
|
63
|
+
"id":"1j2osuxmfs25",
|
64
|
+
"version":1,
|
65
|
+
"createdBy":{
|
66
|
+
"sys":{
|
67
|
+
"type":"Link",
|
68
|
+
"linkType":"User",
|
69
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"createdAt":"2014-11-26T08:05:52Z",
|
73
|
+
"updatedBy":{
|
74
|
+
"sys":{
|
75
|
+
"type":"Link",
|
76
|
+
"linkType":"User",
|
77
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"updatedAt":"2014-11-26T08:05:53Z"
|
81
|
+
},
|
82
|
+
"name":"new space"}
|
83
|
+
http_version:
|
84
|
+
recorded_at: Wed, 26 Nov 2014 08:05:57 GMT
|
85
|
+
- request:
|
86
|
+
method: get
|
87
|
+
uri: https://api.contentful.com/spaces/1j2osuxmfs25/locales
|
88
|
+
body:
|
89
|
+
encoding: US-ASCII
|
90
|
+
string: ''
|
91
|
+
headers:
|
92
|
+
User-Agent:
|
93
|
+
- RubyContentfulManagementGem/0.4.1
|
94
|
+
Authorization:
|
95
|
+
- Bearer <ACCESS_TOKEN>
|
96
|
+
Content-Type:
|
97
|
+
- application/vnd.contentful.management.v1+json
|
98
|
+
Content-Length:
|
99
|
+
- '0'
|
100
|
+
Host:
|
101
|
+
- api.contentful.com
|
102
|
+
response:
|
103
|
+
status:
|
104
|
+
code: 200
|
105
|
+
message: OK
|
106
|
+
headers:
|
107
|
+
Accept-Ranges:
|
108
|
+
- bytes
|
109
|
+
Access-Control-Allow-Headers:
|
110
|
+
- 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
|
111
|
+
Access-Control-Allow-Methods:
|
112
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
113
|
+
Access-Control-Allow-Origin:
|
114
|
+
- "*"
|
115
|
+
Access-Control-Expose-Headers:
|
116
|
+
- Etag
|
117
|
+
Access-Control-Max-Age:
|
118
|
+
- '1728000'
|
119
|
+
Cache-Control:
|
120
|
+
- max-age=0
|
121
|
+
Content-Type:
|
122
|
+
- application/vnd.contentful.management.v1+json
|
123
|
+
Date:
|
124
|
+
- Wed, 26 Nov 2014 08:05:56 GMT
|
125
|
+
Etag:
|
126
|
+
- '"e003b11a376b701bdbeed0165cf21b44"'
|
127
|
+
Server:
|
128
|
+
- nginx
|
129
|
+
Status:
|
130
|
+
- 200 OK
|
131
|
+
X-Contentful-Request-Id:
|
132
|
+
- f1c-641211146
|
133
|
+
Content-Length:
|
134
|
+
- '930'
|
135
|
+
Connection:
|
136
|
+
- keep-alive
|
137
|
+
body:
|
138
|
+
encoding: UTF-8
|
139
|
+
string: |
|
140
|
+
{
|
141
|
+
"sys":{
|
142
|
+
"type":"Array"
|
143
|
+
},
|
144
|
+
"items":[
|
145
|
+
{
|
146
|
+
"sys":{
|
147
|
+
"type":"Locale",
|
148
|
+
"id":"7wpzPPTX0QahGa7rVtE6MR",
|
149
|
+
"version":0,
|
150
|
+
"space":{
|
151
|
+
"sys":{
|
152
|
+
"type":"Link",
|
153
|
+
"linkType":"Space",
|
154
|
+
"id":"1j2osuxmfs25"
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"createdBy":{
|
158
|
+
"sys":{
|
159
|
+
"type":"Link",
|
160
|
+
"linkType":"User",
|
161
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"createdAt":"2014-11-26T08:05:53Z",
|
165
|
+
"updatedBy":{
|
166
|
+
"sys":{
|
167
|
+
"type":"Link",
|
168
|
+
"linkType":"User",
|
169
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
170
|
+
}
|
171
|
+
},
|
172
|
+
"updatedAt":"2014-11-26T08:05:53Z"
|
173
|
+
},
|
174
|
+
"name":"pl-PL",
|
175
|
+
"code":"pl-PL",
|
176
|
+
"default":true,
|
177
|
+
"contentManagementApi":true,
|
178
|
+
"publish":true,
|
179
|
+
"contentDeliveryApi":true
|
180
|
+
}
|
181
|
+
],
|
182
|
+
"total":1,
|
183
|
+
"limit":25,
|
184
|
+
"skip":0}
|
185
|
+
http_version:
|
186
|
+
recorded_at: Wed, 26 Nov 2014 08:05:57 GMT
|
187
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,187 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.contentful.com/spaces
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"name":"pl space","defaultLocale":"pl-pl"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/0.4.1
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
X-Contentful-Organization:
|
17
|
+
- 1EQPR5IHrPx94UY4AViTYO
|
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, 25 Nov 2014 15:44:02 GMT
|
43
|
+
Etag:
|
44
|
+
- '"d7bbe1d4a322e2d57c8ae5f6e60bb920"'
|
45
|
+
Location:
|
46
|
+
- https://api.contentful.com/spaces/xg3e2w77diga
|
47
|
+
Server:
|
48
|
+
- nginx
|
49
|
+
Status:
|
50
|
+
- 201 Created
|
51
|
+
X-Contentful-Request-Id:
|
52
|
+
- 71a-1096805342
|
53
|
+
Content-Length:
|
54
|
+
- '449'
|
55
|
+
Connection:
|
56
|
+
- keep-alive
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: |
|
60
|
+
{
|
61
|
+
"sys":{
|
62
|
+
"type":"Space",
|
63
|
+
"id":"xg3e2w77diga",
|
64
|
+
"version":1,
|
65
|
+
"createdBy":{
|
66
|
+
"sys":{
|
67
|
+
"type":"Link",
|
68
|
+
"linkType":"User",
|
69
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"createdAt":"2014-11-25T15:43:59Z",
|
73
|
+
"updatedBy":{
|
74
|
+
"sys":{
|
75
|
+
"type":"Link",
|
76
|
+
"linkType":"User",
|
77
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"updatedAt":"2014-11-25T15:43:59Z"
|
81
|
+
},
|
82
|
+
"name":"pl space"}
|
83
|
+
http_version:
|
84
|
+
recorded_at: Tue, 25 Nov 2014 15:44:01 GMT
|
85
|
+
- request:
|
86
|
+
method: get
|
87
|
+
uri: https://api.contentful.com/spaces/xg3e2w77diga/locales
|
88
|
+
body:
|
89
|
+
encoding: US-ASCII
|
90
|
+
string: ''
|
91
|
+
headers:
|
92
|
+
User-Agent:
|
93
|
+
- RubyContentfulManagementGem/0.4.1
|
94
|
+
Authorization:
|
95
|
+
- Bearer <ACCESS_TOKEN>
|
96
|
+
Content-Type:
|
97
|
+
- application/vnd.contentful.management.v1+json
|
98
|
+
Content-Length:
|
99
|
+
- '0'
|
100
|
+
Host:
|
101
|
+
- api.contentful.com
|
102
|
+
response:
|
103
|
+
status:
|
104
|
+
code: 200
|
105
|
+
message: OK
|
106
|
+
headers:
|
107
|
+
Accept-Ranges:
|
108
|
+
- bytes
|
109
|
+
Access-Control-Allow-Headers:
|
110
|
+
- 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
|
111
|
+
Access-Control-Allow-Methods:
|
112
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
113
|
+
Access-Control-Allow-Origin:
|
114
|
+
- "*"
|
115
|
+
Access-Control-Expose-Headers:
|
116
|
+
- Etag
|
117
|
+
Access-Control-Max-Age:
|
118
|
+
- '1728000'
|
119
|
+
Cache-Control:
|
120
|
+
- max-age=0
|
121
|
+
Content-Type:
|
122
|
+
- application/vnd.contentful.management.v1+json
|
123
|
+
Date:
|
124
|
+
- Tue, 25 Nov 2014 15:44:03 GMT
|
125
|
+
Etag:
|
126
|
+
- '"b00d24c14d4099a3e87619f20153ce85"'
|
127
|
+
Server:
|
128
|
+
- nginx
|
129
|
+
Status:
|
130
|
+
- 200 OK
|
131
|
+
X-Contentful-Request-Id:
|
132
|
+
- 85f-1322536095
|
133
|
+
Content-Length:
|
134
|
+
- '930'
|
135
|
+
Connection:
|
136
|
+
- keep-alive
|
137
|
+
body:
|
138
|
+
encoding: UTF-8
|
139
|
+
string: |
|
140
|
+
{
|
141
|
+
"sys":{
|
142
|
+
"type":"Array"
|
143
|
+
},
|
144
|
+
"items":[
|
145
|
+
{
|
146
|
+
"sys":{
|
147
|
+
"type":"Locale",
|
148
|
+
"id":"6cYjTjEe9oaQnaVHWVGuIZ",
|
149
|
+
"version":0,
|
150
|
+
"space":{
|
151
|
+
"sys":{
|
152
|
+
"type":"Link",
|
153
|
+
"linkType":"Space",
|
154
|
+
"id":"xg3e2w77diga"
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"createdBy":{
|
158
|
+
"sys":{
|
159
|
+
"type":"Link",
|
160
|
+
"linkType":"User",
|
161
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"createdAt":"2014-11-25T15:43:59Z",
|
165
|
+
"updatedBy":{
|
166
|
+
"sys":{
|
167
|
+
"type":"Link",
|
168
|
+
"linkType":"User",
|
169
|
+
"id":"1E7acJL8I5XUXAMHQt9Grs"
|
170
|
+
}
|
171
|
+
},
|
172
|
+
"updatedAt":"2014-11-25T15:43:59Z"
|
173
|
+
},
|
174
|
+
"name":"pl-pl",
|
175
|
+
"code":"pl-pl",
|
176
|
+
"default":true,
|
177
|
+
"contentManagementApi":true,
|
178
|
+
"publish":true,
|
179
|
+
"contentDeliveryApi":true
|
180
|
+
}
|
181
|
+
],
|
182
|
+
"total":1,
|
183
|
+
"limit":25,
|
184
|
+
"skip":0}
|
185
|
+
http_version:
|
186
|
+
recorded_at: Tue, 25 Nov 2014 15:44:02 GMT
|
187
|
+
recorded_with: VCR 2.9.3
|
@@ -37,6 +37,12 @@ module Contentful
|
|
37
37
|
expect(result).to be_kind_of Contentful::Management::NotFound
|
38
38
|
end
|
39
39
|
end
|
40
|
+
it 'returns space for a given key' do
|
41
|
+
vcr('space/find') do
|
42
|
+
space = subject.find(space_id)
|
43
|
+
expect(space.id).to eql space_id
|
44
|
+
end
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
describe '#destroy' do
|
@@ -78,6 +84,25 @@ module Contentful
|
|
78
84
|
expect(space).to be_kind_of Contentful::Management::AccessDenied
|
79
85
|
end
|
80
86
|
end
|
87
|
+
context 'create with locale' do
|
88
|
+
it 'creates a space within a specified default locale' do
|
89
|
+
vcr('space/create_with_locale') do
|
90
|
+
space = subject.create(name: 'pl space', organization_id: '1EQPR5IHrPx94UY4AViTYO', default_locale: 'pl-pl')
|
91
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
92
|
+
expect(space.name).to eq 'pl space'
|
93
|
+
expect(space.locales.all.first.code).to eql 'pl-pl'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
it 'creates a space within a client default locale' do
|
97
|
+
vcr('space/create_with_client_default_locale') do
|
98
|
+
Client.new('<ACCESS_TOKEN>', default_locale: 'pl-PL')
|
99
|
+
space = subject.create(name: 'new space', organization_id: '1EQPR5IHrPx94UY4AViTYO')
|
100
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
101
|
+
expect(space.name).to eq 'new space'
|
102
|
+
expect(space.locales.all.first.code).to eql 'pl-PL'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
81
106
|
end
|
82
107
|
|
83
108
|
describe '#update' do
|
@@ -172,7 +197,8 @@ module Contentful
|
|
172
197
|
publish: true,
|
173
198
|
contentDeliveryApi: true,
|
174
199
|
code: 'ru-RU')
|
175
|
-
expect(locale).to be_kind_of Contentful::Management::
|
200
|
+
expect(locale).to be_kind_of Contentful::Management::UnprocessableEntity
|
201
|
+
expect(locale.response.error_message).to eql 'The resource you sent in the body is invalid.'
|
176
202
|
end
|
177
203
|
end
|
178
204
|
|
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.
|
4
|
+
version: 0.5.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-
|
13
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -383,6 +383,8 @@ files:
|
|
383
383
|
- spec/fixtures/vcr_cassettes/space/content_type/find.yml
|
384
384
|
- spec/fixtures/vcr_cassettes/space/create.yml
|
385
385
|
- spec/fixtures/vcr_cassettes/space/create_when_limit_has_been_reached.yml
|
386
|
+
- spec/fixtures/vcr_cassettes/space/create_with_client_default_locale.yml
|
387
|
+
- spec/fixtures/vcr_cassettes/space/create_with_locale.yml
|
386
388
|
- spec/fixtures/vcr_cassettes/space/create_with_unknown_organization.yml
|
387
389
|
- spec/fixtures/vcr_cassettes/space/create_without_organization.yml
|
388
390
|
- spec/fixtures/vcr_cassettes/space/destory.yml
|
@@ -612,6 +614,8 @@ test_files:
|
|
612
614
|
- spec/fixtures/vcr_cassettes/space/content_type/find.yml
|
613
615
|
- spec/fixtures/vcr_cassettes/space/create.yml
|
614
616
|
- spec/fixtures/vcr_cassettes/space/create_when_limit_has_been_reached.yml
|
617
|
+
- spec/fixtures/vcr_cassettes/space/create_with_client_default_locale.yml
|
618
|
+
- spec/fixtures/vcr_cassettes/space/create_with_locale.yml
|
615
619
|
- spec/fixtures/vcr_cassettes/space/create_with_unknown_organization.yml
|
616
620
|
- spec/fixtures/vcr_cassettes/space/create_without_organization.yml
|
617
621
|
- spec/fixtures/vcr_cassettes/space/destory.yml
|