googleads / google-api-ads-ruby

Ad Manager SOAP API Client Libraries for Ruby
297 stars 227 forks source link

Build a statement with `importDateTime` query #197

Open anacarolinacastro opened 6 months ago

anacarolinacastro commented 6 months ago

Hello,

I am trying to create a code routine that will clean old content.

To do so, I want to use a statement to list the content objects that have importDateTime older than months. Is there a way to query this field? I am currently getting the following exception:

[...]
irb(main):241:0> limit_import_date_time = ad_manager.now('America/New_York') - 6.months
irb(main):242:1* statement = ad_manager.new_statement_builder do |sb|
irb(main):243:1*     sb.where = "contentSourceId = :content_source_id AND status = :status AND importDateTime < :import_date_time"
irb(main):244:1*     sb.with_bind_variable("status", "ACTIVE")
irb(main):245:1*     sb.with_bind_variable("content_source_id", "2647737")
irb(main):246:1*     sb.with_bind_variable("import_date_time", limit_import_date_time)
irb(main):247:0> end
=> 
#<AdManagerApi::StatementBuilder:0x00007d66ee99a2f0
...
irb(main):248:0> page = ad_manager.service(:ContentService, :v202311).get_content_by_statement(statement.to_statement)
/usr/local/bundle/gems/google-ads-common-1.0.3/lib/ads_common/savon_service.rb:121:in `handle_errors': 

[PublisherQueryLanguageContextError.UNEXECUTABLE @ ] (AdManagerApi::V202311::ContentService::ApiException)

By the API docs, the field importDateTime seems like a valid readable attribute.

Thanks.