quickmail 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +30 -0
  4. data/lib/quickmail.rb +88 -0
  5. data/lib/quickmail/authentication.rb +26 -0
  6. data/lib/quickmail/order.rb +14 -0
  7. data/lib/quickmail/tracking.rb +14 -0
  8. data/lib/quickmail/version.rb +3 -0
  9. data/lib/tasks/quickmail_tasks.rake +4 -0
  10. data/test/dummy/Gemfile +54 -0
  11. data/test/dummy/Gemfile.lock +191 -0
  12. data/test/dummy/README.rdoc +28 -0
  13. data/test/dummy/Rakefile +6 -0
  14. data/test/dummy/app/assets/javascripts/application.js +16 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  16. data/test/dummy/app/controllers/application_controller.rb +5 -0
  17. data/test/dummy/app/helpers/application_helper.rb +2 -0
  18. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/test/dummy/bin/bundle +3 -0
  20. data/test/dummy/bin/rails +9 -0
  21. data/test/dummy/bin/rake +9 -0
  22. data/test/dummy/bin/setup +29 -0
  23. data/test/dummy/bin/spring +17 -0
  24. data/test/dummy/config.ru +4 -0
  25. data/test/dummy/config/application.rb +26 -0
  26. data/test/dummy/config/boot.rb +3 -0
  27. data/test/dummy/config/database.yml +25 -0
  28. data/test/dummy/config/environment.rb +5 -0
  29. data/test/dummy/config/environments/development.rb +41 -0
  30. data/test/dummy/config/environments/production.rb +79 -0
  31. data/test/dummy/config/environments/test.rb +42 -0
  32. data/test/dummy/config/initializers/assets.rb +11 -0
  33. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  34. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  35. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  36. data/test/dummy/config/initializers/inflections.rb +16 -0
  37. data/test/dummy/config/initializers/mime_types.rb +4 -0
  38. data/test/dummy/config/initializers/quickmail.rb +3 -0
  39. data/test/dummy/config/initializers/session_store.rb +3 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +56 -0
  43. data/test/dummy/config/secrets.yml +22 -0
  44. data/test/dummy/db/seeds.rb +7 -0
  45. data/test/dummy/public/404.html +67 -0
  46. data/test/dummy/public/422.html +67 -0
  47. data/test/dummy/public/500.html +66 -0
  48. data/test/dummy/public/favicon.ico +0 -0
  49. data/test/dummy/public/robots.txt +5 -0
  50. data/test/dummy/test/test_helper.rb +10 -0
  51. data/test/quickmail_test.rb +7 -0
  52. data/test/test_helper.rb +20 -0
  53. metadata +151 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 35118afcf14f6b0d12429305f1befbf9d636fc339ac6428797e8e69b628b5c49
4
+ data.tar.gz: '08cb795c83fcc712514371a73ca44d67fb015af680b734d30f1160798d104768'
5
+ SHA512:
6
+ metadata.gz: e869398ab8d318089d7fc5ba0b2ef74b9f6bb9ced895fd08dd7198ed7b704a3bc25df7d6ce255ca143b68f9345bf8a841c8ebaf56e4cf5404248ca2ebb100a71
7
+ data.tar.gz: 72c211e74e91a6e3bf5bd390e809e7a96f4c4f39d0eeae61d4854a00f0426c656ac84e3878e337ac1eac079e4084a22e6d5a6e46792957c19a896404f379b82e
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Tom Dallimore
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Quickmail'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+ Bundler::GemHelper.install_tasks
19
+
20
+ require 'rake/testtask'
21
+
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+
29
+
30
+ task default: :test
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+
5
+ require 'quickmail/authentication'
6
+ require 'quickmail/order'
7
+ require 'quickmail/tracking'
8
+
9
+ module Quickmail
10
+
11
+ API_BASE = Quickmail.test_mode ? "https://quickmailonline.com.au/api/test" : "https://quickmailonline.com.au/api/"
12
+
13
+ class QuickmailError < StandardError
14
+ end
15
+
16
+ class AuthenticationError < QuickmailError;
17
+ end
18
+ class ConfigurationError < QuickmailError;
19
+ end
20
+ class ApiRequestError < QuickmailError
21
+ attr_reader :response_code, :response_headers, :response_body
22
+
23
+ def initialize(response_code:, response_headers:, response_body:)
24
+ @response_code = response_code
25
+ @response_headers = response_headers
26
+ @response_body = response_body
27
+ end
28
+ end
29
+
30
+ class << self
31
+ def access_token
32
+ defined? @access_token and @access_token or raise(
33
+ ConfigurationError, "Quickmail access token not configured"
34
+ )
35
+ end
36
+
37
+ def api_version
38
+ defined? @api_version and @api_version or raise(
39
+ ConfigurationError, "Quickmail api version not configured"
40
+ )
41
+ end
42
+
43
+ def test_mode
44
+ @test_mode
45
+ end
46
+
47
+ attr_writer :access_token, :api_version, :test_mode
48
+
49
+ def request(method, resource, params = {})
50
+ ss_access_token = Quickmail.access_token
51
+ ss_api_version = Quickmail.api_version
52
+
53
+ defined? method or raise(
54
+ ArgumentError, "Request method has not been specified"
55
+ )
56
+ defined? resource or raise(
57
+ ArgumentError, "Request resource has not been specified"
58
+ )
59
+ if method == :get
60
+ headers = {accept: :json, content_type: :json, access_token: ss_access_token}.merge({params: params})
61
+ payload = nil
62
+ else
63
+ headers = {accept: :json, content_type: :json, access_token: ss_access_token}
64
+ payload = params
65
+ end
66
+ RestClient::Request.new({
67
+ method: method,
68
+ url: API_BASE + ss_api_version + '/' + resource,
69
+ payload: payload ? payload.to_json : nil,
70
+ headers: headers
71
+ }).execute do |response, request, result|
72
+ if response.code != 200
73
+ raise ApiRequestError.new(
74
+ response_code: response.code,
75
+ response_headers: response.headers,
76
+ response_body: response.to_str
77
+ )
78
+ end
79
+ str_response = response.to_str
80
+ str_response.blank? ? '' : JSON.parse(str_response)
81
+ end
82
+ end
83
+
84
+ def datetime_format(datetime)
85
+ datetime.strftime("%Y-%m-%d %T")
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Quickmail
4
+ class Authentication
5
+
6
+ class << self
7
+ def oauth(payload = {})
8
+ RestClient::Request.new({
9
+ method: :post,
10
+ url: API_BASE + '/token',
11
+ payload: payload ? payload.to_json : nil,
12
+ headers: {content_type: "application/x-www-form-urlencoded"}
13
+ }).execute do |response, request, result|
14
+ if response.code != 201
15
+ raise ApiRequestError.new(
16
+ response_code: response.code,
17
+ response_headers: response.headers,
18
+ response_body: response.to_str
19
+ )
20
+ end
21
+ response
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Quickmail
4
+ class Order
5
+
6
+ class << self
7
+ def create(params = {})
8
+ response = Quickmail.request(:post, 'orders', params)
9
+
10
+ response
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Quickmail
4
+ class Tracking
5
+
6
+ class << self
7
+ def poll(params = {})
8
+ response = Quickmail.request(:get, 'tracking', params)
9
+
10
+ response
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Quickmail
2
+ VERSION = "0.4.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :quickmail do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,54 @@
1
+ source 'http://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.2.7'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 5.0'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .coffee assets and views
13
+ gem 'coffee-rails', '~> 4.1.0'
14
+ # See https://github.com/rails/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ gem 'ffi', '~> 1.9.24'
27
+ gem 'sprockets', '~> 3.7.2'
28
+
29
+ gem 'rest-client'
30
+ gem 'Quickmail'
31
+
32
+
33
+ # Use ActiveModel has_secure_password
34
+ # gem 'bcrypt', '~> 3.1.7'
35
+
36
+ # Use Unicorn as the app server
37
+ # gem 'unicorn'
38
+
39
+ # Use Capistrano for deployment
40
+ # gem 'capistrano-rails', group: :development
41
+
42
+ group :development, :test do
43
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
44
+ gem 'byebug'
45
+ end
46
+
47
+ group :development do
48
+ # Access an IRB console on exception pages or by using <%= console %> in views
49
+ gem 'web-console', '~> 2.0'
50
+
51
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
52
+ gem 'spring'
53
+ end
54
+
@@ -0,0 +1,191 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ Quickmail (0.1.0)
5
+ rest-client (~> 2)
6
+ actionmailer (4.2.7)
7
+ actionpack (= 4.2.7)
8
+ actionview (= 4.2.7)
9
+ activejob (= 4.2.7)
10
+ mail (~> 2.5, >= 2.5.4)
11
+ rails-dom-testing (~> 1.0, >= 1.0.5)
12
+ actionpack (4.2.7)
13
+ actionview (= 4.2.7)
14
+ activesupport (= 4.2.7)
15
+ rack (~> 1.6)
16
+ rack-test (~> 0.6.2)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (4.2.7)
20
+ activesupport (= 4.2.7)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
+ activejob (4.2.7)
26
+ activesupport (= 4.2.7)
27
+ globalid (>= 0.3.0)
28
+ activemodel (4.2.7)
29
+ activesupport (= 4.2.7)
30
+ builder (~> 3.1)
31
+ activerecord (4.2.7)
32
+ activemodel (= 4.2.7)
33
+ activesupport (= 4.2.7)
34
+ arel (~> 6.0)
35
+ activesupport (4.2.7)
36
+ i18n (~> 0.7)
37
+ json (~> 1.7, >= 1.7.7)
38
+ minitest (~> 5.1)
39
+ thread_safe (~> 0.3, >= 0.3.4)
40
+ tzinfo (~> 1.1)
41
+ arel (6.0.4)
42
+ binding_of_caller (0.8.0)
43
+ debug_inspector (>= 0.0.1)
44
+ builder (3.2.3)
45
+ byebug (10.0.2)
46
+ coffee-rails (4.1.1)
47
+ coffee-script (>= 2.2.0)
48
+ railties (>= 4.0.0, < 5.1.x)
49
+ coffee-script (2.4.1)
50
+ coffee-script-source
51
+ execjs
52
+ coffee-script-source (1.12.2)
53
+ concurrent-ruby (1.0.5)
54
+ crass (1.0.6)
55
+ debug_inspector (0.0.3)
56
+ domain_name (0.5.20190701)
57
+ unf (>= 0.0.5, < 1.0.0)
58
+ erubis (2.7.0)
59
+ execjs (2.7.0)
60
+ ffi (1.9.25)
61
+ globalid (0.4.1)
62
+ activesupport (>= 4.2.0)
63
+ http-cookie (1.0.3)
64
+ domain_name (~> 0.5)
65
+ i18n (0.9.5)
66
+ concurrent-ruby (~> 1.0)
67
+ jbuilder (2.7.0)
68
+ activesupport (>= 4.2.0)
69
+ multi_json (>= 1.2)
70
+ jquery-rails (4.3.3)
71
+ rails-dom-testing (>= 1, < 3)
72
+ railties (>= 4.2.0)
73
+ thor (>= 0.14, < 2.0)
74
+ json (1.8.6)
75
+ loofah (2.5.0)
76
+ crass (~> 1.0.2)
77
+ nokogiri (>= 1.5.9)
78
+ mail (2.7.0)
79
+ mini_mime (>= 0.1.1)
80
+ mime-types (3.3.1)
81
+ mime-types-data (~> 3.2015)
82
+ mime-types-data (3.2020.0512)
83
+ mini_mime (1.0.1)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.11.3)
86
+ multi_json (1.13.1)
87
+ netrc (0.11.0)
88
+ nokogiri (1.10.9)
89
+ mini_portile2 (~> 2.4.0)
90
+ rack (1.6.13)
91
+ rack-test (0.6.3)
92
+ rack (>= 1.0)
93
+ rails (4.2.7)
94
+ actionmailer (= 4.2.7)
95
+ actionpack (= 4.2.7)
96
+ actionview (= 4.2.7)
97
+ activejob (= 4.2.7)
98
+ activemodel (= 4.2.7)
99
+ activerecord (= 4.2.7)
100
+ activesupport (= 4.2.7)
101
+ bundler (>= 1.3.0, < 2.0)
102
+ railties (= 4.2.7)
103
+ sprockets-rails
104
+ rails-deprecated_sanitizer (1.0.3)
105
+ activesupport (>= 4.2.0.alpha)
106
+ rails-dom-testing (1.0.9)
107
+ activesupport (>= 4.2.0, < 5.0)
108
+ nokogiri (~> 1.6)
109
+ rails-deprecated_sanitizer (>= 1.0.1)
110
+ rails-html-sanitizer (1.0.4)
111
+ loofah (~> 2.2, >= 2.2.2)
112
+ railties (4.2.7)
113
+ actionpack (= 4.2.7)
114
+ activesupport (= 4.2.7)
115
+ rake (>= 0.8.7)
116
+ thor (>= 0.18.1, < 2.0)
117
+ rake (13.0.1)
118
+ rb-fsevent (0.10.3)
119
+ rb-inotify (0.9.10)
120
+ ffi (>= 0.5.0, < 2)
121
+ rdoc (4.3.0)
122
+ rest-client (2.0.2)
123
+ http-cookie (>= 1.0.2, < 2.0)
124
+ mime-types (>= 1.16, < 4.0)
125
+ netrc (~> 0.8)
126
+ sass (3.5.7)
127
+ sass-listen (~> 4.0.0)
128
+ sass-listen (4.0.0)
129
+ rb-fsevent (~> 0.9, >= 0.9.4)
130
+ rb-inotify (~> 0.9, >= 0.9.7)
131
+ sass-rails (5.0.7)
132
+ railties (>= 4.0.0, < 6)
133
+ sass (~> 3.1)
134
+ sprockets (>= 2.8, < 4.0)
135
+ sprockets-rails (>= 2.0, < 4.0)
136
+ tilt (>= 1.1, < 3)
137
+ sdoc (0.4.2)
138
+ json (~> 1.7, >= 1.7.7)
139
+ rdoc (~> 4.0)
140
+ spring (2.0.2)
141
+ activesupport (>= 4.2)
142
+ sprockets (3.7.2)
143
+ concurrent-ruby (~> 1.0)
144
+ rack (> 1, < 3)
145
+ sprockets-rails (3.2.1)
146
+ actionpack (>= 4.0)
147
+ activesupport (>= 4.0)
148
+ sprockets (>= 3.0.0)
149
+ sqlite3 (1.3.13)
150
+ thor (0.20.0)
151
+ thread_safe (0.3.6)
152
+ tilt (2.0.8)
153
+ turbolinks (5.2.0)
154
+ turbolinks-source (~> 5.2)
155
+ turbolinks-source (5.2.0)
156
+ tzinfo (1.2.5)
157
+ thread_safe (~> 0.1)
158
+ uglifier (4.1.18)
159
+ execjs (>= 0.3.0, < 3)
160
+ unf (0.1.4)
161
+ unf_ext
162
+ unf_ext (0.0.7.7)
163
+ web-console (2.3.0)
164
+ activemodel (>= 4.0)
165
+ binding_of_caller (>= 0.7.2)
166
+ railties (>= 4.0)
167
+ sprockets-rails (>= 2.0, < 4.0)
168
+
169
+ PLATFORMS
170
+ ruby
171
+
172
+ DEPENDENCIES
173
+ Quickmail
174
+ byebug
175
+ coffee-rails (~> 4.1.0)
176
+ ffi (~> 1.9.24)
177
+ jbuilder (~> 2.0)
178
+ jquery-rails
179
+ rails (= 4.2.7)
180
+ rest-client
181
+ sass-rails (~> 5.0)
182
+ sdoc (~> 0.4.0)
183
+ spring
184
+ sprockets (~> 3.7.2)
185
+ sqlite3
186
+ turbolinks
187
+ uglifier (>= 1.3.0)
188
+ web-console (~> 2.0)
189
+
190
+ BUNDLED WITH
191
+ 1.14.6