contentful-management 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -29
  3. data/.rubocop_todo.yml +24 -0
  4. data/.travis.yml +1 -1
  5. data/.yardopts +4 -0
  6. data/CHANGELOG.md +12 -0
  7. data/Gemfile +1 -0
  8. data/Guardfile +39 -34
  9. data/README.md +42 -1
  10. data/Rakefile +2 -0
  11. data/contentful-management.gemspec +2 -1
  12. data/lib/contentful/management/api_key.rb +65 -0
  13. data/lib/contentful/management/array.rb +3 -2
  14. data/lib/contentful/management/asset.rb +124 -58
  15. data/lib/contentful/management/client.rb +60 -19
  16. data/lib/contentful/management/content_type.rb +104 -49
  17. data/lib/contentful/management/content_type_entry_methods_factory.rb +21 -0
  18. data/lib/contentful/management/dynamic_entry.rb +22 -18
  19. data/lib/contentful/management/entry.rb +138 -80
  20. data/lib/contentful/management/error.rb +23 -23
  21. data/lib/contentful/management/field.rb +16 -13
  22. data/lib/contentful/management/http_client.rb +29 -0
  23. data/lib/contentful/management/link.rb +3 -3
  24. data/lib/contentful/management/locale.rb +55 -26
  25. data/lib/contentful/management/location.rb +1 -1
  26. data/lib/contentful/management/request.rb +11 -12
  27. data/lib/contentful/management/resource.rb +27 -12
  28. data/lib/contentful/management/resource/array_like.rb +1 -1
  29. data/lib/contentful/management/resource/asset_fields.rb +1 -0
  30. data/lib/contentful/management/resource/entry_fields.rb +2 -0
  31. data/lib/contentful/management/resource/field_aware.rb +16 -5
  32. data/lib/contentful/management/resource/fields.rb +16 -8
  33. data/lib/contentful/management/resource/refresher.rb +1 -0
  34. data/lib/contentful/management/resource/system_properties.rb +13 -6
  35. data/lib/contentful/management/resource_builder.rb +43 -40
  36. data/lib/contentful/management/space.rb +67 -28
  37. data/lib/contentful/management/space_api_key_methods_factory.rb +15 -0
  38. data/lib/contentful/management/space_asset_methods_factory.rb +4 -0
  39. data/lib/contentful/management/space_association_all_published_method_factory.rb +11 -0
  40. data/lib/contentful/management/space_association_methods_factory.rb +4 -2
  41. data/lib/contentful/management/space_content_type_methods_factory.rb +4 -0
  42. data/lib/contentful/management/space_entry_methods_factory.rb +4 -0
  43. data/lib/contentful/management/space_locale_methods_factory.rb +2 -0
  44. data/lib/contentful/management/space_webhook_methods_factory.rb +2 -0
  45. data/lib/contentful/management/validation.rb +3 -2
  46. data/lib/contentful/management/version.rb +4 -1
  47. data/lib/contentful/management/webhook.rb +42 -21
  48. data/spec/fixtures/vcr_cassettes/api_key/all_for_space.yml +194 -0
  49. data/spec/fixtures/vcr_cassettes/api_key/create_for_space.yml +113 -0
  50. data/spec/fixtures/vcr_cassettes/api_key/find.yml +113 -0
  51. data/spec/fixtures/vcr_cassettes/api_key/find_for_space_not_found.yml +71 -0
  52. data/spec/fixtures/vcr_cassettes/asset/all_public.yml +112 -0
  53. data/spec/fixtures/vcr_cassettes/content_type/all_public.yml +106 -0
  54. data/spec/fixtures/vcr_cassettes/entry/all_public.yml +102 -0
  55. data/spec/fixtures/vcr_cassettes/locale/destroy.yml +330 -0
  56. data/spec/fixtures/vcr_cassettes/locale/update_both.yml +306 -0
  57. data/spec/fixtures/vcr_cassettes/locale/update_code.yml +306 -0
  58. data/spec/fixtures/vcr_cassettes/locale/update_name.yml +306 -0
  59. data/spec/fixtures/vcr_cassettes/space/api_key/all.yml +410 -0
  60. data/spec/fixtures/vcr_cassettes/space/api_key/create.yml +329 -0
  61. data/spec/fixtures/vcr_cassettes/space/api_key/find.yml +329 -0
  62. data/spec/fixtures/vcr_cassettes/space/asset/all_public.yml +328 -0
  63. data/spec/fixtures/vcr_cassettes/space/content_type/all_public.yml +322 -0
  64. data/spec/fixtures/vcr_cassettes/space/entry/all_public.yml +318 -0
  65. data/spec/lib/contentful/management/api_key_spec.rb +55 -0
  66. data/spec/lib/contentful/management/asset_spec.rb +10 -0
  67. data/spec/lib/contentful/management/content_type_spec.rb +10 -0
  68. data/spec/lib/contentful/management/entry_spec.rb +10 -0
  69. data/spec/lib/contentful/management/locale_spec.rb +58 -0
  70. data/spec/lib/contentful/management/space_spec.rb +53 -0
  71. metadata +58 -9
@@ -2,7 +2,7 @@ module Contentful
2
2
  module Management
3
3
  module Resource
4
4
  # Useful methods for array-like resources that can be included if an
5
- # :items property exists
5
+ # [#items] property exists
6
6
  module ArrayLike
7
7
  include Enumerable
8
8
 
@@ -1,6 +1,7 @@
1
1
  module Contentful
2
2
  module Management
3
3
  module Resource
4
+ # Adds Field Coercions for [Asset]
4
5
  module AssetFields
5
6
  # Special fields for Asset.
6
7
  def fields_coercions
@@ -1,7 +1,9 @@
1
1
  module Contentful
2
2
  module Management
3
3
  module Resource
4
+ # Adds Field Coercions for Entries
4
5
  module EntryFields
6
+ # Special fields for Entry.
5
7
  def fields_coercions
6
8
  {}
7
9
  end
@@ -1,7 +1,11 @@
1
1
  module Contentful
2
2
  module Management
3
3
  module Resource
4
+ # Module for creating Fields based off of ContentTypes
4
5
  module FieldAware
6
+ # Creates fields for entry based on it's ContentType
7
+ #
8
+ # @param [Entry] entry the expected entry to modify
5
9
  def self.create_fields_for_content_type(entry)
6
10
  entry.instance_eval do
7
11
  content_type.fields.each do |field|
@@ -15,16 +19,16 @@ module Contentful
15
19
  define_singleton_method accessor_name do
16
20
  fields[field.id.to_sym]
17
21
  end
18
- define_singleton_method "#{ accessor_name }_with_locales" do
22
+ define_singleton_method "#{accessor_name}_with_locales" do
19
23
  fields_for_query[field.id.to_sym]
20
24
  end
21
- define_singleton_method "#{ accessor_name }=" do |value|
25
+ define_singleton_method "#{accessor_name}=" do |value|
22
26
  if localized_or_default_locale
23
- @fields[locale] ||= {}
24
- @fields[locale][field.id.to_sym] = value
27
+ @fields[locale] ||= {}
28
+ @fields[locale][field.id.to_sym] = value
25
29
  end
26
30
  end
27
- define_singleton_method "#{ accessor_name }_with_locales=" do |values|
31
+ define_singleton_method "#{accessor_name}_with_locales=" do |values|
28
32
  values.each do |locale, value|
29
33
  if localized_or_default_locale
30
34
  @fields[locale] ||= {}
@@ -36,6 +40,13 @@ module Contentful
36
40
  end
37
41
  end
38
42
 
43
+ # Verifies if field is localized or default locale matches current locale
44
+ #
45
+ # @param [Field] field an entry field
46
+ # @param [String] default_locale
47
+ # @param [String] locale
48
+ #
49
+ # @return [Boolean]
39
50
  def self.localized_or_default_locale(field, default_locale, locale)
40
51
  field.localized || default_locale == locale
41
52
  end
@@ -3,47 +3,55 @@ require_relative '../file'
3
3
  module Contentful
4
4
  module Management
5
5
  module Resource
6
+ # Adds fields logic for [Resource] classes
6
7
  module Fields
8
+ # Returns the fields hash for the specified locale
9
+ #
10
+ # @param [String] wanted_locale
11
+ #
12
+ # @return [Hash] localized fields
7
13
  def fields(wanted_locale = default_locale)
8
14
  requested_locale = locale || wanted_locale
9
15
  @fields[requested_locale] = {} unless @fields[requested_locale]
10
16
  @fields[requested_locale]
11
17
  end
12
18
 
19
+ # @private
13
20
  def initialize(object = nil, *)
14
21
  super
15
22
  @fields = {}
16
23
  extract_fields_from_object! object if object
17
24
  end
18
25
 
26
+ # @private
19
27
  def inspect(info = nil)
20
28
  if fields.empty?
21
29
  super(info)
22
30
  else
23
- super("#{ info } @fields=#{ fields.inspect }")
31
+ super("#{info} @fields=#{fields.inspect}")
24
32
  end
25
33
  end
26
34
 
27
35
  # Create accessors for content type, asset, entry objects.
28
36
  def self.included(base)
29
- base.fields_coercions.keys.each { |name|
37
+ base.fields_coercions.keys.each do |name|
30
38
  accessor_name = Contentful::Management::Support.snakify(name)
31
39
  base.send :define_method, accessor_name do
32
40
  fields[name.to_sym]
33
41
  end
34
- base.send :define_method, "#{ accessor_name }_with_locales" do
42
+ base.send :define_method, "#{accessor_name}_with_locales" do
35
43
  fields_for_query[name.to_sym]
36
44
  end
37
- base.send :define_method, "#{ accessor_name }=" do |value|
45
+ base.send :define_method, "#{accessor_name}=" do |value|
38
46
  fields[name.to_sym] = value
39
47
  end
40
- base.send :define_method, "#{ accessor_name }_with_locales=" do |values|
48
+ base.send :define_method, "#{accessor_name}_with_locales=" do |values|
41
49
  values.each do |locale, value|
42
50
  @fields[locale] = {} unless @fields[locale]
43
51
  @fields[locale][name.to_sym] = value
44
52
  end
45
53
  end
46
- }
54
+ end
47
55
  end
48
56
 
49
57
  private
@@ -54,8 +62,8 @@ module Contentful
54
62
  nested_child_object.each do |object_locale, real_child_object|
55
63
  @fields[object_locale] ||= {}
56
64
  @fields[object_locale].merge! extract_from_object(
57
- {field_name => real_child_object}, :fields
58
- )
65
+ { field_name => real_child_object }, :fields
66
+ )
59
67
  end
60
68
  end
61
69
  else
@@ -11,6 +11,7 @@ module Contentful
11
11
  refresh_data(resource) if resource.is_a? self_class
12
12
  end
13
13
 
14
+ # @private
14
15
  def refresh_data(resource)
15
16
  if resource.is_a? Error
16
17
  resource
@@ -3,6 +3,8 @@ module Contentful
3
3
  module Resource
4
4
  # Adds the feature to have system properties to a Resource.
5
5
  module SystemProperties
6
+ # @private
7
+ # Coercions for System Properties to native types
6
8
  SYS_COERCIONS = {
7
9
  type: :string,
8
10
  id: :string,
@@ -16,38 +18,43 @@ module Contentful
16
18
  }
17
19
  attr_reader :sys
18
20
 
19
- def initialize(object = {'sys' => nil}, *)
21
+ # @private
22
+ def initialize(object = { 'sys' => nil }, *)
20
23
  super
21
- object ||= {'sys' => nil}
24
+ object ||= { 'sys' => nil }
22
25
  @sys = extract_from_object object['sys'], :sys
23
26
  end
24
27
 
28
+ # @private
25
29
  def inspect(info = nil)
26
30
  if sys.empty?
27
31
  super(info)
28
32
  else
29
- super("#{ info } @sys=#{ sys.inspect }")
33
+ super("#{info} @sys=#{sys.inspect}")
30
34
  end
31
35
  end
32
36
 
37
+ # @private
33
38
  module ClassMethods
39
+ # @private
34
40
  def sys_coercions
35
41
  SYS_COERCIONS
36
42
  end
37
43
  end
38
44
 
45
+ # @private
39
46
  def self.included(base)
40
47
  base.extend(ClassMethods)
41
48
 
42
- base.sys_coercions.keys.each { |name|
49
+ base.sys_coercions.keys.each do |name|
43
50
  accessor_name = Contentful::Management::Support.snakify(name)
44
51
  base.send :define_method, accessor_name do
45
52
  sys[name.to_sym]
46
53
  end
47
- base.send :define_method, "#{ accessor_name }=" do |value|
54
+ base.send :define_method, "#{accessor_name}=" do |value|
48
55
  sys[name.to_sym] = value
49
56
  end
50
- }
57
+ end
51
58
  end
52
59
  end
53
60
  end
@@ -14,15 +14,19 @@ module Contentful
14
14
  # Transforms a Contentful::Response into a Contentful::Resource or a Contentful::Error
15
15
  # See example/resource_mapping.rb for avanced usage
16
16
  class ResourceBuilder
17
+ # Default Resource Mapping
18
+ # @see _ README for more information on Resource Mapping
17
19
  DEFAULT_RESOURCE_MAPPING = {
18
- 'Space' => Contentful::Management::Space,
19
- 'ContentType' => Contentful::Management::ContentType,
20
- 'Entry' => :find_entry_class,
21
- 'Asset' => Contentful::Management::Asset,
22
- 'Array' => :array_or_sync_page,
23
- 'Link' => Contentful::Management::Link,
24
- 'WebhookDefinition' => Contentful::Management::Webhook
20
+ 'Space' => Contentful::Management::Space,
21
+ 'ContentType' => Contentful::Management::ContentType,
22
+ 'Entry' => :find_entry_class,
23
+ 'Asset' => Contentful::Management::Asset,
24
+ 'Array' => :array_or_sync_page,
25
+ 'Link' => Contentful::Management::Link,
26
+ 'WebhookDefinition' => Contentful::Management::Webhook
25
27
  }
28
+ # Default Entry Mapping
29
+ # @see _ README for more information on Entry Mapping
26
30
  DEFAULT_ENTRY_MAPPING = {}
27
31
 
28
32
  attr_reader :client, :response, :resource_mapping, :entry_mapping, :resource
@@ -39,7 +43,7 @@ module Contentful
39
43
  end
40
44
 
41
45
  # Starts the parsing process.
42
- # Either returns an Error, or the parsed Resource
46
+ # @return [Contentful::Management::Resource, Contentful::Management::Error]
43
47
  def run
44
48
  if response.status == :ok
45
49
  create_all_resources!
@@ -94,9 +98,8 @@ module Contentful
94
98
 
95
99
  # Finds the proper DynamicEntry class for an entry
96
100
  def get_dynamic_entry(object)
97
- if content_id = content_type_id_for_entry(object)
98
- client.dynamic_entry_cache[content_id.to_sym]
99
- end
101
+ content_id = content_type_id_for_entry(object)
102
+ client.dynamic_entry_cache[content_id.to_sym] if content_id
100
103
  end
101
104
 
102
105
  # Returns the id of the related ContentType, if there is one
@@ -123,14 +126,14 @@ module Contentful
123
126
  def detect_resource_class(object)
124
127
  type = object['sys'] && object['sys']['type']
125
128
  case res_class = resource_mapping[type]
126
- when Symbol
127
- public_send(res_class, object)
128
- when Proc
129
- res_class[object]
130
- when nil
131
- fail UnparsableResource.new(response)
132
- else
133
- res_class
129
+ when Symbol
130
+ public_send(res_class, object)
131
+ when Proc
132
+ res_class[object]
133
+ when nil
134
+ fail UnparsableResource, response
135
+ else
136
+ res_class
134
137
  end
135
138
  end
136
139
 
@@ -158,9 +161,9 @@ module Contentful
158
161
  if object.is_a? Hash
159
162
  object.select do |_, value|
160
163
  value.is_a?(::Array) &&
161
- value.first &&
162
- value.first.is_a?(Hash) &&
163
- value.first.key?('sys')
164
+ value.first &&
165
+ value.first.is_a?(Hash) &&
166
+ value.first.key?('sys')
164
167
  end
165
168
  else
166
169
  {}
@@ -188,30 +191,30 @@ module Contentful
188
191
  end
189
192
 
190
193
  def create_included_resources!(included_objects)
191
- if included_objects
192
- included_objects.each do |type, objects|
193
- @included_resources[type] = Hash[
194
- objects.map do |object|
195
- res = create_resource(object)
196
- [res.id, res]
197
- end
198
- ]
199
- end
194
+ return unless included_objects
195
+
196
+ included_objects.each do |type, objects|
197
+ @included_resources[type] = Hash[
198
+ objects.map do |object|
199
+ res = create_resource(object)
200
+ [res.id, res]
201
+ end
202
+ ]
200
203
  end
201
204
  end
202
205
 
203
206
  def replace_links_with_known_resources(res, seen_resource_ids = [])
204
207
  seen_resource_ids << res.id
205
208
 
206
- [:properties, :sys, :fields].map do |property_container_name|
209
+ property_containers = [:properties, :sys, :fields].map do |property_container_name|
207
210
  res.public_send(property_container_name)
208
- end.compact.each do |property_container|
211
+ end.compact
212
+
213
+ property_containers.each do |property_container|
209
214
  replace_links_in_properties(property_container, seen_resource_ids)
210
215
  end
211
216
 
212
- if res.array?
213
- replace_links_in_array res.items, seen_resource_ids
214
- end
217
+ replace_links_in_array res.items, seen_resource_ids if res.array?
215
218
  end
216
219
 
217
220
  def replace_links_in_properties(property_container, seen_resource_ids)
@@ -239,10 +242,10 @@ module Contentful
239
242
  end
240
243
 
241
244
  def maybe_replace_link(link, parent, key)
242
- if @known_resources[link.link_type] &&
243
- @known_resources[link.link_type].key?(link.id)
244
- parent[key] = @known_resources[link.link_type][link.id]
245
- end
245
+ return unless @known_resources[link.link_type] &&
246
+ @known_resources[link.link_type].key?(link.id)
247
+
248
+ parent[key] = @known_resources[link.link_type][link.id]
246
249
  end
247
250
 
248
251
  def replace_links_in_included_resources_with_known_resources
@@ -9,11 +9,13 @@ require_relative 'entry'
9
9
  require_relative 'space_entry_methods_factory'
10
10
  require_relative 'webhook'
11
11
  require_relative 'space_webhook_methods_factory'
12
+ require_relative 'api_key'
13
+ require_relative 'space_api_key_methods_factory'
12
14
 
13
15
  module Contentful
14
16
  module Management
15
17
  # Resource class for Space.
16
- # https://www.contentful.com/developers/documentation/content-management-api/#resources-spaces
18
+ # @see _ https://www.contentful.com/developers/documentation/content-management-api/#resources-spaces
17
19
  class Space
18
20
  include Contentful::Management::Resource
19
21
  include Contentful::Management::Resource::SystemProperties
@@ -26,7 +28,7 @@ module Contentful
26
28
  attr_accessor :found_locale
27
29
 
28
30
  # Gets a collection of spaces.
29
- # Returns a Contentful::Management::Array of Contentful::Management::Space.
31
+ # @return [Contentful::Management::Array<Contentful::Management::Space>]
30
32
  def self.all
31
33
  request = Request.new('')
32
34
  response = request.get
@@ -37,10 +39,12 @@ module Contentful
37
39
  end
38
40
 
39
41
  # Gets a specific space.
40
- # Takes an id of space.
41
- # Returns a Contentful::Management::Space.
42
+ #
43
+ # @param [String] space_id
44
+ #
45
+ # @return [Contentful::Management::Space]
42
46
  def self.find(space_id)
43
- request = Request.new("/#{ space_id }")
47
+ request = Request.new("/#{space_id}")
44
48
  response = request.get
45
49
  result = ResourceBuilder.new(response, {}, {})
46
50
  space = result.run
@@ -49,15 +53,20 @@ module Contentful
49
53
  end
50
54
 
51
55
  # Create a space.
52
- # Takes a hash of attributes with optional organization id if client has more than one organization.
53
- # Returns a Contentful::Management::Space.
56
+ #
57
+ # @param [Hash] attributes
58
+ # @option attributes [String] :name
59
+ # @option attributes [String] :default_locale
60
+ # @option attributes [String] :organization_id Required if user has more than one organization
61
+ #
62
+ # @return [Contentful::Management::Space]
54
63
  def self.create(attributes)
55
64
  default_locale = attributes[:default_locale] || client.default_locale
56
65
  request = Request.new(
57
- '',
58
- {'name' => attributes.fetch(:name), defaultLocale: default_locale},
59
- id = nil,
60
- organization_id: attributes[:organization_id]
66
+ '',
67
+ { 'name' => attributes.fetch(:name), defaultLocale: default_locale },
68
+ nil,
69
+ organization_id: attributes[:organization_id]
61
70
  )
62
71
  response = request.post
63
72
  result = ResourceBuilder.new(response, {}, {})
@@ -67,15 +76,19 @@ module Contentful
67
76
  end
68
77
 
69
78
  # Updates a space.
70
- # Takes a hash of attributes with optional organization id if client has more than one organization.
71
- # Returns a Contentful::Management::Space.
79
+ #
80
+ # @param [Hash] attributes
81
+ # @option attributes [String] :name
82
+ # @option attributes [String] :organization_id Required if user has more than one organization
83
+ #
84
+ # @return [Contentful::Management::Space]
72
85
  def update(attributes)
73
86
  request = Request.new(
74
- "/#{ id }",
75
- {'name' => attributes.fetch(:name)},
76
- id = nil,
77
- version: sys[:version],
78
- organization_id: attributes[:organization_id]
87
+ "/#{id}",
88
+ { 'name' => attributes.fetch(:name) },
89
+ nil,
90
+ version: sys[:version],
91
+ organization_id: attributes[:organization_id]
79
92
  )
80
93
  response = request.put
81
94
  result = ResourceBuilder.new(response, {}, {})
@@ -83,7 +96,9 @@ module Contentful
83
96
  end
84
97
 
85
98
  # If a space is new, an object gets created in the Contentful, otherwise the existing space gets updated.
86
- # See README for details.
99
+ # @see _ README for details.
100
+ #
101
+ # @return [Contentful::Management::Space]
87
102
  def save
88
103
  if id
89
104
  update(name: name, organization_id: organization)
@@ -94,12 +109,13 @@ module Contentful
94
109
  end
95
110
 
96
111
  # Destroys a space.
97
- # Returns true if succeed.
112
+ #
113
+ # @return [true, Contentful::Management::Error] success
98
114
  def destroy
99
- request = Request.new("/#{ id }")
115
+ request = Request.new("/#{id}")
100
116
  response = request.delete
101
117
  if response.status == :no_content
102
- return true
118
+ true
103
119
  else
104
120
  ResourceBuilder.new(response, {}, {}).run
105
121
  end
@@ -107,48 +123,71 @@ module Contentful
107
123
 
108
124
  # Allows manipulation of content types in context of the current space
109
125
  # Allows listing all content types of space, creating new and finding one by id.
110
- # See README for details.
126
+ # @see _ README for details.
127
+ #
128
+ # @return [Contentful::Management::SpaceContentTypeMethodsFactory]
111
129
  def content_types
112
130
  SpaceContentTypeMethodsFactory.new(self)
113
131
  end
114
132
 
133
+ # Allows manipulation of api keys in context of the current space
134
+ # Allows listing all api keys of space, creating new and finding one by id.
135
+ # @see _ README for details.
136
+ #
137
+ # @return [Contentful::Management::SpaceApiKeyMethodsFactory]
138
+ def api_keys
139
+ SpaceApiKeyMethodsFactory.new(self)
140
+ end
141
+
115
142
  # Allows manipulation of locales in context of the current space
116
143
  # Allows listing all locales of space, creating new and finding one by id.
117
- # See README for details.
144
+ # @see _ README for details.
145
+ #
146
+ # @return [Contentful::Management::SpaceLocaleMethodsFactory]
118
147
  def locales
119
148
  SpaceLocaleMethodsFactory.new(self)
120
149
  end
121
150
 
122
151
  # Allows manipulation of assets in context of the current space
123
152
  # Allows listing all assets of space, creating new and finding one by id.
124
- # See README for details.
153
+ # @see _ README for details.
154
+ #
155
+ # @return [Contentful::Management::SpaceAssetMethodsFactory]
125
156
  def assets
126
157
  SpaceAssetMethodsFactory.new(self)
127
158
  end
128
159
 
129
160
  # Allows manipulation of entries in context of the current space
130
161
  # Allows listing all entries for space and finding one by id.
131
- # See README for details.
162
+ # @see _ README for details.
163
+ #
164
+ # @return [Contentful::Management::SpaceEntryMethodsFactory]
132
165
  def entries
133
166
  SpaceEntryMethodsFactory.new(self)
134
167
  end
135
168
 
136
169
  # Allows manipulation of webhooks in context of the current space
137
170
  # Allows listing all webhooks for space and finding one by id.
138
- # See README for details.
171
+ # @see _ README for details.
172
+ #
173
+ # @return [Contentful::Management::SpaceWebhookMethodsFactory]
139
174
  def webhooks
140
175
  SpaceWebhookMethodsFactory.new(self)
141
176
  end
142
177
 
143
178
  # Retrieves Default Locale for current Space and leaves it cached
179
+ #
180
+ # @return [String]
144
181
  def default_locale
145
182
  self.found_locale ||= find_locale
146
183
  end
147
184
 
148
185
  # Finds Default Locale Code for current Space
149
186
  # This request makes an API call to the Locale endpoint
187
+ #
188
+ # @return [String]
150
189
  def find_locale
151
- locale = ::Contentful::Management::Locale.all(self.id).detect { |l| l.default }
190
+ locale = ::Contentful::Management::Locale.all(id).detect(&:default)
152
191
  return locale.code unless locale.nil?
153
192
  @default_locale
154
193
  end