sg 0.1.1 → 0.1.2
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/lib/sg/version.rb +1 -1
- data/lib/sg.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eaa89c4c56a1cf5469e661cde10f289b64a20aaf
|
|
4
|
+
data.tar.gz: 9839ff7cb03669aca8446aef3735fcd4525a05af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6652d239bc497fbb8afc74bb02bed0cd40f11ed3bc29860c4a3ea27289046f24fec43a8e96e202e989735c0c871e9d1267b924147eddbc300088889053acc209
|
|
7
|
+
data.tar.gz: 6ebfffb783ca2c35ba9ca1136c4174b9fc41aba0a35a23184f37081db9794ae1ff77869db11432a21e9eff7f978574b2d90f10a4b90e1f80aec4094d77a594a7
|
data/lib/sg/version.rb
CHANGED
data/lib/sg.rb
CHANGED
|
@@ -51,13 +51,22 @@ module Sg
|
|
|
51
51
|
api_key ||= ENV['SENDGRID_API_KEY']
|
|
52
52
|
sg = SendGrid::API.new(api_key: api_key)
|
|
53
53
|
idx = 0
|
|
54
|
+
params = CLI.parameterise(options)
|
|
54
55
|
response = args.inject(sg.client) do |c, arg|
|
|
55
56
|
idx += 1
|
|
56
|
-
(args.length == idx
|
|
57
|
+
(args.length == idx) ? c.send(arg, params) : c.send(arg)
|
|
57
58
|
end
|
|
58
59
|
puts response.status_code if options[:response_status]
|
|
59
60
|
puts response.headers if options[:response_header]
|
|
60
61
|
puts response.body
|
|
61
62
|
end
|
|
63
|
+
|
|
64
|
+
def self.parameterise(options)
|
|
65
|
+
options.each_with_object({}) do |(k, v), memo|
|
|
66
|
+
if k.to_s == 'request_body' || k.to_s == 'query_params'
|
|
67
|
+
memo[k.to_s.to_sym] = JSON.parse(v) unless v.nil?
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
62
71
|
end
|
|
63
72
|
end
|