trycourier 1.5.0 → 1.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9bd120c1a6bd12bf0960fae9661848fe6a6e41c2782baa6eb3ae166882c428b
4
- data.tar.gz: 4d2f6ba063c1dfb2270feaab7c0763c7aafb88920ea1f327d91bdc681abbc975
3
+ metadata.gz: b109ca392cd8dc7760b016a016c6014cdda3aa46e86443e23f89b302e14d547e
4
+ data.tar.gz: e4aaccf736dd71f8903bd477b10aacce0d2f341254004edcd023679797be7aed
5
5
  SHA512:
6
- metadata.gz: 56c1130d7caa6e4484ce56ff35dbce92518cd5559c32cf2895a18c45227bd81c49f27fb376e45d8c610eef5c49c2857265233028a5020bcf76a8f8a8630cb671
7
- data.tar.gz: 1680c9bf19b28f762ce9ec73c01c33f6ae7035a0a824f4a013f5d489471c54ef2dde450f85729aba4658ff7b8db129f6e898b1bc77bd3cce8e3e867c5a03807f
6
+ metadata.gz: ac34939a4b50cb50b6df3650934fc8143b440add045aaf046ffb8044ce9ab3e867d322e06bcb1b1d7b5004470068c7efd4430e2e7cb732a2b2f6f917eaecbc12
7
+ data.tar.gz: 6b9dbd28970b57e097cc6d26f6d2eaa07c3fbc1b2160737ae3dbd2bc2aff70e2e547ad2c37744eba76e44bad54d01bfc2b3dcb09eedd5972034c45371a21cbec
data/CHANGELOG.md CHANGED
@@ -5,7 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased][unreleased]
7
7
 
8
+ ## [v1.7.0] - 2023-06-22
9
+
10
+ - Support for cancel message API
11
+
12
+ ## [v1.6.0] - 2022-07-25
13
+
14
+ - Support for audit events API
15
+
8
16
  ## [v1.5.0] - 2022-03-28
17
+
9
18
  - Support for audiences API
10
19
 
11
20
  ## [v1.4.0] - 2022-01-31
@@ -94,7 +103,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
94
103
 
95
104
  Initial release by @troygoode
96
105
 
97
- [unreleased]: https://github.com/trycourier/courier-ruby/compare/v1.5.0...HEAD
106
+ [unreleased]: https://github.com/trycourier/courier-ruby/compare/v1.6.0...HEAD
107
+ [v1.6.0]: https://github.com/trycourier/courier-ruby/compare/v1.5.0...v1.6.0
98
108
  [v1.5.0]: https://github.com/trycourier/courier-ruby/compare/v1.4.0...v1.5.0
99
109
  [v1.4.0]: https://github.com/trycourier/courier-ruby/compare/v1.3.0...v1.4.0
100
110
  [v1.3.0]: https://github.com/trycourier/courier-ruby/compare/v1.2.0...v1.3.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trycourier (1.5.0)
4
+ trycourier (1.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -107,6 +107,7 @@ res = client.send_message({
107
107
  "utm" => {
108
108
  "source" => "Ruby"
109
109
  },
110
+ "tags" => ["tag-1", "tag-2"],
110
111
  "trace_id" => "feed-me-hungry"
111
112
  }
112
113
  }
@@ -118,6 +119,75 @@ rescue Courier::CourierAPIError => re #error sent from from the API
118
119
  end
119
120
  ```
120
121
 
122
+ ### Sending a message to an individual with granular metadata
123
+
124
+ ```ruby
125
+ client = Courier::Client.new "your-auth-token" # or set via COURIER_AUTH_TOKEN env var
126
+ res = client.send_message({
127
+ "message" => {
128
+ "to" => {
129
+ "email" => "foo@bar.com"
130
+ },
131
+ "content" => {
132
+ "version" => "2020-01-01",
133
+ "elements" => [
134
+ {
135
+ "type" => "text",
136
+ "content" => "Thanks for signing up, {{name}}"
137
+ },
138
+ {
139
+ "type" => "action",
140
+ "content" => "Click Me!",
141
+ "href" => "https://www.example.com"
142
+ }
143
+ ]
144
+ },
145
+ "routing" => {
146
+ "method" => "all",
147
+ "channels" => [
148
+ "email"
149
+ ]
150
+ },
151
+ "data" => {
152
+ "name" => "Ruby"
153
+ },
154
+ "metadata" => {
155
+ "utm" => {
156
+ "source" => "Ruby"
157
+ },
158
+ },
159
+ "channels" => {
160
+ "email" => {
161
+ "routing_method" => "all",
162
+ "providers" => [
163
+ "sendgrid",
164
+ "mailjet"
165
+ ],
166
+ "metadata" => {
167
+ "utm" => {
168
+ "medium" => "email"
169
+ }
170
+ }
171
+ }
172
+ },
173
+ "providers" => {
174
+ "sendgrid" => {
175
+ "metadata" => {
176
+ "utm" => {
177
+ "source" => "sendgrid"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ })
184
+ puts res.code # the HTTP response code
185
+ puts res.request_id # if the code is 202, this will be the Courier request ID for this message
186
+ rescue Courier::CourierAPIError => re #error sent from from the API
187
+ puts re.message
188
+ end
189
+ ```
190
+
121
191
  ## Advanced Usage
122
192
 
123
193
  ### Lists
@@ -507,6 +577,20 @@ rescue Courier::CourierAPIError => re #error sent from from the API
507
577
  end
508
578
  ```
509
579
 
580
+ ### Audit Events
581
+
582
+ ```Ruby
583
+ """
584
+ Example: List audit events
585
+ """
586
+ resp = client.audit_events.list()
587
+
588
+ """
589
+ Example: Get a specific audit event
590
+ """
591
+ resp = client.audit_events.get(audit_event_id: "audit-event-id")
592
+ ```
593
+
510
594
  ## Development
511
595
 
512
596
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,27 @@
1
+ module Courier
2
+ class AuditEvents
3
+ KEY = "/audit-events"
4
+
5
+ def initialize(session)
6
+ @session = session
7
+ end
8
+
9
+ def get(audit_event_id:)
10
+ path = "#{KEY}/#{audit_event_id}"
11
+ res = @session.send(path, "GET")
12
+ ErrorHandler.check_err(res)
13
+ end
14
+
15
+ def list(cursor: nil)
16
+ path = "#{KEY}"
17
+
18
+ params = {}
19
+ if cursor
20
+ params["cursor"] = cursor
21
+ end
22
+
23
+ res = @session.send(path, "GET", params: params)
24
+ ErrorHandler.check_err(res)
25
+ end
26
+ end
27
+ end
@@ -38,6 +38,12 @@ module Courier
38
38
  ErrorHandler.check_err(res)
39
39
  end
40
40
 
41
+ def cancel(message_id:)
42
+ path = "#{KEY}/#{message_id}/cancel"
43
+ res = @session.send(path, "POST")
44
+ ErrorHandler.check_err(res)
45
+ end
46
+
41
47
  def get_history(message_id:, type: nil)
42
48
  path = "#{KEY}/#{message_id}/history"
43
49
  params = {}
@@ -1,3 +1,3 @@
1
1
  module Courier
2
- VERSION = "1.5.0"
2
+ VERSION = "1.7.0"
3
3
  end
data/lib/trycourier.rb CHANGED
@@ -7,6 +7,7 @@ require "trycourier/messages"
7
7
  require "trycourier/automations"
8
8
  require "trycourier/bulk"
9
9
  require "trycourier/audiences"
10
+ require "trycourier/audit_events"
10
11
  require "trycourier/version"
11
12
  require "trycourier/exceptions"
12
13
 
@@ -65,6 +66,7 @@ module Courier
65
66
  @automations = Courier::Automations.new(@session)
66
67
  @bulk = Courier::Bulk.new(@session)
67
68
  @audiences = Courier::Audiences.new(@session)
69
+ @audit_events = Courier::AuditEvents.new(@session)
68
70
  end
69
71
 
70
72
  def send(body)
@@ -135,6 +137,7 @@ module Courier
135
137
 
136
138
  attr_reader :audiences
137
139
 
140
+ attr_reader :audit_events
138
141
 
139
142
  end
140
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trycourier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -62,6 +62,7 @@ files:
62
62
  - bin/setup
63
63
  - lib/trycourier.rb
64
64
  - lib/trycourier/audiences.rb
65
+ - lib/trycourier/audit_events.rb
65
66
  - lib/trycourier/automations.rb
66
67
  - lib/trycourier/brands.rb
67
68
  - lib/trycourier/bulk.rb