Class: Contentful::Management::Space
- Inherits:
-
Object
- Object
- Contentful::Management::Space
- Includes:
- Resource, Resource::Refresher, Resource::SystemProperties
- Defined in:
- lib/contentful/management/space.rb
Overview
Resource class for Space.
Instance Attribute Summary collapse
-
#found_locale ⇒ Object
Returns the value of attribute found_locale.
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #properties, #raw_object, #request
Class Method Summary collapse
-
.all(client) ⇒ Contentful::Management::Array<Contentful::Management::Space>
Gets all Spaces.
-
.create(client, attributes) ⇒ Contentful::Management::Space
Create a space.
-
.find(client, space_id) ⇒ Contentful::Management::Space
Gets a specific space.
Instance Method Summary collapse
-
#api_keys ⇒ Contentful::Management::SpaceApiKeyMethodsFactory
Allows manipulation of api keys in context of the current space Allows listing all api keys of space, creating new and finding one by id.
-
#assets ⇒ Contentful::Management::SpaceAssetMethodsFactory
Allows manipulation of assets in context of the current space Allows listing all assets of space, creating new and finding one by id.
-
#content_types ⇒ Contentful::Management::SpaceContentTypeMethodsFactory
Allows manipulation of content types in context of the current space Allows listing all content types of space, creating new and finding one by id.
-
#default_locale ⇒ String
Retrieves Default Locale for current Space and leaves it cached.
-
#destroy ⇒ true, Contentful::Management::Error
Destroys a space.
-
#editor_interfaces ⇒ Contentful::Management::SpaceEditorInterfaceMethodsFactory
Allows manipulation of editor interfaces in context of the current space Allows listing all editor interfaces of space, creating new and finding one by id.
-
#entries ⇒ Contentful::Management::SpaceEntryMethodsFactory
Allows manipulation of entries in context of the current space Allows listing all entries for space and finding one by id.
-
#find_locale ⇒ String
Finds Default Locale Code for current Space This request makes an API call to the Locale endpoint.
-
#locales ⇒ Contentful::Management::SpaceLocaleMethodsFactory
Allows manipulation of locales in context of the current space Allows listing all locales of space, creating new and finding one by id.
-
#roles ⇒ Contentful::Management::SpaceRoleMethodsFactory
Allows manipulation of roles in context of the current space Allows listing all roles of space, creating new and finding one by id.
-
#save ⇒ Contentful::Management::Space
If a space is new, an object gets created in the Contentful, otherwise the existing space gets updated.
-
#update(attributes) ⇒ Contentful::Management::Space
Updates a space.
-
#webhooks ⇒ Contentful::Management::SpaceWebhookMethodsFactory
Allows manipulation of webhooks in context of the current space Allows listing all webhooks for space and finding one by id.
Methods included from Resource::Refresher
Methods included from Resource
#array?, #fields, #nested_locale_fields?, #resource?, #sys
Instance Attribute Details
#found_locale ⇒ Object
Returns the value of attribute found_locale.
32 33 34 |
# File 'lib/contentful/management/space.rb', line 32 def found_locale @found_locale end |
Class Method Details
.all(client) ⇒ Contentful::Management::Array<Contentful::Management::Space>
Gets all Spaces
45 46 47 |
# File 'lib/contentful/management/space.rb', line 45 def self.all(client) ClientSpaceMethodsFactory.new(client).all end |
.create(client, attributes) ⇒ Contentful::Management::Space
Create a space.
84 85 86 |
# File 'lib/contentful/management/space.rb', line 84 def self.create(client, attributes) ResourceRequester.new(client, self).create({}, attributes) end |
.find(client, space_id) ⇒ Contentful::Management::Space
Gets a specific space.
55 56 57 |
# File 'lib/contentful/management/space.rb', line 55 def self.find(client, space_id) ClientSpaceMethodsFactory.new(client).find(space_id) end |
Instance Method Details
#api_keys ⇒ Contentful::Management::SpaceApiKeyMethodsFactory
Allows manipulation of api keys in context of the current space Allows listing all api keys of space, creating new and finding one by id.
139 140 141 |
# File 'lib/contentful/management/space.rb', line 139 def api_keys SpaceApiKeyMethodsFactory.new(self) end |
#assets ⇒ Contentful::Management::SpaceAssetMethodsFactory
Allows manipulation of assets in context of the current space Allows listing all assets of space, creating new and finding one by id.
175 176 177 |
# File 'lib/contentful/management/space.rb', line 175 def assets SpaceAssetMethodsFactory.new(self) end |
#content_types ⇒ Contentful::Management::SpaceContentTypeMethodsFactory
Allows manipulation of content types in context of the current space Allows listing all content types of space, creating new and finding one by id.
130 131 132 |
# File 'lib/contentful/management/space.rb', line 130 def content_types SpaceContentTypeMethodsFactory.new(self) end |
#default_locale ⇒ String
Retrieves Default Locale for current Space and leaves it cached
200 201 202 |
# File 'lib/contentful/management/space.rb', line 200 def default_locale self.found_locale ||= find_locale end |
#destroy ⇒ true, Contentful::Management::Error
Destroys a space.
121 122 123 |
# File 'lib/contentful/management/space.rb', line 121 def destroy ResourceRequester.new(client, self.class).destroy(space_id: id) end |
#editor_interfaces ⇒ Contentful::Management::SpaceEditorInterfaceMethodsFactory
Allows manipulation of editor interfaces in context of the current space Allows listing all editor interfaces of space, creating new and finding one by id.
166 167 168 |
# File 'lib/contentful/management/space.rb', line 166 def editor_interfaces SpaceEditorInterfaceMethodsFactory.new(self) end |
#entries ⇒ Contentful::Management::SpaceEntryMethodsFactory
Allows manipulation of entries in context of the current space Allows listing all entries for space and finding one by id.
184 185 186 |
# File 'lib/contentful/management/space.rb', line 184 def entries SpaceEntryMethodsFactory.new(self) end |
#find_locale ⇒ String
Finds Default Locale Code for current Space This request makes an API call to the Locale endpoint
208 209 210 211 212 |
# File 'lib/contentful/management/space.rb', line 208 def find_locale locale = locales.all.detect(&:default) return locale.code unless locale.nil? @default_locale end |
#locales ⇒ Contentful::Management::SpaceLocaleMethodsFactory
Allows manipulation of locales in context of the current space Allows listing all locales of space, creating new and finding one by id.
148 149 150 |
# File 'lib/contentful/management/space.rb', line 148 def locales SpaceLocaleMethodsFactory.new(self) end |
#roles ⇒ Contentful::Management::SpaceRoleMethodsFactory
Allows manipulation of roles in context of the current space Allows listing all roles of space, creating new and finding one by id.
157 158 159 |
# File 'lib/contentful/management/space.rb', line 157 def roles SpaceRoleMethodsFactory.new(self) end |
#save ⇒ Contentful::Management::Space
If a space is new, an object gets created in the Contentful, otherwise the existing space gets updated.
109 110 111 112 113 114 115 116 |
# File 'lib/contentful/management/space.rb', line 109 def save if id update(name: name, organization_id: organization) else new_instance = self.class.create(client, name: name, organization_id: organization) refresh_data(new_instance) end end |
#update(attributes) ⇒ Contentful::Management::Space
Updates a space.
95 96 97 98 99 100 101 102 103 |
# File 'lib/contentful/management/space.rb', line 95 def update(attributes) ResourceRequester.new(client, self.class).update( self, { space_id: id }, { 'name' => attributes.fetch(:name) }, version: sys[:version], organization_id: attributes[:organization_id] ) end |
#webhooks ⇒ Contentful::Management::SpaceWebhookMethodsFactory
Allows manipulation of webhooks in context of the current space Allows listing all webhooks for space and finding one by id.
193 194 195 |
# File 'lib/contentful/management/space.rb', line 193 def webhooks SpaceWebhookMethodsFactory.new(self) end |