mailosaur 1.0.1 → 3.0.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/mailosaur.rb +12 -11
- data/lib/mailosaur/email.rb +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1f5cd8eee1338957480eefdd2a8ce560388ac0
|
4
|
+
data.tar.gz: 2903aed8d22f6555607826ef7231e0e0950fa9bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2e95a516ead64c04f7797f29082af5db8c7bc64e95b9b7e6f8016204aea922e5e7ed3bf9c8cdb6d44c17135ae5b64e7e210f94e151a2d429d128a3c1ee5869
|
7
|
+
data.tar.gz: ff9b637d8ea7bb90ebc331e8ef899af901b12037cb9438a6a94bca736567663237b7de799f5d144b26917636ecc894fa6083e5d7effdb14645e0e1348e794ae8
|
data/lib/mailosaur.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require_relative 'helper.rb'
|
2
2
|
|
3
|
+
|
3
4
|
class Mailosaur
|
4
5
|
attr_reader :message
|
5
6
|
|
6
|
-
def initialize(mailbox = nil, apiKey = nil)
|
7
|
+
def initialize(mailbox = nil, apiKey = nil, base_url = nil, smtp_host = nil)
|
7
8
|
@mailbox = ENV['MAILOSAUR_MAILBOX'] || mailbox
|
8
9
|
@api_key = ENV['MAILOSAUR_APIKEY'] || apiKey
|
9
|
-
@
|
10
|
+
@base_url = base_url || ENV['MAILOSAUR_BASE_URL'] || 'https://mailosaur.com/api'
|
11
|
+
@smtp_host = smtp_host || ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.in'
|
10
12
|
@message = MessageGenerator.new
|
11
13
|
end
|
12
14
|
|
@@ -16,7 +18,6 @@ class Mailosaur
|
|
16
18
|
search_criteria = {'search' => search_criteria}
|
17
19
|
end
|
18
20
|
search_criteria['key'] = @api_key
|
19
|
-
search_criteria['mailbox'] = @mailbox
|
20
21
|
response = send_get_emails_request(search_criteria)
|
21
22
|
if !response.nil? && response.length > 2
|
22
23
|
data = JSON.parse(response.body)
|
@@ -35,39 +36,39 @@ class Mailosaur
|
|
35
36
|
# Retrieves the email with the given id.
|
36
37
|
def get_email(email_id)
|
37
38
|
params = {'key' => @api_key}
|
38
|
-
response = RestClient.get("#{@
|
39
|
+
response = RestClient.get("#{@base_url}/emails/#{email_id}", {:params => params})
|
39
40
|
data = JSON.parse(response.body)
|
40
41
|
Email.new(data)
|
41
42
|
end
|
42
43
|
|
43
44
|
# Deletes all emails in a @mailbox.
|
44
45
|
def delete_all_emails
|
45
|
-
query_params = {'key' => @api_key
|
46
|
-
RestClient.post("#{@
|
46
|
+
query_params = {'key' => @api_key }
|
47
|
+
RestClient.post("#{@base_url}/mailboxes/#{@mailbox}/empty", nil, {:params => query_params})
|
47
48
|
end
|
48
49
|
|
49
50
|
# Deletes the email with the given id.
|
50
51
|
def delete_email(email_id)
|
51
52
|
params = {'key' => @api_key}
|
52
|
-
RestClient.post("#{@
|
53
|
+
RestClient.post("#{@base_url}/emails/#{email_id}/delete", nil, {:params => params})
|
53
54
|
end
|
54
55
|
|
55
56
|
# Retrieves the attachment with specified id.
|
56
57
|
def get_attachment(attachment_id)
|
57
58
|
params = {'key' => @api_key}
|
58
|
-
RestClient.get("#{@
|
59
|
+
RestClient.get("#{@base_url}/attachments/#{attachment_id}", {:params => params}).body
|
59
60
|
end
|
60
61
|
|
61
62
|
# Retrieves the complete raw EML file for the rawId given. RawId is a property on the email object.
|
62
63
|
def get_raw_email(raw_id)
|
63
64
|
params = {'key' => @api_key}
|
64
|
-
RestClient.get("#{@
|
65
|
+
RestClient.get("#{@base_url}/raw/#{raw_id}", {:params => params}).body
|
65
66
|
end
|
66
67
|
|
67
68
|
# Generates a random email address which can be used to send emails into the @mailbox.
|
68
69
|
def generate_email_address
|
69
70
|
uuid = SecureRandom.hex(3)
|
70
|
-
"%s.%s
|
71
|
+
"%s.%s@%s" % [uuid, @mailbox, @smtp_host]
|
71
72
|
end
|
72
73
|
|
73
74
|
# old methods
|
@@ -107,6 +108,6 @@ class Mailosaur
|
|
107
108
|
private
|
108
109
|
|
109
110
|
def send_get_emails_request(search_criteria)
|
110
|
-
RestClient.get("#{@
|
111
|
+
RestClient.get("#{@base_url}/mailboxes/#{@mailbox}/emails", {:params => search_criteria})
|
111
112
|
end
|
112
113
|
end
|
data/lib/mailosaur/email.rb
CHANGED
@@ -3,16 +3,16 @@ require "#{File.dirname(__FILE__)}/email_data"
|
|
3
3
|
require "#{File.dirname(__FILE__)}/attachment"
|
4
4
|
|
5
5
|
class Email
|
6
|
-
attr_accessor :id, :creationdate, :
|
6
|
+
attr_accessor :id, :creationdate, :senderhost, :from, :to, :mailbox, :rawid, :html, :text, :headers, :subject, :priority, :attachments
|
7
7
|
|
8
8
|
def initialize(hash)
|
9
9
|
@id = hash['id']
|
10
10
|
@creationdate = DateTime.iso8601(hash['creationdate'])
|
11
|
-
@
|
11
|
+
@senderhost = hash['senderhost'] || hash['senderHost']
|
12
12
|
@from= hash['from'].map { |f| EmailAddress.new(f) }
|
13
13
|
@to= hash['to'].map { |t| EmailAddress.new(t) }
|
14
14
|
@mailbox = hash['mailbox']
|
15
|
-
@
|
15
|
+
@rawid = hash['rawId'] || hash['rawid']
|
16
16
|
@html = hash.has_key?('html')?EmailData.new(hash['html']):nil
|
17
17
|
@text = hash.has_key?('text')?EmailData.new(hash['text']):nil
|
18
18
|
@headers = hash['headers']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailosaur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clickity Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 10.3.2
|
83
|
-
description: Gem containing ruby
|
83
|
+
description: Gem containing ruby client library for Mailosaur.
|
84
84
|
email: support@mailosaur.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
@@ -97,7 +97,7 @@ files:
|
|
97
97
|
- lib/mailosaur/image.rb
|
98
98
|
- lib/mailosaur/link.rb
|
99
99
|
- lib/mailosaur/message_generator.rb
|
100
|
-
homepage:
|
100
|
+
homepage: https://mailosaur.com
|
101
101
|
licenses:
|
102
102
|
- MIT
|
103
103
|
metadata: {}
|
@@ -117,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
|
-
summary:
|
123
|
+
summary: Client library for Mailosaur
|
124
124
|
test_files: []
|