Class: ActiveForce::CompositeBatchQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/active_force/composite_batch_query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(soql, sfdc_client) ⇒ CompositeBatchQuery

Returns a new instance of CompositeBatchQuery.



11
12
13
14
# File 'lib/active_force/composite_batch_query.rb', line 11

def initialize(soql, sfdc_client)
  @sfdc_client = sfdc_client
  @soql = soql
end

Instance Attribute Details

#sfdc_clientObject (readonly)

Returns the value of attribute sfdc_client.



9
10
11
# File 'lib/active_force/composite_batch_query.rb', line 9

def sfdc_client
  @sfdc_client
end

#soqlObject (readonly)

Returns the value of attribute soql.



9
10
11
# File 'lib/active_force/composite_batch_query.rb', line 9

def soql
  @soql
end

Class Method Details

.call(soql, sfdc_client = ActiveForce.sfdc_client) ⇒ Object



5
6
7
# File 'lib/active_force/composite_batch_query.rb', line 5

def self.call(soql, sfdc_client = ActiveForce.sfdc_client)
  new(soql, sfdc_client).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_force/composite_batch_query.rb', line 16

def call
  results = sfdc_client.batch do |subrequests|
    subrequests.requests << {
      method: "GET",
      url: "v#{subrequests.options[:api_version]}/query?" + {q: soql}.to_query
    }
  end

  r = results.first

  process_composite_batch_error_response(r) if r.statusCode >= 300

  r.result
end