forked from mailjet/mailjet-gem
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mailjet#208 from mailjet/develop
mailjet v1.6.0
- Loading branch information
Showing
73 changed files
with
3,435 additions
and
864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,6 @@ doc | |
.yardoc | ||
pkg | ||
|
||
/spec/cassettes/ | ||
|
||
/config.yml | ||
|
||
.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
#!/usr/bin/env rake | ||
require 'rake/testtask' | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks | ||
require "rspec/core/rake_task" | ||
|
||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
Rake::TestTask.new(:spec) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'spec' | ||
# t.pattern = 'spec/**/*_spec.rb' | ||
t.verbose = true | ||
t.test_files = Dir['spec/**/*_spec.rb'] | ||
RSpec::Core::RakeTask.new(:spec) do |t| | ||
t.pattern = [ | ||
"spec/mailjet/api_error_spec.rb", | ||
"spec/mailjet/apikey_spec.rb", | ||
"spec/mailjet/mailer_spec.rb", | ||
"spec/mailjet/resource_spec.rb", | ||
"spec/configuration_spec.rb", | ||
"spec/mailjet_spec.rb", | ||
"spec/resources/contact_spec.rb", | ||
"spec/resources/contactmetadata_spec.rb", | ||
"spec/resources/messagehistory_spec.rb", | ||
"spec/resources/getcontactslists_spec.rb", | ||
"spec/resources/template_detailcontent_spec.rb", | ||
"spec/resources/integration_spec.rb", | ||
"spec/resources/newsletter_spec.rb", | ||
"spec/resources/statcounters_spec.rb", | ||
] | ||
end | ||
|
||
|
||
task :default => :spec | ||
task default: [:spec] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
# encoding: utf-8 | ||
require 'active_support' | ||
require "json" | ||
|
||
module Mailjet | ||
class ApiError < StandardError | ||
attr_reader :code, :reason | ||
|
||
attr_accessor :code, :reason | ||
# @param code [Integer] HTTP response status code | ||
# @param body [String] JSON response body | ||
# @param request [Object] any request object | ||
# @param url [String] request URL | ||
# @param params [Hash] request headers and parameters | ||
def initialize(code, body, request, url, params) | ||
@code = code | ||
@reason = begin | ||
resdec = JSON.parse(body) | ||
resdec['ErrorMessage'] | ||
rescue JSON::ParserError | ||
body | ||
end | ||
|
||
message = "error #{code} while sending #{request.inspect} to #{url} with #{params.inspect}" | ||
error_details = body.inspect | ||
hint = "Please see https://dev.mailjet.com/guides/#status-codes for more informations on error numbers." | ||
|
||
def initialize(code, res, request, request_path, params) | ||
self.code = code | ||
self.reason = "" | ||
unless res.blank? | ||
resdec = ActiveSupport::JSON.decode(res) | ||
self.reason = resdec['ErrorMessage'] | ||
end | ||
# code is ugly, output is pretty | ||
super("error #{code} while sending #{request.inspect} to #{request_path} with #{params.inspect}\n\n" + | ||
if res.respond_to?(:[]) && res['errors'].present? | ||
[(res['errors'] || [])].flatten.map do |param, text| | ||
[param, text].map(&:to_s).reject(&:blank?).join(': ') | ||
end.join("\n") | ||
else | ||
res.inspect | ||
end + "\n\nPlease see https://dev.mailjet.com/guides/#status-codes for more informations on error numbers.\n\n" | ||
) | ||
super("#{message}\n\n#{error_details}\n\n#{hint}\n\n") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Mailjet | ||
class Statcounters | ||
include Mailjet::Resource | ||
self.resource_path = 'REST/statcounters' | ||
self.public_operations = [:get] | ||
self.filters = [:source_id, :counter_resolution, :counter_source, :counter_timing] | ||
self.resourceprop = [ | ||
:api_key_id, | ||
:event_click_delay, | ||
:event_clicked_count, | ||
:event_open_delay, | ||
:event_opened_count, | ||
:event_spam_count, | ||
:event_unsubscribed_count, | ||
:event_workflow_exited_count, | ||
:message_blocked_count, | ||
:message_clicked_count, | ||
:message_deferred_count, | ||
:message_hard_bounced_count, | ||
:message_opened_count, | ||
:message_queued_count, | ||
:message_sent_count, | ||
:message_soft_bounced_count, | ||
:message_spam_count, | ||
:message_unsubscribed_count, | ||
:message_work_flow_exited_count, | ||
:source_id, | ||
:timeslice, | ||
:total, | ||
] | ||
self.read_only = true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Mailjet | ||
VERSION = "1.5.4" | ||
VERSION = "1.6.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ut_any_Text_or_HTML_body_and_an_attachment_with_API_v3_1_but_raise_a_Mailjet_ApiError.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.