Class: Bambora::BatchUpload::BeanstreamSendBatch
- Inherits:
-
Object
- Object
- Bambora::BatchUpload::BeanstreamSendBatch
- Defined in:
- lib/bambora/batch_upload/beanstream_send_batch.rb
Constant Summary collapse
- BATCH_PROCESS_SUCCESS =
1
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#process_date ⇒ Object
Returns the value of attribute process_date.
-
#process_now ⇒ Object
Returns the value of attribute process_now.
Instance Method Summary collapse
-
#initialize(file_path, process_date, process_now) ⇒ BeanstreamSendBatch
constructor
A new instance of BeanstreamSendBatch.
- #send ⇒ Object
Constructor Details
#initialize(file_path, process_date, process_now) ⇒ BeanstreamSendBatch
Returns a new instance of BeanstreamSendBatch.
12 13 14 15 16 |
# File 'lib/bambora/batch_upload/beanstream_send_batch.rb', line 12 def initialize(file_path, process_date, process_now) @file_path = file_path @process_date = process_date @process_now = process_now end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/bambora/batch_upload/beanstream_send_batch.rb', line 8 def file_path @file_path end |
#process_date ⇒ Object
Returns the value of attribute process_date.
9 10 11 |
# File 'lib/bambora/batch_upload/beanstream_send_batch.rb', line 9 def process_date @process_date end |
#process_now ⇒ Object
Returns the value of attribute process_now.
10 11 12 |
# File 'lib/bambora/batch_upload/beanstream_send_batch.rb', line 10 def process_now @process_now end |
Instance Method Details
#send ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bambora/batch_upload/beanstream_send_batch.rb', line 20 def send c = Curl::Easy.new(batch_uploads_api_url) do |curl| curl.headers["Authorization"] = "Passcode #{encoded_pass_code}" end c.multipart_form_post = true c.http_post(criteria_content,file_content) response = JSON.parse(c.body) response_code = c.response_code if response["code"] == BATCH_PROCESS_SUCCESS response["batch_id"] else raise BatchUploadError.new(code: response["code"], category: response["category"], message: response["message"], http_code: response_code) end end |