class Restforce::Concerns::BatchAPI::Subrequests
Attributes
options[R]
requests[R]
Public Class Methods
new(options)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 37 def initialize(options) @options = options @requests = [] end
Public Instance Methods
create(sobject, attrs)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 43 def create(sobject, attrs) requests << { method: 'POST', url: batch_api_path(sobject), richInput: attrs } end
destroy(sobject, id)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 59 def destroy(sobject, id) requests << { method: 'DELETE', url: batch_api_path("#{sobject}/#{id}") } end
update(sobject, attrs)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 47 def update(sobject, attrs) id = attrs.fetch(attrs.keys.find { |k, v| k.to_s.casecmp?('id') }, nil) raise ArgumentError, 'Id field missing from attrs.' unless id attrs_without_id = attrs.reject { |k, v| k.to_s.casecmp?('id') } requests << { method: 'PATCH', url: batch_api_path("#{sobject}/#{id}"), richInput: attrs_without_id } end
upsert(sobject, ext_field, attrs)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 63 def upsert(sobject, ext_field, attrs) raise ArgumentError, 'External id field missing.' unless ext_field ext_id = attrs.fetch(attrs.keys.find { |k, v| k.to_s.casecmp?(ext_field.to_s) }, nil) raise ArgumentError, 'External id missing from attrs.' unless ext_id attrs_without_ext_id = attrs.reject { |k, v| k.to_s.casecmp?(ext_field) } requests << { method: 'PATCH', url: batch_api_path("#{sobject}/#{ext_field}/#{ext_id}"), richInput: attrs_without_ext_id } end
Private Instance Methods
batch_api_path(path)
click to toggle source
# File lib/restforce/concerns/batch_api.rb, line 81 def batch_api_path(path) "v#{options[:api_version]}/sobjects/#{path}" end