Sha256: 0eb58c8f098bcb5ccbfda2b90a8d588445694e8363ef47636c8a9b10d7f9831d

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

module Blurb
  class Report < BaseResource
    CAMPAIGNS = "campaigns"
    AD_GROUPS = "adGroups"
    KEYWORDS = "keywords"
    PRODUCT_ADS = "productAds"

    def self.create(params = {}, opts = {})
      # required argument checks
      raise ArgumentError.new("params hash must contain a recordType") unless params["recordType"]

      api_params = {
        "campaignType" => "sponsoredProducts",
        "reportDate" => params["reportDate"],
        "metrics" => params["metrics"]
      }

      api_params["segment"] = params["segment"] if params["segment"]

      post_request("/v1/#{params["recordType"]}/report", api_params)
    end

    def self.status(report_id, opts = {})
      get_request("/v1/reports/#{report_id}")
    end

    def self.download(location, opts = {})
      opts.merge!({:full_path => true, :gzip => true, :no_token => true})
      get_request(location, opts)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blurb-0.1.2 lib/blurb/report.rb
blurb-0.1.1 lib/blurb/report.rb