Sha256: c9295e87328743490fa287f99f4dcee9e11015a2fae6e667bef83a581416a652

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require_relative 'resource'
require_relative 'resource/environment_aware'

module Contentful
  module Management
    # Resource Class for Tags
    # https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-tags
    class Tag
      include Contentful::Management::Resource
      include Contentful::Management::Resource::Refresher
      include Contentful::Management::Resource::SystemProperties
      include Contentful::Management::Resource::EnvironmentAware

      property :name

      # @private
      def self.create_attributes(_client, attributes)
        return {} if attributes.nil? || attributes.empty?

        {
          'name' => attributes.fetch(:name),
          'sys' => {
            'visibility' => attributes.fetch(:visibility, 'private'),
            'id' => attributes.fetch(:id),
            'type' => 'Tag'
          }
        }
      end

      def destroy
        ResourceRequester.new(client, self.class).destroy(
          { space_id: space.id,
            environment_id: environment_id,
            resource_id: id },
          {},
          version: sys[:version]
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contentful-management-3.8.0 lib/contentful/management/tag.rb
contentful-management-3.7.0 lib/contentful/management/tag.rb
contentful-management-3.6.0 lib/contentful/management/tag.rb
contentful-management-3.5.0 lib/contentful/management/tag.rb
contentful-management-3.4.0 lib/contentful/management/tag.rb