Class: Attio::Resources::Meta Private

Inherits:
Base
  • Object
show all
Defined in:
lib/attio/resources/meta.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Meta resource for getting information about the API token and workspace

The Meta resource provides a single endpoint (/v2/self) that returns information about the current access token, workspace, and permissions.

Examples:

Get token and workspace information

meta_info = client.meta.identify
puts "Workspace: #{meta_info['data']['workspace_name']}"
puts "Token active: #{meta_info['data']['active']}"

Check if token is active

if client.meta.active?
  puts "Token is valid and active"
end

Get workspace details

workspace = client.meta.workspace
puts "Working in: #{workspace['name']} (#{workspace['id']})"

Check permissions

if client.meta.permission?("record_permission:read-write")
  # Can read and write records
end

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Attio::Resources::Base

Instance Method Details

#active?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if the current token is active

Examples:

if client.meta.active?
  # Proceed with API calls
else
  # Token is inactive or invalid
end

Returns:

  • (Boolean)

    true if token is active, false otherwise

Since:

  • 1.0.0



55
56
57
58
# File 'lib/attio/resources/meta.rb', line 55

def active?
  response = identify
  response.dig("data", "active") || false
end

#identifyHash Also known as: self, get

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get information about the current access token and workspace

This is the primary method that calls the /v2/self endpoint. Returns full token metadata including workspace info and permissions.

Examples:

info = client.meta.identify
# => { "data" => { "active" => true, "workspace_name" => "My Workspace", ... } }

Returns:

  • (Hash)

    Token and workspace information

Since:

  • 1.0.0



38
39
40
# File 'lib/attio/resources/meta.rb', line 38

def identify
  request(:get, "self")
end

#permission?(permission) ⇒ Boolean Also known as: has_permission?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if token has a specific permission

Examples:

if client.meta.permission?("record_permission:read-write")
  # Can manage records
end

Parameters:

  • permission (String)

    The permission to check (e.g., "comment:read-write")

Returns:

  • (Boolean)

    true if permission is granted

Since:

  • 1.0.0



102
103
104
# File 'lib/attio/resources/meta.rb', line 102

def permission?(permission)
  permissions.include?(permission)
end

#permissionsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the token's permissions/scopes

Parses the space-separated scope string into an array.

Examples:

permissions = client.meta.permissions
# => ["comment:read-write", "list_configuration:read", "note:read-write"]

Returns:

  • (Array<String>)

    List of permission scopes

Since:

  • 1.0.0



88
89
90
91
92
# File 'lib/attio/resources/meta.rb', line 88

def permissions
  response = identify
  scope = response.dig("data", "scope") || ""
  scope.split
end

#token_infoHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get token expiration and metadata

Returns detailed token information including expiration, issue time, client ID, and who authorized it.

Examples:

info = client.meta.token_info
# => { "active" => true, "type" => "Bearer", "expires_at" => nil, ... }

Returns:

  • (Hash)

    Token metadata

Since:

  • 1.0.0



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/attio/resources/meta.rb', line 118

def token_info
  response = identify
  return { "active" => false } unless response.dig("data", "active")

  {
    "active" => true,
    "type" => response.dig("data", "token_type"),
    "expires_at" => response.dig("data", "exp"),
    "issued_at" => response.dig("data", "iat"),
    "client_id" => response.dig("data", "client_id"),
    "authorized_by" => response.dig("data", "authorized_by_workspace_member_id"),
  }
end

#workspaceHash?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the workspace information

Returns workspace details if token is active, nil otherwise.

Examples:

workspace = client.meta.workspace
# => { "id" => "uuid", "name" => "My Workspace", "slug" => "my-workspace", "logo_url" => nil }

Returns:

  • (Hash, nil)

    Workspace details or nil if token inactive

Since:

  • 1.0.0



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/attio/resources/meta.rb', line 68

def workspace
  response = identify
  return nil unless response.dig("data", "active")

  {
    "id" => response.dig("data", "workspace_id"),
    "name" => response.dig("data", "workspace_name"),
    "slug" => response.dig("data", "workspace_slug"),
    "logo_url" => response.dig("data", "workspace_logo_url"),
  }
end