mailosaur 1.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bc63d96b4be5d0d2237c75e37d178c3b751ff97
4
- data.tar.gz: 693a017692b35b80e1247b2efd09ca7594b7fc1b
3
+ metadata.gz: 8b1f5cd8eee1338957480eefdd2a8ce560388ac0
4
+ data.tar.gz: 2903aed8d22f6555607826ef7231e0e0950fa9bf
5
5
  SHA512:
6
- metadata.gz: 44f8d684eb2171409644a2c50a5168b3923b77f78b8be71cd0996c59878866702a852e745efe265f256b6501ee47d312c4bf70b0580f717689c43d740630d62d
7
- data.tar.gz: 0e51f9927c4bc92cd56c20aa3e3eea4cdfa480595ee7aa90a86605a285973e69121769a8961e926c17e21801b0e28050aa6d6609dd9df95ec9312fb2a14de5ba
6
+ metadata.gz: 3e2e95a516ead64c04f7797f29082af5db8c7bc64e95b9b7e6f8016204aea922e5e7ed3bf9c8cdb6d44c17135ae5b64e7e210f94e151a2d429d128a3c1ee5869
7
+ data.tar.gz: ff9b637d8ea7bb90ebc331e8ef899af901b12037cb9438a6a94bca736567663237b7de799f5d144b26917636ecc894fa6083e5d7effdb14645e0e1348e794ae8
@@ -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
- @base_uri = 'https://mailosaur.com/v2'
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("#{@base_uri}/email/#{email_id}", {:params => params})
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, '@mailbox' => @mailbox }
46
- RestClient.post("#{@base_uri}/emails/deleteall", nil, {:params => query_params})
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("#{@base_uri}/email/#{email_id}/delete/", nil, {:params => params})
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("#{@base_uri}/attachment/#{attachment_id}", {:params => params}).body
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("#{@base_uri}/raw/#{raw_id}", {:params => params}).body
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@mailosaur.in" % [uuid, @mailbox]
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("#{@base_uri}/emails", {:params => search_criteria})
111
+ RestClient.get("#{@base_url}/mailboxes/#{@mailbox}/emails", {:params => search_criteria})
111
112
  end
112
113
  end
@@ -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, :senderHost, :from, :to, :mailbox, :rawId, :html, :text, :headers, :subject, :priority, :attachments
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
- @senderHost = hash['senderHost']
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
- @rawId = hash['rawId']
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: 1.0.1
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-05 00:00:00.000000000 Z
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 bindings for the mailosaur.com mail testing api.
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: http://mailosaur.com
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.2.2
120
+ rubygems_version: 2.5.1
121
121
  signing_key:
122
122
  specification_version: 4
123
- summary: Bindings for mailosaur.com
123
+ summary: Client library for Mailosaur
124
124
  test_files: []