maxemail_api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/maxemail_api.rb +11 -73
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ed69942ce651c7d29ecb6894019b80068fc1217
4
- data.tar.gz: b50dc7d3634599e0b408169b1fc374286648c0ff
3
+ metadata.gz: b63e6b603d366f92c8ff3dc6541e67fae333a8ea
4
+ data.tar.gz: 145e66dc3824ac0ebb22fb71f04c70f408242e15
5
5
  SHA512:
6
- metadata.gz: 99e47221a6f383900530cdd1b2e4cb6564f941f46ea9fc637467145c05dbce9b124542d03733d1f76c4107f3755895a8ee915655a90fd0adad4473c53f97a6c2
7
- data.tar.gz: bdd5f3920c1fcc05ae6990e7c5f9bc0d6c311f7b4f089bb54dae42c62cb39d9bc761cda5664156a3dbe4f84d237cb1a75baf57be6181b2b06365f67000ca531b
6
+ metadata.gz: 490295ebaee2a99e4c4c82b79ded3c56f32db69a29deb452337c647f5c451e7a41e461d55542ad689eeea5d2b848f2ab8df88133045345196d16914d6a2fffec
7
+ data.tar.gz: 4f972365eb4f7da49a505cfe78252359f9ae12a5edf081dad5994b427c05da52efd4b5661635c07a5da81d2760f6f5d5a5f7c1e043bc70bfb8386c384e593852
data/lib/maxemail_api.rb CHANGED
@@ -1,74 +1,12 @@
1
- module MaxemailApi
2
- class << self
3
- require 'base64'
4
- require 'http'
5
- require 'json'
6
-
7
- def send(params)
8
- params[:email_id] = email_id(folder_name: params[:folder_name], email_name: params[:email_name]) if params[:email_id].nil?
9
- send_triggered(email_address: params[:email_address], email_id: params[:email_id], profile_data: params[:profile_data])
10
- end
11
-
12
- private
13
-
14
- def fetch_root(tree: 'email', children: '[]')
15
- HTTP.headers(authentication_header)
16
- .get("#{ENV['MAXEMAIL_API_URL']}tree",
17
- params: {
18
- method: 'fetchRoot',
19
- tree: tree,
20
- children: children
21
- })
22
- end
23
-
24
- def fetch_tree(tree: 'email', node_id: nil, node_class: 'folder')
25
- HTTP.headers(authentication_header)
26
- .get("#{ENV['MAXEMAIL_API_URL']}tree",
27
- params: {
28
- method: 'fetchTree',
29
- tree: tree,
30
- nodeId: node_id,
31
- nodeClass: node_class
32
- })
33
- end
34
-
35
- def fetch_trigged(folder_id: nil)
36
- HTTP.headers(authentication_header)
37
- .get("#{ENV['MAXEMAIL_API_URL']}email_triggered",
38
- params: {
39
- method: 'fetchAll',
40
- folderId: folder_id
41
- })
42
- end
43
-
44
- def send_triggered(email_address: nil, email_id: nil, profile_data: nil)
45
- HTTP.headers(authentication_header)
46
- .get("#{ENV['MAXEMAIL_API_URL']}email_send",
47
- params: {
48
- method: 'trigger',
49
- emailAddress: email_address,
50
- emailId: email_id,
51
- profileData: profile_data
52
- })
53
- end
54
-
55
- def folder_id(folder_name: nil)
56
- response = JSON.parse(fetch_root)
57
- response[0]['children'].map do |node|
58
- node['nodeId'].to_i if node['text'] == folder_name
59
- end.compact.first
60
- end
61
-
62
- def email_id(folder_name: nil, email_name: nil)
63
- folder_id = folder_id(folder_name: folder_name)
64
- response = JSON.parse(fetch_tree(tree: 'email', node_id: folder_id, node_class: 'folder'))
65
- response.map do |node|
66
- node['nodeId'].to_i if node['text'] == email_name
67
- end.compact.first
68
- end
69
-
70
- def authentication_header
71
- { Authorization: 'Basic ' + Base64.encode64(ENV['MAXEMAIL_USERNAME'] + ':' + ENV['MAXEMAIL_PASSWORD']).remove("\n") }
72
- end
73
- end
1
+ require 'base64'
2
+ require 'http'
3
+ require 'json'
4
+ require 'maxemail_api/shared'
5
+ require 'maxemail_api/response'
6
+ require 'maxemail_api/triggered'
7
+ require 'maxemail_api/subscriptions'
8
+
9
+ class MaxemailApi
10
+ extend MaxemailApiSubscriptions
11
+ extend MaxemailApiTriggered
74
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxemail_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Catto