blurb 0.5.1 → 0.5.9
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 +19 -2
- 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: 189f95ae42271c0eb40c991c4f767cb4208b46ce7c96afd95264e1e42aca6fe8
|
4
|
+
data.tar.gz: 61364e5de152694f60f68ada4a368c46122155c5f3956d9bf682193b6c99ebf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd65504f6683e3fb7080300f78f947072d6124d7a9ae4f2e560d587aaa9d28751704add4e7da5424fff3c56c5e2d4311b69a7d152ae3296a49645bec59617a3f
|
7
|
+
data.tar.gz: a7eadcaa4c2843d7dba312a6846bc4285b1d5b44a766c321c4825a23e322b1ab72666c666193bd6cd6a5795fdbca209798c0e483bc643dc056c935fb77fc3d1a
|
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
|
@@ -46,7 +50,11 @@ class Blurb
|
|
46
50
|
raise err
|
47
51
|
end
|
48
52
|
rescue RestClient::ExceptionWithResponse => err
|
49
|
-
|
53
|
+
if err.response.present?
|
54
|
+
raise FailedRequest.new(JSON.parse(err.response.body))
|
55
|
+
else
|
56
|
+
raise err
|
57
|
+
end
|
50
58
|
end
|
51
59
|
resp = convert_response(resp)
|
52
60
|
return resp
|
@@ -102,5 +110,14 @@ class Blurb
|
|
102
110
|
k.to_s.underscore.to_sym
|
103
111
|
end
|
104
112
|
|
113
|
+
def log(header, message)
|
114
|
+
if ENV["BLURB_LOGGING"]
|
115
|
+
puts "\n"
|
116
|
+
puts header.upcase
|
117
|
+
puts message
|
118
|
+
puts "\n"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
105
122
|
end
|
106
123
|
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.9
|
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-03-04 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
|