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.
- checksums.yaml +4 -4
- data/lib/maxemail_api.rb +11 -73
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b63e6b603d366f92c8ff3dc6541e67fae333a8ea
|
4
|
+
data.tar.gz: 145e66dc3824ac0ebb22fb71f04c70f408242e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490295ebaee2a99e4c4c82b79ded3c56f32db69a29deb452337c647f5c451e7a41e461d55542ad689eeea5d2b848f2ab8df88133045345196d16914d6a2fffec
|
7
|
+
data.tar.gz: 4f972365eb4f7da49a505cfe78252359f9ae12a5edf081dad5994b427c05da52efd4b5661635c07a5da81d2760f6f5d5a5f7c1e043bc70bfb8386c384e593852
|
data/lib/maxemail_api.rb
CHANGED
@@ -1,74 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|