govdelivery-tms 0.8.5 → 0.8.7

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: 520742183591839f3f51140b34e2d96e740c1171
4
- data.tar.gz: f9ceb6d7d7fbd7a0ebb12ed4a9a16cc08e0c7833
3
+ metadata.gz: a7269ba85a59ca7423d2c9cd28d18fa4a3506bd1
4
+ data.tar.gz: 199987cd9eb5fcd4151d35d795342df16f28bd5c
5
5
  SHA512:
6
- metadata.gz: 5db5dc48b49fc4f8ac19e031eebe91bb2fed6819a58c97935136f226c4e04141b59acf2e84b148b329d8e9d0d462f52ff46936d0165d9769afb0a873af2c0877
7
- data.tar.gz: 81e2c0be20ad23096cd623b852e557545e37edcbe1ec7db633c81fda9b9f46794771cbe583a85abd0bc1ed26610a5bf96b89094788bd907ca16ccfa4bbca52c1
6
+ metadata.gz: ef42c0a9d0d7d3b5a695e30c7ad4e60c20dc7e6c29caa4e6e13badd8b68e3a7c31270773a76a8c2293adfce9acf23af8ee27ced70f94da0f0d39f308c23505b6
7
+ data.tar.gz: c70613ea0c76272620f62253bf4d34f0fc7c819e85415c8b0931acebc963cb469f789dfe7b27e4350a4ded0e727c7db41891f2794c616a1decc46442e0e11851
@@ -162,11 +162,11 @@ module GovDelivery::TMS::InstanceResource
162
162
  self.class.collection_attributes.each do |coll|
163
163
  json_hash[coll] = send(coll).to_json
164
164
  end
165
- self.class.linkable_attributes.each do |attr|
166
- json_hash[:_links] ||= {}
165
+ self.class.linkable_attributes.reject { |attr| @links[attr].nil? }.each do |attr|
166
+ json_hash[:_links] ||= {}
167
167
  json_hash[:_links][attr] = @links[attr]
168
168
  end
169
- json_hash
169
+ json_hash.reject { |_, value| value.nil? }
170
170
  end
171
171
 
172
172
  protected
@@ -28,12 +28,12 @@ module GovDelivery::TMS
28
28
  fail GovDelivery::TMS::Errors::NoRelation.new('email_messages', client) unless client.respond_to?(:email_messages)
29
29
 
30
30
  body = case
31
- when mail.html_part
32
- mail.html_part.body
33
- when mail.text_part
34
- mail.text_part.body
35
- else
36
- mail.body
31
+ when mail.html_part
32
+ mail.html_part.body
33
+ when mail.text_part
34
+ mail.text_part.body
35
+ else
36
+ mail.body
37
37
  end.decoded
38
38
 
39
39
  message_params = {
@@ -45,7 +45,6 @@ module GovDelivery::TMS
45
45
 
46
46
  tms_message = client.email_messages.build(message_params)
47
47
 
48
-
49
48
  mail.to.each { |recip| tms_message.recipients.build(email: recip) }
50
49
  tms_message.post!
51
50
  tms_message
@@ -60,6 +59,6 @@ end
60
59
 
61
60
  if defined?(ActionMailer)
62
61
  ActionMailer::Base.add_delivery_method :govdelivery_tms, GovDelivery::TMS::Mail::DeliveryMethod, auth_token: nil,
63
- logger: ActionMailer::Base.logger,
64
- api_root: GovDelivery::TMS::Client::DEFAULTS[:api_root]
62
+ logger: ActionMailer::Base.logger,
63
+ api_root: GovDelivery::TMS::Client::DEFAULTS[:api_root]
65
64
  end
@@ -76,5 +76,7 @@ module GovDelivery::TMS #:nodoc:
76
76
  ##
77
77
  # A CollectionResource of EmailRecipients that failed, not neccessarily bounced
78
78
  collection_attribute :failed, 'EmailRecipients'
79
+
80
+ linkable_attributes :email_template
79
81
  end
80
82
  end
@@ -7,7 +7,7 @@ module GovDelivery::TMS #:nodoc:
7
7
 
8
8
  linkable_attributes :from_address
9
9
 
10
- # @!parse attr_reader :created_at
10
+ # @!parse attr_reader :id, :created_at
11
11
  readonly_attributes :id, :created_at
12
12
 
13
13
  collection_attribute :from_address, 'FromAddress'
@@ -5,6 +5,7 @@ module GovDelivery::TMS #:nodoc:
5
5
  # @!parse attr_accessor :from_email, :reply_to_email, :bounce_email, :is_default
6
6
  writeable_attributes :from_email, :reply_to_email, :bounce_email, :is_default
7
7
 
8
- readonly_attributes :created_at
8
+ # @!parse attr_reader :id, :created_at
9
+ readonly_attributes :id, :created_at
9
10
  end
10
11
  end
@@ -1,5 +1,5 @@
1
1
  module GovDelivery
2
2
  module TMS #:nodoc:
3
- VERSION = '0.8.5'
3
+ VERSION = '0.8.7'
4
4
  end
5
5
  end
@@ -79,13 +79,15 @@ describe GovDelivery::TMS::EmailMessage do
79
79
  @message = GovDelivery::TMS::EmailMessage.new(client, '/messages/99', {})
80
80
  end
81
81
  it 'should GET cleanly' do
82
- response = { body: 'processed',
83
- subject: 'hey',
84
- from_email: 'eric@evotest.govdelivery.com',
85
- errors_to: 'errors@evotest.govdelivery.com',
86
- reply_to: 'replyto@evotest.govdelivery.com',
87
- recipients: [{ email: 'billy@evotest.govdelivery.com' }],
88
- created_at: 'time' }
82
+ response = { 'body' => 'processed',
83
+ 'subject' => 'hey',
84
+ 'from_email' => 'eric@evotest.govdelivery.com',
85
+ 'errors_to' => 'errors@evotest.govdelivery.com',
86
+ 'reply_to' => 'replyto@evotest.govdelivery.com',
87
+ 'recipients' => [{ email: 'billy@evotest.govdelivery.com' }],
88
+ 'created_at' => 'time',
89
+ '_links' => { 'self' => '/messages/email/1', 'email_template' => '/templates/email/1' }
90
+ }
89
91
  expect(@message.client).to receive('get').with(@message.href).and_return(double('response', status: 200, body: response))
90
92
  @message.get
91
93
  expect(@message.body).to eq('processed')
@@ -94,6 +96,7 @@ describe GovDelivery::TMS::EmailMessage do
94
96
  expect(@message.reply_to).to eq('replyto@evotest.govdelivery.com')
95
97
  expect(@message.errors_to).to eq('errors@evotest.govdelivery.com')
96
98
  expect(@message.created_at).to eq('time')
99
+ expect(@message.email_template).to be_a(GovDelivery::TMS::EmailTemplate)
97
100
  end
98
101
  end
99
102
  end
@@ -56,7 +56,7 @@ describe GovDelivery::TMS::EmailTemplate do
56
56
  expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 201, body: {}))
57
57
  @template.post
58
58
  links = @template.to_json[:_links]
59
- expect(links[:from_address]).to be_nil
59
+ expect(links).to be_nil
60
60
  end
61
61
 
62
62
  it 'should not clear the links property after an invalid post' do
@@ -15,6 +15,7 @@ describe GovDelivery::TMS::FromAddress do
15
15
  'reply_to_email' => 'something@evotest.govdelivery.com',
16
16
  'bounce_email' => 'something@evotest.govdelivery.com',
17
17
  'is_default' => true,
18
+ 'id' => '1',
18
19
  'created_at' => 'sometime',
19
20
  '_links' => { 'self' => '/from_addresses/1' }
20
21
  }]
@@ -30,6 +30,11 @@ describe GovDelivery::TMS::InstanceResource do
30
30
  expect(@instance_resource.shah.class).to eq(GovDelivery::TMS::EmailMessage)
31
31
  end
32
32
 
33
+ it 'should ignore nils in to_json' do
34
+ @instance_resource.bar = nil
35
+ expect(@instance_resource.to_json).to eq({blah: {recipients: [], opened: [], clicked: [], sent: [], failed: []}})
36
+ end
37
+
33
38
  it 'should not GET on initialization' do
34
39
  expect(client).not_to receive(:get)
35
40
  Foo.new(client, 'https://example.com/foos/1')
@@ -13,22 +13,22 @@ describe GovDelivery::TMS::Mail::DeliveryMethod do
13
13
  end
14
14
 
15
15
  context 'a basic Mail::Message with all options' do
16
- let(:mail) {
16
+ let(:mail) do
17
17
  Mail.new do
18
18
  subject 'hi'
19
19
  from '"My mom" <my@mom.com>'
20
20
  to '"A Nice Fellow" <tyler@sink.govdelivery.com>'
21
21
  body '<blink>HI</blink>'
22
22
  end
23
- }
23
+ end
24
24
 
25
25
  it 'should get sent' do
26
26
  expect(email_messages).to receive(:build).with(
27
- from_name: mail[:from].display_names.first,
28
- from_email: mail.from.first,
29
- subject: mail.subject,
30
- body: '<blink>HI</blink>'
31
- ).and_return(tms_message)
27
+ from_name: mail[:from].display_names.first,
28
+ from_email: mail.from.first,
29
+ subject: mail.subject,
30
+ body: '<blink>HI</blink>'
31
+ ).and_return(tms_message)
32
32
  expect(tms_message).to receive(:post!).and_return(true)
33
33
 
34
34
  subject.deliver!(mail)
@@ -36,27 +36,27 @@ describe GovDelivery::TMS::Mail::DeliveryMethod do
36
36
  end
37
37
 
38
38
  context 'a basic Mail::Message with minimal options' do
39
- let(:mail) {
39
+ let(:mail) do
40
40
  Mail.new do
41
41
  subject 'hi'
42
42
  to '"A Nice Fellow" <tyler@sink.govdelivery.com>'
43
43
  body '<blink>HI</blink>'
44
44
  end
45
- }
45
+ end
46
46
 
47
47
  it 'should get sent' do
48
48
  expect(email_messages).to receive(:build).with(
49
- subject: mail.subject,
50
- body: '<blink>HI</blink>'
51
- ).and_return(tms_message)
49
+ subject: mail.subject,
50
+ body: '<blink>HI</blink>'
51
+ ).and_return(tms_message)
52
52
  expect(tms_message).to receive(:post!).and_return(true)
53
53
 
54
54
  subject.deliver!(mail)
55
55
  end
56
56
  end
57
57
 
58
- context "a multipart Mail::Message" do
59
- let(:mail) {
58
+ context 'a multipart Mail::Message' do
59
+ let(:mail) do
60
60
  Mail.new do
61
61
  subject 'hi'
62
62
  from '"My mom" <my@mom.com>'
@@ -67,15 +67,15 @@ describe GovDelivery::TMS::Mail::DeliveryMethod do
67
67
  body '<blink>HTML</blink>'
68
68
  end
69
69
  end
70
- }
70
+ end
71
71
 
72
72
  it 'should send' do
73
73
  expect(email_messages).to receive(:build).with(
74
- from_name: mail[:from].display_names.first,
75
- from_email: mail.from.first,
76
- subject: mail.subject,
77
- body: '<blink>HTML</blink>'
78
- ).and_return(tms_message)
74
+ from_name: mail[:from].display_names.first,
75
+ from_email: mail.from.first,
76
+ subject: mail.subject,
77
+ body: '<blink>HTML</blink>'
78
+ ).and_return(tms_message)
79
79
  expect(tms_message).to receive(:post!).and_return(true)
80
80
 
81
81
  subject.deliver!(mail)
metadata CHANGED
@@ -1,60 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govdelivery-tms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - GovDelivery
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
15
20
  requirement: !ruby/object:Gem::Requirement
16
21
  requirements:
17
- - - ">="
22
+ - - '>='
18
23
  - !ruby/object:Gem::Version
19
24
  version: '0'
20
- type: :runtime
21
25
  prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
22
29
  version_requirements: !ruby/object:Gem::Requirement
23
30
  requirements:
24
- - - ">="
31
+ - - '>='
25
32
  - !ruby/object:Gem::Version
26
33
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: faraday
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
- - - ">="
36
+ - - '>='
32
37
  - !ruby/object:Gem::Version
33
38
  version: '0'
34
- type: :runtime
35
39
  prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
36
43
  version_requirements: !ruby/object:Gem::Requirement
37
44
  requirements:
38
- - - ">="
45
+ - - '>='
39
46
  - !ruby/object:Gem::Version
40
47
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - ">="
50
+ - - '>='
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0'
48
- type: :runtime
49
53
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description: "A reference implementation, written in Ruby,\n to
56
- interact with GovDelivery's TMS API. The client is\n compatible
57
- with Ruby 1.9 and 2.0. "
54
+ type: :runtime
55
+ description: "A reference implementation, written in Ruby,\n to\
56
+ \ interact with GovDelivery's TMS API. The client is\n compatible\
57
+ \ with Ruby 1.9 and 2.0. "
58
58
  email:
59
59
  - support@govdelivery.com
60
60
  executables: []
@@ -74,6 +74,7 @@ files:
74
74
  - lib/govdelivery/tms/instance_resource.rb
75
75
  - lib/govdelivery/tms/link_header.rb
76
76
  - lib/govdelivery/tms/logger.rb
77
+ - lib/govdelivery/tms/version.rb
77
78
  - lib/govdelivery/tms/mail/delivery_method.rb
78
79
  - lib/govdelivery/tms/resource/collections.rb
79
80
  - lib/govdelivery/tms/resource/command.rb
@@ -92,7 +93,6 @@ files:
92
93
  - lib/govdelivery/tms/resource/webhook.rb
93
94
  - lib/govdelivery/tms/util/core_ext.rb
94
95
  - lib/govdelivery/tms/util/hal_link_parser.rb
95
- - lib/govdelivery/tms/version.rb
96
96
  - spec/client_spec.rb
97
97
  - spec/command_types_spec.rb
98
98
  - spec/email_message_spec.rb
@@ -111,24 +111,24 @@ files:
111
111
  homepage: http://govdelivery.com
112
112
  licenses: []
113
113
  metadata: {}
114
- post_install_message:
114
+ post_install_message:
115
115
  rdoc_options: []
116
116
  require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">="
125
+ - - '>='
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.4.5
131
- signing_key:
129
+ rubyforge_project:
130
+ rubygems_version: 2.1.9
131
+ signing_key:
132
132
  specification_version: 4
133
133
  summary: A ruby client to interact with the GovDelivery TMS REST API.
134
134
  test_files:
@@ -147,4 +147,4 @@ test_files:
147
147
  - spec/sms_messages_spec.rb
148
148
  - spec/spec_helper.rb
149
149
  - spec/tms_spec.rb
150
- has_rdoc:
150
+ has_rdoc: