lib/blurb/snapshot.rb in blurb-0.2.2 vs lib/blurb/snapshot.rb in blurb-0.2.3

- old
+ new

@@ -4,17 +4,25 @@ AD_GROUPS = "adGroups" KEYWORDS = "keywords" NEGATIVE_KEYWORDS = "negativeKeywords" CAMPAIGN_NEGATIVE_KEYWORDS = "campaignNegativeKeywords" PRODUCT_ADS = "productAds" + TARGETS = "targets" + SPONSORED_PRODUCTS = "sp" + SPONSORED_BRANDS = "hsa" def self.create(params = {}, opts = {}) # required argument checks raise ArgumentError.new("params hash must contain a recordType") unless params["recordType"] - post_request("/v2/#{params["recordType"]}/snapshot", { - "campaignType" => "sponsoredProducts", - "stateFilter" => params["stateFilter"] + # Default State Filter if no params passed in + state_filter = params["stateFilter"] || "enabled,paused" + + # Default campaign type so version 2.3 is backward compatible with version 2.2 + campaign_type = params["campaignType"] || SPONSORED_PRODUCTS + + post_request("/v2/#{campaign_type}/#{params["recordType"]}/snapshot", { + "stateFilter" => state_filter }) end def self.status(snapshot_id, opts = {}) get_request("/v2/snapshots/#{snapshot_id}")