Class: AdwordsApi::V13::ReportService::ReportServiceWrapper
- Inherits:
-
Object
- Object
- AdwordsApi::V13::ReportService::ReportServiceWrapper
- Defined in:
- lib/adwords_api/v13/ReportServiceWrapper.rb
Overview
Wrapper class for the v13 ReportService service. This class is automatically generated.
Constant Summary collapse
- REGISTRY =
AdwordsApi::V13::ReportService::DefaultMappingRegistry::LiteralRegistry
- NAMESPACE =
This takes advantage of the code generated by soap4r to get the correct namespace for a given service. It accesses one of the fields in the description of the service’s methods, which indicates the namespace. Since we’re using a fixed version of soap4r (1.5.8), and this is automatically generated as part of the stub generation, it will always point to what we want.
'https://adwords.google.com/api/adwords/v13'
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Holds the API object to which the wrapper belongs.
-
#module ⇒ Object
readonly
Holds a shortcut to the parent module.
-
#service ⇒ Object
readonly
Version and service utility fields.
-
#version ⇒ Object
readonly
Version and service utility fields.
Instance Method Summary collapse
-
#convert_from_object(object) ⇒ Object
Converts real soap4r objects into dynamic ones (property hashes).
-
#convert_to_object(object, parent_class = nil, property = nil) ⇒ Object
Converts dynamic objects (property hashes) into real soap4r objects.
-
#deleteReport(reportJobId) ⇒ Object
(also: #delete_report)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#download_csv_report(job_id) ⇒ Object
Extension method – Calls the AdwordsApi::Extensions.download_csv_report method with
selfas the first parameter. -
#download_xml_report(job_id) ⇒ Object
Extension method – Calls the AdwordsApi::Extensions.download_xml_report method with
selfas the first parameter. -
#getAllJobs ⇒ Object
(also: #get_all_jobs)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#getGzipReportDownloadUrl(reportJobId) ⇒ Object
(also: #get_gzip_report_download_url)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#getReportDownloadUrl(reportJobId) ⇒ Object
(also: #get_report_download_url)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#getReportJobStatus(reportJobId) ⇒ Object
(also: #get_report_job_status)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#initialize(driver, api) ⇒ ReportServiceWrapper
constructor
Constructor for ReportServiceWrapper.
-
#namespace ⇒ Object
Returns the namespace for this service.
-
#scheduleReportJob(job) ⇒ Object
(also: #schedule_report_job)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
-
#validateReportJob(job) ⇒ Object
(also: #validate_report_job)
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
Constructor Details
#initialize(driver, api) ⇒ ReportServiceWrapper
Constructor for ReportServiceWrapper.
Args:
-
driver: SOAP::RPC::Driver object with the remote SOAP methods for this service
-
api: the API object to which the wrapper belongs
47 48 49 50 51 52 53 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 47 def initialize(driver, api) @driver = driver @api = api @module = AdwordsApi::V13::ReportService @version = :v13 @service = :ReportService end |
Instance Attribute Details
#api ⇒ Object (readonly)
Holds the API object to which the wrapper belongs.
14 15 16 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 14 def api @api end |
#module ⇒ Object (readonly)
Holds a shortcut to the parent module. Use this to avoid typing the full class name when creating classes belonging to this service, e.g.
service_object.module::ClassName
instead of
AdwordsApi::V13::ReportService::ClassName
This will make it easier to migrate your code between API versions.
36 37 38 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 36 def module @module end |
#service ⇒ Object (readonly)
Version and service utility fields.
17 18 19 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 17 def service @service end |
#version ⇒ Object (readonly)
Version and service utility fields.
17 18 19 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 17 def version @version end |
Instance Method Details
#convert_from_object(object) ⇒ Object
Converts real soap4r objects into dynamic ones (property hashes). This is meant to be called for return objects of remote calls.
Args:
-
object: the object being converted
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 227 def convert_from_object(object) if object.class.name =~ /AdwordsApi::V13::\w+::\w+/ # Handle soap4r object object_class = REGISTRY.schema_definition_from_class(object.class) if object_class.elements and !object_class.elements.entries.empty? # Process complex object. hash = {} hash[:xsi_type] = object.class.name.split('::').last object_class.elements.entries.each do |entry| property = entry.varname.to_s if object.respond_to? property and !property.include?('_Type') value = object.send(property) property_name = nil if @api.config.read('service.use_ruby_names', true) property_name = underscore(property).to_sym else property_name = property.to_sym end # Recurse. hash[property_name] = convert_from_object(value) if value end end return hash else # Process simple object. parent = object.class.superclass return parent.new(object) end elsif object.is_a? Array # Handle arrays return object.map do |entry| # Recurse. convert_from_object(entry) end else # Handle native objects return object end end |
#convert_to_object(object, parent_class = nil, property = nil) ⇒ Object
Converts dynamic objects (property hashes) into real soap4r objects. This is meant to be called when setting properties on a class, so the method receives an optional parameter specifying the class and property. This way, it’s possible to determine the default type for the object if none is provided.
Args:
-
object: the object being converted
-
parent_class: the class whose property is being set
-
property: the property being set
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 162 def convert_to_object(object, parent_class = nil, property = nil) property = camel_case(property.to_s) if property if object.is_a? Hash # Process a hash. specified_class = object[:xsi_type] or object['xsi_type'] default_class = nil # Determine default class for this object, given the property # being set. if parent_class and property parent = REGISTRY.schema_definition_from_class(parent_class) element = parent.elements.entries.find do |entry| entry.varname.to_s == property.to_s end default_class = element.mapped_class if element end validate_object(object, default_class) real_class = nil if specified_class real_class = @module.class_eval(specified_class) else real_class = default_class end # Instance real object. real_object = real_class.new # Set each of its properties. object.each do |entry, value| entry = entry.to_s unless entry == 'xsi_type' if @api.config.read('service.use_ruby_names', true) entry = camel_case(entry) end if value.is_a? Hash # Recurse. set_object_property(real_object, entry, convert_to_object(value, real_class, entry)) elsif value.is_a? Array set_object_property(real_object, entry, value.map do |item| # Recurse. convert_to_object(item, real_class, entry) end ) else set_object_property(real_object, entry, value) end end end return real_object elsif object.is_a? Array # Process an array return object.map do |entry| # Recurse. convert_to_object(entry, parent_class, property) end else return object end end |
#deleteReport(reportJobId) ⇒ Object Also known as: delete_report
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 280 def deleteReport(reportJobId) begin arg_array = [] validate_object(reportJobId, SOAP::SOAPLong) arg_array << convert_to_object(reportJobId, AdwordsApi::V13::ReportService::DeleteReport, 'reportJobId') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::DeleteReport.new(*arg_array) reply = convert_from_object(@driver.deleteReport(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#download_csv_report(job_id) ⇒ Object
Extension method – Calls the AdwordsApi::Extensions.download_csv_report method with self as the first parameter.
493 494 495 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 493 def download_csv_report(job_id) return AdwordsApi::Extensions.download_csv_report(self, job_id) end |
#download_xml_report(job_id) ⇒ Object
Extension method – Calls the AdwordsApi::Extensions.download_xml_report method with self as the first parameter.
486 487 488 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 486 def download_xml_report(job_id) return AdwordsApi::Extensions.download_xml_report(self, job_id) end |
#getAllJobs ⇒ Object Also known as: get_all_jobs
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 309 def getAllJobs() begin arg_array = [] # Construct request object and make API call obj = AdwordsApi::V13::ReportService::GetAllJobs.new(*arg_array) reply = convert_from_object(@driver.getAllJobs(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#getGzipReportDownloadUrl(reportJobId) ⇒ Object Also known as: get_gzip_report_download_url
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 338 def getGzipReportDownloadUrl(reportJobId) begin arg_array = [] validate_object(reportJobId, SOAP::SOAPLong) arg_array << convert_to_object(reportJobId, AdwordsApi::V13::ReportService::GetGzipReportDownloadUrl, 'reportJobId') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::GetGzipReportDownloadUrl.new(*arg_array) reply = convert_from_object(@driver.getGzipReportDownloadUrl(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#getReportDownloadUrl(reportJobId) ⇒ Object Also known as: get_report_download_url
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 370 def getReportDownloadUrl(reportJobId) begin arg_array = [] validate_object(reportJobId, SOAP::SOAPLong) arg_array << convert_to_object(reportJobId, AdwordsApi::V13::ReportService::GetReportDownloadUrl, 'reportJobId') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::GetReportDownloadUrl.new(*arg_array) reply = convert_from_object(@driver.getReportDownloadUrl(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#getReportJobStatus(reportJobId) ⇒ Object Also known as: get_report_job_status
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 402 def getReportJobStatus(reportJobId) begin arg_array = [] validate_object(reportJobId, SOAP::SOAPLong) arg_array << convert_to_object(reportJobId, AdwordsApi::V13::ReportService::GetReportJobStatus, 'reportJobId') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::GetReportJobStatus.new(*arg_array) reply = convert_from_object(@driver.getReportJobStatus(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#namespace ⇒ Object
Returns the namespace for this service.
56 57 58 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 56 def namespace return NAMESPACE end |
#scheduleReportJob(job) ⇒ Object Also known as: schedule_report_job
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 434 def scheduleReportJob(job) begin arg_array = [] validate_object(job, AdwordsApi::V13::ReportService::ReportJob) arg_array << convert_to_object(job, AdwordsApi::V13::ReportService::ScheduleReportJob, 'job') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::ScheduleReportJob.new(*arg_array) reply = convert_from_object(@driver.scheduleReportJob(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |
#validateReportJob(job) ⇒ Object Also known as: validate_report_job
Raises: Error::ApiError (or a subclass thereof) if a SOAP fault occurs.
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/adwords_api/v13/ReportServiceWrapper.rb', line 463 def validateReportJob(job) begin arg_array = [] validate_object(job, AdwordsApi::V13::ReportService::ReportJob) arg_array << convert_to_object(job, AdwordsApi::V13::ReportService::ValidateReportJob, 'job') # Construct request object and make API call obj = AdwordsApi::V13::ReportService::ValidateReportJob.new(*arg_array) reply = convert_from_object(@driver.validateReportJob(obj)) reply = reply[:rval] if reply.include?(:rval) return reply rescue SOAP::FaultError => fault raise AdwordsApi::Errors.create_api_exception(fault, self) end end |