Sha256: 61b5c792a90fecc07b814b2318865f0cfe715a1520a26ffc3d3787369317a512

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
contentful-management-3.10.0 lib/contentful/management/tag.rb
contentful-management-3.9.0 lib/contentful/management/tag.rb