class Attio::WorkspaceMember
Represents a workspace member in Attio (read-only)
def self.resource_path
-
(String)
- The API path
def self.resource_path "workspace_members" end
def active(**opts)
def active(**opts) list(**opts).select(&:active?) end
def active?
def active? status == "active" end
def admin?
def admin? access_level == "admin" end
def admins(**opts)
def admins(**opts) list(**opts).select(&:admin?) end
def create(*)
def create(*) raise NotImplementedError, "Workspace members cannot be created via API" end
def deactivated?
def deactivated? status == "deactivated" end
def delete(*)
def delete(*) raise NotImplementedError, "Workspace members cannot be deleted via API" end
def destroy(*)
def destroy(*) raise NotImplementedError, "Workspace members cannot be deleted via API" end
def find_by(**conditions)
def find_by(**conditions) # Extract any opts that aren't conditions opts = {} known_opts = [:api_key, :timeout, :idempotency_key] known_opts.each do |opt| opts[opt] = conditions.delete(opt) if conditions.key?(opt) end # Currently only supports email if conditions.key?(:email) email = conditions[:email] list(**opts).find { |member| member.email_address == email } || raise(NotFoundError, "Workspace member with email '#{email}' not found") else raise ArgumentError, "find_by only supports email attribute for workspace members" end end
def full_name
def full_name [first_name, last_name].compact.join(" ") end
def initialize(attributes = {}, opts = {})
def initialize(attributes = {}, opts = {}) super normalized_attrs = normalize_attributes(attributes) @email_address = normalized_attrs[:email_address] @first_name = normalized_attrs[:first_name] @last_name = normalized_attrs[:last_name] @avatar_url = normalized_attrs[:avatar_url] @access_level = normalized_attrs[:access_level] @status = normalized_attrs[:status] @invited_at = parse_timestamp(normalized_attrs[:invited_at]) @last_accessed_at = parse_timestamp(normalized_attrs[:last_accessed_at]) end
def invited?
def invited? status == "invited" end
def me(**opts)
def me(**opts) # The /v2/workspace_members/me endpoint doesn't exist, use /v2/self instead # and then fetch the workspace member details self_response = execute_request(:GET, "self", {}, opts) member_id = self_response[:authorized_by_workspace_member_id] self_response[:workspace_id] # Now fetch the actual workspace member members = list(**opts) members.find { |m| m.id[:workspace_member_id] == member_id } end
def save(*)
def save(*) raise NotImplementedError, "Workspace members cannot be updated via API" end
def standard?
def standard? access_level == "standard" end
def to_h
-
(Hash)
- Member data as a hash
def to_h super.merge( email_address: email_address, first_name: first_name, last_name: last_name, avatar_url: avatar_url, access_level: access_level, status: status, invited_at: invited_at&.iso8601, last_accessed_at: last_accessed_at&.iso8601 ).compact end
def update(*)
def update(*) raise NotImplementedError, "Workspace members cannot be updated via API" end
def update(*)
def update(*) raise NotImplementedError, "Workspace members cannot be updated via API" end