contentful-management 3.2.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -0
- data/CHANGELOG.md +10 -0
- data/README.md +45 -1
- data/lib/contentful/management/asset.rb +2 -2
- data/lib/contentful/management/client.rb +10 -0
- data/lib/contentful/management/client_tag_methods_factory.rb +11 -0
- data/lib/contentful/management/editor_interface.rb +12 -4
- data/lib/contentful/management/entry.rb +16 -3
- data/lib/contentful/management/environment.rb +10 -0
- data/lib/contentful/management/environment_tag_methods_factory.rb +11 -0
- data/lib/contentful/management/resource/refresher.rb +1 -0
- data/lib/contentful/management/resource_requester.rb +2 -2
- data/lib/contentful/management/tag.rb +27 -0
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/editor_interfaces/update_sidebar.yml +553 -0
- data/spec/fixtures/vcr_cassettes/entry/references.yml +496 -0
- data/spec/fixtures/vcr_cassettes/environment/tag_proxy.yml +658 -0
- data/spec/fixtures/vcr_cassettes/tag/add_tag_to_asset.yml +456 -0
- data/spec/fixtures/vcr_cassettes/tag/add_tag_to_entry.yml +315 -0
- data/spec/fixtures/vcr_cassettes/tag/all.yml +252 -0
- data/spec/fixtures/vcr_cassettes/tag/create_asset_with_tags.yml +147 -0
- data/spec/fixtures/vcr_cassettes/tag/create_entry_with_tags.yml +293 -0
- data/spec/fixtures/vcr_cassettes/tag/create_visibility_private.yml +125 -0
- data/spec/fixtures/vcr_cassettes/tag/create_visibility_public.yml +125 -0
- data/spec/fixtures/vcr_cassettes/tag/destroy.yml +208 -0
- data/spec/fixtures/vcr_cassettes/tag/destroy_referenced.yml +226 -0
- data/spec/fixtures/vcr_cassettes/tag/find.yml +125 -0
- data/spec/fixtures/vcr_cassettes/tag/not_found.yml +98 -0
- data/spec/fixtures/vcr_cassettes/tag/remove_tag_from_asset.yml +456 -0
- data/spec/fixtures/vcr_cassettes/tag/remove_tag_from_entry.yml +315 -0
- data/spec/fixtures/vcr_cassettes/tag/update.yml +251 -0
- data/spec/lib/contentful/management/editor_interface_spec.rb +30 -0
- data/spec/lib/contentful/management/entry_spec.rb +11 -0
- data/spec/lib/contentful/management/environment_spec.rb +12 -0
- data/spec/lib/contentful/management/tag_spec.rb +186 -0
- metadata +45 -7
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60951b91e0b816f76ce81387b1be4d70673f7365b384161d3882fadbc04d947e
|
4
|
+
data.tar.gz: ffbde8522e8ffb96dd247f2c14508e48b505ca00f6e4c71047f905472cc30eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbda6173a0e1cb13a62f4f9aa8274969a011bca71866aab1be0983f367dfabb6041b2cc132c9fbb5b4d22d235e9d07647c6ec28a6ebe84cfd2ddffb3f1c09271
|
7
|
+
data.tar.gz: fac67fa15e95c1dbdcf44c9ebe0934d7be17d54825dc24f16b12cea7a1b746f90ba31b301b4023040a815b97574b89eb3ad09c0f476f36eb3170dfeb02166cf7
|
@@ -0,0 +1,23 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test_and_lint:
|
5
|
+
parameters:
|
6
|
+
ruby-version:
|
7
|
+
type: string
|
8
|
+
docker:
|
9
|
+
- image: cimg/ruby:<< parameters.ruby-version >>
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run: gem install bundler
|
13
|
+
- run: bundle install
|
14
|
+
- run: bundle exec rake rspec_rubocop
|
15
|
+
|
16
|
+
workflows:
|
17
|
+
version: 2
|
18
|
+
workflow:
|
19
|
+
jobs:
|
20
|
+
- test_and_lint:
|
21
|
+
matrix:
|
22
|
+
parameters:
|
23
|
+
ruby-version: ["2.6", "2.7", "3.0"]
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 3.5.0
|
6
|
+
* Added support for Entry References API
|
7
|
+
|
8
|
+
## 3.4.0
|
9
|
+
* Changed CI/CD vendor
|
10
|
+
* Added support for Tags API
|
11
|
+
|
12
|
+
## 3.3.0
|
13
|
+
* Added getter/setter for EditorInterface#sidebar
|
14
|
+
|
5
15
|
## 3.2.0
|
6
16
|
* Added support for parameters on Users API. [#227](https://github.com/contentful/contentful-management.rb/pull/227)
|
7
17
|
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Contentful::Management
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/contentful-management.svg)](http://badge.fury.io/rb/contentful-management) [![
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/contentful-management.svg)](http://badge.fury.io/rb/contentful-management) [![CircleCI](https://circleci.com/gh/contentful/contentful-management.rb/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/contentful/contentful-management.rb?branch=master)
|
3
3
|
|
4
4
|
Ruby client for the Contentful Content Management API.
|
5
5
|
|
@@ -640,6 +640,50 @@ Destroying a locale:
|
|
640
640
|
blog_post_locale.destroy
|
641
641
|
```
|
642
642
|
|
643
|
+
### Tags
|
644
|
+
|
645
|
+
Retrieving all tags from the environment:
|
646
|
+
|
647
|
+
```ruby
|
648
|
+
tags = environment.tags.all
|
649
|
+
```
|
650
|
+
|
651
|
+
Retrieving one tag by ID from the environment:
|
652
|
+
|
653
|
+
```ruby
|
654
|
+
tag = environment.tags.find(tag_id)
|
655
|
+
```
|
656
|
+
|
657
|
+
Creating a tag:
|
658
|
+
|
659
|
+
```ruby
|
660
|
+
environment.tags.create(name: 'tag name', id: 'tagID')
|
661
|
+
```
|
662
|
+
|
663
|
+
Updating a tag:
|
664
|
+
|
665
|
+
```ruby
|
666
|
+
tag.update(name: 'new name')
|
667
|
+
```
|
668
|
+
|
669
|
+
Destroying a tag:
|
670
|
+
|
671
|
+
```ruby
|
672
|
+
tag.destroy
|
673
|
+
```
|
674
|
+
|
675
|
+
Tagging an entry:
|
676
|
+
|
677
|
+
```ruby
|
678
|
+
entry.update(_metadata: {"tags": [{ "sys": { "type": "Link", "linkType": "Tag", "id": "fooTag" } }]})
|
679
|
+
```
|
680
|
+
|
681
|
+
Tagging an asset:
|
682
|
+
|
683
|
+
```ruby
|
684
|
+
asset.update(_metadata: {"tags": [{ "sys": { "type": "Link", "linkType": "Tag", "id": "fooTag" } }]})
|
685
|
+
```
|
686
|
+
|
643
687
|
### Roles
|
644
688
|
|
645
689
|
Retrieving all roles from the space:
|
@@ -40,7 +40,7 @@ module Contentful
|
|
40
40
|
fields[:description] = { locale => attributes[:description] } if attributes[:description]
|
41
41
|
fields[:file] = { locale => attributes[:file].properties } if attributes[:file]
|
42
42
|
|
43
|
-
{ fields: fields }
|
43
|
+
{ fields: fields, metadata: attributes[:_metadata] }
|
44
44
|
end
|
45
45
|
|
46
46
|
# @private
|
@@ -122,7 +122,7 @@ module Contentful
|
|
122
122
|
self.description = attributes[:description] || description
|
123
123
|
self.file = attributes[:file] || file
|
124
124
|
|
125
|
-
{ fields: fields_for_query }
|
125
|
+
{ fields: fields_for_query, metadata: attributes[:_metadata] }
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -10,6 +10,7 @@ require 'contentful/management/version'
|
|
10
10
|
require 'contentful/management/response'
|
11
11
|
require 'contentful/management/resource_builder'
|
12
12
|
|
13
|
+
require 'contentful/management/client_tag_methods_factory'
|
13
14
|
require 'contentful/management/client_role_methods_factory'
|
14
15
|
require 'contentful/management/client_user_methods_factory'
|
15
16
|
require 'contentful/management/client_space_methods_factory'
|
@@ -194,6 +195,15 @@ module Contentful
|
|
194
195
|
ClientAssetMethodsFactory.new(self, space_id, environment_id)
|
195
196
|
end
|
196
197
|
|
198
|
+
# Allows manipulation of tags in context of the current client
|
199
|
+
# Allows listing all tags for client, creating new and finding one by ID.
|
200
|
+
# @see _ README for details.
|
201
|
+
#
|
202
|
+
# @return [Contentful::Management::ClientTagMethodsFactory]
|
203
|
+
def tags(space_id, environment_id)
|
204
|
+
ClientTagMethodsFactory.new(self, space_id, environment_id)
|
205
|
+
end
|
206
|
+
|
197
207
|
# Allows manipulation of content types in context of the current client
|
198
208
|
# Allows listing all content types for client, creating new and finding one by ID.
|
199
209
|
# @see _ README for details.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'client_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for Tag API for usage from within Client
|
6
|
+
# @private
|
7
|
+
class ClientTagMethodsFactory
|
8
|
+
include Contentful::Management::ClientAssociationMethodsFactory
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -11,6 +11,7 @@ module Contentful
|
|
11
11
|
include Contentful::Management::Resource::EnvironmentAware
|
12
12
|
|
13
13
|
property :controls, :array
|
14
|
+
property :sidebar, :array
|
14
15
|
|
15
16
|
# Gets the Default Editor Interface
|
16
17
|
#
|
@@ -39,7 +40,10 @@ module Contentful
|
|
39
40
|
|
40
41
|
# @private
|
41
42
|
def self.create_attributes(_client, attributes)
|
42
|
-
{
|
43
|
+
{
|
44
|
+
'controls' => attributes.fetch(:controls),
|
45
|
+
'sidebar' => attributes.fetch(:sidebar)
|
46
|
+
}
|
43
47
|
end
|
44
48
|
|
45
49
|
# @private
|
@@ -54,7 +58,7 @@ module Contentful
|
|
54
58
|
# Updates an Editor Interface
|
55
59
|
#
|
56
60
|
# @param [Hash] attributes
|
57
|
-
# @option attributes [Array<Hash>] :controls
|
61
|
+
# @option attributes [Array<Hash>] :controls, :sidebar
|
58
62
|
#
|
59
63
|
# @return [Contentful::Management::EditorInterface]
|
60
64
|
def update(attributes)
|
@@ -66,7 +70,10 @@ module Contentful
|
|
66
70
|
content_type_id: content_type.id,
|
67
71
|
editor_id: id
|
68
72
|
},
|
69
|
-
{
|
73
|
+
{
|
74
|
+
'controls' => attributes[:controls] || controls,
|
75
|
+
'sidebar' => attributes[:sidebar] || sidebar
|
76
|
+
},
|
70
77
|
version: sys[:version]
|
71
78
|
)
|
72
79
|
end
|
@@ -86,7 +93,8 @@ module Contentful
|
|
86
93
|
|
87
94
|
def query_attributes(attributes)
|
88
95
|
{
|
89
|
-
controls: controls
|
96
|
+
controls: controls,
|
97
|
+
sidebar: sidebar
|
90
98
|
}.merge(
|
91
99
|
attributes.each_with_object({}) { |(k, v), result| result[k.to_sym] = v }
|
92
100
|
)
|
@@ -58,8 +58,7 @@ module Contentful
|
|
58
58
|
end
|
59
59
|
|
60
60
|
client.register_dynamic_entry(content_type.id, DynamicEntry.create(content_type, client))
|
61
|
-
|
62
|
-
{ fields: fields_for_create }
|
61
|
+
{ fields: fields_for_create, metadata: attributes[:_metadata] }
|
63
62
|
end
|
64
63
|
|
65
64
|
# @private
|
@@ -180,10 +179,24 @@ module Contentful
|
|
180
179
|
EntrySnapshotMethodsFactory.new(self)
|
181
180
|
end
|
182
181
|
|
182
|
+
def references(query = {}, headers = {})
|
183
|
+
ResourceRequester.new(client, self.class).all(
|
184
|
+
{
|
185
|
+
space_id: space.id,
|
186
|
+
environment_id: environment_id,
|
187
|
+
resource_id: id,
|
188
|
+
suffix: '/references'
|
189
|
+
},
|
190
|
+
query,
|
191
|
+
headers
|
192
|
+
)
|
193
|
+
end
|
194
|
+
|
183
195
|
protected
|
184
196
|
|
185
197
|
def query_attributes(attributes)
|
186
|
-
{
|
198
|
+
{ metadata: attributes.delete(:_metadata),
|
199
|
+
fields: Contentful::Management::Support.deep_hash_merge(fields_for_query, fields_from_attributes(attributes)) }
|
187
200
|
end
|
188
201
|
|
189
202
|
private
|
@@ -4,6 +4,7 @@ require_relative 'environment_locale_methods_factory'
|
|
4
4
|
require_relative 'environment_content_type_methods_factory'
|
5
5
|
require_relative 'environment_ui_extension_methods_factory'
|
6
6
|
require_relative 'environment_editor_interface_methods_factory'
|
7
|
+
require_relative 'environment_tag_methods_factory'
|
7
8
|
|
8
9
|
module Contentful
|
9
10
|
module Management
|
@@ -121,6 +122,15 @@ module Contentful
|
|
121
122
|
EnvironmentEditorInterfaceMethodsFactory.new(self)
|
122
123
|
end
|
123
124
|
|
125
|
+
# Allows manipulation of tags in context of the current environment
|
126
|
+
# Allows listing all tags for the current environment, creating new and finding one by ID.
|
127
|
+
# @see _ README for details.
|
128
|
+
#
|
129
|
+
# @return [Contentful::Management::EnvironmentTagMethodsFactory]
|
130
|
+
def tags
|
131
|
+
EnvironmentTagMethodsFactory.new(self)
|
132
|
+
end
|
133
|
+
|
124
134
|
# Gets the environment ID
|
125
135
|
def environment_id
|
126
136
|
id
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'environment_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for Tag API for usage from within Environment
|
6
|
+
# @private
|
7
|
+
class EnvironmentTagMethodsFactory
|
8
|
+
include Contentful::Management::EnvironmentAssociationMethodsFactory
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -24,6 +24,7 @@ module Contentful
|
|
24
24
|
@properties = resource.instance_variable_get(:@properties)
|
25
25
|
@fields = resource.instance_variable_get(:@fields)
|
26
26
|
@sys = resource.instance_variable_get(:@sys).merge(locale: locale)
|
27
|
+
@_metadata = resource.instance_variable_get(:@_metadata)
|
27
28
|
self
|
28
29
|
end
|
29
30
|
end
|
@@ -38,8 +38,8 @@ module Contentful
|
|
38
38
|
object.refresh_data(put(endpoint_options, attributes, headers, object))
|
39
39
|
end
|
40
40
|
|
41
|
-
def destroy(endpoint_options = {})
|
42
|
-
delete(endpoint_options)
|
41
|
+
def destroy(endpoint_options = {}, attributes = {}, headers = {})
|
42
|
+
delete(endpoint_options, attributes, headers)
|
43
43
|
end
|
44
44
|
|
45
45
|
def archive(object, endpoint_options = {}, headers = {})
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'resource'
|
2
|
+
require_relative 'resource/environment_aware'
|
2
3
|
|
3
4
|
module Contentful
|
4
5
|
module Management
|
@@ -6,9 +7,35 @@ module Contentful
|
|
6
7
|
# https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-tags
|
7
8
|
class Tag
|
8
9
|
include Contentful::Management::Resource
|
10
|
+
include Contentful::Management::Resource::Refresher
|
9
11
|
include Contentful::Management::Resource::SystemProperties
|
12
|
+
include Contentful::Management::Resource::EnvironmentAware
|
10
13
|
|
11
14
|
property :name
|
15
|
+
|
16
|
+
# @private
|
17
|
+
def self.create_attributes(_client, attributes)
|
18
|
+
return {} if attributes.nil? || attributes.empty?
|
19
|
+
|
20
|
+
{
|
21
|
+
'name' => attributes.fetch(:name),
|
22
|
+
'sys' => {
|
23
|
+
'visibility' => attributes.fetch(:visibility, 'private'),
|
24
|
+
'id' => attributes.fetch(:id),
|
25
|
+
'type' => 'Tag'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
ResourceRequester.new(client, self.class).destroy(
|
32
|
+
{ space_id: space.id,
|
33
|
+
environment_id: environment_id,
|
34
|
+
resource_id: id },
|
35
|
+
{},
|
36
|
+
version: sys[:version]
|
37
|
+
)
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
14
41
|
end
|