blurb 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/blurb.gemspec +2 -2
- data/lib/blurb/profile.rb +16 -0
- data/lib/blurb/request.rb +29 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669e05b5dc6b0c14fb71f93de5d7a0b779c22e133a24b760d8d6547d4050c67e
|
4
|
+
data.tar.gz: 2101c431694c2294c17ac660d1d18e11e6d1848262a18e44e2f6fa9fe232b04a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfb8710e76e917a67358f44053a3918e0a907ba5dc8ef741a4fc8216c3e95e0f3a6c68043165d396b37c3bec2166748d601f2f96554504bffed53849751feaa
|
7
|
+
data.tar.gz: 17b92a47dce657e57a33bde1bd952e1b4ecd9e6f6cda62bce5a1915819ceea3ffc8fedebdba942392daeb317ff923d175aa6104f46489e3f00a857456a025e11
|
data/blurb.gemspec
CHANGED
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "blurb"
|
7
|
-
spec.version = "0.4.
|
8
|
-
spec.authors = ["dlbunker", "eamigo13"]
|
7
|
+
spec.version = "0.4.7"
|
8
|
+
spec.authors = ["dlbunker", "eamigo13", "smithworx"]
|
9
9
|
spec.email = ["evan@pattern.com"]
|
10
10
|
|
11
11
|
spec.summary = %q{Ruby gem for the Amazon Advertising API}
|
data/lib/blurb/profile.rb
CHANGED
@@ -131,6 +131,22 @@ class Blurb
|
|
131
131
|
return @sb_reports if campaign_type == :sb || campaign_type == :hsa
|
132
132
|
end
|
133
133
|
|
134
|
+
def request(api_path: "",request_type: :get, payload: nil, url_params: nil, headers: headers_hash)
|
135
|
+
@base_url = @account.api_url
|
136
|
+
|
137
|
+
url = "#{@base_url}#{api_path}"
|
138
|
+
|
139
|
+
request = Request.new(
|
140
|
+
url: url,
|
141
|
+
url_params: url_params,
|
142
|
+
request_type: request_type,
|
143
|
+
payload: payload,
|
144
|
+
headers: headers
|
145
|
+
)
|
146
|
+
|
147
|
+
request.make_request
|
148
|
+
end
|
149
|
+
|
134
150
|
def profile_details
|
135
151
|
@account.retrieve_profile(@profile_id)
|
136
152
|
end
|
data/lib/blurb/request.rb
CHANGED
@@ -60,29 +60,45 @@ class Blurb
|
|
60
60
|
|
61
61
|
def convert_payload(payload)
|
62
62
|
return if payload.nil?
|
63
|
-
payload =
|
64
|
-
payload = camelcase_keys(payload) if payload.class == Hash
|
63
|
+
payload = camelcase_keys(payload)
|
65
64
|
return payload.to_json
|
66
65
|
end
|
67
66
|
|
68
67
|
def convert_response(resp)
|
69
68
|
resp = JSON.parse(resp)
|
70
|
-
resp =
|
71
|
-
resp = underscore_keys(resp) if resp.class == Hash
|
72
|
-
#TODO convert to symbols recursively
|
69
|
+
resp = underscore_keys(resp)
|
73
70
|
return resp
|
74
71
|
end
|
75
72
|
|
76
|
-
def camelcase_keys(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
def camelcase_keys(value)
|
74
|
+
case value
|
75
|
+
when Array
|
76
|
+
value.map { |v| camelcase_keys(v) }
|
77
|
+
when Hash
|
78
|
+
Hash[value.map { |k, v| [camelcase_key(k), camelcase_keys(v)] }]
|
79
|
+
else
|
80
|
+
value = value.strftime('%Y%m%d') if [Date, Time, ActiveSupport::TimeWithZone].include?(value.class)
|
81
|
+
value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def camelcase_key(k)
|
86
|
+
k.to_s.camelize(:lower)
|
87
|
+
end
|
88
|
+
|
89
|
+
def underscore_keys(value)
|
90
|
+
case value
|
91
|
+
when Array
|
92
|
+
value.map { |v| underscore_keys(v) }
|
93
|
+
when Hash
|
94
|
+
Hash[value.map { |k, v| [underscore_key(k), underscore_keys(v)] }]
|
95
|
+
else
|
96
|
+
value
|
97
|
+
end
|
82
98
|
end
|
83
99
|
|
84
|
-
def
|
85
|
-
|
100
|
+
def underscore_key(k)
|
101
|
+
k.to_s.underscore.to_sym
|
86
102
|
end
|
87
103
|
|
88
104
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blurb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dlbunker
|
8
8
|
- eamigo13
|
9
|
+
- smithworx
|
9
10
|
autorequire:
|
10
11
|
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date: 2019-
|
13
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: bundler
|