Module: SfCli::Sf::Org::Display

Included in:
Core
Defined in:
lib/sf_cli/sf/org/display.rb

Defined Under Namespace

Classes: ConnectionInfo

Instance Method Summary collapse

Instance Method Details

#display(target_org: nil) ⇒ Object

returns the org’s connection information. (equivalent to sf org display)

target_org — an alias of paticular org, or username can be used

# example (in irb):

> sf.org.display
=>
#<struct SfCli::Sf::Org::Display::ConnectionInfo
 id="00D5j00000DiuxmEAB",
 access_token="<some access token>",
 alias="dev",
 instance_url="https://hoge-bar-baz.abc.my.salesforce.com.example",
 user_name="[email protected]",
 api_version="61.0",
 status="Connected">

For more command details, see the command reference



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sf_cli/sf/org/display.rb', line 26

def display(target_org: nil)
  flags    = {:"target-org" => target_org}
  json = exec(__method__, flags: flags, redirection: :null_stderr)

  ConnectionInfo.new(
    id:           json['result']['id'],
    access_token: json['result']['accessToken'],
    alias:        json['result']['alias'],
    instance_url: json['result']['instanceUrl'],
    user_name:    json['result']['username'],
    api_version:  json['result']['apiVersion'],
    status:       json['result']['connectedStatus']
  )
end