blurb 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -10
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/Gemfile +0 -2
- data/README.md +23 -7
- data/lib/blurb/base_resource.rb +28 -18
- data/lib/blurb/bid_recommendation.rb +3 -3
- data/lib/blurb/campaign.rb +18 -18
- data/lib/blurb/profile.rb +2 -2
- data/lib/blurb/report.rb +188 -4
- data/lib/blurb/snapshot.rb +2 -2
- data/lib/blurb/suggested_keyword.rb +5 -5
- data/lib/blurb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63a760f4bc9527d16c8807493e9c18fb0119b32e
|
4
|
+
data.tar.gz: 0a9ac5d8323d027edbc2f0955309408c081598c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91605250485ba4b8f3b7916b223ba897eb5867df87b81d49fc798f2db157ac458e33985c73dece02b5db505a27715beba4df24e450a7147bc2b92275837abdf1
|
7
|
+
data.tar.gz: e5d06e3a7bdf21e35e77b44bccede935db2071552a1aea90bb6e0880944945eb63fc66835b38b8d77acc1e6e6c9818ade1c69b363b8cf08f6f317aaee833d8a7
|
data/.circleci/config.yml
CHANGED
@@ -6,15 +6,7 @@ version: 2
|
|
6
6
|
jobs:
|
7
7
|
build:
|
8
8
|
docker:
|
9
|
-
|
10
|
-
- image: circleci/ruby:2.3-node-browsers
|
11
|
-
|
12
|
-
# Specify service dependencies here if necessary
|
13
|
-
# CircleCI maintains a library of pre-built images
|
14
|
-
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
-
# - image: circleci/postgres:9.4
|
16
|
-
|
17
|
-
working_directory: ~/repo
|
9
|
+
- image: circleci/ruby:2.4.4
|
18
10
|
|
19
11
|
steps:
|
20
12
|
- checkout
|
@@ -33,7 +25,7 @@ jobs:
|
|
33
25
|
|
34
26
|
- save_cache:
|
35
27
|
paths:
|
36
|
-
-
|
28
|
+
- vendor/bundle
|
37
29
|
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
38
30
|
|
39
31
|
# run tests!
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Blurb
|
2
2
|
|
3
3
|
[](https://circleci.com/gh/iserve-products/blurb)
|
4
|
+
[](https://travis-ci.org/iserve-products/blurb)
|
5
|
+
[](https://badge.fury.io/rb/blurb)
|
4
6
|
|
5
7
|
Blurb is an API wrapper (written in Ruby and packaged as a Gem) for the Amazon Advertising API. The Amazon Ad API lets you tie in programmatically to
|
6
8
|
Amazon's Advertising Service. More info can be found at [Amazon Advertising](https://services.amazon.com/advertising/overview.htm?ld=NSGoogleAS)
|
7
9
|
|
10
|
+
Version 0.2.0 has been updated to use v2.0 of the Amazon Advertising API.
|
11
|
+
|
8
12
|
## Installation
|
9
13
|
|
10
14
|
Add this line to your application's Gemfile:
|
@@ -25,12 +29,12 @@ Or install it yourself as:
|
|
25
29
|
|
26
30
|
Getting setup to make calls to the Amazon Advertising API can unfortunately be a tedious process.
|
27
31
|
You will need to apply for and have a valid Amazon Advertising Account. You can find that info
|
28
|
-
here: [Amazon Advertising](https://
|
32
|
+
here: [Amazon Advertising](https://advertising.amazon.com/)
|
29
33
|
|
30
34
|
You may also want to get a copy of the advertising docs and getting started guides which can be found here:
|
31
35
|
|
32
|
-
1. [Amazon Advertising API Getting Started Guide
|
33
|
-
2. [Amazon Advertising API Reference
|
36
|
+
1. [Amazon Advertising API Getting Started Guide](https://advertising.amazon.com/API/docs/v2/guides/get_started?ref_=a20m_us_api_dc1)
|
37
|
+
2. [Amazon Advertising API Reference](https://advertising.amazon.com/API/docs/v2/reference/profiles?ref_=a20m_us_api_dc2)
|
34
38
|
|
35
39
|
Once you have an account you will be assigned a "client_id" and a "client_secret".
|
36
40
|
|
@@ -128,6 +132,8 @@ Blurb.test_env = true
|
|
128
132
|
All API calls have been setup as closely as possible to REST Resource calls.
|
129
133
|
All you need to do is find the appropriate resource object and make a method call on it and Blurb will do the rest.
|
130
134
|
|
135
|
+
In calls that require 'campaign_type' as a parameter, you must pass in either 'sp' for sponsored products or 'hsa' for sponsored brands (formerly known as headline search ads).
|
136
|
+
|
131
137
|
NOTE: Not all API endpoints are currently supported by Blurb. Over time we will get more
|
132
138
|
endpoints added. In the mean time you are always welcome to submit a pull request.
|
133
139
|
|
@@ -142,21 +148,20 @@ Blurb::Profile.list()
|
|
142
148
|
List campaigns
|
143
149
|
|
144
150
|
```ruby
|
145
|
-
Blurb::Campaign.list()
|
151
|
+
Blurb::Campaign.list(campaign_type)
|
146
152
|
```
|
147
153
|
|
148
154
|
Get a campaign
|
149
155
|
|
150
156
|
```ruby
|
151
|
-
Blurb::Campaign.retrieve(campaign_id)
|
157
|
+
Blurb::Campaign.retrieve(campaign_id, campaign_type)
|
152
158
|
```
|
153
159
|
|
154
160
|
Create a campaign
|
155
161
|
|
156
162
|
```ruby
|
157
|
-
Blurb::Campaign.create({
|
163
|
+
Blurb::Campaign.create(campaign_type, {
|
158
164
|
"name" => "test",
|
159
|
-
"campaignType" => "sponsoredProducts",
|
160
165
|
"state" => "enabled",
|
161
166
|
"dailyBudget" => 10,
|
162
167
|
"startDate" => (Time.now).strftime('%Y%m%d'),
|
@@ -164,16 +169,20 @@ Blurb::Campaign.create({
|
|
164
169
|
})
|
165
170
|
```
|
166
171
|
|
172
|
+
Note: Sponsored Brands cannot be created through the Amazon Advertising API and must be added through the user interface. The create call only works for Sponsored Products.
|
173
|
+
|
167
174
|
### Reports
|
168
175
|
Request a report
|
169
176
|
|
170
177
|
```ruby
|
171
178
|
payload_response = Blurb::Report.create({
|
179
|
+
"campaignType" => Blurb::Report::SPONSORED_PRODUCTS,
|
172
180
|
"recordType" => Blurb::Report::KEYWORDS,
|
173
181
|
"reportDate" => (Time.now - 2592000).strftime('%Y%m%d'),
|
174
182
|
"metrics" => "impressions,clicks"
|
175
183
|
})
|
176
184
|
```
|
185
|
+
If no metrics are included in the request, blurb will request all available metrics available for the given campaign type and report type.
|
177
186
|
|
178
187
|
Report record types are
|
179
188
|
|
@@ -184,6 +193,13 @@ Blurb::Report::AD_GROUPS
|
|
184
193
|
Blurb::Report::PRODUCT_ADS
|
185
194
|
```
|
186
195
|
|
196
|
+
Campaign types are
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
Blurb::Report::SPONSORED_PRODUCTS
|
200
|
+
Blurb::Report::SPONSORED_BRANDS
|
201
|
+
```
|
202
|
+
|
187
203
|
Check report status
|
188
204
|
|
189
205
|
```ruby
|
data/lib/blurb/base_resource.rb
CHANGED
@@ -7,8 +7,9 @@ module Blurb
|
|
7
7
|
method: :get,
|
8
8
|
url: "#{Blurb.active_api_url}#{api_path}",
|
9
9
|
headers: {
|
10
|
-
|
11
|
-
"Content-Type" => "application/json"
|
10
|
+
"Authorization" => "Bearer #{access_token['access_token']}",
|
11
|
+
"Content-Type" => "application/json",
|
12
|
+
"Amazon-Advertising-API-ClientId" => Blurb.client_id
|
12
13
|
}
|
13
14
|
}
|
14
15
|
|
@@ -25,7 +26,8 @@ module Blurb
|
|
25
26
|
headers_hash = {
|
26
27
|
"Authorization" => "Bearer #{access_token['access_token']}",
|
27
28
|
"Content-Type" => "application/json",
|
28
|
-
"Amazon-Advertising-API-Scope" => Blurb.profile_id
|
29
|
+
"Amazon-Advertising-API-Scope" => Blurb.profile_id,
|
30
|
+
"Amazon-Advertising-API-ClientId" => Blurb.client_id
|
29
31
|
}
|
30
32
|
|
31
33
|
headers_hash["Content-Encoding"] = "gzip" if opts[:gzip]
|
@@ -38,17 +40,7 @@ module Blurb
|
|
38
40
|
max_redirects: 0
|
39
41
|
}
|
40
42
|
|
41
|
-
|
42
|
-
resp = RestClient::Request.execute(request_config)
|
43
|
-
rescue RestClient::ExceptionWithResponse => err
|
44
|
-
# If this happens, then we are downloading a report from the api, so we can simply download the location
|
45
|
-
if err.response.code == 307
|
46
|
-
return RestClient.get(err.response.headers[:location])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
response = JSON.parse(resp) if resp
|
51
|
-
return response
|
43
|
+
return make_request(request_config)
|
52
44
|
end
|
53
45
|
|
54
46
|
def self.post_request(api_path, payload)
|
@@ -59,14 +51,32 @@ module Blurb
|
|
59
51
|
url: "#{Blurb::API_URL}#{api_path}",
|
60
52
|
payload: payload.to_json,
|
61
53
|
headers: {
|
62
|
-
|
54
|
+
"Authorization" => "Bearer #{access_token['access_token']}",
|
63
55
|
"Content-Type" => "application/json",
|
64
|
-
"Amazon-Advertising-API-Scope" => Blurb.profile_id.to_i
|
56
|
+
"Amazon-Advertising-API-Scope" => Blurb.profile_id.to_i,
|
57
|
+
"Amazon-Advertising-API-ClientId" => Blurb.client_id
|
65
58
|
}
|
66
59
|
}
|
67
60
|
|
68
|
-
|
69
|
-
|
61
|
+
return make_request(request_config)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def self.make_request(request_config)
|
67
|
+
begin
|
68
|
+
resp = RestClient::Request.execute(request_config)
|
69
|
+
rescue RestClient::ExceptionWithResponse => err
|
70
|
+
# If this happens, then we are downloading a report from the api, so we can simply download the location
|
71
|
+
if err.response.code == 307
|
72
|
+
return RestClient.get(err.response.headers[:location])
|
73
|
+
else
|
74
|
+
return err.response.body
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
response = JSON.parse(resp) if resp
|
79
|
+
return response
|
70
80
|
end
|
71
81
|
end
|
72
82
|
end
|
@@ -4,21 +4,21 @@ module Blurb
|
|
4
4
|
# required argument checks
|
5
5
|
raise ArgumentError.new("params hash must contain an adGroupId") unless params["adGroupId"]
|
6
6
|
|
7
|
-
get_request("/
|
7
|
+
get_request("/v2/adGroups/#{params["adGroupId"]}/bidRecommendations")
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.keyword_recommendations(params = {}, opts = {})
|
11
11
|
# required argument checks
|
12
12
|
raise ArgumentError.new("params hash must contain an keywordId") unless params["keywordId"]
|
13
13
|
|
14
|
-
get_request("/
|
14
|
+
get_request("/v2/keywords/#{params["keywordId"]}/bidRecommendations")
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.bulk_keyword_recommendations(params = {}, opts = {})
|
18
18
|
# required argument checks
|
19
19
|
raise ArgumentError.new("params hash must contain an array of keywordIds") unless params["keywordIds"]
|
20
20
|
|
21
|
-
post_request("/
|
21
|
+
post_request("/v2/keywords/bidRecommendations", params["keywordIds"])
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/blurb/campaign.rb
CHANGED
@@ -1,29 +1,34 @@
|
|
1
1
|
module Blurb
|
2
2
|
class Campaign < BaseResource
|
3
|
-
|
4
|
-
|
3
|
+
SPONSORED_PRODUCTS = "sp"
|
4
|
+
SPONSORED_BRANDS = "hsa"
|
5
|
+
|
6
|
+
def self.retrieve(campaign_id, campaign_type)
|
7
|
+
get_request("/v2/#{campaign_type}/campaigns/#{campaign_id}")
|
5
8
|
end
|
6
9
|
|
7
|
-
def self.retrieve_extended(campaign_id)
|
8
|
-
get_request("/
|
10
|
+
def self.retrieve_extended(campaign_id, campaign_type)
|
11
|
+
get_request("/v2/#{campaign_type}/campaigns/extended/#{campaign_id}")
|
9
12
|
end
|
10
13
|
|
11
|
-
def self.list(params = {}, opts = {})
|
12
|
-
get_request("/
|
14
|
+
def self.list(campaign_type, params = {}, opts = {})
|
15
|
+
get_request("/v2/#{campaign_type}/campaigns?#{setup_url_params(params)}")
|
13
16
|
end
|
14
17
|
|
15
|
-
def self.create(params = {}, opts = {})
|
18
|
+
def self.create(campaign_type, params = {}, opts = {})
|
16
19
|
# required argument checks
|
17
|
-
if !params["name"] && !params["
|
18
|
-
raise ArgumentError.new("params hash must contain name,
|
20
|
+
if !params["name"] && !params["targetingType"] && !params["state"] && !params["dailyBudget"] && !params["startDate"]
|
21
|
+
raise ArgumentError.new("params hash must contain name, targetingType, state, dailyBudget and startDate")
|
19
22
|
end
|
23
|
+
raise ArgumentError.new("Only sponsored product campaigns can be created through the api. Sponsored Brands campaigns must be created through the user interface") unless campaign_type = SPONSORED_PRODUCTS
|
20
24
|
|
21
|
-
post_request("/
|
25
|
+
post_request("/v2/#{campaign_type}/campaigns", [params])
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
# Deprecated in v2
|
29
|
+
# def self.create_bulk(campaign_array, opts = {})
|
30
|
+
# post_request("/v1/campaigns", campaign_array)
|
31
|
+
# end
|
27
32
|
|
28
33
|
private
|
29
34
|
|
@@ -36,11 +41,6 @@ module Blurb
|
|
36
41
|
url_params += "count=#{params['count']}"
|
37
42
|
end
|
38
43
|
|
39
|
-
if params['campaignType']
|
40
|
-
url_params += "&" if url_params.size > 0
|
41
|
-
url_params += "campaignType=#{params['campaignType']}"
|
42
|
-
end
|
43
|
-
|
44
44
|
if params['stateFilter']
|
45
45
|
url_params += "&" if url_params.size > 0
|
46
46
|
url_params += "stateFilter=#{params['stateFilter']}"
|
data/lib/blurb/profile.rb
CHANGED
@@ -2,11 +2,11 @@ module Blurb
|
|
2
2
|
class Profile < BaseResource
|
3
3
|
|
4
4
|
def self.list()
|
5
|
-
profile_request("/
|
5
|
+
profile_request("/v2/profiles")
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.retrieve(profile_id)
|
9
|
-
profile_request("/
|
9
|
+
profile_request("/v2/profiles/#{profile_id}")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/blurb/report.rb
CHANGED
@@ -4,29 +4,213 @@ module Blurb
|
|
4
4
|
AD_GROUPS = "adGroups"
|
5
5
|
KEYWORDS = "keywords"
|
6
6
|
PRODUCT_ADS = "productAds"
|
7
|
+
SPONSORED_PRODUCTS = "sp"
|
8
|
+
SPONSORED_BRANDS = "hsa"
|
7
9
|
|
8
10
|
def self.create(params = {}, opts = {})
|
9
11
|
# required argument checks
|
10
12
|
raise ArgumentError.new("params hash must contain a recordType") unless params["recordType"]
|
11
13
|
|
14
|
+
# If no metrics are passed in, use the default metrics
|
15
|
+
metrics = params["metrics"] || get_default_metrics(params["recordType"],params["campaignType"])
|
16
|
+
|
12
17
|
api_params = {
|
13
|
-
"campaignType" => "sponsoredProducts",
|
14
18
|
"reportDate" => params["reportDate"],
|
15
|
-
"metrics" =>
|
19
|
+
"metrics" => metrics
|
16
20
|
}
|
17
21
|
|
18
22
|
api_params["segment"] = params["segment"] if params["segment"]
|
19
23
|
|
20
|
-
post_request("/
|
24
|
+
post_request("/v2/#{params["campaignType"]}/#{params["recordType"]}/report", api_params)
|
21
25
|
end
|
22
26
|
|
23
27
|
def self.status(report_id, opts = {})
|
24
|
-
get_request("/
|
28
|
+
get_request("/v2/reports/#{report_id}")
|
25
29
|
end
|
26
30
|
|
27
31
|
def self.download(location, opts = {})
|
28
32
|
opts.merge!({:full_path => true, :gzip => true, :no_token => true})
|
29
33
|
get_request(location, opts)
|
30
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def self.get_default_metrics(record_type, campaign_type)
|
39
|
+
if campaign_type == SPONSORED_BRANDS
|
40
|
+
return [
|
41
|
+
"campaignName",
|
42
|
+
"campaignId",
|
43
|
+
"campaignStatus",
|
44
|
+
"campaignBudget",
|
45
|
+
"campaignBudgetType",
|
46
|
+
"impressions",
|
47
|
+
"clicks",
|
48
|
+
"cost",
|
49
|
+
"attributedSales14d",
|
50
|
+
"attributedSales14dSameSKU",
|
51
|
+
"attributedConversions14d",
|
52
|
+
"attributedConversions14dSameSKU"
|
53
|
+
].join(",") if record_type == CAMPAIGNS
|
54
|
+
return [
|
55
|
+
"adGroupId",
|
56
|
+
"adGroupName",
|
57
|
+
"campaignName",
|
58
|
+
"campaignId",
|
59
|
+
"campaignStatus",
|
60
|
+
"campaignBudget",
|
61
|
+
"campaignBudgetType",
|
62
|
+
"impressions",
|
63
|
+
"clicks",
|
64
|
+
"cost",
|
65
|
+
"attributedSales14d",
|
66
|
+
"attributedSales14dSameSKU",
|
67
|
+
"attributedConversions14d",
|
68
|
+
"attributedConversions14dSameSKU"
|
69
|
+
].join(",") if record_type == AD_GROUPS
|
70
|
+
return [
|
71
|
+
"keywordId",
|
72
|
+
"keywordStatus",
|
73
|
+
"keywordBid",
|
74
|
+
"keywordText",
|
75
|
+
"matchType",
|
76
|
+
"adGroupId",
|
77
|
+
"adGroupName",
|
78
|
+
"campaignName",
|
79
|
+
"campaignId",
|
80
|
+
"campaignStatus",
|
81
|
+
"campaignBudget",
|
82
|
+
"campaignBudgetType",
|
83
|
+
"impressions",
|
84
|
+
"clicks",
|
85
|
+
"cost",
|
86
|
+
"attributedSales14d",
|
87
|
+
"attributedSales14dSameSKU",
|
88
|
+
"attributedConversions14d",
|
89
|
+
"attributedConversions14dSameSKU"
|
90
|
+
].join(",") if record_type == KEYWORDS
|
91
|
+
elsif campaign_type == SPONSORED_PRODUCTS
|
92
|
+
return [
|
93
|
+
"bidPlus",
|
94
|
+
"campaignName",
|
95
|
+
"campaignId",
|
96
|
+
"campaignStatus",
|
97
|
+
"campaignBudget",
|
98
|
+
"impressions",
|
99
|
+
"clicks",
|
100
|
+
"cost",
|
101
|
+
"attributedConversions1d",
|
102
|
+
"attributedConversions7d",
|
103
|
+
"attributedConversions14d",
|
104
|
+
"attributedConversions30d",
|
105
|
+
"attributedConversions1dSameSKU",
|
106
|
+
"attributedConversions7dSameSKU",
|
107
|
+
"attributedConversions14dSameSKU",
|
108
|
+
"attributedConversions30dSameSKU",
|
109
|
+
"attributedUnitsOrdered1d",
|
110
|
+
"attributedUnitsOrdered7d",
|
111
|
+
"attributedUnitsOrdered14d",
|
112
|
+
"attributedUnitsOrdered30d",
|
113
|
+
"attributedSales1d",
|
114
|
+
"attributedSales7d",
|
115
|
+
"attributedSales14d",
|
116
|
+
"attributedSales30d",
|
117
|
+
"attributedSales1dSameSKU",
|
118
|
+
"attributedSales7dSameSKU",
|
119
|
+
"attributedSales14dSameSKU",
|
120
|
+
"attributedSales30dSameSKU"
|
121
|
+
].join(",") if record_type == CAMPAIGNS
|
122
|
+
return [
|
123
|
+
"campaignName",
|
124
|
+
"campaignId",
|
125
|
+
"adGroupName",
|
126
|
+
"adGroupId",
|
127
|
+
"impressions",
|
128
|
+
"clicks",
|
129
|
+
"cost",
|
130
|
+
"attributedConversions1d",
|
131
|
+
"attributedConversions7d",
|
132
|
+
"attributedConversions14d",
|
133
|
+
"attributedConversions30d",
|
134
|
+
"attributedConversions1dSameSKU",
|
135
|
+
"attributedConversions7dSameSKU",
|
136
|
+
"attributedConversions14dSameSKU",
|
137
|
+
"attributedConversions30dSameSKU",
|
138
|
+
"attributedUnitsOrdered1d",
|
139
|
+
"attributedUnitsOrdered7d",
|
140
|
+
"attributedUnitsOrdered14d",
|
141
|
+
"attributedUnitsOrdered30d",
|
142
|
+
"attributedSales1d",
|
143
|
+
"attributedSales7d",
|
144
|
+
"attributedSales14d",
|
145
|
+
"attributedSales30d",
|
146
|
+
"attributedSales1dSameSKU",
|
147
|
+
"attributedSales7dSameSKU",
|
148
|
+
"attributedSales14dSameSKU",
|
149
|
+
"attributedSales30dSameSKU"
|
150
|
+
].join(",") if record_type == AD_GROUPS
|
151
|
+
return [
|
152
|
+
"campaignName",
|
153
|
+
"campaignId",
|
154
|
+
"keywordId",
|
155
|
+
"keywordText",
|
156
|
+
"matchType",
|
157
|
+
"impressions",
|
158
|
+
"clicks",
|
159
|
+
"cost",
|
160
|
+
"attributedConversions1d",
|
161
|
+
"attributedConversions7d",
|
162
|
+
"attributedConversions14d",
|
163
|
+
"attributedConversions30d",
|
164
|
+
"attributedConversions1dSameSKU",
|
165
|
+
"attributedConversions7dSameSKU",
|
166
|
+
"attributedConversions14dSameSKU",
|
167
|
+
"attributedConversions30dSameSKU",
|
168
|
+
"attributedUnitsOrdered1d",
|
169
|
+
"attributedUnitsOrdered7d",
|
170
|
+
"attributedUnitsOrdered14d",
|
171
|
+
"attributedUnitsOrdered30d",
|
172
|
+
"attributedSales1d",
|
173
|
+
"attributedSales7d",
|
174
|
+
"attributedSales14d",
|
175
|
+
"attributedSales30d",
|
176
|
+
"attributedSales1dSameSKU",
|
177
|
+
"attributedSales7dSameSKU",
|
178
|
+
"attributedSales14dSameSKU",
|
179
|
+
"attributedSales30dSameSKU"
|
180
|
+
].join(",") if record_type == KEYWORDS
|
181
|
+
return [
|
182
|
+
"campaignName",
|
183
|
+
"campaignId",
|
184
|
+
"adGroupName",
|
185
|
+
"adGroupId",
|
186
|
+
"impressions",
|
187
|
+
"clicks",
|
188
|
+
"cost",
|
189
|
+
"currency",
|
190
|
+
"asin",
|
191
|
+
"sku",
|
192
|
+
"attributedConversions1d",
|
193
|
+
"attributedConversions7d",
|
194
|
+
"attributedConversions14d",
|
195
|
+
"attributedConversions30d",
|
196
|
+
"attributedConversions1dSameSKU",
|
197
|
+
"attributedConversions7dSameSKU",
|
198
|
+
"attributedConversions14dSameSKU",
|
199
|
+
"attributedConversions30dSameSKU",
|
200
|
+
"attributedUnitsOrdered1d",
|
201
|
+
"attributedUnitsOrdered7d",
|
202
|
+
"attributedUnitsOrdered14d",
|
203
|
+
"attributedUnitsOrdered30d",
|
204
|
+
"attributedSales1d",
|
205
|
+
"attributedSales7d",
|
206
|
+
"attributedSales14d",
|
207
|
+
"attributedSales30d",
|
208
|
+
"attributedSales1dSameSKU",
|
209
|
+
"attributedSales7dSameSKU",
|
210
|
+
"attributedSales14dSameSKU",
|
211
|
+
"attributedSales30dSameSKU"
|
212
|
+
].join(",") if record_type == PRODUCT_ADS
|
213
|
+
end
|
214
|
+
end
|
31
215
|
end
|
32
216
|
end
|
data/lib/blurb/snapshot.rb
CHANGED
@@ -11,14 +11,14 @@ module Blurb
|
|
11
11
|
# required argument checks
|
12
12
|
raise ArgumentError.new("params hash must contain a recordType") unless params["recordType"]
|
13
13
|
|
14
|
-
post_request("/
|
14
|
+
post_request("/v2/#{params["recordType"]}/snapshot", {
|
15
15
|
"campaignType" => "sponsoredProducts",
|
16
16
|
"stateFilter" => params["stateFilter"]
|
17
17
|
})
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.status(snapshot_id, opts = {})
|
21
|
-
get_request("/
|
21
|
+
get_request("/v2/snapshots/#{snapshot_id}")
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.download(location, opts = {})
|
@@ -4,21 +4,21 @@ module Blurb
|
|
4
4
|
# required argument checks
|
5
5
|
raise ArgumentError.new("params hash must contain an adGroupId") unless params["adGroupId"]
|
6
6
|
|
7
|
-
get_request("/
|
7
|
+
get_request("/v2/adGroups/#{params["adGroupId"]}/suggested/keywords?#{setup_url_params(params)}")
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.ad_group_extended_suggestions(params = {}, opts = {})
|
11
11
|
# required argument checks
|
12
12
|
raise ArgumentError.new("params hash must contain an adGroupId") unless params["adGroupId"]
|
13
13
|
|
14
|
-
get_request("/
|
14
|
+
get_request("/v2/adGroups/#{params["adGroupId"]}/suggested/keywords/extended?#{setup_url_params(params)}")
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.asin_suggestions(params = {}, opts = {})
|
18
18
|
# required argument checks
|
19
19
|
raise ArgumentError.new("params hash must contain an asinValue") unless params["asinValue"]
|
20
20
|
|
21
|
-
get_request("/
|
21
|
+
get_request("/v2/asins/#{params["asinValue"]}/suggested/keywords?#{setup_url_params(params)}")
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.bulk_asin_suggestions(params = {}, opts = {})
|
@@ -27,8 +27,8 @@ module Blurb
|
|
27
27
|
|
28
28
|
maxNumSuggestions = 100
|
29
29
|
maxNumSuggestions = params["maxNumSuggestions"] if params["maxNumSuggestions"]
|
30
|
-
|
31
|
-
post_request("/
|
30
|
+
|
31
|
+
post_request("/v2/asins/suggested/keywords", {
|
32
32
|
"asins" => params["asins"],
|
33
33
|
"maxNumSuggestions" => maxNumSuggestions
|
34
34
|
})
|
data/lib/blurb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blurb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dlbunker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|