Module: SfCli::Sf::Sobject::Describe

Defined in:
lib/sf_cli/sf/sobject/describe.rb

Instance Method Summary collapse

Instance Method Details

#describe(object_type, target_org: nil, api_version: nil) ⇒ Schema

Returns a schema object containing the Salesforce object schema

Examples:

schema = sf.sobject.describe :Account
schema.name  # Account
schema.label # Account
schema.field_names            # [:Id, :Name, ....]
schema.fields.name_and_labels # [['Id', 'Account Id'], ['Name', 'Account Name'], ...]

Parameters:

  • object_type (Symbol, String)

    object type(ex: Account)

  • target_org (Symbol, String) (defaults to: nil)

    an alias of paticular org, or username can be used

  • api_version (Numeric) (defaults to: nil)

    override the api version used for api requests made by this command

Returns:

  • (Schema)

    a schema object that represents the object schema

See Also:



21
22
23
24
25
26
27
28
29
# File 'lib/sf_cli/sf/sobject/describe.rb', line 21

def describe(object_type, target_org: nil, api_version: nil)
  flags    = {
    :"sobject"     => object_type,
    :"target-org"  => target_org,
    :"api-version" => api_version,
  }
  json = exec(__method__, flags: flags, redirection: :null_stderr)
  Schema.new(json['result'])
end