quickmail 0.4.0 → 0.9.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.
- checksums.yaml +4 -4
- data/lib/quickmail.rb +18 -13
- data/lib/quickmail/authentication.rb +2 -2
- data/lib/quickmail/version.rb +1 -1
- data/test/dummy/config/initializers/quickmail.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 672837930a7b8f7312ccd8845761fe5e9d7db28bda156e913fd0880cc8c8da9f
|
4
|
+
data.tar.gz: 6ec1e7fd28578317984605b72e067e305b1fa22d94a7baedbc725a31ca30e531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e707d689dc88ee66de7bfa5b9055e8a66c60aa3649e7a4425df2d8f2d0008fd9defc5cd42989cbad4846ec3ffab712ae9c26815f473a67e5979d675d1263de3
|
7
|
+
data.tar.gz: fad1200dd04b9008f36c5f78a50e18ff504b9fe1585a14863d98c4791f01505d03c697331a367006a8a7db3f83f3b19c4ee19da7e48e38eb49f5d4f7c54ef300
|
data/lib/quickmail.rb
CHANGED
@@ -8,15 +8,13 @@ require 'quickmail/tracking'
|
|
8
8
|
|
9
9
|
module Quickmail
|
10
10
|
|
11
|
-
API_BASE = Quickmail.test_mode ? "https://quickmailonline.com.au/api/test" : "https://quickmailonline.com.au/api/"
|
12
|
-
|
13
11
|
class QuickmailError < StandardError
|
14
12
|
end
|
15
13
|
|
16
|
-
class AuthenticationError < QuickmailError;
|
17
|
-
|
18
|
-
class ConfigurationError < QuickmailError;
|
19
|
-
|
14
|
+
class AuthenticationError < QuickmailError; end
|
15
|
+
|
16
|
+
class ConfigurationError < QuickmailError; end
|
17
|
+
|
20
18
|
class ApiRequestError < QuickmailError
|
21
19
|
attr_reader :response_code, :response_headers, :response_body
|
22
20
|
|
@@ -28,6 +26,9 @@ module Quickmail
|
|
28
26
|
end
|
29
27
|
|
30
28
|
class << self
|
29
|
+
|
30
|
+
attr_writer :access_token, :api_version, :test_mode, :api_base
|
31
|
+
|
31
32
|
def access_token
|
32
33
|
defined? @access_token and @access_token or raise(
|
33
34
|
ConfigurationError, "Quickmail access token not configured"
|
@@ -41,15 +42,19 @@ module Quickmail
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def test_mode
|
44
|
-
@test_mode
|
45
|
+
@test_mode.nil? ? false : @test_mode
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
|
+
def api_base
|
49
|
+
Quickmail.test_mode ? "https://quickmailonline.com.au/api/test" : "https://quickmailonline.com.au/api/"
|
50
|
+
end
|
48
51
|
|
49
52
|
def request(method, resource, params = {})
|
50
|
-
ss_access_token = Quickmail.access_token
|
53
|
+
ss_access_token = params[:access_token] || Quickmail.access_token
|
51
54
|
ss_api_version = Quickmail.api_version
|
52
55
|
|
56
|
+
params.except!(:access_token)
|
57
|
+
|
53
58
|
defined? method or raise(
|
54
59
|
ArgumentError, "Request method has not been specified"
|
55
60
|
)
|
@@ -57,16 +62,16 @@ module Quickmail
|
|
57
62
|
ArgumentError, "Request resource has not been specified"
|
58
63
|
)
|
59
64
|
if method == :get
|
60
|
-
headers = {accept: :json, content_type: :json,
|
65
|
+
headers = {accept: :json, content_type: :json, Authorization: "Bearer #{ss_access_token}"}.merge({params: params})
|
61
66
|
payload = nil
|
62
67
|
else
|
63
|
-
headers = {accept: :json, content_type: :json,
|
68
|
+
headers = {accept: :json, content_type: :json, Authorization: "Bearer #{ss_access_token}"}
|
64
69
|
payload = params
|
65
70
|
end
|
66
71
|
RestClient::Request.new({
|
67
72
|
method: method,
|
68
|
-
url:
|
69
|
-
payload: payload
|
73
|
+
url: Quickmail.api_base + ss_api_version + '/' + resource,
|
74
|
+
payload: payload,
|
70
75
|
headers: headers
|
71
76
|
}).execute do |response, request, result|
|
72
77
|
if response.code != 200
|
@@ -7,8 +7,8 @@ module Quickmail
|
|
7
7
|
def oauth(payload = {})
|
8
8
|
RestClient::Request.new({
|
9
9
|
method: :post,
|
10
|
-
url:
|
11
|
-
payload: payload
|
10
|
+
url: Quickmail.api_base + '/token',
|
11
|
+
payload: payload,
|
12
12
|
headers: {content_type: "application/x-www-form-urlencoded"}
|
13
13
|
}).execute do |response, request, result|
|
14
14
|
if response.code != 201
|
data/lib/quickmail/version.rb
CHANGED