contentful-management 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +15 -0
- data/README.md +209 -41
- data/contentful-management.gemspec +1 -1
- data/lib/contentful/management/asset.rb +1 -1
- data/lib/contentful/management/client.rb +155 -31
- data/lib/contentful/management/client_organization_methods_factory.rb +23 -0
- data/lib/contentful/management/client_personal_access_tokens_methods_factory.rb +27 -0
- data/lib/contentful/management/client_snapshot_methods_factory.rb +16 -6
- data/lib/contentful/management/client_space_membership_methods_factory.rb +15 -0
- data/lib/contentful/management/client_ui_extension_methods_factory.rb +15 -0
- data/lib/contentful/management/client_user_methods_factory.rb +27 -0
- data/lib/contentful/management/client_webhook_call_methods_factory.rb +30 -0
- data/lib/contentful/management/client_webhook_health_methods_factory.rb +27 -0
- data/lib/contentful/management/content_type.rb +10 -0
- data/lib/contentful/management/content_type_snapshot_methods_factory.rb +35 -0
- data/lib/contentful/management/editor_interface.rb +1 -1
- data/lib/contentful/management/organization.rb +20 -0
- data/lib/contentful/management/personal_access_token.rb +45 -0
- data/lib/contentful/management/request.rb +0 -1
- data/lib/contentful/management/resource.rb +4 -2
- data/lib/contentful/management/resource_builder.rb +15 -0
- data/lib/contentful/management/snapshot.rb +31 -20
- data/lib/contentful/management/space.rb +32 -10
- data/lib/contentful/management/space_membership.rb +43 -0
- data/lib/contentful/management/space_space_membership_methods_factory.rb +15 -0
- data/lib/contentful/management/space_ui_extension_methods_factory.rb +15 -0
- data/lib/contentful/management/ui_extension.rb +106 -0
- data/lib/contentful/management/user.rb +28 -0
- data/lib/contentful/management/version.rb +1 -1
- data/lib/contentful/management/webhook.rb +20 -0
- data/lib/contentful/management/webhook_call.rb +77 -0
- data/lib/contentful/management/webhook_health.rb +79 -0
- data/lib/contentful/management/webhook_webhook_call_methods_factory.rb +30 -0
- data/lib/contentful/management/webhook_webhook_health_methods_factory.rb +28 -0
- data/spec/fixtures/vcr_cassettes/get_request.yml +34 -17
- data/spec/fixtures/vcr_cassettes/organization/all.yml +100 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/all.yml +101 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/create.yml +94 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/find.yml +91 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/find_not_found.yml +88 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/revoke.yml +179 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_all.yml +207 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_find.yml +198 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_find_not_found.yml +94 -0
- data/spec/fixtures/vcr_cassettes/space/all_disabled_cache.yml +428 -0
- data/spec/fixtures/vcr_cassettes/space/disabled_cache.yml +120 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/all.yml +190 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/create.yml +143 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/delete.yml +322 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/find.yml +141 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/all.yml +1020 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/create.yml +133 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/delete.yml +291 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/find.yml +126 -0
- data/spec/fixtures/vcr_cassettes/user/find.yml +96 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/all.yml +151 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/find.yml +88 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/find_not_found.yml +93 -0
- data/spec/fixtures/vcr_cassettes/webhook_health/find.yml +111 -0
- data/spec/lib/contentful/management/client_spec.rb +25 -26
- data/spec/lib/contentful/management/entry_spec.rb +48 -48
- data/spec/lib/contentful/management/organization_spec.rb +33 -0
- data/spec/lib/contentful/management/personal_access_token_spec.rb +85 -0
- data/spec/lib/contentful/management/snapshot_spec.rb +134 -47
- data/spec/lib/contentful/management/space_membership_spec.rb +147 -0
- data/spec/lib/contentful/management/space_spec.rb +35 -1
- data/spec/lib/contentful/management/ui_extension_spec.rb +276 -0
- data/spec/lib/contentful/management/user_spec.rb +52 -0
- data/spec/lib/contentful/management/webhook_calls_spec.rb +69 -0
- data/spec/lib/contentful/management/webhook_health_spec.rb +51 -0
- metadata +88 -8
- data/lib/contentful/management/http_client.rb +0 -89
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'guard-rubocop'
|
32
32
|
spec.add_development_dependency 'guard-yard'
|
33
33
|
spec.add_development_dependency 'rubocop', '~> 0.41.0'
|
34
|
-
spec.add_development_dependency 'listen', '3.0
|
34
|
+
spec.add_development_dependency 'listen', '~> 3.0'
|
35
35
|
spec.add_development_dependency 'vcr'
|
36
36
|
spec.add_development_dependency 'webmock', '~> 1', '>= 1.17.3'
|
37
37
|
spec.add_development_dependency 'simplecov'
|
@@ -53,7 +53,7 @@ module Contentful
|
|
53
53
|
instance_variable_get(:@fields).keys.each do |locale|
|
54
54
|
request = Request.new(
|
55
55
|
client,
|
56
|
-
"/#{space.id}/assets/#{id}/files/#{locale}/process",
|
56
|
+
"spaces/#{space.id}/assets/#{id}/files/#{locale}/process",
|
57
57
|
{},
|
58
58
|
nil,
|
59
59
|
version: sys[:version]
|
@@ -3,17 +3,23 @@ require 'contentful/management/response'
|
|
3
3
|
require 'contentful/management/resource_builder'
|
4
4
|
|
5
5
|
require 'contentful/management/version'
|
6
|
-
require 'contentful/management/http_client'
|
7
6
|
|
8
7
|
require 'contentful/management/client_space_methods_factory'
|
8
|
+
require 'contentful/management/client_space_membership_methods_factory'
|
9
|
+
require 'contentful/management/client_organization_methods_factory'
|
10
|
+
require 'contentful/management/client_user_methods_factory'
|
9
11
|
require 'contentful/management/client_api_key_methods_factory'
|
12
|
+
require 'contentful/management/client_personal_access_tokens_methods_factory'
|
10
13
|
require 'contentful/management/client_asset_methods_factory'
|
11
14
|
require 'contentful/management/client_content_type_methods_factory'
|
12
15
|
require 'contentful/management/client_entry_methods_factory'
|
13
16
|
require 'contentful/management/client_locale_methods_factory'
|
14
17
|
require 'contentful/management/client_role_methods_factory'
|
18
|
+
require 'contentful/management/client_ui_extension_methods_factory'
|
15
19
|
require 'contentful/management/client_editor_interface_methods_factory'
|
16
20
|
require 'contentful/management/client_webhook_methods_factory'
|
21
|
+
require 'contentful/management/client_webhook_call_methods_factory'
|
22
|
+
require 'contentful/management/client_webhook_health_methods_factory'
|
17
23
|
require 'contentful/management/client_upload_methods_factory'
|
18
24
|
require 'contentful/management/client_snapshot_methods_factory'
|
19
25
|
|
@@ -28,10 +34,8 @@ module Contentful
|
|
28
34
|
# Client for interacting with the Contentful Management API
|
29
35
|
# @see _ https://www.contentful.com/developers/docs/references/content-management-api/
|
30
36
|
class Client
|
31
|
-
extend Contentful::Management::HTTPClient
|
32
|
-
|
33
37
|
attr_reader :access_token, :configuration, :logger
|
34
|
-
attr_accessor :organization_id, :version, :
|
38
|
+
attr_accessor :organization_id, :version, :content_type_id, :dynamic_entry_cache
|
35
39
|
|
36
40
|
# Default configuration for Contentful::Management::Client
|
37
41
|
DEFAULT_CONFIGURATION = {
|
@@ -45,6 +49,7 @@ module Contentful
|
|
45
49
|
log_level: Logger::INFO,
|
46
50
|
raise_errors: false,
|
47
51
|
dynamic_entries: [],
|
52
|
+
disable_content_type_caching: false,
|
48
53
|
proxy_host: nil,
|
49
54
|
proxy_port: nil,
|
50
55
|
proxy_username: nil,
|
@@ -70,6 +75,7 @@ module Contentful
|
|
70
75
|
# @option configuration [::Logger::DEBUG, ::Logger::INFO, ::Logger::WARN, ::Logger::ERROR] :log_level
|
71
76
|
# @option configuration [Boolean] :raise_errors
|
72
77
|
# @option configuration [::Array<String>] :dynamic_entries
|
78
|
+
# @option configuration [Boolean] :disable_content_type_caching
|
73
79
|
# @option configuration [String] :proxy_host
|
74
80
|
# @option configuration [Fixnum] :proxy_port
|
75
81
|
# @option configuration [String] :proxy_username
|
@@ -88,7 +94,7 @@ module Contentful
|
|
88
94
|
end
|
89
95
|
|
90
96
|
# Allows manipulation of spaces in context of the current client
|
91
|
-
# Allows listing all spaces for client and finding one by
|
97
|
+
# Allows listing all spaces for client and finding one by ID.
|
92
98
|
# @see _ README for details.
|
93
99
|
#
|
94
100
|
# @return [Contentful::Management::ClientSpaceMethodsFactory]
|
@@ -96,8 +102,35 @@ module Contentful
|
|
96
102
|
ClientSpaceMethodsFactory.new(self)
|
97
103
|
end
|
98
104
|
|
105
|
+
# Allows manipulation of space memberships in context of the current client
|
106
|
+
# Allows listing all space memberships for client, creating new and finding one by ID.
|
107
|
+
# @see _ README for details.
|
108
|
+
#
|
109
|
+
# @return [Contentful::Management::ClientSpaceMembershipMethodsFactory]
|
110
|
+
def space_memberships
|
111
|
+
ClientSpaceMembershipMethodsFactory.new(self)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Allows viewing of organizations in context of the current client
|
115
|
+
# Allows listing all organizations for client.
|
116
|
+
# @see _ README for details.
|
117
|
+
#
|
118
|
+
# @return [Contentful::Management::ClientOrganizationMethodsFactory]
|
119
|
+
def organizations
|
120
|
+
ClientOrganizationMethodsFactory.new(self)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Allows viewing of users in context of the current client
|
124
|
+
# Allows listing all users for client.
|
125
|
+
# @see _ README for details.
|
126
|
+
#
|
127
|
+
# @return [Contentful::Management::ClientUserMethodsFactory]
|
128
|
+
def users
|
129
|
+
ClientUserMethodsFactory.new(self)
|
130
|
+
end
|
131
|
+
|
99
132
|
# Allows manipulation of api keys in context of the current client
|
100
|
-
# Allows listing all api keys for client, creating new and finding one by
|
133
|
+
# Allows listing all api keys for client, creating new and finding one by ID.
|
101
134
|
# @see _ README for details.
|
102
135
|
#
|
103
136
|
# @return [Contentful::Management::ClientApiKeyMethodsFactory]
|
@@ -105,8 +138,17 @@ module Contentful
|
|
105
138
|
ClientApiKeyMethodsFactory.new(self)
|
106
139
|
end
|
107
140
|
|
141
|
+
# Allows manipulation of personal access tokens in context of the current client
|
142
|
+
# Allows listing all personal access tokens for client, creating new and finding one by ID.
|
143
|
+
# @see _ README for details.
|
144
|
+
#
|
145
|
+
# @return [Contentful::Management::ClientPersonalAccessTokenMethodsFactory]
|
146
|
+
def personal_access_tokens
|
147
|
+
ClientPersonalAccessTokenMethodsFactory.new(self)
|
148
|
+
end
|
149
|
+
|
108
150
|
# Allows manipulation of assets in context of the current client
|
109
|
-
# Allows listing all assets for client, creating new and finding one by
|
151
|
+
# Allows listing all assets for client, creating new and finding one by ID.
|
110
152
|
# @see _ README for details.
|
111
153
|
#
|
112
154
|
# @return [Contentful::Management::ClientAssetMethodsFactory]
|
@@ -115,7 +157,7 @@ module Contentful
|
|
115
157
|
end
|
116
158
|
|
117
159
|
# Allows manipulation of content types in context of the current client
|
118
|
-
# Allows listing all content types for client, creating new and finding one by
|
160
|
+
# Allows listing all content types for client, creating new and finding one by ID.
|
119
161
|
# @see _ README for details.
|
120
162
|
#
|
121
163
|
# @return [Contentful::Management::ClientContentTypeMethodsFactory]
|
@@ -124,7 +166,7 @@ module Contentful
|
|
124
166
|
end
|
125
167
|
|
126
168
|
# Allows manipulation of entries in context of the current client
|
127
|
-
# Allows listing all entries for client, creating new and finding one by
|
169
|
+
# Allows listing all entries for client, creating new and finding one by ID.
|
128
170
|
# @see _ README for details.
|
129
171
|
#
|
130
172
|
# @return [Contentful::Management::ClientEntryMethodsFactory]
|
@@ -133,7 +175,7 @@ module Contentful
|
|
133
175
|
end
|
134
176
|
|
135
177
|
# Allows manipulation of locales in context of the current client
|
136
|
-
# Allows listing all locales for client, creating new and finding one by
|
178
|
+
# Allows listing all locales for client, creating new and finding one by ID.
|
137
179
|
# @see _ README for details.
|
138
180
|
#
|
139
181
|
# @return [Contentful::Management::ClientLocaleMethodsFactory]
|
@@ -142,7 +184,7 @@ module Contentful
|
|
142
184
|
end
|
143
185
|
|
144
186
|
# Allows manipulation of roles in context of the current client
|
145
|
-
# Allows listing all roles for client, creating new and finding one by
|
187
|
+
# Allows listing all roles for client, creating new and finding one by ID.
|
146
188
|
# @see _ README for details.
|
147
189
|
#
|
148
190
|
# @return [Contentful::Management::ClientRoleMethodsFactory]
|
@@ -150,8 +192,17 @@ module Contentful
|
|
150
192
|
ClientRoleMethodsFactory.new(self)
|
151
193
|
end
|
152
194
|
|
195
|
+
# Allows manipulation of UI extensions in context of the current client
|
196
|
+
# Allows listing all UI extensions for client, creating new and finding one by ID.
|
197
|
+
# @see _ README for details.
|
198
|
+
#
|
199
|
+
# @return [Contentful::Management::ClientUIExtensionMethodsFactory]
|
200
|
+
def ui_extensions
|
201
|
+
ClientUIExtensionMethodsFactory.new(self)
|
202
|
+
end
|
203
|
+
|
153
204
|
# Allows manipulation of editor interfaces in context of the current client
|
154
|
-
# Allows listing all editor interfaces for client
|
205
|
+
# Allows listing all editor interfaces for client and finding one by content type.
|
155
206
|
# @see _ README for details.
|
156
207
|
#
|
157
208
|
# @return [Contentful::Management::ClientEditorInterfaceMethodsFactory]
|
@@ -160,7 +211,7 @@ module Contentful
|
|
160
211
|
end
|
161
212
|
|
162
213
|
# Allows manipulation of webhooks in context of the current client
|
163
|
-
# Allows listing all webhooks for client, creating new and finding one by
|
214
|
+
# Allows listing all webhooks for client, creating new and finding one by ID.
|
164
215
|
# @see _ README for details.
|
165
216
|
#
|
166
217
|
# @return [Contentful::Management::ClientWebhookMethodsFactory]
|
@@ -168,8 +219,26 @@ module Contentful
|
|
168
219
|
ClientWebhookMethodsFactory.new(self)
|
169
220
|
end
|
170
221
|
|
222
|
+
# Allows manipulation of webhook calls in context of the current client
|
223
|
+
# Allows listing all webhook call details for client and finding one by ID.
|
224
|
+
# @see _ README for details.
|
225
|
+
#
|
226
|
+
# @return [Contentful::Management::ClientWebhookCallMethodsFactory]
|
227
|
+
def webhook_calls
|
228
|
+
ClientWebhookCallMethodsFactory.new(self)
|
229
|
+
end
|
230
|
+
|
231
|
+
# Allows manipulation of webhook health in context of the current client
|
232
|
+
# Allows listing all webhook health details for client and finding one by ID.
|
233
|
+
# @see _ README for details.
|
234
|
+
#
|
235
|
+
# @return [Contentful::Management::ClientWebhookHealthMethodsFactory]
|
236
|
+
def webhook_health
|
237
|
+
ClientWebhookHealthMethodsFactory.new(self)
|
238
|
+
end
|
239
|
+
|
171
240
|
# Allows manipulation of uploads in context of the current client
|
172
|
-
# Allows creating new and finding uploads by
|
241
|
+
# Allows creating new and finding uploads by ID.
|
173
242
|
# @see _ README for details.
|
174
243
|
#
|
175
244
|
# @return [Contentful::Management::ClientUploadMethodsFactory]
|
@@ -178,12 +247,30 @@ module Contentful
|
|
178
247
|
end
|
179
248
|
|
180
249
|
# Allows manipulation of snapshots in context of the current client
|
181
|
-
# Allows listing all
|
250
|
+
# Allows listing all snapshots for client and finding one by ID.
|
251
|
+
# @see _ README for details.
|
252
|
+
#
|
253
|
+
# @return [Contentful::Management::ClientSnapshotMethodsFactory]
|
254
|
+
def snapshots(resource_type = 'entries')
|
255
|
+
ClientSnapshotMethodsFactory.new(self, resource_type)
|
256
|
+
end
|
257
|
+
|
258
|
+
# Allows manipulation of entry snapshots in context of the current client
|
259
|
+
# Allows listing all entry snapshots for client and finding one by ID.
|
260
|
+
# @see _ README for details.
|
261
|
+
#
|
262
|
+
# @return [Contentful::Management::ClientSnapshotMethodsFactory]
|
263
|
+
def entry_snapshots
|
264
|
+
ClientSnapshotMethodsFactory.new(self, 'entries')
|
265
|
+
end
|
266
|
+
|
267
|
+
# Allows manipulation of content type snapshots in context of the current client
|
268
|
+
# Allows listing all content type snapshots for client and finding one by ID.
|
182
269
|
# @see _ README for details.
|
183
270
|
#
|
184
271
|
# @return [Contentful::Management::ClientSnapshotMethodsFactory]
|
185
|
-
def
|
186
|
-
ClientSnapshotMethodsFactory.new(self)
|
272
|
+
def content_type_snapshots
|
273
|
+
ClientSnapshotMethodsFactory.new(self, 'content_types')
|
187
274
|
end
|
188
275
|
|
189
276
|
# @private
|
@@ -194,7 +281,7 @@ module Contentful
|
|
194
281
|
|
195
282
|
# @private
|
196
283
|
def update_all_dynamic_entry_cache!
|
197
|
-
return if configuration[:dynamic_entries].empty?
|
284
|
+
return if configuration[:dynamic_entries].empty? || configuration[:disable_content_type_caching]
|
198
285
|
|
199
286
|
spaces = configuration[:dynamic_entries].map { |space_id| ::Contentful::Management::Space.find(self, space_id) }
|
200
287
|
update_dynamic_entry_cache_for_spaces!(spaces)
|
@@ -202,6 +289,8 @@ module Contentful
|
|
202
289
|
|
203
290
|
# @private
|
204
291
|
def update_dynamic_entry_cache_for_spaces!(spaces)
|
292
|
+
return if configuration[:disable_content_type_caching]
|
293
|
+
|
205
294
|
spaces.each do |space|
|
206
295
|
update_dynamic_entry_cache_for_space!(space)
|
207
296
|
end
|
@@ -211,6 +300,8 @@ module Contentful
|
|
211
300
|
# See README for details.
|
212
301
|
# @private
|
213
302
|
def update_dynamic_entry_cache_for_space!(space)
|
303
|
+
return if configuration[:disable_content_type_caching]
|
304
|
+
|
214
305
|
update_dynamic_entry_cache!(space.content_types.all)
|
215
306
|
end
|
216
307
|
|
@@ -271,7 +362,7 @@ module Contentful
|
|
271
362
|
|
272
363
|
# @private
|
273
364
|
def host_url(request)
|
274
|
-
(%r{
|
365
|
+
(%r{^spaces/[\w|-|_]+/uploads(?:/[\w|-|_]*)?$} =~ request.url) ? uploads_url : base_url
|
275
366
|
end
|
276
367
|
|
277
368
|
# @private
|
@@ -298,39 +389,78 @@ module Contentful
|
|
298
389
|
# @private
|
299
390
|
def delete(request)
|
300
391
|
execute_request(request) do |url|
|
301
|
-
|
392
|
+
http_send(:delete, url, { params: request.query }, request_headers(request), proxy_parameters)
|
302
393
|
end
|
303
394
|
end
|
304
395
|
|
305
396
|
# @private
|
306
397
|
def get(request)
|
307
398
|
execute_request(request) do |url|
|
308
|
-
|
399
|
+
http_send(:get, url, { params: request.query }, request_headers(request), proxy_parameters)
|
309
400
|
end
|
310
401
|
end
|
311
402
|
|
312
403
|
# @private
|
313
404
|
def post(request)
|
314
405
|
execute_request(request) do |url|
|
315
|
-
|
406
|
+
data = if url.include?(Client::DEFAULT_CONFIGURATION[:uploads_url])
|
407
|
+
{ body: request.query }
|
408
|
+
else
|
409
|
+
{ json: request.query }
|
410
|
+
end
|
411
|
+
|
412
|
+
http_send(:post, url, data, request_headers(request), proxy_parameters)
|
316
413
|
end
|
317
414
|
end
|
318
415
|
|
319
416
|
# @private
|
320
417
|
def put(request)
|
321
418
|
execute_request(request) do |url|
|
322
|
-
|
419
|
+
http_send(:put, url, { json: request.query }, request_headers(request), proxy_parameters)
|
323
420
|
end
|
324
421
|
end
|
325
422
|
|
423
|
+
# Proxy Helper
|
424
|
+
#
|
425
|
+
# @param [Symbol] type
|
426
|
+
# @param [String] url
|
427
|
+
# @param [Hash] params
|
428
|
+
# @param [Hash] headers
|
429
|
+
# @param [Hash] proxy
|
430
|
+
#
|
431
|
+
# @return [HTTP::Response]
|
432
|
+
def proxy_send(type, url, params, headers, proxy)
|
433
|
+
HTTP[headers].via(
|
434
|
+
proxy[:host],
|
435
|
+
proxy[:port],
|
436
|
+
proxy[:username],
|
437
|
+
proxy[:password]
|
438
|
+
).public_send(type, url, params)
|
439
|
+
end
|
440
|
+
|
441
|
+
# HTTP Helper
|
442
|
+
# Abtracts the Proxy/No-Proxy logic
|
443
|
+
#
|
444
|
+
# @param [Symbol] type
|
445
|
+
# @param [String] url
|
446
|
+
# @param [Hash] params
|
447
|
+
# @param [Hash] headers
|
448
|
+
# @param [Hash] proxy
|
449
|
+
#
|
450
|
+
# @return [HTTP::Response]
|
451
|
+
def http_send(type, url, params, headers, proxy)
|
452
|
+
return proxy_send(type, url, params, headers, proxy) unless proxy[:host].nil?
|
453
|
+
HTTP[headers].public_send(type, url, params)
|
454
|
+
end
|
455
|
+
|
326
456
|
# @private
|
327
457
|
def base_url
|
328
|
-
"#{protocol}://#{configuration[:api_url]}/
|
458
|
+
"#{protocol}://#{configuration[:api_url]}/"
|
329
459
|
end
|
330
460
|
|
331
461
|
# @private
|
332
462
|
def uploads_url
|
333
|
-
"#{protocol}://#{configuration[:uploads_url]}/
|
463
|
+
"#{protocol}://#{configuration[:uploads_url]}/"
|
334
464
|
end
|
335
465
|
|
336
466
|
# @private
|
@@ -436,11 +566,6 @@ module Contentful
|
|
436
566
|
Hash['X-Contentful-Content-Type', content_type_id]
|
437
567
|
end
|
438
568
|
|
439
|
-
# @private
|
440
|
-
def zero_length_header
|
441
|
-
Hash['Content-Length', 0]
|
442
|
-
end
|
443
|
-
|
444
569
|
# @private
|
445
570
|
def accept_encoding_header(encoding)
|
446
571
|
Hash['Accept-Encoding', encoding]
|
@@ -455,7 +580,6 @@ module Contentful
|
|
455
580
|
headers.merge! api_version_header
|
456
581
|
headers.merge! organization_header(organization_id) if organization_id
|
457
582
|
headers.merge! version_header(version) if version
|
458
|
-
headers.merge! zero_length_header if zero_length
|
459
583
|
headers.merge! content_type_header(content_type_id) if content_type_id
|
460
584
|
headers.merge! accept_encoding_header('gzip') if gzip_encoded
|
461
585
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'client_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for Organizations API for usage from within Client
|
6
|
+
# @private
|
7
|
+
class ClientOrganizationMethodsFactory
|
8
|
+
include Contentful::Management::ClientAssociationMethodsFactory
|
9
|
+
|
10
|
+
def new(*)
|
11
|
+
fail 'Not supported'
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(*)
|
15
|
+
fail 'Not supported'
|
16
|
+
end
|
17
|
+
|
18
|
+
def all(*)
|
19
|
+
super(nil)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'client_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for Personal Access Token API for usage from within Client
|
6
|
+
# @private
|
7
|
+
class ClientPersonalAccessTokenMethodsFactory
|
8
|
+
include Contentful::Management::ClientAssociationMethodsFactory
|
9
|
+
|
10
|
+
def new(*)
|
11
|
+
fail 'Not supported'
|
12
|
+
end
|
13
|
+
|
14
|
+
def all(params = {})
|
15
|
+
super(nil, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(personal_access_token_id)
|
19
|
+
super(nil, personal_access_token_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(attributes)
|
23
|
+
super(nil, attributes)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,21 +7,31 @@ module Contentful
|
|
7
7
|
class ClientSnapshotMethodsFactory
|
8
8
|
include Contentful::Management::ClientAssociationMethodsFactory
|
9
9
|
|
10
|
+
def initialize(client, resource_type)
|
11
|
+
super(client)
|
12
|
+
@resource_type = resource_type
|
13
|
+
end
|
14
|
+
|
10
15
|
def create(*)
|
11
16
|
fail 'Not supported'
|
12
17
|
end
|
13
18
|
|
14
|
-
def all(space_id,
|
15
|
-
@resource_requester.
|
16
|
-
|
17
|
-
|
19
|
+
def all(space_id, resource_id, params = {})
|
20
|
+
@resource_requester.all(
|
21
|
+
{
|
22
|
+
resource_type: @resource_type,
|
23
|
+
space_id: space_id,
|
24
|
+
resource_id: resource_id
|
25
|
+
},
|
26
|
+
params
|
18
27
|
)
|
19
28
|
end
|
20
29
|
|
21
|
-
def find(space_id,
|
30
|
+
def find(space_id, resource_id, snapshot_id)
|
22
31
|
@resource_requester.find(
|
32
|
+
resource_type: @resource_type,
|
23
33
|
space_id: space_id,
|
24
|
-
|
34
|
+
resource_id: resource_id,
|
25
35
|
snapshot_id: snapshot_id
|
26
36
|
)
|
27
37
|
end
|