Sha256: 9ede8550ee6c0797af03b6a4e663e8c7e204d2d90f355c5c3c7922a7a177bd5a

Contents?: true

Size: 1.27 KB

Versions: 33

Compression:

Stored size: 1.27 KB

Contents

require_relative 'resource'

module Contentful
  module Management
    # Resource class for PersonalAccessToken.
    # @see _ https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens
    class PersonalAccessToken
      include Contentful::Management::Resource
      include Contentful::Management::Resource::Refresher
      include Contentful::Management::Resource::SystemProperties

      property :name, :string
      property :scopes, :array
      property :token, :string
      property :revokedAt, :date

      # @private
      def self.build_endpoint(endpoint_options)
        endpoint = 'users/me/access_tokens'
        endpoint = "#{endpoint}/#{endpoint_options[:resource_id]}" if endpoint_options[:resource_id]
        endpoint = "#{endpoint}#{endpoint_options[:suffix]}" if endpoint_options[:suffix]
        endpoint
      end

      # @private
      def self.create_attributes(_client, attributes)
        attributes
      end

      # Not supported
      def destroy
        fail 'Not supported'
      end

      # Revokes the personal access token.
      def revoke
        ResourceRequester.new(client, self.class).update(
          self,
          resource_id: id,
          suffix: '/revoked'
        )
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
contentful-management-3.8.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.7.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.6.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.5.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.4.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.3.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.2.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.1.0 lib/contentful/management/personal_access_token.rb
contentful-management-3.0.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.13.1 lib/contentful/management/personal_access_token.rb
contentful-management-2.13.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.12.1 lib/contentful/management/personal_access_token.rb
contentful-management-2.12.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.11.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.10.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.9.1 lib/contentful/management/personal_access_token.rb
contentful-management-2.9.0 lib/contentful/management/personal_access_token.rb
contentful-management-2.8.2 lib/contentful/management/personal_access_token.rb
contentful-management-2.8.1 lib/contentful/management/personal_access_token.rb
contentful-management-2.8.0 lib/contentful/management/personal_access_token.rb