Class: SfCli::Sf::Sobject::Core

Inherits:
Object
  • Object
show all
Includes:
Core::Base
Defined in:
lib/sf_cli/sf/sobject/core.rb

Overview

Instance Attribute Summary

Attributes included from Core::Base

#varbose

Instance Method Summary collapse

Instance Method Details

#describe(object_type, target_org: nil) ⇒ Object

returns a schema object containing the Salesforce object schema

objectType — object type (ex: Account)

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

schema = sf.sobject.describe :Account
schema.name  # Account
schema.label # Account
schema.field_names # [:Id, :Name, ....]
schema.fields[:Name] # => {"aggregatable"=>true, "aiPredictionField"=>false, "autoNumber"=>false,...}

For more command details, see the command reference



30
31
32
33
34
35
36
37
# File 'lib/sf_cli/sf/sobject/core.rb', line 30

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

#list(object_type, target_org: nil) ⇒ Object

returns a list of Salesforce object name

object_type — all or custom

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

For more command details, see the command reference



47
48
49
50
51
52
53
54
# File 'lib/sf_cli/sf/sobject/core.rb', line 47

def list(object_type, target_org: nil)
  flags    = {
    :"sobject"    => (object_type.to_sym == :custom ? :custom : :all),
    :"target-org" => target_org,
  }
  json = exec(__method__, flags: flags, redirection: :null_stderr)
  json['result']
end