mailgun-ruby 1.4.5 → 1.4.6
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/CHANGELOG.md +17 -1
- data/README.md +3 -1
- data/lib/mailgun/api_keys/api_keys.rb +2 -2
- data/lib/mailgun/client.rb +1 -1
- data/lib/mailgun/domains/domain_keys.rb +5 -5
- data/lib/mailgun/domains/domains.rb +12 -9
- data/lib/mailgun/events/events.rb +1 -1
- data/lib/mailgun/helpers/api_version_checker.rb +23 -12
- data/lib/mailgun/helpers/deprecation.rb +32 -0
- data/lib/mailgun/lists/mailing_lists.rb +250 -0
- data/lib/mailgun/messages/message_builder.rb +17 -7
- data/lib/mailgun/response.rb +1 -1
- data/lib/mailgun/routes/routes.rb +98 -0
- data/lib/mailgun/tags/analytics_tags.rb +2 -2
- data/lib/mailgun/tags/tags.rb +16 -8
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun/webhooks/account_webhooks.rb +2 -2
- data/lib/mailgun/webhooks/webhooks.rb +17 -9
- data/lib/mailgun.rb +1 -0
- metadata +6 -326
- data/.github/workflows/ci.yml +0 -49
- data/.github_changelog_generator +0 -1
- data/.gitignore +0 -24
- data/.rubocop.yml +0 -68
- data/.ruby-env.yml.example +0 -13
- data/Gemfile +0 -9
- data/Rakefile +0 -32
- data/docs/AccountWebhooks.md +0 -55
- data/docs/AnalyticsTags.md +0 -63
- data/docs/ApiKeys.md +0 -65
- data/docs/DomainKeys.md +0 -49
- data/docs/Domains.md +0 -82
- data/docs/EmailValidation.md +0 -34
- data/docs/Events.md +0 -48
- data/docs/Logs.md +0 -67
- data/docs/MessageBuilder.md +0 -120
- data/docs/Metrics.md +0 -108
- data/docs/OptInHandler.md +0 -103
- data/docs/Snippets.md +0 -519
- data/docs/Subaccounts.md +0 -68
- data/docs/Suppressions.md +0 -92
- data/docs/Templates.md +0 -92
- data/docs/Webhooks.md +0 -65
- data/docs/railgun/EmailValidation.md +0 -34
- data/docs/railgun/Overview.md +0 -11
- data/docs/railgun/Parameters.md +0 -83
- data/mailgun.gemspec +0 -47
- data/spec/integration/account_webhooks_spec.rb +0 -57
- data/spec/integration/analytics_tags_spec.rb +0 -54
- data/spec/integration/api_keys_spec.rb +0 -50
- data/spec/integration/bounces_spec.rb +0 -45
- data/spec/integration/campaign_spec.rb +0 -62
- data/spec/integration/complaints_spec.rb +0 -40
- data/spec/integration/domain_keys_spec.rb +0 -124
- data/spec/integration/domains_spec.rb +0 -201
- data/spec/integration/email_validation_spec.rb +0 -73
- data/spec/integration/events_spec.rb +0 -28
- data/spec/integration/list_members_spec.rb +0 -64
- data/spec/integration/list_spec.rb +0 -59
- data/spec/integration/logs_spec.rb +0 -105
- data/spec/integration/mailer_spec.rb +0 -65
- data/spec/integration/mailgun_spec.rb +0 -198
- data/spec/integration/messages/sample_data/mime.txt +0 -38
- data/spec/integration/metrics_spec.rb +0 -224
- data/spec/integration/routes_spec.rb +0 -91
- data/spec/integration/stats_spec.rb +0 -17
- data/spec/integration/subaccounts_spec.rb +0 -57
- data/spec/integration/suppressions_spec.rb +0 -320
- data/spec/integration/templates_spec.rb +0 -137
- data/spec/integration/unsubscribes_spec.rb +0 -44
- data/spec/integration/webhook_spec.rb +0 -79
- data/spec/spec_helper.rb +0 -53
- data/spec/unit/client_spec.rb +0 -448
- data/spec/unit/connection/test_client.rb +0 -169
- data/spec/unit/events/events_spec.rb +0 -88
- data/spec/unit/exceptions/exceptions_spec.rb +0 -31
- data/spec/unit/helpers/api_version_checker_spec.rb +0 -206
- data/spec/unit/lists/opt_in_handler_spec.rb +0 -28
- data/spec/unit/mailgun_spec.rb +0 -171
- data/spec/unit/messages/batch_message_spec.rb +0 -148
- data/spec/unit/messages/message_builder_spec.rb +0 -745
- data/spec/unit/messages/sample_data/mailgun_icon.png +0 -0
- data/spec/unit/messages/sample_data/mime.txt +0 -38
- data/spec/unit/messages/sample_data/rackspace_logo.jpg +0 -0
- data/spec/unit/messages/sample_data/unknown.type +0 -0
- data/spec/unit/railgun/content_type_spec.rb +0 -89
- data/spec/unit/railgun/mailer_spec.rb +0 -391
- data/spec/unit/response_spec.rb +0 -225
- data/spec/unit/webhooks_spec.rb +0 -121
- data/vcr_cassettes/For_the_suppressions_handling_class/creates_a_single_bounce.yml +0 -55
- data/vcr_cassettes/account_webhooks.yml +0 -269
- data/vcr_cassettes/analytics_tags.yml +0 -187
- data/vcr_cassettes/api_keys.yml +0 -212
- data/vcr_cassettes/bounces.yml +0 -136
- data/vcr_cassettes/complaints.yml +0 -315
- data/vcr_cassettes/domains.todo.yml +0 -42
- data/vcr_cassettes/domains.yml +0 -1243
- data/vcr_cassettes/email_validation.yml +0 -152
- data/vcr_cassettes/events.yml +0 -69
- data/vcr_cassettes/exceptions-invalid-api-key.yml +0 -52
- data/vcr_cassettes/exceptions-invalid-data.yml +0 -52
- data/vcr_cassettes/exceptions-not-allowed.yml +0 -54
- data/vcr_cassettes/exceptions.yml +0 -92
- data/vcr_cassettes/list_members.yml +0 -328
- data/vcr_cassettes/logs.yml +0 -53
- data/vcr_cassettes/mailer_invalid_domain.yml +0 -109
- data/vcr_cassettes/mailing_list.todo.yml +0 -43
- data/vcr_cassettes/mailing_list.yml +0 -682
- data/vcr_cassettes/message_deliver.yml +0 -149
- data/vcr_cassettes/metrics.yml +0 -116
- data/vcr_cassettes/routes.yml +0 -359
- data/vcr_cassettes/send_message.yml +0 -158
- data/vcr_cassettes/stats.yml +0 -48
- data/vcr_cassettes/subaccounts.yml +0 -270
- data/vcr_cassettes/suppressions.yml +0 -1392
- data/vcr_cassettes/templates.yml +0 -1065
- data/vcr_cassettes/unsubscribes.yml +0 -401
- data/vcr_cassettes/webhooks.yml +0 -246
- data/vcr_cassettes/webhooks_v4.yml +0 -275
data/docs/Templates.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
Mailgun - Templates
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Templates* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions.
|
|
8
|
-
|
|
9
|
-
Usage - Templates
|
|
10
|
-
-----------------------
|
|
11
|
-
|
|
12
|
-
**Build a message with a template:**
|
|
13
|
-
|
|
14
|
-
```ruby
|
|
15
|
-
mb_obj = Mailgun::MessageBuilder.new
|
|
16
|
-
|
|
17
|
-
mb_obj.from("sender@example.com")
|
|
18
|
-
mb_obj.add_recipient("to", "recipient@example.com")
|
|
19
|
-
mb_obj.subject ("This is the subject!")
|
|
20
|
-
message.template('example.template.name')
|
|
21
|
-
message.template_version('example.tag')
|
|
22
|
-
|
|
23
|
-
mg_client.send_message "sending_domain.com", mb_obj
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**Rails Example. Build a message with a template:**
|
|
27
|
-
|
|
28
|
-
```ruby
|
|
29
|
-
class UserMailer < ApplicationMailer
|
|
30
|
-
def welcome_email
|
|
31
|
-
message = mail(
|
|
32
|
-
from: "sender@example.com",
|
|
33
|
-
to: "recipient@example.com",
|
|
34
|
-
subject: "This is the subject!",
|
|
35
|
-
template: 'example.template.name'
|
|
36
|
-
) do |format|
|
|
37
|
-
format.text { render plain: "Test!" }
|
|
38
|
-
end
|
|
39
|
-
message.tap do |message|
|
|
40
|
-
message.mailgun_template_variables ||= {
|
|
41
|
-
'version' => 'example.tag'
|
|
42
|
-
}
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Template Handlebars
|
|
49
|
-
-------------------------
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
{{#if english}}
|
|
53
|
-
<p>This text is in the English language.</p>
|
|
54
|
-
{{else if spanish}}
|
|
55
|
-
<p>Este texto está en idioma español.</p>
|
|
56
|
-
{{else if french}}
|
|
57
|
-
<p>Ce texte est en langue française.</p>
|
|
58
|
-
{{/if}}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
In order to send the spanish version, for example:
|
|
62
|
-
|
|
63
|
-
```ruby
|
|
64
|
-
message.variable('spanish', 'true')
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Also, Rails example:
|
|
68
|
-
|
|
69
|
-
```ruby
|
|
70
|
-
class UserMailer < ApplicationMailer
|
|
71
|
-
def welcome_email
|
|
72
|
-
message = mail(
|
|
73
|
-
from: "sender@example.com",
|
|
74
|
-
to: "recipient@example.com",
|
|
75
|
-
subject: "This is the subject!",
|
|
76
|
-
template: 'example.template.name'
|
|
77
|
-
) do |format|
|
|
78
|
-
format.text { render plain: "Test!" }
|
|
79
|
-
end
|
|
80
|
-
message.tap do |message|
|
|
81
|
-
message.mailgun_variables ||= {
|
|
82
|
-
'spanish' => 'true'
|
|
83
|
-
}
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
More Documentation
|
|
90
|
-
------------------
|
|
91
|
-
See the official [Mailgun Templates Docs](https://documentation.mailgun.com/en/latest/api-templates.html)
|
|
92
|
-
for more information
|
data/docs/Webhooks.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Mailgun - Webhooks
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Webhook* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions.
|
|
8
|
-
|
|
9
|
-
Usage - Webhooks
|
|
10
|
-
-----------------------
|
|
11
|
-
|
|
12
|
-
```ruby
|
|
13
|
-
# First, instantiate the Mailgun Client with your API key
|
|
14
|
-
mg_client = Mailgun::Client.new('your-api-key')
|
|
15
|
-
hook = Mailgun::Webhooks.new(mg_client)
|
|
16
|
-
|
|
17
|
-
# Get a list webhooks for a domain.
|
|
18
|
-
hook.list 'my.perfect.domain'
|
|
19
|
-
|
|
20
|
-
# View a single webhook detail
|
|
21
|
-
hook.info 'my.perfect.domain', 'delivered'
|
|
22
|
-
|
|
23
|
-
# Add a single url for all webhooks
|
|
24
|
-
hook.create_all 'my.perfect.domain', 'https://the.webhook.url/'
|
|
25
|
-
|
|
26
|
-
# Add a url for a specific webhook
|
|
27
|
-
hook.create 'my.perfect.domain', 'delivered', 'https://the.webhook.url/'
|
|
28
|
-
|
|
29
|
-
# Update the url for a specific webhook
|
|
30
|
-
hook.update 'my.perfect.domain', 'delivered', 'https://the.webhook.url/'
|
|
31
|
-
|
|
32
|
-
# Remove a url for a specific webhook
|
|
33
|
-
hook.remove 'my.perfect.domain', 'delivered'
|
|
34
|
-
|
|
35
|
-
# Remove all webhooks for a domain
|
|
36
|
-
hook.remove_all 'my.perfect.domain'
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Usage - Webhooks (v4)
|
|
40
|
-
-----------------------
|
|
41
|
-
|
|
42
|
-
The v4 endpoints work with a URL across multiple event types in a single request.
|
|
43
|
-
They require a client configured for the `v4` API.
|
|
44
|
-
|
|
45
|
-
```ruby
|
|
46
|
-
mg_client = Mailgun::Client.new('your-api-key', 'api.mailgun.net', 'v4')
|
|
47
|
-
hook = Mailgun::Webhooks.new(mg_client)
|
|
48
|
-
|
|
49
|
-
# Associate a url with one or more event types
|
|
50
|
-
hook.create_v4 'my.perfect.domain', url: 'https://the.webhook.url/', event_types: %w[delivered opened]
|
|
51
|
-
|
|
52
|
-
# Replace the event types associated with a url
|
|
53
|
-
hook.update_v4 'my.perfect.domain', url: 'https://the.webhook.url/', event_types: %w[clicked]
|
|
54
|
-
|
|
55
|
-
# Remove one or more urls from all event types they are associated with
|
|
56
|
-
hook.remove_v4 'my.perfect.domain', url: 'https://the.webhook.url/'
|
|
57
|
-
hook.remove_v4 'my.perfect.domain', url: ['https://the.webhook.url/', 'https://another.webhook.url/']
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Each v4 method returns a Hash of the domain's webhooks keyed by event type.
|
|
61
|
-
|
|
62
|
-
More Documentation
|
|
63
|
-
------------------
|
|
64
|
-
See the official [Mailgun Webhooks Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-webhooks)
|
|
65
|
-
for more information
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Mailgun - Email Validation
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Email Validation* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions.
|
|
8
|
-
|
|
9
|
-
Usage - Email Validation
|
|
10
|
-
-----------------------
|
|
11
|
-
|
|
12
|
-
```ruby
|
|
13
|
-
# First, instantiate the Mailgun Address. It pulls api key for Client from Mailgun.api_key variable.
|
|
14
|
-
email_validator = Mailgun::Address.new
|
|
15
|
-
|
|
16
|
-
# Given an arbitrary address, validates address based off defined checks.
|
|
17
|
-
# Response Example:
|
|
18
|
-
# {
|
|
19
|
-
# "address": "existingemail@realdomain.com",
|
|
20
|
-
# "is_disposable_address": false,
|
|
21
|
-
# "is_role_address": false,
|
|
22
|
-
# "reason": [],
|
|
23
|
-
# "result": "deliverable",
|
|
24
|
-
# "risk": "low"
|
|
25
|
-
# }
|
|
26
|
-
email_validator.validate('email@example.com')
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
More Documentation
|
|
32
|
-
------------------
|
|
33
|
-
See the official [Mailgun Email Validation Docs](https://documentation.mailgun.com/en/latest/api-email-validation.html)
|
|
34
|
-
for more information
|
data/docs/railgun/Overview.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Overview
|
|
2
|
-
========
|
|
3
|
-
|
|
4
|
-
Railgun is a Rails add-on that allows ActionMailer to send via the Mailgun API.
|
|
5
|
-
|
|
6
|
-
See [railgun-sample](https://github.com/pirogoeth/railgun-sample/) for examples of integrating Railgun with your Rails app.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Table of Contents
|
|
10
|
-
|
|
11
|
-
- [Parameters](/docs/railgun/Parameters.md)
|
data/docs/railgun/Parameters.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
Parameters
|
|
2
|
-
==========
|
|
3
|
-
|
|
4
|
-
When sending messages via Railgun, it is often useful to set options, headers, and variables
|
|
5
|
-
that should be added to the `POST` request against the messages endpoint.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Options
|
|
9
|
-
|
|
10
|
-
See [Mailgun Docs | Sending](https://documentation.mailgun.com/en/latest/api-sending.html#sending) for available options.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
To set options on a message:
|
|
15
|
-
|
|
16
|
-
```ruby
|
|
17
|
-
# app/controllers/some_controller.rb
|
|
18
|
-
|
|
19
|
-
message = YourMailer.your_message(@args)
|
|
20
|
-
|
|
21
|
-
message.mailgun_options ||= {
|
|
22
|
-
"tracking-opens" => "true",
|
|
23
|
-
"tracking-clicks" => "htmlonly",
|
|
24
|
-
"tag" => "some,tags",
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Variables
|
|
30
|
-
|
|
31
|
-
See [Mailgun Docs | Attaching Data to Messages](https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages) for more information.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
To set variables on a message:
|
|
36
|
-
|
|
37
|
-
```ruby
|
|
38
|
-
# app/controllers/some_controller.rb
|
|
39
|
-
|
|
40
|
-
message = YourMailer.your_message(@args)
|
|
41
|
-
|
|
42
|
-
message.mailgun_variables ||= {
|
|
43
|
-
"user_info" => {"id" => "1", "name" => "tstark"},
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Headers
|
|
49
|
-
|
|
50
|
-
See [Mailgun Docs | Sending](https://documentation.mailgun.com/en/latest/api-sending.html#sending) for more information.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
To set headers on a message *from a controller*:
|
|
55
|
-
|
|
56
|
-
```ruby
|
|
57
|
-
# app/controllers/some_controller.rb
|
|
58
|
-
|
|
59
|
-
message = YourMailer.your_message(@args)
|
|
60
|
-
|
|
61
|
-
message.mailgun_headers ||= {
|
|
62
|
-
"X-Sent-From-Rails" => "true",
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
To set headers on a message *from a mailer*:
|
|
67
|
-
|
|
68
|
-
```ruby
|
|
69
|
-
# app/mailers/your_mailer.rb
|
|
70
|
-
|
|
71
|
-
class YourMailer < ApplicationMailer
|
|
72
|
-
# ...
|
|
73
|
-
|
|
74
|
-
def your_message(args)
|
|
75
|
-
headers({
|
|
76
|
-
"X-Sent-From-Rails" => "true",
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
mail to: "some-address@example.org", ...
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
```
|
data/mailgun.gemspec
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require 'mailgun/version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name = 'mailgun-ruby'
|
|
9
|
-
spec.version = Mailgun::VERSION
|
|
10
|
-
spec.homepage = 'https://www.mailgun.com/'
|
|
11
|
-
spec.platform = Gem::Platform::RUBY
|
|
12
|
-
spec.license = 'Apache-2.0'
|
|
13
|
-
|
|
14
|
-
spec.summary = "Mailgun's Official Ruby SDK"
|
|
15
|
-
spec.description = "Mailgun's Official Ruby SDK for interacting with the Mailgun API."
|
|
16
|
-
|
|
17
|
-
spec.authors = ['Mailgun', 'Travis Swientek']
|
|
18
|
-
spec.email = 'support@mailgunhq.com'
|
|
19
|
-
|
|
20
|
-
spec.metadata['documentation_uri'] = 'https://documentation.mailgun.com/'
|
|
21
|
-
spec.metadata['source_code_uri'] = 'https://github.com/mailgun/mailgun-ruby'
|
|
22
|
-
|
|
23
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
24
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
25
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
26
|
-
spec.require_paths = ['lib']
|
|
27
|
-
|
|
28
|
-
spec.required_ruby_version = '>= 3.0.0'
|
|
29
|
-
|
|
30
|
-
spec.add_development_dependency 'bundler', '>= 1.16.2'
|
|
31
|
-
spec.add_development_dependency 'pry', '~> 0.16.0'
|
|
32
|
-
spec.add_development_dependency 'rails'
|
|
33
|
-
spec.add_development_dependency 'rake', '~> 13.3.1'
|
|
34
|
-
spec.add_development_dependency 'rspec', '~> 3.13.0'
|
|
35
|
-
spec.add_development_dependency 'rspec-its', '~> 2.0.0'
|
|
36
|
-
spec.add_development_dependency 'rubocop'
|
|
37
|
-
spec.add_development_dependency 'rubocop-rake'
|
|
38
|
-
spec.add_development_dependency 'rubocop-rspec'
|
|
39
|
-
spec.add_development_dependency 'simplecov'
|
|
40
|
-
spec.add_development_dependency 'simplecov-json'
|
|
41
|
-
spec.add_development_dependency 'vcr', '~> 6.4.0'
|
|
42
|
-
spec.add_development_dependency 'webmock', '~> 3.7'
|
|
43
|
-
spec.add_dependency 'faraday', '~> 2.1'
|
|
44
|
-
spec.add_dependency 'faraday-multipart', '< 2'
|
|
45
|
-
spec.add_dependency 'mini_mime'
|
|
46
|
-
spec.add_dependency 'zeitwerk'
|
|
47
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'account_webhooks' }
|
|
7
|
-
|
|
8
|
-
describe 'For the webhooks endpoint', order: :defined, vcr: vcr_opts do
|
|
9
|
-
let(:api_version) { 'v1' }
|
|
10
|
-
let(:mg_client) { Mailgun::Client.new(APIKEY, APIHOST, api_version, SSL) }
|
|
11
|
-
let(:mg_obj) { Mailgun::AccountWebhooks.new(mg_client) }
|
|
12
|
-
|
|
13
|
-
it 'creates a webhook' do
|
|
14
|
-
result = mg_obj.create(
|
|
15
|
-
description: 'test',
|
|
16
|
-
event_types: 'accepted',
|
|
17
|
-
url: 'http://example.com/mailgun/events'
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
expect(result).to have_key('webhook_id')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'gets a webhook' do
|
|
24
|
-
result = mg_obj.get('test')
|
|
25
|
-
|
|
26
|
-
expect(result['url']).to eq('http://example.com/mailgun/events')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'gets a list of all account webhooks' do
|
|
30
|
-
result = mg_obj.list
|
|
31
|
-
|
|
32
|
-
expect(result[0]['url']).to eq('http://example.com/mailgun/events')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'updates a webhook' do
|
|
36
|
-
result = mg_obj.update(
|
|
37
|
-
'test',
|
|
38
|
-
description: 'test2',
|
|
39
|
-
event_types: 'accepted',
|
|
40
|
-
url: 'http://example.com/mailgun/events'
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
expect(result).to be_truthy
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'removes a webhook' do
|
|
47
|
-
result = mg_obj.remove_by_id('test')
|
|
48
|
-
|
|
49
|
-
expect(result).to be_truthy
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'removes all webhooks' do
|
|
53
|
-
result = mg_obj.remove(all: true)
|
|
54
|
-
|
|
55
|
-
expect(result).to be_truthy
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'analytics_tags' }
|
|
7
|
-
|
|
8
|
-
describe 'AnalyticsTags', vcr: vcr_opts do
|
|
9
|
-
let(:api_version) { APIVERSION }
|
|
10
|
-
let(:mg_client) { Mailgun::Client.new(APIKEY, APIHOST, api_version, SSL) }
|
|
11
|
-
let(:mg_obj) { Mailgun::AnalyticsTags.new(mg_client) }
|
|
12
|
-
let(:api_version) { 'v1' }
|
|
13
|
-
|
|
14
|
-
describe '#update' do
|
|
15
|
-
it 'updates a tag' do
|
|
16
|
-
response = mg_obj.update('test1', 'test_description')
|
|
17
|
-
|
|
18
|
-
expect(response).to be_truthy
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe '#list' do
|
|
23
|
-
it 'returns a list of tags' do
|
|
24
|
-
response = mg_obj.list(
|
|
25
|
-
{
|
|
26
|
-
pagination: {
|
|
27
|
-
sort: 'lastseen:desc',
|
|
28
|
-
limit: 10
|
|
29
|
-
},
|
|
30
|
-
include_subaccounts: true
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
expect(response[0]['account_id']).to eq('test')
|
|
35
|
-
expect(response[0]['tag']).to eq('test1')
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe '#remove' do
|
|
40
|
-
it 'removes a tag' do
|
|
41
|
-
response = mg_obj.remove('test1')
|
|
42
|
-
|
|
43
|
-
expect(response).to be_truthy
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '#limits' do
|
|
48
|
-
it 'returns limits' do
|
|
49
|
-
response = mg_obj.limits
|
|
50
|
-
|
|
51
|
-
expect(response['limit']).to eq(100_000)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'api_keys' }
|
|
7
|
-
|
|
8
|
-
describe 'ApiKeys', order: :defined, vcr: vcr_opts do
|
|
9
|
-
let(:api_version) { 'v1' }
|
|
10
|
-
let(:mg_client) { Mailgun::Client.new(APIKEY, APIHOST, api_version, SSL) }
|
|
11
|
-
let(:mg_obj) { Mailgun::ApiKeys.new(mg_client) }
|
|
12
|
-
|
|
13
|
-
it 'creates an api key' do
|
|
14
|
-
result = mg_obj.create(
|
|
15
|
-
{
|
|
16
|
-
kind: 'user',
|
|
17
|
-
'description': 'test test',
|
|
18
|
-
'role': 'admin'
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
expect(result['description']).to eq('test test')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'gets api keys' do
|
|
26
|
-
result = mg_obj.list
|
|
27
|
-
|
|
28
|
-
expect(result[0]['id']).to eq('test')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'gets api keys filtered by kind and domain' do
|
|
32
|
-
result = mg_obj.list(kind: 'domain', domain_name: 'DOMAIN.TEST')
|
|
33
|
-
|
|
34
|
-
domain_keys = result.select { |key| key['kind'] == 'domain' }
|
|
35
|
-
expect(domain_keys.map { |key| key['domain_name'] }).to eq(['DOMAIN.TEST'])
|
|
36
|
-
expect(result.map { |key| key['kind'] }).not_to include('user', 'web')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'removes an api key' do
|
|
40
|
-
result = mg_obj.remove('test')
|
|
41
|
-
|
|
42
|
-
expect(result).to be_truthy
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'regenerates public api key' do
|
|
46
|
-
result = mg_obj.regenerate
|
|
47
|
-
|
|
48
|
-
expect(result).to be_truthy
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'bounces' }
|
|
7
|
-
|
|
8
|
-
describe 'For the Bounces endpoint', order: :defined, vcr: vcr_opts do
|
|
9
|
-
before(:all) do
|
|
10
|
-
@mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
|
|
11
|
-
@domain = TESTDOMAIN
|
|
12
|
-
@email = "integration-test+email@#{TESTDOMAIN}"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'creates a bounce' do
|
|
16
|
-
@result = @mg_obj.post("#{@domain}/bounces",
|
|
17
|
-
{ address: @email,
|
|
18
|
-
code: 550,
|
|
19
|
-
error: 'Integration Test' })
|
|
20
|
-
|
|
21
|
-
@result.to_h!
|
|
22
|
-
expect(@result.body['message']).to eq('Address has been added to the bounces table')
|
|
23
|
-
expect(@result.body['address']).to eq(@email)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'get a bounce.' do
|
|
27
|
-
result = @mg_obj.get("#{@domain}/bounces/#{CGI.escape(@email)}")
|
|
28
|
-
|
|
29
|
-
result.to_h!
|
|
30
|
-
expect(result.body['code']).to eq('550')
|
|
31
|
-
expect(result.body['address']).to eq(@email)
|
|
32
|
-
expect(result.body['error']).to eq('Integration Test')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'gets a list of bounces.' do
|
|
36
|
-
result = @mg_obj.get("#{@domain}/bounces")
|
|
37
|
-
|
|
38
|
-
result.to_h!
|
|
39
|
-
expect(result.body['items'].length).to be > 0
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'deletes a bounce' do
|
|
43
|
-
@mg_obj.delete("#{@domain}/bounces/#{CGI.escape(@email)}")
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'campaigns' }
|
|
7
|
-
|
|
8
|
-
describe 'For the campaigns endpoint', vcr: vcr_opts do
|
|
9
|
-
before(:all) do
|
|
10
|
-
skip 'pending removal'
|
|
11
|
-
@mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
|
|
12
|
-
@domain = TESTDOMAIN
|
|
13
|
-
@campaign_id = 'integration_test_campaign'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'creates a campaign' do
|
|
17
|
-
result = @mg_obj.post("#{@domain}/campaigns", { name: 'My Campaign',
|
|
18
|
-
id: @campaign_id })
|
|
19
|
-
|
|
20
|
-
result.to_h!
|
|
21
|
-
expect(result.body['message']).to eq('Campaign created')
|
|
22
|
-
expect(result.body['campaign']['id']).to eq(@campaign_id)
|
|
23
|
-
expect(result.body['campaign']['name']).to eq('My Campaign')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'get a campaign.' do
|
|
27
|
-
result = @mg_obj.get("#{@domain}/campaigns/#{@campaign_id}")
|
|
28
|
-
|
|
29
|
-
result.to_h!
|
|
30
|
-
expect(result.body['id']).to eq(@campaign_id)
|
|
31
|
-
expect(result.body['name']).to eq('My Campaign')
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'gets a list of all campaigns.' do
|
|
35
|
-
result = @mg_obj.get("#{@domain}/campaigns", { limit: 50 })
|
|
36
|
-
|
|
37
|
-
result.to_h!
|
|
38
|
-
expect(result.body['total_count']).to be > 0
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'update a campaign.' do
|
|
42
|
-
result = @mg_obj.put("#{@domain}/campaigns/#{@campaign_id}", { name: 'My Updated Campaign',
|
|
43
|
-
id: @campaign_id })
|
|
44
|
-
|
|
45
|
-
result.to_h!
|
|
46
|
-
expect(result.body['message']).to eq('Campaign updated')
|
|
47
|
-
expect(result.body['campaign']['id']).to eq(@campaign_id)
|
|
48
|
-
expect(result.body['campaign']['name']).to eq('My Updated Campaign')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'get campaign events.' do
|
|
52
|
-
expect { @mg_obj.get("#{@domain}/campaigns/#{@campaign_id}/events", { groupby: 'clicked' }) }.not_to raise_error
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'get campaign stats.' do
|
|
56
|
-
expect { @mg_obj.get("#{@domain}/campaigns/#{@campaign_id}/stats", { groupby: 'domain' }) }.not_to raise_error
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'removes a campaign' do
|
|
60
|
-
@mg_obj.delete("#{@domain}/campaigns/#{@campaign_id}")
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'mailgun'
|
|
5
|
-
|
|
6
|
-
vcr_opts = { cassette_name: 'complaints' }
|
|
7
|
-
|
|
8
|
-
describe 'For the Complaints endpoint', order: :defined, vcr: vcr_opts do
|
|
9
|
-
before(:all) do
|
|
10
|
-
@mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
|
|
11
|
-
@domain = TESTDOMAIN
|
|
12
|
-
@email = "integration-test-email@#{TESTDOMAIN}"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'creates a complaint' do
|
|
16
|
-
@result = @mg_obj.post("#{@domain}/complaints", { address: @email })
|
|
17
|
-
|
|
18
|
-
@result.to_h!
|
|
19
|
-
expect(@result.body['message']).to eq('Address has been added to the complaints table')
|
|
20
|
-
expect(@result.body['address']).to eq(@email)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'get a complaint.' do
|
|
24
|
-
result = @mg_obj.get("#{@domain}/complaints/#{@email}")
|
|
25
|
-
|
|
26
|
-
result.to_h!
|
|
27
|
-
expect(result.body['address']).to eq(@email)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'gets a list of complaints.' do
|
|
31
|
-
result = @mg_obj.get("#{@domain}/complaints")
|
|
32
|
-
|
|
33
|
-
result.to_h!
|
|
34
|
-
expect(result.body['items'].length).to be > 0
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'removes a complaint' do
|
|
38
|
-
@mg_obj.delete("#{@domain}/complaints/#{@email}")
|
|
39
|
-
end
|
|
40
|
-
end
|