lib/blurb/report.rb in blurb-0.2.1 vs lib/blurb/report.rb in blurb-0.2.2

- old
+ new

@@ -2,10 +2,11 @@ class Report < BaseResource CAMPAIGNS = "campaigns" AD_GROUPS = "adGroups" KEYWORDS = "keywords" PRODUCT_ADS = "productAds" + ASINS = "asins" SPONSORED_PRODUCTS = "sp" SPONSORED_BRANDS = "hsa" def self.create(params = {}, opts = {}) # required argument checks @@ -19,11 +20,19 @@ "metrics" => metrics } api_params["segment"] = params["segment"] if params["segment"] - post_request("/v2/#{params["campaignType"]}/#{params["recordType"]}/report", api_params) + if params["recordType"] == ASINS + request_url = "/v2/#{ASINS}/report" + api_params["campaignType"] = 'sponsoredProducts' if params["campaignType"] == SPONSORED_PRODUCTS + raise ArgumentError.new("ASIN report is not supported for Sponsored Brands") if params["campaignType"] == SPONSORED_BRANDS + else + request_url = "/v2/#{params["campaignType"]}/#{params["recordType"]}/report" + end + + post_request(request_url, api_params) end def self.status(report_id, opts = {}) get_request("/v2/reports/#{report_id}") end @@ -87,9 +96,27 @@ "attributedSales14dSameSKU", "attributedConversions14d", "attributedConversions14dSameSKU" ].join(",") if record_type == KEYWORDS elsif campaign_type == SPONSORED_PRODUCTS + return [ + "campaignName", + "campaignId", + "adGroupId", + "adGroupName", + "asin", + "otherAsin", + "sku", + "currency", + "attributedUnitsOrdered1dOtherSKU", + "attributedUnitsOrdered7dOtherSKU", + "attributedUnitsOrdered14dOtherSKU", + "attributedUnitsOrdered30dOtherSKU", + "attributedSales1dOtherSKU", + "attributedSales7dOtherSKU", + "attributedSales14dOtherSKU", + "attributedSales30dOtherSKU" + ].join(",") if record_type == ASINS return [ "bidPlus", "campaignName", "campaignId", "campaignStatus",