contentful-management 0.9.0 → 1.0.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/.rubocop_todo.yml +2 -2
- data/CHANGELOG.md +27 -3
- data/README.md +34 -7
- data/lib/contentful/management/api_key.rb +4 -43
- data/lib/contentful/management/array.rb +1 -2
- data/lib/contentful/management/asset.rb +29 -191
- data/lib/contentful/management/client.rb +96 -7
- data/lib/contentful/management/client_api_key_methods_factory.rb +15 -0
- data/lib/contentful/management/client_asset_methods_factory.rb +13 -0
- data/lib/contentful/management/client_association_all_published_method_factory.rb +21 -0
- data/lib/contentful/management/client_association_methods_factory.rb +54 -0
- data/lib/contentful/management/client_content_type_methods_factory.rb +13 -0
- data/lib/contentful/management/client_entry_methods_factory.rb +21 -0
- data/lib/contentful/management/client_locale_methods_factory.rb +15 -0
- data/lib/contentful/management/client_space_methods_factory.rb +58 -0
- data/lib/contentful/management/client_webhook_methods_factory.rb +15 -0
- data/lib/contentful/management/content_type.rb +30 -151
- data/lib/contentful/management/content_type_entry_methods_factory.rb +9 -3
- data/lib/contentful/management/dynamic_entry.rb +20 -39
- data/lib/contentful/management/entry.rb +47 -182
- data/lib/contentful/management/http_client.rb +41 -8
- data/lib/contentful/management/locale.rb +7 -76
- data/lib/contentful/management/request.rb +3 -3
- data/lib/contentful/management/resource.rb +105 -7
- data/lib/contentful/management/resource/all_published.rb +24 -0
- data/lib/contentful/management/resource/archiver.rb +37 -0
- data/lib/contentful/management/resource/field_aware.rb +49 -29
- data/lib/contentful/management/resource/publisher.rb +37 -0
- data/lib/contentful/management/resource/refresher.rb +1 -1
- data/lib/contentful/management/resource_builder.rb +8 -4
- data/lib/contentful/management/resource_requester.rb +96 -0
- data/lib/contentful/management/space.rb +40 -43
- data/lib/contentful/management/space_association_all_published_method_factory.rb +1 -1
- data/lib/contentful/management/space_association_methods_factory.rb +6 -3
- data/lib/contentful/management/space_entry_methods_factory.rb +1 -1
- data/lib/contentful/management/version.rb +1 -1
- data/lib/contentful/management/webhook.rb +9 -82
- data/spec/fixtures/vcr_cassettes/asset/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/asset/create_with_locale.yml +1 -1
- data/spec/fixtures/vcr_cassettes/asset/process.yml +1 -1
- data/spec/fixtures/vcr_cassettes/asset/publish_after_create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Array_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Boolean_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Date_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Integer_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Link_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Location_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Number_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Object_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Symbol_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Text_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_types.yml +1 -1
- data/spec/fixtures/vcr_cassettes/content_type/save_new.yml +1 -1
- data/spec/fixtures/vcr_cassettes/delete_request.yml +38 -0
- data/spec/fixtures/vcr_cassettes/entry/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_asset.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_assets.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_entries.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_entry.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_just_id.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_location.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_specified_locale.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_symbols.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/too_many_requests.yml +1 -1
- data/spec/fixtures/vcr_cassettes/entry/update_bool_field.yml +1 -1
- data/spec/fixtures/vcr_cassettes/post_request.yml +64 -0
- data/spec/fixtures/vcr_cassettes/proxy_request.yml +562 -0
- data/spec/fixtures/vcr_cassettes/put_request.yml +40 -0
- data/spec/fixtures/vcr_cassettes/space/asset/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/space/asset/create_with_multiple_locales.yml +1 -1
- data/spec/fixtures/vcr_cassettes/space/content_type/create.yml +1 -1
- data/spec/fixtures/vcr_cassettes/space/create_with_client_default_locale.yml +197 -36
- data/spec/fixtures/vcr_cassettes/space/webhook/create.yml +1 -1
- data/spec/lib/contentful/management/api_key_spec.rb +7 -1
- data/spec/lib/contentful/management/array_spec.rb +1 -1
- data/spec/lib/contentful/management/asset_spec.rb +52 -32
- data/spec/lib/contentful/management/client_spec.rb +38 -0
- data/spec/lib/contentful/management/content_type_spec.rb +37 -22
- data/spec/lib/contentful/management/entry_spec.rb +68 -57
- data/spec/lib/contentful/management/locale_spec.rb +7 -1
- data/spec/lib/contentful/management/space_spec.rb +9 -3
- data/spec/lib/contentful/management/webhook_spec.rb +11 -5
- metadata +23 -2
@@ -11,9 +11,12 @@ module Contentful
|
|
11
11
|
|
12
12
|
let!(:client) { Client.new(token) }
|
13
13
|
|
14
|
-
subject {
|
14
|
+
subject { client.locales }
|
15
15
|
|
16
16
|
describe '.all' do
|
17
|
+
it 'class method also works' do
|
18
|
+
vcr('locale/all_for_space') { expect(Contentful::Management::Locale.all(client, space_id)).to be_kind_of Contentful::Management::Array }
|
19
|
+
end
|
17
20
|
it 'returns a Contentful::Array' do
|
18
21
|
vcr('locale/all_for_space') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
|
19
22
|
end
|
@@ -23,6 +26,9 @@ module Contentful
|
|
23
26
|
end
|
24
27
|
|
25
28
|
describe '.find' do
|
29
|
+
it 'class method also works' do
|
30
|
+
vcr('locale/find') { expect(Contentful::Management::Locale.find(client, space_id, locale_id)).to be_kind_of Contentful::Management::Locale }
|
31
|
+
end
|
26
32
|
it 'returns a Contentful::Management::Locale' do
|
27
33
|
vcr('locale/find') { expect(subject.find(space_id, locale_id)).to be_kind_of Contentful::Management::Locale }
|
28
34
|
end
|
@@ -10,9 +10,12 @@ module Contentful
|
|
10
10
|
|
11
11
|
let!(:client) { Client.new(token) }
|
12
12
|
|
13
|
-
subject {
|
13
|
+
subject { client.spaces }
|
14
14
|
|
15
15
|
describe '.all' do
|
16
|
+
it 'class method also works' do
|
17
|
+
vcr('space/all') { expect(Contentful::Management::Space.all(client)).to be_kind_of Contentful::Management::Array }
|
18
|
+
end
|
16
19
|
it 'returns a Contentful::Array' do
|
17
20
|
vcr('space/all') { expect(subject.all).to be_kind_of Contentful::Management::Array }
|
18
21
|
end
|
@@ -22,6 +25,9 @@ module Contentful
|
|
22
25
|
end
|
23
26
|
|
24
27
|
describe '.find' do
|
28
|
+
it 'class method also works' do
|
29
|
+
vcr('space/find') { expect(Contentful::Management::Space.find(client, space_id)).to be_kind_of Contentful::Management::Space }
|
30
|
+
end
|
25
31
|
it 'returns a Contentful::Management::Space' do
|
26
32
|
vcr('space/find') { expect(subject.find(space_id)).to be_kind_of Contentful::Management::Space }
|
27
33
|
end
|
@@ -96,8 +102,8 @@ module Contentful
|
|
96
102
|
end
|
97
103
|
it 'creates a space within a client default locale' do
|
98
104
|
vcr('space/create_with_client_default_locale') do
|
99
|
-
Client.new('<ACCESS_TOKEN>', default_locale: 'pl-PL')
|
100
|
-
space =
|
105
|
+
client = Client.new('<ACCESS_TOKEN>', default_locale: 'pl-PL')
|
106
|
+
space = client.spaces.create(name: 'new space', organization_id: '4SsuxQCaMaemfIms52Jr8s')
|
101
107
|
expect(space).to be_kind_of Contentful::Management::Space
|
102
108
|
expect(space.name).to eq 'new space'
|
103
109
|
expect(space.locales.all.first.code).to eql 'pl-PL'
|
@@ -10,9 +10,12 @@ module Contentful
|
|
10
10
|
let(:webhook_id) { '0rK8ZNEOWLgYnO5gaah2pp' }
|
11
11
|
let!(:client) { Client.new(token) }
|
12
12
|
|
13
|
-
subject {
|
13
|
+
subject { client.webhooks }
|
14
14
|
|
15
15
|
describe '.all' do
|
16
|
+
it 'class method also works' do
|
17
|
+
vcr('webhook/all') { expect(Contentful::Management::Webhook.all(client, space_id)).to be_kind_of Contentful::Management::Array }
|
18
|
+
end
|
16
19
|
it 'returns a Contentful::Array' do
|
17
20
|
vcr('webhook/all') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
|
18
21
|
end
|
@@ -22,6 +25,9 @@ module Contentful
|
|
22
25
|
end
|
23
26
|
|
24
27
|
describe '.find' do
|
28
|
+
it 'class method also works' do
|
29
|
+
vcr('webhook/find') { expect(Contentful::Management::Webhook.find(client, space_id, webhook_id)).to be_kind_of Contentful::Management::Webhook }
|
30
|
+
end
|
25
31
|
it 'returns a Contentful::Management::Webhook' do
|
26
32
|
vcr('webhook/find') { expect(subject.find(space_id, webhook_id)).to be_kind_of Contentful::Management::Webhook }
|
27
33
|
end
|
@@ -42,14 +48,14 @@ module Contentful
|
|
42
48
|
describe '.create' do
|
43
49
|
it 'builds Contentful::Management::Webhook object' do
|
44
50
|
vcr('webhook/create') do
|
45
|
-
webhook =
|
51
|
+
webhook = subject.create(space_id, id: 'test_webhook', url: 'https://www.example3.com')
|
46
52
|
expect(webhook).to be_kind_of Contentful::Management::Webhook
|
47
53
|
expect(webhook.url).to eq 'https://www.example3.com'
|
48
54
|
end
|
49
55
|
end
|
50
56
|
it 'return error if url is already taken' do
|
51
57
|
vcr('webhook/create_with_taken_url') do
|
52
|
-
webhook =
|
58
|
+
webhook = subject.create(space_id, id: 'taken_webhook', url: 'https://www.example3.com')
|
53
59
|
expect(webhook).to be_kind_of Contentful::Management::Error
|
54
60
|
end
|
55
61
|
end
|
@@ -58,7 +64,7 @@ module Contentful
|
|
58
64
|
describe '#update' do
|
59
65
|
it 'all parameters' do
|
60
66
|
vcr('webhook/update') do
|
61
|
-
webhook =
|
67
|
+
webhook = subject.find(space_id, 'test_webhook')
|
62
68
|
updated_webhook = webhook.update(url: 'https://www.example5.com',
|
63
69
|
httpBasicUsername: 'test_username',
|
64
70
|
httpBasicPassword: 'test_password')
|
@@ -72,7 +78,7 @@ module Contentful
|
|
72
78
|
describe '#destroy' do
|
73
79
|
it 'returns true' do
|
74
80
|
vcr('webhook/destroy') do
|
75
|
-
webhook =
|
81
|
+
webhook = subject.find(space_id, 'test_webhook')
|
76
82
|
result = webhook.destroy
|
77
83
|
expect(result).to eq true
|
78
84
|
end
|
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: 1.0.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: 2016-
|
13
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -206,6 +206,15 @@ files:
|
|
206
206
|
- lib/contentful/management/array.rb
|
207
207
|
- lib/contentful/management/asset.rb
|
208
208
|
- lib/contentful/management/client.rb
|
209
|
+
- lib/contentful/management/client_api_key_methods_factory.rb
|
210
|
+
- lib/contentful/management/client_asset_methods_factory.rb
|
211
|
+
- lib/contentful/management/client_association_all_published_method_factory.rb
|
212
|
+
- lib/contentful/management/client_association_methods_factory.rb
|
213
|
+
- lib/contentful/management/client_content_type_methods_factory.rb
|
214
|
+
- lib/contentful/management/client_entry_methods_factory.rb
|
215
|
+
- lib/contentful/management/client_locale_methods_factory.rb
|
216
|
+
- lib/contentful/management/client_space_methods_factory.rb
|
217
|
+
- lib/contentful/management/client_webhook_methods_factory.rb
|
209
218
|
- lib/contentful/management/content_type.rb
|
210
219
|
- lib/contentful/management/content_type_entry_methods_factory.rb
|
211
220
|
- lib/contentful/management/dynamic_entry.rb
|
@@ -219,14 +228,18 @@ files:
|
|
219
228
|
- lib/contentful/management/location.rb
|
220
229
|
- lib/contentful/management/request.rb
|
221
230
|
- lib/contentful/management/resource.rb
|
231
|
+
- lib/contentful/management/resource/all_published.rb
|
232
|
+
- lib/contentful/management/resource/archiver.rb
|
222
233
|
- lib/contentful/management/resource/array_like.rb
|
223
234
|
- lib/contentful/management/resource/asset_fields.rb
|
224
235
|
- lib/contentful/management/resource/entry_fields.rb
|
225
236
|
- lib/contentful/management/resource/field_aware.rb
|
226
237
|
- lib/contentful/management/resource/fields.rb
|
238
|
+
- lib/contentful/management/resource/publisher.rb
|
227
239
|
- lib/contentful/management/resource/refresher.rb
|
228
240
|
- lib/contentful/management/resource/system_properties.rb
|
229
241
|
- lib/contentful/management/resource_builder.rb
|
242
|
+
- lib/contentful/management/resource_requester.rb
|
230
243
|
- lib/contentful/management/response.rb
|
231
244
|
- lib/contentful/management/space.rb
|
232
245
|
- lib/contentful/management/space_api_key_methods_factory.rb
|
@@ -344,6 +357,7 @@ files:
|
|
344
357
|
- spec/fixtures/vcr_cassettes/content_type/validation/range_update.yml
|
345
358
|
- spec/fixtures/vcr_cassettes/content_type/validation/regexp.yml
|
346
359
|
- spec/fixtures/vcr_cassettes/content_type/validation/size.yml
|
360
|
+
- spec/fixtures/vcr_cassettes/delete_request.yml
|
347
361
|
- spec/fixtures/vcr_cassettes/entry/all.yml
|
348
362
|
- spec/fixtures/vcr_cassettes/entry/all_public.yml
|
349
363
|
- spec/fixtures/vcr_cassettes/entry/archive.yml
|
@@ -425,6 +439,9 @@ files:
|
|
425
439
|
- spec/fixtures/vcr_cassettes/locale/update_both.yml
|
426
440
|
- spec/fixtures/vcr_cassettes/locale/update_code.yml
|
427
441
|
- spec/fixtures/vcr_cassettes/locale/update_name.yml
|
442
|
+
- spec/fixtures/vcr_cassettes/post_request.yml
|
443
|
+
- spec/fixtures/vcr_cassettes/proxy_request.yml
|
444
|
+
- spec/fixtures/vcr_cassettes/put_request.yml
|
428
445
|
- spec/fixtures/vcr_cassettes/space/all.yml
|
429
446
|
- spec/fixtures/vcr_cassettes/space/api_key/all.yml
|
430
447
|
- spec/fixtures/vcr_cassettes/space/api_key/create.yml
|
@@ -616,6 +633,7 @@ test_files:
|
|
616
633
|
- spec/fixtures/vcr_cassettes/content_type/validation/range_update.yml
|
617
634
|
- spec/fixtures/vcr_cassettes/content_type/validation/regexp.yml
|
618
635
|
- spec/fixtures/vcr_cassettes/content_type/validation/size.yml
|
636
|
+
- spec/fixtures/vcr_cassettes/delete_request.yml
|
619
637
|
- spec/fixtures/vcr_cassettes/entry/all.yml
|
620
638
|
- spec/fixtures/vcr_cassettes/entry/all_public.yml
|
621
639
|
- spec/fixtures/vcr_cassettes/entry/archive.yml
|
@@ -697,6 +715,9 @@ test_files:
|
|
697
715
|
- spec/fixtures/vcr_cassettes/locale/update_both.yml
|
698
716
|
- spec/fixtures/vcr_cassettes/locale/update_code.yml
|
699
717
|
- spec/fixtures/vcr_cassettes/locale/update_name.yml
|
718
|
+
- spec/fixtures/vcr_cassettes/post_request.yml
|
719
|
+
- spec/fixtures/vcr_cassettes/proxy_request.yml
|
720
|
+
- spec/fixtures/vcr_cassettes/put_request.yml
|
700
721
|
- spec/fixtures/vcr_cassettes/space/all.yml
|
701
722
|
- spec/fixtures/vcr_cassettes/space/api_key/all.yml
|
702
723
|
- spec/fixtures/vcr_cassettes/space/api_key/create.yml
|