Skip to content

Commit 2471f10

Browse files
committed
renamed batch methods in Mailtrap::Mail
1 parent 6995844 commit 2471f10

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

examples/batch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# client = Mailtrap::Client.new(sandbox: true, inbox_id: 12)
1414

1515
# Batch sending with Mailtrap::Mail::Base
16-
mail = Mailtrap::Mail.batch_from_content(
16+
mail = Mailtrap::Mail.batch_base_from_content(
1717
from: { email: '[email protected]', name: 'Mailtrap Test' },
1818
subject: 'You are awesome!',
1919
text: 'Congrats for sending test email with Mailtrap!',
@@ -48,7 +48,7 @@
4848
)
4949

5050
# Batch sending with Mailtrap::Mail::Base
51-
mail = Mailtrap::Mail.batch_from_template(
51+
mail = Mailtrap::Mail.batch_base_from_template(
5252
from: { email: '[email protected]', name: 'Mailtrap Test' },
5353
reply_to: { email: '[email protected]', name: 'Mailtrap Reply-To' },
5454
template_uuid: '339c8ab0-e73c-4269-984e-0d2446aacf2c',

lib/mailtrap/mail.rb

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,62 @@ def from_content( # rubocop:disable Metrics/ParameterLists
122122
# defined in the Mailtrap dashboard and referenced by the template_uuid.
123123
# Template variables can be passed to customize the template content.
124124
# @example
125-
# mail = Mailtrap::Mail.batch_from_template(
125+
# mail = Mailtrap::Mail.batch_base_from_template(
126126
# from: { email: '[email protected]', name: 'Mailtrap Test' },
127127
# template_uuid: '2f45b0aa-bbed-432f-95e4-e145e1965ba2',
128128
# template_variables: {
129129
# 'user_name' => 'John Doe'
130130
# }
131131
# )
132-
def batch_from_template(**args)
133-
from_template(**args.except(:to, :cc, :bcc))
132+
def batch_base_from_template( # rubocop:disable Metrics/ParameterLists
133+
from: nil,
134+
reply_to: nil,
135+
attachments: [],
136+
headers: {},
137+
custom_variables: {},
138+
template_uuid: nil,
139+
template_variables: {}
140+
)
141+
Mailtrap::Mail::Base.new(
142+
from:,
143+
reply_to:,
144+
attachments:,
145+
headers:,
146+
custom_variables:,
147+
template_uuid:,
148+
template_variables:
149+
)
134150
end
135151

136152
# Builds a mail object with content including subject, text, html, and category.
137153
# @example
138-
# mail = Mailtrap::Mail.batch_from_content(
154+
# mail = Mailtrap::Mail.batch_base_from_content(
139155
# from: { email: '[email protected]', name: 'Mailtrap Test' },
140156
# subject: 'You are awesome!',
141157
# text: 'Congrats for sending test email with Mailtrap!'
142158
# )
143-
def batch_from_content(**args)
144-
from_content(**args.except(:to, :cc, :bcc))
159+
def batch_base_from_content( # rubocop:disable Metrics/ParameterLists
160+
from: nil,
161+
reply_to: nil,
162+
attachments: [],
163+
headers: {},
164+
custom_variables: {},
165+
subject: nil,
166+
text: nil,
167+
html: nil,
168+
category: nil
169+
)
170+
Mailtrap::Mail::Base.new(
171+
from:,
172+
reply_to:,
173+
attachments:,
174+
headers:,
175+
custom_variables:,
176+
subject:,
177+
text:,
178+
html:,
179+
category:
180+
)
145181
end
146182

147183
# Builds a mail object from Mail::Message

0 commit comments

Comments
 (0)