class Attio::Meta
Provides metadata about the current API token and workspace
def self.identify(**opts)
def self.identify(**opts) response = execute_request(:GET, resource_path, {}, opts) new(response["data"] || response, opts) end
def self.resource_path
def self.resource_path "self" end
def actor
def actor return nil unless self[:authorized_by_workspace_member_id] { type: "workspace-member", id: self[:authorized_by_workspace_member_id] } end
def can_read?(resource)
def can_read?(resource) has_scope?("#{resource}:read") || has_scope?("#{resource}:read-write") end
def can_write?(resource)
def can_write?(resource) has_scope?("#{resource}:write") || has_scope?("#{resource}:read-write") end
def destroy(**opts)
def destroy(**opts) raise InvalidRequestError, "Meta information is read-only" end
def has_scope?(scope)
def has_scope?(scope) scope_str = scope.to_s.tr("_", ":") scopes.include?(scope_str) end
def immutable?
def immutable? true end
def inspect
def inspect "#<#{self.class.name}:#{object_id} workspace=#{workspace_slug.inspect} token=#{token_name.inspect}>" end
def save(**opts)
def save(**opts) raise InvalidRequestError, "Meta information is read-only" end
def scopes
-
(Array
- Array of scope strings)
def scopes return [] unless self[:scope] self[:scope].split(" ") end
def to_h
def to_h { workspace: workspace, token: token, actor: actor }.compact end
def token
def token return nil unless self[:client_id] { id: self[:client_id], type: self[:token_type] || "Bearer", scope: self[:scope] }.compact end
def token_id
def token_id self[:client_id] end
def token_name
-
(String, nil)
- The token name (not available in flat format)
def token_name nil end
def token_type
-
(String, nil)
- The token type
def token_type self[:token_type] end
def workspace
def workspace return nil unless self[:workspace_id] { id: self[:workspace_id], name: self[:workspace_name], slug: self[:workspace_slug], logo_url: self[:workspace_logo_url] }.compact end
def workspace_id
def workspace_id self[:workspace_id] end
def workspace_name
-
(String, nil)
- The workspace name
def workspace_name self[:workspace_name] end
def workspace_slug
-
(String, nil)
- The workspace slug
def workspace_slug self[:workspace_slug] end