mailjet / mailjet-gem

[API v3] Mailjet official Ruby GEM
https://dev.mailjet.com
Other
130 stars 72 forks source link

Using v3.0 and v3.1 in same app #175

Closed ssendev closed 3 years ago

ssendev commented 5 years ago

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

ssendev commented 5 years ago
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

xab3r commented 3 years ago

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