mailjet / mailjet-gem

[API v3] Mailjet official Ruby GEM

Home Page:https://dev.mailjet.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using v3.0 and v3.1 in same app

ssendev opened this issue · comments

I have an app that uses api v3.0 (send and contacts) but i would like to use v3.1 for new send stuff. #141 suggests it's not safe to Mailjet.config.api_verions = 'v3.1' before sending mails and resetting it afterwards. while #143 prevents a complete migration.

Is it somehow possible to use both apis in the same app? i tried

class Mailjet31
  include Mailjet
end
Mailjet31::Configuration.api_version = 'v3.1'

but that also sets the api version of Mailjet

module Mailjet
  class Send31
    include Mailjet::Resource
    self.version = 'v3.1'
    self.resource_path = 'send'
    self.public_operations = [:post]
  end
end

seems to work. but maybe something like it should be included by default? and/or maybe a config.send_api_version

You can pass API version as second argument. Mailjet::Send.create({...}, version: 'v3.1')