class Flo::Provider::SalesforceFlo

Public Class Methods

new(opts={}) click to toggle source

Creates a new SalesforceFlo Provider instance

@param [Hash] opts The options needed to create the provider @option opts [Restforce, call] :client An instance of a Restforce client, or

an object that will produce a client when #call is invoked
# 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

Public Instance Methods

object(sobject, object_name) click to toggle source

Provides the current state of a Salesforce object

@param sobject [String] The api name of sobject to query @param object_name [String] The name of the object instance to search for

# File lib/flo/provider/salesforce_flo.rb, line 46
def object(sobject, object_name)
  @client.find(sobject, object_name, 'Name')
end
update_object(opts={}) click to toggle source

Updates a Salesforce object using the client

@param [Hash] opts The options needed to update the object @option opts [String] :sobject The api name of the sobject to update @option opts [String] :name The name of the object instance you wish to update @option opts [Hash] :fields A mapping of the field names and values you wish to update

# 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