Class: SfCli::Sf::Model::SfCommandConnection
- Inherits:
-
Object
- Object
- SfCli::Sf::Model::SfCommandConnection
- Defined in:
- lib/sf_cli/sf/model/sf_command_connection.rb
Overview
Connection object to access Salesforce based on Sf command
Instance Attribute Summary collapse
-
#instance_url ⇒ Object
readonly
Returns the value of attribute instance_url.
- #sf_data ⇒ Object readonly
- #sf_org ⇒ Object readonly
- #sf_sobject ⇒ Object readonly
-
#target_org ⇒ Object
readonly
Returns the value of attribute target_org.
Instance Method Summary collapse
- #create(object_type, values, klass = nil) ⇒ Object
- #delete(object_type, id) ⇒ Object
- #describe(object_type) ⇒ Object
-
#exec_query(soql, format: nil, bulk: false, wait: nil, model_class: nil) ⇒ Object
Sf command style query interface for Model module.
- #find(object_type, id, klass) ⇒ Object
-
#initialize(target_org: nil, instance_url: nil) ⇒ SfCommandConnection
constructor
A new instance of SfCommandConnection.
- #open ⇒ Object
- #query(soql, klass, format = nil) ⇒ Object
- #update(object_type, id, values) ⇒ Object
Constructor Details
#initialize(target_org: nil, instance_url: nil) ⇒ SfCommandConnection
Returns a new instance of SfCommandConnection.
20 21 22 23 24 25 26 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 20 def initialize(target_org: nil, instance_url: nil) @sf_org = ::SfCli::Sf::Org::Core.new @sf_data = ::SfCli::Sf::Data::Core.new @sf_sobject = ::SfCli::Sf::Sobject::Core.new @target_org = target_org @instance_url = instance_url end |
Instance Attribute Details
#instance_url ⇒ Object (readonly)
Returns the value of attribute instance_url.
12 13 14 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 12 def instance_url @instance_url end |
#sf_data ⇒ Object (readonly)
15 16 17 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 15 def sf_data @sf_data end |
#sf_org ⇒ Object (readonly)
15 16 17 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 15 def sf_org @sf_org end |
#sf_sobject ⇒ Object (readonly)
15 16 17 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 15 def sf_sobject @sf_sobject end |
#target_org ⇒ Object (readonly)
Returns the value of attribute target_org.
12 13 14 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 12 def target_org @target_org end |
Instance Method Details
#create(object_type, values, klass = nil) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 50 def create(object_type, values, klass = nil) id = sf_data.create_record object_type, values: values, target_org: target_org return id if klass.nil? find(object_type, id, klass) end |
#delete(object_type, id) ⇒ Object
63 64 65 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 63 def delete(object_type, id) sf_data.delete_record object_type, record_id: id, where: nil, target_org: target_org end |
#describe(object_type) ⇒ Object
73 74 75 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 73 def describe(object_type) sf_sobject.describe(object_type, target_org: target_org) end |
#exec_query(soql, format: nil, bulk: false, wait: nil, model_class: nil) ⇒ Object
Sf command style query interface for Model module
For query details, see sf data query
40 41 42 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 40 def exec_query(soql, format: nil, bulk: false, wait: nil, model_class: nil) sf_data.query(soql, target_org: target_org, format: format, bulk: bulk, wait: wait, model_class: model_class) end |
#find(object_type, id, klass) ⇒ Object
45 46 47 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 45 def find(object_type, id, klass) sf_data.get_record object_type, record_id: id, target_org: target_org, model_class: klass end |
#open ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 28 def open if ENV['SF_ACCESS_TOKEN'] sf_org.login_access_token target_org: target_org, instance_url: instance_url else sf_org.login_web target_org: target_org, instance_url: instance_url end end |
#query(soql, klass, format = nil) ⇒ Object
68 69 70 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 68 def query(soql, klass, format = nil) sf_data.query soql, target_org: target_org, format: format, model_class: klass end |
#update(object_type, id, values) ⇒ Object
58 59 60 |
# File 'lib/sf_cli/sf/model/sf_command_connection.rb', line 58 def update(object_type, id, values) sf_data.update_record object_type, record_id: id, where: nil, values: values, target_org: target_org end |