Sha256: 72c550822c08cbb953cdde22bff79a8d6b95f9f6b1d0861ef73dfbbbe72da8d5

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Contentful
  module Management
    module Resource
      # Wrapper for Resources with /archived API
      module Archiver
        # Archives a resource.
        #
        # @return [Contentful::Management::Resource]
        def archive
          ResourceRequester.new(client, self.class).archive(
            self,
            {
              space_id: space.id,
              environment_id: environment_id,
              resource_id: id,
              suffix: '/archived'
            },
            version: sys[:version]
          )
        end

        # Unarchives a resource.
        #
        # @return [Contentful::Management::Resource]
        def unarchive
          ResourceRequester.new(client, self.class).unarchive(
            self,
            {
              space_id: space.id,
              environment_id: environment_id,
              resource_id: id,
              suffix: '/archived'
            },
            version: sys[:version]
          )
        end

        # Checks if a resource is archived.
        #
        # @return [Boolean]
        def archived?
          sys[:archivedAt] ? true : false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contentful-management-3.10.0 lib/contentful/management/resource/archiver.rb
contentful-management-3.9.0 lib/contentful/management/resource/archiver.rb