unsent 1.0.2 → 1.0.3
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 +49 -3
- data/lib/unsent/activity.rb +23 -0
- data/lib/unsent/client.rb +8 -3
- data/lib/unsent/domains.rb +34 -0
- data/lib/unsent/emails.rb +15 -0
- data/lib/unsent/events.rb +27 -0
- data/lib/unsent/metrics.rb +23 -0
- data/lib/unsent/stats.rb +23 -0
- data/lib/unsent/system.rb +21 -0
- data/lib/unsent/teams.rb +22 -0
- data/lib/unsent/types.rb +10708 -41
- data/lib/unsent/version.rb +1 -1
- data/lib/unsent/webhooks.rb +14 -0
- data/lib/unsent.rb +6 -0
- metadata +7 -30
- data/lib/unsent/models/add_suppression_request.rb +0 -223
- data/lib/unsent/models/create_api_key_request.rb +0 -218
- data/lib/unsent/models/create_campaign200_response.rb +0 -750
- data/lib/unsent/models/create_campaign_request.rb +0 -426
- data/lib/unsent/models/create_campaign_request_reply_to.rb +0 -103
- data/lib/unsent/models/create_contact200_response.rb +0 -147
- data/lib/unsent/models/create_contact_book200_response.rb +0 -304
- data/lib/unsent/models/create_contact_book_request.rb +0 -193
- data/lib/unsent/models/create_contact_request.rb +0 -202
- data/lib/unsent/models/create_domain_request.rb +0 -190
- data/lib/unsent/models/create_template200_response.rb +0 -164
- data/lib/unsent/models/create_template_request.rb +0 -226
- data/lib/unsent/models/delete_contact_book200_response.rb +0 -164
- data/lib/unsent/models/get_api_keys200_response_inner.rb +0 -278
- data/lib/unsent/models/get_campaigns200_response_inner.rb +0 -296
- data/lib/unsent/models/get_contact_book200_response.rb +0 -330
- data/lib/unsent/models/get_contact_book200_response_details.rb +0 -218
- data/lib/unsent/models/get_domains200_response_inner.rb +0 -482
- data/lib/unsent/models/get_domains200_response_inner_dns_records_inner.rb +0 -318
- data/lib/unsent/models/get_health200_response.rb +0 -216
- data/lib/unsent/models/get_templates200_response_inner.rb +0 -314
- data/lib/unsent/models/list_emails_domain_id_parameter.rb +0 -103
- data/lib/unsent/models/schedule_campaign_request.rb +0 -185
- data/lib/unsent/models/send_email_request.rb +0 -378
- data/lib/unsent/models/send_email_request_to.rb +0 -103
- data/lib/unsent/models/update_contact_book200_response.rb +0 -190
- data/lib/unsent/models/update_contact_book_request.rb +0 -167
- data/lib/unsent/models/update_contact_request.rb +0 -176
- data/lib/unsent/models/update_template_request.rb +0 -174
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42d9faa896c32041c471383db9a85085ca126b1dce7025b871e649c43225cb84
|
|
4
|
+
data.tar.gz: 3c664ba5678b2c025c3abd501be29fc42301ad658af48b8fc5d3224b498c815c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0135b319de54f560145a9158f006034125a3d3e336107ec3b15eaa0dd58a98cbf1ecb4c7528638703e2f0d52f484fe1ef0c66255e7f9b8236b8c7fe9ef831af
|
|
7
|
+
data.tar.gz: 1d5eff7f34e8a259eaac976cc017f7578f59d29c90fcd23a3d0c14c8b4f806d8e9a24a379f0ec14281d4f4899d175917a215d92c0590752f7aac8c4a7a43ed0f
|
data/README.md
CHANGED
|
@@ -307,13 +307,59 @@ data, error = client.emails.get_bounces(page: 1, limit: 10)
|
|
|
307
307
|
|
|
308
308
|
# Get unsubscribes
|
|
309
309
|
data, error = client.emails.get_unsubscribes(page: 1, limit: 10)
|
|
310
|
+
|
|
311
|
+
# Get events for a specific email
|
|
312
|
+
events, error = client.emails.get_events('email_123', page: 1, limit: 10)
|
|
313
|
+
if events
|
|
314
|
+
events['data'].each do |event|
|
|
315
|
+
puts "Event: #{event['type']} at #{event['timestamp']}"
|
|
316
|
+
end
|
|
317
|
+
end
|
|
310
318
|
```
|
|
311
319
|
|
|
312
|
-
##
|
|
320
|
+
## Domains
|
|
321
|
+
|
|
322
|
+
Manage your sending domains and retrieve domain-specific analytics.
|
|
323
|
+
|
|
324
|
+
### Domain Analytics & Statistics
|
|
313
325
|
|
|
314
|
-
|
|
326
|
+
```ruby
|
|
327
|
+
# Get analytics for a specific domain
|
|
328
|
+
data, error = client.domains.get_analytics('domain_123', days: 30)
|
|
329
|
+
puts "Total sent: #{data['sent']}, Delivered: #{data['delivered']}" if data
|
|
330
|
+
|
|
331
|
+
# Get analytics with custom date range
|
|
332
|
+
data, error = client.domains.get_analytics(
|
|
333
|
+
'domain_123',
|
|
334
|
+
startDate: '2024-01-01',
|
|
335
|
+
endDate: '2024-01-31'
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
# Get domain statistics
|
|
339
|
+
stats, error = client.domains.get_stats('domain_123', days: 7)
|
|
340
|
+
puts "Bounce rate: #{stats['bounceRate']}%" if stats
|
|
341
|
+
|
|
342
|
+
# Get stats with custom date range
|
|
343
|
+
stats, error = client.domains.get_stats(
|
|
344
|
+
'domain_123',
|
|
345
|
+
startDate: '2024-01-01',
|
|
346
|
+
endDate: '2024-01-15'
|
|
347
|
+
)
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Domain Management
|
|
351
|
+
|
|
352
|
+
#### List Domains
|
|
353
|
+
|
|
354
|
+
```ruby
|
|
355
|
+
domains, error = client.domains.list
|
|
356
|
+
domains.each do |domain|
|
|
357
|
+
puts "Domain: #{domain['domain']}, Status: #{domain['status']}"
|
|
358
|
+
end if domains
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Create Domain
|
|
315
362
|
|
|
316
|
-
### Create Contact Book
|
|
317
363
|
|
|
318
364
|
```ruby
|
|
319
365
|
data, error = client.contact_books.create(
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class Activity
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Retrieve activity feed with email events and email details
|
|
10
|
+
# @param query [Hash] Query parameters
|
|
11
|
+
# @option query [Integer] :page Page number (default: 1)
|
|
12
|
+
# @option query [Integer] :limit Number of items per page (default: 50, max: 100)
|
|
13
|
+
# @return [Array] Response data and error
|
|
14
|
+
def get(query = {})
|
|
15
|
+
params = []
|
|
16
|
+
params << "page=#{query[:page]}" if query[:page]
|
|
17
|
+
params << "limit=#{query[:limit]}" if query[:limit]
|
|
18
|
+
|
|
19
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
20
|
+
@client.get("/activity#{query_string}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/unsent/client.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Unsent
|
|
|
9
9
|
DEFAULT_BASE_URL = "https://api.unsent.dev"
|
|
10
10
|
|
|
11
11
|
attr_reader :key, :url, :raise_on_error
|
|
12
|
-
attr_accessor :emails, :contacts, :campaigns, :domains, :analytics, :api_keys, :contact_books, :settings, :suppressions, :templates, :webhooks
|
|
12
|
+
attr_accessor :system, :emails, :contacts, :campaigns, :domains, :analytics, :api_keys, :contact_books, :settings, :suppressions, :templates, :webhooks, :events, :metrics, :stats, :activity, :teams
|
|
13
13
|
|
|
14
14
|
def initialize(key = nil, url: nil, raise_on_error: true)
|
|
15
15
|
@key = key || ENV["UNSENT_API_KEY"] || ENV["UNSENT_API_KEY"]
|
|
@@ -20,6 +20,7 @@ module Unsent
|
|
|
20
20
|
@raise_on_error = raise_on_error
|
|
21
21
|
|
|
22
22
|
# Initialize resource clients
|
|
23
|
+
@system = System.new(self)
|
|
23
24
|
@emails = Emails.new(self)
|
|
24
25
|
@contacts = Contacts.new(self)
|
|
25
26
|
@campaigns = Campaigns.new(self)
|
|
@@ -31,6 +32,11 @@ module Unsent
|
|
|
31
32
|
@suppressions = Suppressions.new(self)
|
|
32
33
|
@templates = Templates.new(self)
|
|
33
34
|
@webhooks = Webhooks.new(self)
|
|
35
|
+
@events = Events.new(self)
|
|
36
|
+
@metrics = Metrics.new(self)
|
|
37
|
+
@stats = Stats.new(self)
|
|
38
|
+
@activity = Activity.new(self)
|
|
39
|
+
@teams = Teams.new(self)
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
def request(method, path, body = nil, headers = {})
|
|
@@ -72,8 +78,7 @@ module Unsent
|
|
|
72
78
|
end
|
|
73
79
|
|
|
74
80
|
begin
|
|
75
|
-
|
|
76
|
-
[data, nil]
|
|
81
|
+
JSON.parse(response.body)
|
|
77
82
|
rescue JSON::ParserError
|
|
78
83
|
[nil, default_error]
|
|
79
84
|
end
|
data/lib/unsent/domains.rb
CHANGED
|
@@ -25,5 +25,39 @@ module Unsent
|
|
|
25
25
|
def delete(domain_id)
|
|
26
26
|
@client.delete("/domains/#{domain_id}")
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
# Get analytics for a specific domain
|
|
30
|
+
# @param domain_id [String] The domain ID
|
|
31
|
+
# @param query [Hash] Query parameters
|
|
32
|
+
# @option query [Integer] :days Number of days to retrieve (optional)
|
|
33
|
+
# @option query [String] :startDate Start date for analytics (ISO 8601)
|
|
34
|
+
# @option query [String] :endDate End date for analytics (ISO 8601)
|
|
35
|
+
# @return [Array] Response data and error
|
|
36
|
+
def get_analytics(domain_id, query = {})
|
|
37
|
+
params = []
|
|
38
|
+
params << "days=#{query[:days]}" if query[:days]
|
|
39
|
+
params << "startDate=#{query[:startDate]}" if query[:startDate]
|
|
40
|
+
params << "endDate=#{query[:endDate]}" if query[:endDate]
|
|
41
|
+
|
|
42
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
43
|
+
@client.get("/domains/#{domain_id}/analytics#{query_string}")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Get stats for a specific domain
|
|
47
|
+
# @param domain_id [String] The domain ID
|
|
48
|
+
# @param query [Hash] Query parameters
|
|
49
|
+
# @option query [Integer] :days Number of days to retrieve (optional)
|
|
50
|
+
# @option query [String] :startDate Start date for stats (ISO 8601)
|
|
51
|
+
# @option query [String] :endDate End date for stats (ISO 8601)
|
|
52
|
+
# @return [Array] Response data and error
|
|
53
|
+
def get_stats(domain_id, query = {})
|
|
54
|
+
params = []
|
|
55
|
+
params << "days=#{query[:days]}" if query[:days]
|
|
56
|
+
params << "startDate=#{query[:startDate]}" if query[:startDate]
|
|
57
|
+
params << "endDate=#{query[:endDate]}" if query[:endDate]
|
|
58
|
+
|
|
59
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
60
|
+
@client.get("/domains/#{domain_id}/stats#{query_string}")
|
|
61
|
+
end
|
|
28
62
|
end
|
|
29
63
|
end
|
data/lib/unsent/emails.rb
CHANGED
|
@@ -100,5 +100,20 @@ module Unsent
|
|
|
100
100
|
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
101
101
|
@client.get("/emails/unsubscribes#{query_string}")
|
|
102
102
|
end
|
|
103
|
+
|
|
104
|
+
# Get events for a specific email
|
|
105
|
+
# @param email_id [String] The email ID
|
|
106
|
+
# @param query [Hash] Query parameters
|
|
107
|
+
# @option query [Integer] :page Page number (default: 1)
|
|
108
|
+
# @option query [Integer] :limit Number of items per page (default: 50, max: 100)
|
|
109
|
+
# @return [Array] Response data and error
|
|
110
|
+
def get_events(email_id, query = {})
|
|
111
|
+
params = []
|
|
112
|
+
params << "page=#{query[:page]}" if query[:page]
|
|
113
|
+
params << "limit=#{query[:limit]}" if query[:limit]
|
|
114
|
+
|
|
115
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
116
|
+
@client.get("/emails/#{email_id}/events#{query_string}")
|
|
117
|
+
end
|
|
103
118
|
end
|
|
104
119
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class Events
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Retrieve all email events
|
|
10
|
+
# @param query [Hash] Query parameters
|
|
11
|
+
# @option query [Integer] :page Page number (default: 1)
|
|
12
|
+
# @option query [Integer] :limit Number of items per page (default: 50, max: 100)
|
|
13
|
+
# @option query [String] :status Filter by event status
|
|
14
|
+
# @option query [String] :startDate Filter events from this date (ISO 8601)
|
|
15
|
+
# @return [Array] Response data and error
|
|
16
|
+
def list(query = {})
|
|
17
|
+
params = []
|
|
18
|
+
params << "page=#{query[:page]}" if query[:page]
|
|
19
|
+
params << "limit=#{query[:limit]}" if query[:limit]
|
|
20
|
+
params << "status=#{query[:status]}" if query[:status]
|
|
21
|
+
params << "startDate=#{query[:startDate]}" if query[:startDate]
|
|
22
|
+
|
|
23
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
24
|
+
@client.get("/events#{query_string}")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class Metrics
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Retrieve metrics data
|
|
10
|
+
# @param query [Hash] Query parameters
|
|
11
|
+
# @option query [Integer] :page Page number (default: 1)
|
|
12
|
+
# @option query [Integer] :limit Number of items per page (default: 50, max: 100)
|
|
13
|
+
# @return [Array] Response data and error
|
|
14
|
+
def get(query = {})
|
|
15
|
+
params = []
|
|
16
|
+
params << "page=#{query[:page]}" if query[:page]
|
|
17
|
+
params << "limit=#{query[:limit]}" if query[:limit]
|
|
18
|
+
|
|
19
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
20
|
+
@client.get("/metrics#{query_string}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/unsent/stats.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class Stats
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Retrieve statistics data
|
|
10
|
+
# @param query [Hash] Query parameters
|
|
11
|
+
# @option query [Integer] :page Page number (default: 1)
|
|
12
|
+
# @option query [Integer] :limit Number of items per page (default: 50, max: 100)
|
|
13
|
+
# @return [Array] Response data and error
|
|
14
|
+
def get(query = {})
|
|
15
|
+
params = []
|
|
16
|
+
params << "page=#{query[:page]}" if query[:page]
|
|
17
|
+
params << "limit=#{query[:limit]}" if query[:limit]
|
|
18
|
+
|
|
19
|
+
query_string = params.empty? ? '' : "?#{params.join('&')}"
|
|
20
|
+
@client.get("/stats#{query_string}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class System
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Check if the API is running correctly
|
|
10
|
+
# @return [Array] Response data and error
|
|
11
|
+
def health
|
|
12
|
+
@client.get('/health')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Retrieve API version information
|
|
16
|
+
# @return [Array] Response data and error
|
|
17
|
+
def version
|
|
18
|
+
@client.get('/version')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/unsent/teams.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unsent
|
|
4
|
+
class Teams
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# List all teams
|
|
10
|
+
# @return [Array] Response data and error
|
|
11
|
+
def list
|
|
12
|
+
@client.get('/teams')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Get a specific team by ID
|
|
16
|
+
# @param team_id [String] The team ID
|
|
17
|
+
# @return [Array] Response data and error
|
|
18
|
+
def get(team_id)
|
|
19
|
+
@client.get("/teams/#{team_id}")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|