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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a81f06527bbaa32aede8f4f6d842aaa8b9acbd74abd2602e6c040fd9119b4725
4
- data.tar.gz: 27558e7dae46e19ee01645fc2b5ea19ac55f7c616e964b8b47482331e7b58b41
3
+ metadata.gz: 669e05b5dc6b0c14fb71f93de5d7a0b779c22e133a24b760d8d6547d4050c67e
4
+ data.tar.gz: 2101c431694c2294c17ac660d1d18e11e6d1848262a18e44e2f6fa9fe232b04a
5
5
  SHA512:
6
- metadata.gz: 5241d1a2aae458d0057a5a8cbbba97adb6f3a885d18521d33c833ae636fe7364318802e3f02d4ebeaeefe2cb60eff3569a8bc3bbe18883fbd0e0008e5740a8c8
7
- data.tar.gz: 50b13d78e0efab9c6862454afd2e9e1c7052157e5b2ec9e9329d56bf20e6d4adcd847f217bfea2f75017e14c757389760e61bb4584dd5cef8eb95e650ccb4c07
6
+ metadata.gz: fbfb8710e76e917a67358f44053a3918e0a907ba5dc8ef741a4fc8216c3e95e0f3a6c68043165d396b37c3bec2166748d601f2f96554504bffed53849751feaa
7
+ data.tar.gz: 17b92a47dce657e57a33bde1bd952e1b4ecd9e6f6cda62bce5a1915819ceea3ffc8fedebdba942392daeb317ff923d175aa6104f46489e3f00a857456a025e11
@@ -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.6"
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}
@@ -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
@@ -60,29 +60,45 @@ class Blurb
60
60
 
61
61
  def convert_payload(payload)
62
62
  return if payload.nil?
63
- payload = payload.map{|r| camelcase_keys(r)} if payload.class == Array
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 = resp.map{|r| underscore_keys(r)} if resp.class == Array
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(hash)
77
- map = hash.map do |key,value|
78
- value = value.strftime('%Y%m%d') if [Date, Time, ActiveSupport::TimeWithZone].include?(value.class)
79
- [key.to_s.camelize(:lower), value]
80
- end
81
- map.to_h
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 underscore_keys(hash)
85
- hash.map{|k,v| [k.underscore.to_sym, v]}.to_h
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.6
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-11-21 00:00:00.000000000 Z
13
+ date: 2019-12-09 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: bundler