Skip to content

Commit

Permalink
resolve merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Aridjar committed Feb 8, 2017
1 parent dd14c5e commit 95186b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
6 changes: 1 addition & 5 deletions Gemfile
@@ -1,12 +1,8 @@
source "http://rubygems.org"

#group :development, :test do
# gem 'rspec-rails', '~> 3.5'
#end

gem 'mime-types'

#gemspec
gemspec

platform :jruby do
gem 'jruby-openssl'
Expand Down
20 changes: 10 additions & 10 deletions lib/mailjet/connection.rb
Expand Up @@ -39,29 +39,29 @@ def initialize(end_point, api_key, secret_key, options = {})
self.adapter = adapter_class.new(end_point, options.merge(user: api_key, password: secret_key, content_type: 'application/json'))
end

def get(additional_headers = {}, call, &block)
handle_api_call(:get, additional_headers, call, &block)
def get(additional_headers = {}, perform_api_call, &block)
handle_api_call(:get, additional_headers, perform_api_call, &block)
end

def post(payload, additional_headers = {}, call, &block)
handle_api_call(:post, additional_headers, payload, call, &block)
def post(payload, additional_headers = {}, perform_api_call, &block)
handle_api_call(:post, additional_headers, payload, perform_api_call, &block)
end

def put(payload, additional_headers = {}, call, &block)
handle_api_call(:put, additional_headers, payload, call, &block)
def put(payload, additional_headers = {}, perform_api_call, &block)
handle_api_call(:put, additional_headers, payload, perform_api_call, &block)
end

def delete(additional_headers = {}, call, &block)
handle_api_call(:delete, additional_headers, call, &block)
def delete(additional_headers = {}, perform_api_call, &block)
handle_api_call(:delete, additional_headers, perform_api_call, &block)
end

private

def handle_api_call(method, additional_headers = {}, payload = {}, call, &block)
def handle_api_call(method, additional_headers = {}, payload = {}, perform_api_call, &block)
formatted_payload = (additional_headers[:content_type] == :json) ? payload.to_json : payload
raise Mailjet::MethodNotAllowed unless method_allowed(method)

if call == true
if perform_api_call
if [:get, :delete].include?(method)
@adapter.send(method, additional_headers, &block)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/mailjet/message_delivery.rb
Expand Up @@ -3,7 +3,7 @@
module Mailjet
class MessageDelivery
include Mailjet::Resource
self.version = 'v3.1/'
# self.version = 'v3.1/'
self.resource_path = 'send/message'
self.public_operations = [:post]
self.resourceprop = [:from, :sender, :to, :cc, :bcc, :subject, :text, :html, :attachment, :inline_attachments, :headers]
Expand Down
15 changes: 15 additions & 0 deletions spec/mailjet/mailer_spec.rb
Expand Up @@ -3,6 +3,7 @@
require 'mailjet/mailer'

module Mailjet
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
RSpec.describe APIMailer do
it 'set proper fields also for multipart emails' do
message = Mail.new
Expand Down Expand Up @@ -190,6 +191,20 @@ module Mailjet

APIMailer.new.deliver!(message)
end

#it 'fails to send' do
# from_name = 'Albert'
# from_email = 'albert@bar.com'
# recipients = ''
# message = Mail.new do
# from ""
# to recipients
# end

# expect { raise NoMethodError }.to raise_error

# APIMailer.new.deliver!(message)
#end

# it 'test the attachments' do
# from_name = 'Albert'
Expand Down

0 comments on commit 95186b0

Please sign in to comment.