Sha256: b2a99424a8adf81200a36131e93416fd5c0a6d75cd76359b15e21c5209674b94

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

module GroupDocs
  class Signature::Role < Api::Entity

    #
    # Returns array of predefined roles.
    #
    # @param [Hash] options Hash of options
    # @option options [String] :id Filter by identifier
    # @param [Hash] access Access credentials
    # @option access [String] :client_id
    # @option access [String] :private_key
    # @return [Array<GroupDocs::Signature::role>]
    #
    def self.get!(options = {}, access = {})
      api = Api::Request.new do |request|
        request[:access] = access
        request[:method] = :GET
        request[:path] = '/signature/{{client_id}}/roles'
      end
      api.add_params(options)
      json = api.execute!

      json[:roles].map do |role|
        new(role)
      end
    end

    # @attr [String] id
    attr_accessor :id
    # @attr [String] name
    attr_accessor :name
    # @attr [Integer] canEdit
    attr_accessor :canEdit
    # @attr [Integer] canSign
    attr_accessor :canSign
    # @attr [Integer] canAnnotate
    attr_accessor :canAnnotate
    # @attr [Integer] canDelegate
    attr_accessor :canDelegate

    # Human-readable accessors
    alias_method :can_edit,      :canEdit
    alias_method :can_edit=,     :canEdit=
    alias_method :can_sign,      :canSign
    alias_method :can_sign=,     :canSign=
    alias_method :can_annotate,  :canAnnotate
    alias_method :can_annotate=, :canAnnotate=
    alias_method :can_delegate,  :canDelegate
    alias_method :can_delegate=, :canDelegate=

    #
    # Returns true if role can edit.
    # @return [Boolean]
    #
    def can_edit?
      can_edit == 1
    end

    #
    # Returns true if role can sign.
    # @return [Boolean]
    #
    def can_sign?
      can_sign == 1
    end

    #
    # Returns true if role can annotate.
    # @return [Boolean]
    #
    def can_annotate?
      can_annotate == 1
    end

    #
    # Returns true if role can delegate.
    # @return [Boolean]
    #
    def can_delegate?
      can_delegate == 1
    end

  end # Signature::Role
end # GroupDocs

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
groupdocs-1.1.0 lib/groupdocs/signature/role.rb
groupdocs-1.0.0 lib/groupdocs/signature/role.rb