Class: Metaforce::Services::Client

Inherits:
AbstractClient show all
Defined in:
lib/metaforce/services/client.rb

Instance Method Summary collapse

Methods inherited from AbstractClient

endpoint, #initialize, wsdl

Constructor Details

This class inherits a constructor from Metaforce::AbstractClient

Instance Method Details

#describe_layout(sobject, record_type_id = nil) ⇒ Object

Public: Retrieves layout information for the specified sobject.

sobject - String name of the sobject. record_type_id - String id of a record type to filter on.

Examples

client.describe_layout('Account', '012000000000000AAA')

Returns the layout metadata for the sobject.



39
40
41
42
43
44
# File 'lib/metaforce/services/client.rb', line 39

def describe_layout(sobject, record_type_id=nil)
  request :describe_layout do |soap|
    soap.body = { 'sObjectType' => sobject }
    soap.body.merge!('recordTypeID' => record_type_id) if record_type_id
  end
end

#get_server_timestampObject

Public: Retrieves the current system timestamp

(Coordinated Universal Time (UTC) time zone) from the API.

Example: client.services.send(:get_server_timestamp)



72
73
74
# File 'lib/metaforce/services/client.rb', line 72

def get_server_timestamp
  request :get_server_timestamp
end

#get_user_infoObject

Public: Retrieves personal information for the user associated

with the current session.

Example: client.services.send(:get_user_info)



79
80
81
# File 'lib/metaforce/services/client.rb', line 79

def 
  request :get_user_info
end

#inspectObject



64
65
66
# File 'lib/metaforce/services/client.rb', line 64

def inspect
  "#<#{self.class} @options=#{@options.inspect}>"
end

#picklist_values(sobject, record_type_id, field) ⇒ Object

Public: Get active picklists for a record type.

sobject - String name of the sobject. record_type_id - String id of a record type to filter on. field - String name of the field to get picklist values for.

Examples

client.picklist_values('Account', '012000000000000AAA', 'Some_Field__c')
# => [['Label', 'Value']]

Returns the picklist_values



58
59
60
61
62
# File 'lib/metaforce/services/client.rb', line 58

def picklist_values(sobject, record_type_id, field)
  describe_layout(sobject, record_type_id).record_type_mappings.picklists_for_record_type
    .select { |p| p.picklist_name == field }.first.picklist_values
    .select { |p| p.active }.collect { |p| [ p.label, p.value ] }
end

#send_email(options = {}) ⇒ Object

Public: Sends an email using Salesforce.

options - Hash of email options (www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sendemail.htm)

Examples

client.send_email(
  to_addresses: ['[email protected]'],
  subject: 'Hello World',
  plain_text_body: 'Hello World'
)

Returns the result.



20
21
22
23
24
25
26
27
# File 'lib/metaforce/services/client.rb', line 20

def send_email(options={})
  request :send_email do |soap|
    soap.body = {
      :messages => options,
      :attributes! => { 'ins0:messages' => { 'xsi:type' => 'ins0:SingleEmailMessage' } }
    }
  end
end