Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More explicitly handle min max dates

  • Loading branch information...
commit 66387b3666d92cb7c52c1732a1fda1955a547b54 1 parent e2258b4
@Kequc Kequc authored
Showing with 32 additions and 29 deletions.
  1. +24 −24 lib/adapi.rb
  2. +8 −5 lib/adapi/report.rb
48 lib/adapi.rb
@@ -10,32 +10,32 @@
# TODO require only ActiveSupport parts that we actually use
require 'active_support/all'
-require 'adapi/common'
-require 'adapi/version'
-require 'adapi/config'
-require 'adapi/api'
-require 'adapi/service_api'
-require 'adapi/account'
-require 'adapi/serviced_account'
-require 'adapi/campaign'
-require 'adapi/campaign_criterion'
-require 'adapi/campaign_ad_extension'
-require 'adapi/geo_location'
-require 'adapi/address'
-require 'adapi/ad_group'
-require 'adapi/ad_group_criterion'
-require 'adapi/keyword'
-require 'adapi/ad'
-require 'adapi/ad/text_ad'
-require 'adapi/ad_param'
-require 'adapi/constant_data'
-require 'adapi/constant_data/language'
-require 'adapi/constant_data/country'
-require 'adapi/location'
-require 'adapi/report'
+require './adapi/common'
+require './adapi/version'
+require './adapi/config'
+require './adapi/api'
+require './adapi/service_api'
+require './adapi/account'
+require './adapi/serviced_account'
+require './adapi/campaign'
+require './adapi/campaign_criterion'
+require './adapi/campaign_ad_extension'
+require './adapi/geo_location'
+require './adapi/address'
+require './adapi/ad_group'
+require './adapi/ad_group_criterion'
+require './adapi/keyword'
+require './adapi/ad'
+require './adapi/ad/text_ad'
+require './adapi/ad_param'
+require './adapi/constant_data'
+require './adapi/constant_data/language'
+require './adapi/constant_data/country'
+require './adapi/location'
+require './adapi/report'
# Monkeypatch HTTPI - important, check the file!
-require 'httpi_request_monkeypatch'
+require './httpi_request_monkeypatch'
HTTPI.adapter = :curb
HTTPI.log = false # Supress HTTPI output
13 lib/adapi/report.rb
@@ -31,10 +31,13 @@ def initialize(params={})
if use_custom_date
raise "Date range must be specified for :custom_date date range type" unless params[:date_range]
params[:date_range_type] = :custom_date
- params[:date_range].each do |k, v|
- params[:date_range][k] = v.strftime("%Y%m%d") if v.is_a?(Time)
- end
- if params[:date_range][:min].empty? or params[:date_range][:max].empty?
+ # Format dates to strings
+ date_range = [:min, :max].map { |a| params[:date_range][a] }
+! { |d| d.is_a?(Time) ? Common.string_from_date(d) : d.to_s }
+ date_range = { min: date_range[0], max: date_range[1] }
+ if date_range[:min].blank? or date_range[:max].blank?
raise "Min and max dates must be specified in date_range"
@@ -51,7 +54,7 @@ def initialize(params={})
date_range_type: params[:date_range_type].to_s.upcase,
include_zero_impressions: params[:include_zero_impressions]
- self.report_definition[:selector][:date_range] = params[:date_range] if use_custom_date
+ self.report_definition[:selector][:date_range] = date_range if use_custom_date
@service = @adwords.report_utils(@version)
Please sign in to comment.
Something went wrong with that request. Please try again.