Class: AdwordsApi::IncrementalUploadHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/adwords_api/incremental_upload_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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
# 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
  @upload_url = upload_url
  @finished = false
end

Instance Attribute Details

#upload_urlObject (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_bytesObject (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.



55
56
57
58
59
60
# File 'lib/adwords_api/incremental_upload_helper.rb', line 55

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