class AdwordsApi::IncrementalUploadHelper
Attributes
upload_url[R]
uploaded_bytes[R]
Public Class Methods
new(batch_job_utils, uploaded_bytes, upload_url)
click to toggle source
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.
# 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
Public Instance Methods
upload(operations, is_last_request = false)
click to toggle source
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.
# 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
Private Instance Methods
check_status()
click to toggle source
# File lib/adwords_api/incremental_upload_helper.rb, line 68 def check_status() if @finished raise AdwordsApi::Errors::InvalidBatchJobOperationError, 'Cannot put new operations to completed incremental upload.' end end