trycourier 1.0.0 → 1.0.1
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/README.md +9 -3
- data/lib/trycourier.rb +7 -3
- data/lib/trycourier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b256b56c28effeb0a31e46d1d4d38626527e9bd2e740f4395137624fd46a9b0
|
4
|
+
data.tar.gz: 1933d201eef9368b794166b48cf5723b5f3f442ef6e6ca0b61c5a2efd0a979ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78837d22fe0c63fad281ed61c676aa1d8af8a8685a3a3af35ac2b587ee3e772d0f9e16eae763be6e030aee1caa39f7065dddcbb74123c7b32a56fbd1038327a
|
7
|
+
data.tar.gz: e0499506e39f2a6e33178f7de0dc43b184dc7b05ced7d88a04d4f0af7f4d67dba5a8844a9f971293c92e661f80ded499bb20e3c4172ddda8b93fff625ba4ea46
|
data/README.md
CHANGED
@@ -24,10 +24,16 @@ Or install it yourself as:
|
|
24
24
|
require "trycourier"
|
25
25
|
|
26
26
|
begin
|
27
|
-
client = Courier::Client.new
|
27
|
+
client = Courier::Client.new "your-auth-token" # or set via COURIER_AUTH_TOKEN env var
|
28
28
|
res = client.send({
|
29
|
-
"event" =>
|
30
|
-
"recipient" =>
|
29
|
+
"event" => "your-event-id",
|
30
|
+
"recipient" => "your-recipient-id",
|
31
|
+
|
32
|
+
"profile" => {
|
33
|
+
"email": "example@example.com",
|
34
|
+
"phone_number": "555-867-5309"
|
35
|
+
},
|
36
|
+
|
31
37
|
"data" => {
|
32
38
|
"world" => "Ruby!"
|
33
39
|
}
|
data/lib/trycourier.rb
CHANGED
@@ -18,9 +18,12 @@ module Courier
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Client
|
21
|
-
def initialize(
|
22
|
-
@
|
21
|
+
def initialize(auth_token = nil)
|
22
|
+
@auth_token = auth_token || ENV['COURIER_AUTH_TOKEN']
|
23
23
|
@uri = URI.parse('https://api.trycourier.app/send')
|
24
|
+
if @auth_token == nil or @auth_token == ""
|
25
|
+
raise InputError, "Client requires an auth_token be supplied."
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
def send(body)
|
@@ -41,8 +44,9 @@ module Courier
|
|
41
44
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
42
45
|
|
43
46
|
req = Net::HTTP::Post.new(@uri)
|
44
|
-
req["authorization"] = "Bearer #{@
|
47
|
+
req["authorization"] = "Bearer #{@auth_token}"
|
45
48
|
req["content-type"] = "application/json"
|
49
|
+
req["User-Agent"] = "courier-ruby/#{Courier::VERSION}"
|
46
50
|
req.body = body.to_json
|
47
51
|
|
48
52
|
res = http.request(req)
|
data/lib/trycourier/version.rb
CHANGED