diff --git a/lib/mailjet/resource.rb b/lib/mailjet/resource.rb index ea24d44..d1b9518 100644 --- a/lib/mailjet/resource.rb +++ b/lib/mailjet/resource.rb @@ -251,7 +251,7 @@ def save(options) end if options[:perform_api_call] - if self.resource_path == 'send/' + if self.resource_path.include? 'send' self.attributes = ActiveSupport::JSON.decode(response) return true end diff --git a/spec/mailjet-spec.rb b/spec/mailjet-spec.rb index e4503c0..a93a7fa 100644 --- a/spec/mailjet-spec.rb +++ b/spec/mailjet-spec.rb @@ -10,6 +10,7 @@ Mailjet.configure do |config| config.api_key = API_KEY config.secret_key = API_SECRET + config.api_version = "v3" end end diff --git a/spec/mailjet/mailer_spec.rb b/spec/mailjet/mailer_spec.rb index 283c539..5936e4b 100644 --- a/spec/mailjet/mailer_spec.rb +++ b/spec/mailjet/mailer_spec.rb @@ -252,5 +252,57 @@ module Mailjet }] ) end + + it 'should return data in attribute "Sent" using API v3' do + + Mailjet.configure do |config| + config.api_key = ENV['MJ_APIKEY_PUBLIC'] + config.secret_key = ENV['MJ_APIKEY_PRIVATE'] + config.api_version = "v3" + end + + from_email = 'albert@bar.com' + recipient = { 'Email': 'test@test.com' } + + message = Mailjet::Send.create( + from_email: from_email, + from_name: 'Mailjet Pilot', + subject: 'Your email flight plan!', + text_part: 'Dear passenger, welcome to Mailjet! May the delivery force be with you!', + html_part: '