Class: Executrix::Connection
- Inherits:
-
Object
- Object
- Executrix::Connection
- Defined in:
- lib/executrix/connection.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_batch(job_id, records) ⇒ Object
- #add_file_upload_batch(job_id, filename) ⇒ Object
- #add_query(job_id, data_or_soql) ⇒ Object
- #close_job(job_id) ⇒ Object
- #create_job(operation, sobject, content_type, external_field) ⇒ Object
-
#initialize(username, password, api_version, sandbox) ⇒ Connection
constructor
A new instance of Connection.
- #login ⇒ Object
- #org_id ⇒ Object
- #query_batch(job_id, batch_id) ⇒ Object
- #query_batch_result_data(job_id, batch_id, result_id) ⇒ Object
- #query_batch_result_id(job_id, batch_id) ⇒ Object
Constructor Details
#initialize(username, password, api_version, sandbox) ⇒ Connection
3 4 5 6 7 8 |
# File 'lib/executrix/connection.rb', line 3 def initialize(username, password, api_version, sandbox) @username = username @password = password @api_version = api_version @sandbox = sandbox end |
Class Method Details
.connect(username, password, api_version, sandbox) ⇒ Object
106 107 108 |
# File 'lib/executrix/connection.rb', line 106 def self.connect(username, password, api_version, sandbox) self.new(username, password, api_version, sandbox).login end |
Instance Method Details
#add_batch(job_id, records) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/executrix/connection.rb', line 95 def add_batch job_id, records return -1 if records.nil? || records.empty? Executrix::Http.add_batch( @instance, @session_id, job_id, Executrix::Helper.records_to_csv(records), @api_version)[:id] end |
#add_file_upload_batch(job_id, filename) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/executrix/connection.rb', line 86 def add_file_upload_batch job_id, filename Executrix::Http.add_file_upload_batch( @instance, @session_id, job_id, filename, @api_version)[:id] end |
#add_query(job_id, data_or_soql) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/executrix/connection.rb', line 46 def add_query job_id, data_or_soql Executrix::Http.add_batch( @instance, @session_id, job_id, data_or_soql, @api_version)[:id] end |
#close_job(job_id) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/executrix/connection.rb', line 38 def close_job job_id Executrix::Http.close_job( @instance, @session_id, job_id, @api_version)[:id] end |
#create_job(operation, sobject, content_type, external_field) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/executrix/connection.rb', line 27 def create_job operation, sobject, content_type, external_field Executrix::Http.create_job( @instance, @session_id, operation, sobject, content_type, @api_version, external_field)[:id] end |
#login ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/executrix/connection.rb', line 10 def login response = Executrix::Http.login( @sandbox, @username, @password, @api_version) @session_id = response[:session_id] @instance = response[:instance] self end |
#org_id ⇒ Object
22 23 24 25 |
# File 'lib/executrix/connection.rb', line 22 def org_id raise 'please login first' unless @session_id @session_id.split('!').first end |
#query_batch(job_id, batch_id) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/executrix/connection.rb', line 55 def query_batch job_id, batch_id Executrix::Http.query_batch( @instance, @session_id, job_id, batch_id, @api_version, ) end |
#query_batch_result_data(job_id, batch_id, result_id) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/executrix/connection.rb', line 75 def query_batch_result_data job_id, batch_id, result_id Executrix::Http.query_batch_result_data( @instance, @session_id, job_id, batch_id, result_id, @api_version, ) end |
#query_batch_result_id(job_id, batch_id) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/executrix/connection.rb', line 65 def query_batch_result_id job_id, batch_id Executrix::Http.query_batch_result_id( @instance, @session_id, job_id, batch_id, @api_version, ) end |