quickmail 0.5.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4e5972b28ca802a0ca6748dee33388e1467b1d75c930be525e1d6013bc998b1
4
- data.tar.gz: 1b3de7c13c847c917aa9b13806ab276f5f5d57c45d55f58e03d2f1199302119c
3
+ metadata.gz: 227db5a553ff13e194b8910f3bcf768c4b7daf063a0ad2b73c77bdfc14ea90f0
4
+ data.tar.gz: 02c3d283725fc3b54a0cbc9b417bd460ebca0933da69d1f6dfa0c42e94180d80
5
5
  SHA512:
6
- metadata.gz: 0dae0a7dacdfb6e3ddaa0b6010c44f8af4b26338f96a49a0b9813fff157e69718f58f1b79d02c7e9c7c4830b3be9e8d3b1c4c333be62ae08e26fc63ed061b032
7
- data.tar.gz: fc98b731ab50aba6311b68bc6ec196b0b4c4c44f2c16b0a4862175536c1384d5dd6230b788a5633b6e77701b04a2f5d17f0922fde08c4a99075434f4fb381abf
6
+ metadata.gz: 800528a13066e116256f8efde7bfd9b1a2a1f2119fea4841c2f1bfff0c9c78e2f061973a60b2cf587de0e1a8d8381a462f0546f6f58a65e18187485b141a0e10
7
+ data.tar.gz: 51c481f400717bed63577a983e5fa92449025c6eefd72e33e3392d385bf867eececf6a07af454a346b6a1dff6d5956f92fda2a37470a04afca6af63acddacc1c
@@ -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
- end
18
- class ConfigurationError < QuickmailError;
19
- end
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
 
@@ -29,7 +27,7 @@ module Quickmail
29
27
 
30
28
  class << self
31
29
 
32
- attr_writer :access_token, :api_version, :test_mode
30
+ attr_writer :access_token, :api_version, :test_mode, :api_base
33
31
 
34
32
  def access_token
35
33
  defined? @access_token and @access_token or raise(
@@ -44,7 +42,11 @@ module Quickmail
44
42
  end
45
43
 
46
44
  def test_mode
47
- @test_mode
45
+ @test_mode.nil? ? false : @test_mode
46
+ end
47
+
48
+ def api_base
49
+ Quickmail.test_mode ? "https://quickmailonline.com.au/api/test" : "https://quickmailonline.com.au/api/"
48
50
  end
49
51
 
50
52
  def request(method, resource, params = {})
@@ -68,8 +70,8 @@ module Quickmail
68
70
  end
69
71
  RestClient::Request.new({
70
72
  method: method,
71
- url: API_BASE + ss_api_version + '/' + resource,
72
- payload: payload ? payload.to_json : nil,
73
+ url: Quickmail.api_base + ss_api_version + '/' + resource,
74
+ payload: payload,
73
75
  headers: headers
74
76
  }).execute do |response, request, result|
75
77
  if response.code != 200
@@ -7,11 +7,11 @@ module Quickmail
7
7
  def oauth(payload = {})
8
8
  RestClient::Request.new({
9
9
  method: :post,
10
- url: API_BASE + '/token',
11
- payload: payload ? payload.to_json : nil,
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
- if response.code != 201
14
+ if response.code != 200
15
15
  raise ApiRequestError.new(
16
16
  response_code: response.code,
17
17
  response_headers: response.headers,
@@ -1,3 +1,3 @@
1
1
  module Quickmail
2
- VERSION = "0.5.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickmail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Dallimore