class WorkOS::Connection

The Connection class provides a lightweight wrapper around a WorkOS Connection resource. This class is not meant to be instantiated in user space, and is instantiated internally but exposed. Note: status is deprecated - use state instead

Attributes

connection_type[RW]
created_at[RW]
domains[RW]
id[RW]
name[RW]
organization_id[RW]
state[RW]
status[RW]
updated_at[RW]

Public Class Methods

new(json) click to toggle source
# File lib/workos/connection.rb, line 17
def initialize(json)
  raw = parse_json(json)

  @id = T.let(raw.id, String)
  @name = T.let(raw.name, String)
  @connection_type = T.let(raw.connection_type, String)
  @domains = T.let(raw.domains, Array)
  @organization_id = T.let(raw.organization_id, String)
  @state = T.let(raw.state, String)
  @status = T.let(raw.status, String)
  @created_at = T.let(raw.created_at, String)
  @updated_at = T.let(raw.updated_at, String)
end

Public Instance Methods

to_json(*) click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/workos/connection.rb, line 32
def to_json(*)
  {
    id: id,
    name: name,
    connection_type: connection_type,
    domains: domains,
    organization_id: organization_id,
    state: state,
    status: status,
    created_at: created_at,
    updated_at: updated_at,
  }
end

Private Instance Methods

parse_json(json_string) click to toggle source
# File lib/workos/connection.rb, line 49
def parse_json(json_string)
  hash = JSON.parse(json_string, symbolize_names: true)

  WorkOS::Types::ConnectionStruct.new(
    id: hash[:id],
    name: hash[:name],
    connection_type: hash[:connection_type],
    domains: hash[:domains],
    organization_id: hash[:organization_id],
    state: hash[:state],
    status: hash[:status],
    created_at: hash[:created_at],
    updated_at: hash[:updated_at],
  )
end