Class: AdwordsApi::IncrementalUploadHelper
- Inherits:
-
Object
- Object
- AdwordsApi::IncrementalUploadHelper
- Defined in:
- lib/adwords_api/incremental_upload_helper.rb
Instance Attribute Summary collapse
-
#upload_url ⇒ Object
readonly
Returns the value of attribute upload_url.
-
#uploaded_bytes ⇒ Object
readonly
Returns the value of attribute uploaded_bytes.
Instance Method Summary collapse
-
#initialize(batch_job_utils, uploaded_bytes, upload_url) ⇒ IncrementalUploadHelper
constructor
Default constructor.
-
#upload(operations, is_last_request = false) ⇒ Object
Takes an array of operations and puts it to the batch job incrementally.
Constructor Details
#initialize(batch_job_utils, uploaded_bytes, upload_url) ⇒ IncrementalUploadHelper
Default constructor.
Args:
-
batch_job_service: The instance of BatchJobService that is providing
this helper
-
uploaded_bytes: The number of bytes that have already been uploaded
as part of this incremental process.
-
upload_url: The URL that should be used to upload incremental
operations for this job.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/adwords_api/incremental_upload_helper.rb', line 35 def initialize(batch_job_utils, uploaded_bytes, upload_url) @batch_job_utils = batch_job_utils @uploaded_bytes = uploaded_bytes if @uploaded_bytes == 0 @upload_url = @batch_job_utils.initialize_url(upload_url) else @upload_url = upload_url end @finished = false end |
Instance Attribute Details
#upload_url ⇒ Object (readonly)
Returns the value of attribute upload_url.
23 24 25 |
# File 'lib/adwords_api/incremental_upload_helper.rb', line 23 def upload_url @upload_url end |
#uploaded_bytes ⇒ Object (readonly)
Returns the value of attribute uploaded_bytes.
23 24 25 |
# File 'lib/adwords_api/incremental_upload_helper.rb', line 23 def uploaded_bytes @uploaded_bytes end |
Instance Method Details
#upload(operations, is_last_request = false) ⇒ Object
Takes an array of operations and puts it to the batch job incrementally.
Args:
-
hash_operations: An array of operations to put, represented in hashes
like you would normally pass to services.
-
is_last_request: Whether this request is the last request of the
incremental job.
Raises:
-
InvalidBatchJobOperationError: If this incremental upload is already
finished or if there is an error converting the hash operations to soap operations.
59 60 61 62 63 64 |
# File 'lib/adwords_api/incremental_upload_helper.rb', line 59 def upload(operations, is_last_request = false) check_status() @uploaded_bytes = @batch_job_utils.put_incremental_operations( operations, @upload_url, @uploaded_bytes, is_last_request) @finished = true if is_last_request end |