blurb 0.5.1 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/blurb.gemspec +1 -1
- data/lib/blurb/account.rb +5 -4
- data/lib/blurb/errors/base_exception.rb +3 -0
- data/lib/blurb/errors/failed_request.rb +1 -0
- data/lib/blurb/errors/invalid_report_request.rb +1 -0
- data/lib/blurb/errors/request_throttled.rb +1 -0
- data/lib/blurb/report_requests.rb +12 -3
- data/lib/blurb/request.rb +14 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bbe7e13044fb8056d3f7a82b7ec546c737dccbb5d793012afc19915f27c1df8
|
4
|
+
data.tar.gz: 7f33345f4038f08a44ec11942f733b6200eae8d611bb44f660f51c48ed9afae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf5ab7852856e0748283f2bbd3ff966a4456800538517e6fdf99ccf0c8b6471f46cf72d113ecb3995197623923007c5cb489e538f72323fb24c8d675e88f6e9a
|
7
|
+
data.tar.gz: e4699d01634644264c2046ff4c9c109955abea9a9b5f7ce2bea97b151ed87e028f568b232c15d7bccc5ac56342969368ee8fda42a253aba3b99613453a79bbd6
|
data/blurb.gemspec
CHANGED
data/lib/blurb/account.rb
CHANGED
@@ -98,10 +98,11 @@ class Blurb
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def authorization_client
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
:
|
101
|
+
OAuth2::Client.new(
|
102
|
+
'',
|
103
|
+
'',
|
104
|
+
site: 'https://api.amazon.com',
|
105
|
+
ssl: { version: :TLSv1 }
|
105
106
|
)
|
106
107
|
end
|
107
108
|
end
|
@@ -17,7 +17,7 @@ class Blurb
|
|
17
17
|
segment: nil
|
18
18
|
)
|
19
19
|
# create payload
|
20
|
-
metrics = get_default_metrics(record_type.to_s.underscore.to_sym) if metrics.nil?
|
20
|
+
metrics = get_default_metrics(record_type.to_s.underscore.to_sym, segment) if metrics.nil?
|
21
21
|
payload = {
|
22
22
|
metrics: metrics.map{ |m| m.to_s.camelize(:lower) }.join(","),
|
23
23
|
report_date: report_date
|
@@ -48,7 +48,7 @@ class Blurb
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
-
def get_default_metrics(record_type)
|
51
|
+
def get_default_metrics(record_type, segment = nil)
|
52
52
|
if @campaign_type == CAMPAIGN_TYPE_CODES[:sb]
|
53
53
|
return [
|
54
54
|
"campaignId",
|
@@ -82,7 +82,16 @@ class Blurb
|
|
82
82
|
"attributedSales14dSameSKU",
|
83
83
|
"attributedConversions14d",
|
84
84
|
"attributedConversions14dSameSKU"
|
85
|
-
] if record_type == :keywords
|
85
|
+
] if record_type == :keywords && segment.nil?
|
86
|
+
return [
|
87
|
+
"adGroupId",
|
88
|
+
"campaignId",
|
89
|
+
"impressions",
|
90
|
+
"clicks",
|
91
|
+
"cost",
|
92
|
+
"attributedSales14d",
|
93
|
+
"attributedConversions14d",
|
94
|
+
] if record_type == :keywords && segment.present?
|
86
95
|
elsif @campaign_type == CAMPAIGN_TYPE_CODES[:sp]
|
87
96
|
return [
|
88
97
|
"campaignId",
|
data/lib/blurb/request.rb
CHANGED
@@ -28,13 +28,17 @@ class Blurb
|
|
28
28
|
when :post, :put
|
29
29
|
request_config[:payload] = @payload if @payload
|
30
30
|
end
|
31
|
-
|
31
|
+
log("request type", @request_type)
|
32
|
+
log("request url", @url)
|
33
|
+
log("headers", @headers)
|
34
|
+
log("payload", @payload) if @payload
|
32
35
|
return request_config
|
33
36
|
end
|
34
37
|
|
35
38
|
def make_request
|
36
39
|
begin
|
37
40
|
resp = RestClient::Request.execute(request_config())
|
41
|
+
log("response", resp)
|
38
42
|
rescue RestClient::TooManyRequests => err
|
39
43
|
raise RequestThrottled.new(JSON.parse(err.response.body))
|
40
44
|
rescue RestClient::TemporaryRedirect => err
|
@@ -102,5 +106,14 @@ class Blurb
|
|
102
106
|
k.to_s.underscore.to_sym
|
103
107
|
end
|
104
108
|
|
109
|
+
def log(header, message)
|
110
|
+
if ENV["BLURB_LOGGING"]
|
111
|
+
puts "\n"
|
112
|
+
puts header.upcase
|
113
|
+
puts message
|
114
|
+
puts "\n"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
105
118
|
end
|
106
119
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blurb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dlbunker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/blurb/base_class.rb
|
178
178
|
- lib/blurb/campaign_requests.rb
|
179
179
|
- lib/blurb/client.rb
|
180
|
+
- lib/blurb/errors/base_exception.rb
|
180
181
|
- lib/blurb/errors/failed_request.rb
|
181
182
|
- lib/blurb/errors/invalid_report_request.rb
|
182
183
|
- lib/blurb/errors/request_throttled.rb
|
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
208
|
- !ruby/object:Gem::Version
|
208
209
|
version: '0'
|
209
210
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.1.4
|
211
212
|
signing_key:
|
212
213
|
specification_version: 4
|
213
214
|
summary: Ruby gem for the Amazon Advertising API
|