postageapp 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This is the gem used to integrate Ruby apps with PostageApp service.
4
4
  Personalized, mass email sending can be offloaded to PostageApp via JSON based API.
5
5
 
6
- ### [API Documentation](http://help.postageapp.com/faqs/api) • [PostageApp FAQs](http://help.postageapp.com/faqs) • [PostageApp Help Portal](http://help.postageapp.com)
6
+ ### [API Documentation](http://help.postageapp.com/kb/api/api-overview) • [PostageApp Knowledge Base](http://help.postageapp.com/kb) • [PostageApp Help Portal](http://help.postageapp.com)
7
7
 
8
8
  Installation
9
9
  ------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.14
1
+ 1.0.15
@@ -31,6 +31,7 @@ class PostageApp::Mailer < ActionMailer::Base
31
31
 
32
32
  adv_attr_accessor :postageapp_template
33
33
  adv_attr_accessor :postageapp_variables
34
+ adv_attr_accessor :postageapp_api_key
34
35
 
35
36
  def perform_delivery_postage(mail)
36
37
  mail.send
@@ -73,6 +74,7 @@ class PostageApp::Mailer < ActionMailer::Base
73
74
 
74
75
  params['template'] = self.postageapp_template unless self.postageapp_template.blank?
75
76
  params['variables'] = self.postageapp_variables unless self.postageapp_variables.blank?
77
+ params['api_key'] = self.postageapp_api_key unless self.postageapp_api_key.blank?
76
78
 
77
79
  params.delete('headers') if params['headers'].blank?
78
80
  params.delete('content') if params['content'].blank?
@@ -74,6 +74,10 @@ class PostageApp::Mailer < ActionMailer::Base
74
74
  value ? @_message.arguments['variables'] = value : @_message.arguments['variables']
75
75
  end
76
76
 
77
+ def postageapp_api_key(value = nil)
78
+ value ? @_message.arguments['api_key'] = value : @_message.arguments['api_key']
79
+ end
80
+
77
81
  def attachments
78
82
  @_attachments ||= Attachments.new(@_message)
79
83
  end
@@ -17,9 +17,13 @@ class PostageApp::Request
17
17
  # A list of arguments in a Hash format passed along with the request
18
18
  attr_accessor :arguments
19
19
 
20
+ # Ability to set api_key with eash request
21
+ attr_accessor :api_key
22
+
20
23
  def initialize(method, arguments = {})
21
24
  @method = method
22
25
  @uid = arguments.delete(:uid)
26
+ @api_key = arguments.delete(:api_key) || PostageApp.configuration.api_key
23
27
  @arguments = arguments
24
28
  end
25
29
 
@@ -77,7 +81,7 @@ class PostageApp::Request
77
81
 
78
82
  # Arguments need to be appended with some some stuff before it's ready to be send out
79
83
  def arguments_to_send
80
- hash = { 'uid' => self.uid, 'api_key' => PostageApp.configuration.api_key }
84
+ hash = { 'uid' => self.uid, 'api_key' => self.api_key }
81
85
 
82
86
  if !self.arguments.nil? && !self.arguments.empty?
83
87
  if !PostageApp.configuration.recipient_override.nil? && self.method.to_sym == :send_message
data/postageapp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "postageapp"
8
- s.version = "1.0.14"
8
+ s.version = "1.0.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov, The Working Group Inc"]
12
- s.date = "2011-11-15"
12
+ s.date = "2012-09-13"
13
13
  s.description = "Gem that interfaces with PostageApp.com service to send emails from web apps"
14
14
  s.email = "oleg@twg.ca"
15
15
  s.extra_rdoc_files = [
@@ -77,7 +77,7 @@ Gem::Specification.new do |s|
77
77
  s.homepage = "http://github.com/postageapp/postageapp-ruby"
78
78
  s.licenses = ["MIT"]
79
79
  s.require_paths = ["lib"]
80
- s.rubygems_version = "1.8.10"
80
+ s.rubygems_version = "1.8.23"
81
81
  s.summary = "Easier way to send email from web apps"
82
82
 
83
83
  if s.respond_to? :specification_version then
@@ -51,6 +51,7 @@ class Notifier < PostageApp::Mailer
51
51
  })
52
52
  postageapp_template 'test-template'
53
53
  postageapp_variables 'variable' => 'value'
54
+ postageapp_api_key 'custom_api_key'
54
55
  end
55
56
 
56
57
  private
@@ -49,6 +49,7 @@ class Notifier < PostageApp::Mailer
49
49
 
50
50
  postageapp_template 'test-template'
51
51
  postageapp_variables 'variable' => 'value'
52
+ postageapp_api_key 'custom_api_key'
52
53
 
53
54
  mail(
54
55
  :from => 'test@test.test',
@@ -60,35 +61,6 @@ class Notifier < PostageApp::Mailer
60
61
  )
61
62
  end
62
63
 
63
- def with_old_api
64
- from 'test@test.test'
65
- subject 'Test Email'
66
- recipients 'test@test.test'
67
- end
68
-
69
- def with_old_api_and_manual_parts
70
- from 'test@test.test'
71
- subject 'Test Email'
72
-
73
- headers ({'custom_header' => 'value'})
74
-
75
- recipients ({
76
- 'test1@test.test' => { 'name' => 'Test 1' },
77
- 'test2@test.test' => { 'name' => 'Test 2' }
78
- })
79
-
80
- part :content_type => 'text/html',
81
- :body => 'html content'
82
- part :content_type => 'text/plain',
83
- :body => 'text content'
84
- attachment :content_type => 'image/jpeg',
85
- :filename => 'foo.jpg',
86
- :body => '123456789'
87
-
88
- postageapp_template 'test-template'
89
- postageapp_variables 'variable' => 'value'
90
- end
91
-
92
64
  private
93
65
 
94
66
  def headers_hash(options = {})
@@ -68,6 +68,7 @@ class Mailer2Test < Test::Unit::TestCase
68
68
  def test_create_with_custom_postage_variables
69
69
  assert mail = Notifier.create_with_custom_postage_variables
70
70
  assert_equal 'test-template', mail.arguments['template']
71
+ assert_equal 'custom_api_key', mail.arguments['api_key']
71
72
  assert_equal ({ 'variable' => 'value' }), mail.arguments['variables']
72
73
  assert_equal ({ 'test2@test.text' => { 'name' => 'Test 2'},
73
74
  'test1@test.text' => { 'name' => 'Test 1'}}), mail.arguments['recipients']
@@ -64,36 +64,13 @@ class Mailer3Test < Test::Unit::TestCase
64
64
  }), mail.arguments['recipients']
65
65
  assert_equal 'test-template', mail.arguments['template']
66
66
  assert_equal ({ 'variable' => 'value' }), mail.arguments['variables']
67
+ assert_equal 'custom_api_key', mail.arguments['api_key']
67
68
  assert_equal 'CustomValue1', mail.arguments['headers']['CustomHeader1']
68
69
  assert_equal 'CustomValue2', mail.arguments['headers']['CustomHeader2']
69
70
  assert_equal 'text content', mail.arguments['content']['text/plain']
70
71
  assert_equal 'html content', mail.arguments['content']['text/html']
71
72
  end
72
73
 
73
- def test_create_with_old_api
74
- mail = Notifier.with_old_api
75
- assert_equal 'test@test.test', mail.arguments['headers']['from']
76
- assert_equal 'Test Email', mail.arguments['headers']['subject']
77
- assert_equal 'test@test.test', mail.arguments['recipients']
78
- assert_equal 'html content', mail.arguments['content']['text/html']
79
- assert_equal 'text content', mail.arguments['content']['text/plain']
80
- end
81
-
82
- def test_create_with_old_api_and_manual_parts
83
- mail = Notifier.with_old_api_and_manual_parts
84
- assert_equal ({
85
- 'test2@test.test' => { 'name' => 'Test 2'},
86
- 'test1@test.test' => { 'name' => 'Test 1'}
87
- }), mail.arguments['recipients']
88
- assert_equal 'test@test.test', mail.arguments['headers']['from']
89
- assert_equal 'Test Email', mail.arguments['headers']['subject']
90
- assert_equal 'value', mail.arguments['headers']['custom_header']
91
- assert_equal 'html content', mail.arguments['content']['text/html']
92
- assert_equal 'text content', mail.arguments['content']['text/plain']
93
- assert_equal 'image/jpeg', mail.arguments['attachments']['foo.jpg']['content_type']
94
- assert_equal "MTIzNDU2Nzg5\n", mail.arguments['attachments']['foo.jpg']['content']
95
- end
96
-
97
74
  def test_create_with_recipient_override
98
75
  PostageApp.configuration.recipient_override = 'oleg@test.test'
99
76
  assert mail = Notifier.with_html_and_text_views
data/test/request_test.rb CHANGED
@@ -57,6 +57,14 @@ class RequestTest < Test::Unit::TestCase
57
57
  assert_equal ({:data => 'value'}), request.arguments
58
58
  end
59
59
 
60
+ def test_api_key
61
+ request = PostageApp::Request.new(:test_method)
62
+ assert_equal PostageApp.configuration.api_key, request.api_key
63
+
64
+ request = PostageApp::Request.new(:test_method, {:api_key => 'custom_api_key'})
65
+ assert_equal 'custom_api_key', request.api_key
66
+ end
67
+
60
68
  def test_send
61
69
  mock_successful_send
62
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postageapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-15 00:00:00.000000000Z
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70110451984120 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70110451984120
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: jeweler
27
- requirement: &70110451982980 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70110451982980
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Gem that interfaces with PostageApp.com service to send emails from web
37
47
  apps
38
48
  email: oleg@twg.ca
@@ -113,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
123
  version: '0'
114
124
  segments:
115
125
  - 0
116
- hash: 2753693682518228981
126
+ hash: 2813224235193032805
117
127
  required_rubygems_version: !ruby/object:Gem::Requirement
118
128
  none: false
119
129
  requirements:
@@ -122,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
132
  version: '0'
123
133
  requirements: []
124
134
  rubyforge_project:
125
- rubygems_version: 1.8.10
135
+ rubygems_version: 1.8.23
126
136
  signing_key:
127
137
  specification_version: 3
128
138
  summary: Easier way to send email from web apps