Skip to content

Commit 465d4f4

Browse files
committed
Add new examples
1 parent b8d48db commit 465d4f4

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ mail(delivery_method: :mailtrap_bulk)
173173
Refer to the [`examples`](examples) folder for more examples:
174174

175175
Email API:
176-
- Full email sending – [`full.rb`](examples/full.rb)
177176

177+
- Full email sending – [`full.rb`](examples/full.rb)
178178
- Batch sending – [`batch.rb`](examples/batch.rb)
179+
- Sending domains API – [`sending_domains_api.rb`](examples/sending_domains_api.rb)
179180

180181
Email Sandbox (Testing):
181182

examples/sending_domains_api.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'mailtrap'
2+
3+
account_id = 3229
4+
client = Mailtrap::Client.new(api_key: 'your-api-key')
5+
sending_domains = Mailtrap::InboxesAPI.new(account_id, client)
6+
7+
# Create new Sending Domain
8+
sending_domain = sending_domains.create(domain_name: 'example.com')
9+
# => #<struct Mailtrap::SendingDomain id=1, domain_name="example.com">
10+
11+
# Get all Sending Domains
12+
sending_domains.list
13+
# => [#<struct Mailtrap::SendingDomain id=1, domain_name="example.com">]
14+
15+
# Update Sending Domain
16+
sending_domains.update(sending_domain.id, domain_name: 'proper.com')
17+
# => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com">
18+
19+
# Get sending domain
20+
sending_domain = sending_domains.get(sending_domain.id)
21+
# => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com">
22+
23+
# Send setup email
24+
sending_domains.clean(sending_domain.id, 'jonathan@mail.com')
25+
# => nil
26+
27+
# Delete sending domain
28+
sending_domains.delete(sending_domain.id)
29+
# => nil

0 commit comments

Comments
 (0)