Class: Flo::Provider::SalesforceFlo

Inherits:
Base
  • Object
show all
Defined in:
lib/flo/provider/salesforce_flo.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SalesforceFlo

Creates a new SalesforceFlo Provider instance

Parameters:

  • opts (Hash) (defaults to: {})

    The options needed to create the provider

Options Hash (opts):

  • :client (Restforce, #call)

    An instance of a Restforce client, or an object that will produce a client when #call is invoked



19
20
21
22
23
24
25
# File 'lib/flo/provider/salesforce_flo.rb', line 19

def initialize(opts={})
  @client = if opts[:client].respond_to? :call
    opts[:client].call
  else
    opts[:client]
  end
end

Instance Method Details

#object(sobject, object_name) ⇒ Object

Provides the current state of a Salesforce object

Parameters:

  • sobject (String)

    The api name of sobject to query

  • object_name (String)

    The name of the object instance to search for



46
47
48
# File 'lib/flo/provider/salesforce_flo.rb', line 46

def object(sobject, object_name)
  @client.find(sobject, object_name, 'Name')
end

#update_object(opts = {}) ⇒ Object

Updates a Salesforce object using the client

Parameters:

  • opts (Hash) (defaults to: {})

    The options needed to update the object

Options Hash (opts):

  • :sobject (String)

    The api name of the sobject to update

  • :name (String)

    The name of the object instance you wish to update

  • :fields (Hash)

    A mapping of the field names and values you wish to update



34
35
36
37
38
39
40
# File 'lib/flo/provider/salesforce_flo.rb', line 34

def update_object(opts={})
  sobject = opts.delete(:sobject)

  object = @client.find(sobject, opts.delete(:name), 'Name')
  @client.update(sobject, opts[:fields].merge(Id: object.Id))
  OpenStruct.new(success?: true)
end