NAME

Google::Ads::Common::ReportDownloadHandler

DESCRIPTION

Represents a report response from the AdWords API.

PROPERTIES

The following properties may be accessed using get_PROPERTY methods:

  • client

    A reference to a Google::Ads::AdWords::Client.

  • __user_agent (Private)

    A reference to an LWP::UserAgent.

  • __http_request (Private)

    A reference to an HTTP::Request.

  • download_format

    The download format of the request.

METHODS

new

Constructor. The following data structure may be passed to new():

{ # Google::Ads::Common::ReportDownloadHandler
  client =>  $response, # A ref to a Google::Ads::AdWords::Client object
  __user_agent => $user_agent, # A ref to an LWP::UserAgent
  __http_request => $request, # A ref to an HTTP::Request object
  download_format => $download_format, # The download format for the request
},

METHODS

get_as_string

Issues the report request to the AdWords API and returns the report contents as a string.

Returns

The report contents as a string if the request is successful. Otherwise, returns a Google::Ads::Common::ReportDownloadError. Check for failures by evaluating the return value in a boolean context, where a Google::Ads::Common::ReportDownloadError will always evaluate to false.

Exceptions

Returns a Google::Ads::Common::ReportDownloadError if the report request fails.

save

Issues the report request to the AdWords API and saves the report contents to a file.

Parameters

  • The destination file for the report contents.

Returns

The report contents as a string if the request is successful. Otherwise, returns a Google::Ads::Common::ReportDownloadError. Check for failures by evaluating the return value in a boolean context, where a Google::Ads::Common::ReportDownloadError will always evaluate to false.

Exceptions

Returns a Google::Ads::Common::ReportDownloadError if the report request fails.

process_contents

Issues the report request to the AdWords API and invokes a callback for each chunk of content received. Use this method to process the report contents as a stream.

Parameters

  • A content_callback that will be invoked for each chunk of data returned by the report request. Each invocation will be passed two arguments:

    • The chunk of data

    • The HTTP::Response

Returns

An HTTP::Response if the request is successful. Otherwise, returns a Google::Ads::Common::ReportDownloadError. Check for failures by evaluating the return value in a boolean context, where a Google::Ads::Common::ReportDownloadError will always evaluate to false.

Exceptions

Returns a Google::Ads::Common::ReportDownloadError if the report request fails.