Class: Attio::Resources::Meta Private
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.
Instance Method Summary collapse
-
#active? ⇒ Boolean
private
Check if the current token is active.
-
#identify ⇒ Hash
(also: #self, #get)
private
Get information about the current access token and workspace.
-
#permission?(permission) ⇒ Boolean
(also: #has_permission?)
private
Check if token has a specific permission.
-
#permissions ⇒ Array<String>
private
Get the token's permissions/scopes.
-
#token_info ⇒ Hash
private
Get token expiration and metadata.
-
#workspace ⇒ Hash?
private
Get the workspace information.
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
55 56 57 58 |
# File 'lib/attio/resources/meta.rb', line 55 def active? response = identify response.dig("data", "active") || false end |
#identify ⇒ Hash 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.
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
102 103 104 |
# File 'lib/attio/resources/meta.rb', line 102 def () .include?() end |
#permissions ⇒ Array<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.
88 89 90 91 92 |
# File 'lib/attio/resources/meta.rb', line 88 def response = identify scope = response.dig("data", "scope") || "" scope.split end |
#token_info ⇒ Hash
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.
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 |
#workspace ⇒ Hash?
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.
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 |