require_relative 'resource' module Contentful module Management # Resource class for Editor Interface. class EditorInterface include Contentful::Management::Resource include Contentful::Management::Resource::SystemProperties include Contentful::Management::Resource::Refresher property :controls, :array # Gets the Default Editor Interface # # @param [Contentful::Management::Client] client # @param [String] space_id # @param [String] content_type_id # # @return [Contentful::Management::EditorInterface] def self.default(client, space_id, content_type_id) ClientEditorInterfaceMethodsFactory.new(client).default(space_id, content_type_id) end # Finds an EditorInterface. # # Not Supported def self.find(*) fail 'Not supported' end # Creates an EditorInterface. # # Not Supported def self.create(*) fail 'Not supported' end # @private def self.create_attributes(_client, attributes) { 'controls' => attributes.fetch(:controls) } end # @private def self.build_endpoint(endpoint_options) space_id = endpoint_options.fetch(:space_id) content_type_id = endpoint_options.fetch(:content_type_id) "/#{space_id}/content_types/#{content_type_id}/editor_interface" end # Updates an Editor Interface # # @param [Hash] attributes # @option attributes [Array] :controls # # @return [Contentful::Management::EditorInterface] def update(attributes) ResourceRequester.new(client, self.class).update( self, { space_id: space.id, content_type_id: content_type.id, editor_id: id }, { 'controls' => attributes.fetch(:controls) }, version: sys[:version] ) end # Destroys an EditorInterface. # # Not Supported def destroy fail 'Not supported' end protected def refresh_find self.class.default(client, space.id, content_type.id) end def query_attributes(attributes) attributes.each_with_object({}) { |(k, v), result| result[k.to_sym] = v } end end end end