From 51bed9b970f6d9d99047ab8922796e7874ce4a6f Mon Sep 17 00:00:00 2001 From: Lorel Date: Sat, 1 Jul 2017 13:20:31 +0200 Subject: [PATCH] APIMailer: add @version in options given to Mailjet::Send.create onfly if exists --- lib/mailjet/mailer.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/mailjet/mailer.rb b/lib/mailjet/mailer.rb index 9ef57e8..fb53557 100644 --- a/lib/mailjet/mailer.rb +++ b/lib/mailjet/mailer.rb @@ -57,10 +57,13 @@ def deliver!(mail, opts = {}) # add `@connection_options` in `options` only if not exist yet (values in `options` prime) options.reverse_merge!(@connection_options) - # `options[:version]` primes on attribute, both of them on global config - options[:version] ||= (@version || Mailjet.config.api_version) + # add `@version` in options if set + options[:version] = @version if @version - if (options[:version] == 'v3.1') + # `options[:version]` primes on global config + version = options[:version] || Mailjet.config.api_version + + if (version == 'v3.1') Mailjet::Send.create({ :Messages => [setContentV3_1(mail)] }, options) else Mailjet::Send.create(setContentV3_0(mail), options)