govdelivery-tms 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +8 -8
  3. data/govdelivery-tms.gemspec +2 -2
  4. data/lib/{govdelivery-tms → govdelivery/tms}/base.rb +4 -4
  5. data/lib/{govdelivery-tms → govdelivery/tms}/client.rb +9 -9
  6. data/lib/{govdelivery-tms → govdelivery/tms}/collection_resource.rb +2 -2
  7. data/lib/{govdelivery-tms → govdelivery/tms}/connection.rb +4 -4
  8. data/lib/{govdelivery-tms → govdelivery/tms}/errors.rb +1 -1
  9. data/lib/govdelivery/tms/instance_resource.rb +219 -0
  10. data/lib/{govdelivery-tms → govdelivery/tms}/link_header.rb +0 -0
  11. data/lib/{govdelivery-tms → govdelivery/tms}/logger.rb +1 -1
  12. data/lib/{govdelivery-tms → govdelivery/tms}/mail/delivery_method.rb +11 -11
  13. data/lib/govdelivery/tms/resource/collections.rb +98 -0
  14. data/lib/{govdelivery-tms → govdelivery/tms}/resource/command.rb +7 -7
  15. data/lib/{govdelivery-tms → govdelivery/tms}/resource/command_action.rb +1 -1
  16. data/lib/{govdelivery-tms → govdelivery/tms}/resource/command_type.rb +1 -1
  17. data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_message.rb +1 -1
  18. data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient.rb +1 -1
  19. data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient_click.rb +1 -1
  20. data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient_open.rb +1 -1
  21. data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_template.rb +1 -1
  22. data/lib/{govdelivery-tms → govdelivery/tms}/resource/from_address.rb +1 -1
  23. data/lib/{govdelivery-tms → govdelivery/tms}/resource/inbound_sms_message.rb +1 -1
  24. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_acknowledgement.rb +1 -1
  25. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_alert.rb +1 -1
  26. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_category.rb +1 -1
  27. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_cog_profile.rb +1 -1
  28. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_event_code.rb +1 -1
  29. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_area.rb +1 -1
  30. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_authorization.rb +1 -1
  31. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_auxilary_data.rb +1 -1
  32. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_response_type.rb +1 -1
  33. data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_static_resource.rb +2 -2
  34. data/lib/{govdelivery-tms → govdelivery/tms}/resource/keyword.rb +1 -1
  35. data/lib/{govdelivery-tms → govdelivery/tms}/resource/recipient.rb +1 -1
  36. data/lib/{govdelivery-tms → govdelivery/tms}/resource/sms_message.rb +1 -1
  37. data/lib/{govdelivery-tms → govdelivery/tms}/resource/webhook.rb +1 -1
  38. data/lib/{govdelivery-tms → govdelivery/tms}/util/core_ext.rb +1 -1
  39. data/lib/{govdelivery-tms → govdelivery/tms}/util/hal_link_parser.rb +2 -2
  40. data/lib/govdelivery/tms/version.rb +5 -0
  41. data/lib/govdelivery-tms/instance_resource.rb +7 -7
  42. data/lib/govdelivery-tms.rb +38 -36
  43. data/spec/client_spec.rb +18 -18
  44. data/spec/command_types_spec.rb +6 -6
  45. data/spec/email_message_spec.rb +58 -58
  46. data/spec/email_template_spec.rb +39 -39
  47. data/spec/errors_spec.rb +3 -3
  48. data/spec/from_address_spec.rb +22 -22
  49. data/spec/inbound_sms_messages_spec.rb +5 -5
  50. data/spec/instance_resource_spec.rb +14 -14
  51. data/spec/ipaws_acknowledgement_spec.rb +6 -6
  52. data/spec/ipaws_alerts_spec.rb +31 -31
  53. data/spec/ipaws_cog_profile_spec.rb +26 -26
  54. data/spec/ipaws_event_codes_spec.rb +5 -5
  55. data/spec/ipaws_nwem_areas_spec.rb +22 -22
  56. data/spec/ipaws_nwem_authorization_spec.rb +6 -6
  57. data/spec/keyword_spec.rb +23 -23
  58. data/spec/keywords_spec.rb +5 -5
  59. data/spec/mail/delivery_method_spec.rb +19 -19
  60. data/spec/sms_message_spec.rb +29 -29
  61. data/spec/sms_messages_spec.rb +7 -7
  62. data/spec/spec_helper.rb +2 -3
  63. data/spec/tms_spec.rb +2 -2
  64. metadata +50 -41
  65. checksums.yaml +0 -15
  66. data/lib/govdelivery-tms/resource/collections.rb +0 -98
  67. data/lib/govdelivery-tms/version.rb +0 -3
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  group :development, :test do
5
5
  gem "appraisal"
6
- gem 'rspec', '~> 2.99'
6
+ gem 'rspec', '~> 3.2.0'
7
7
  gem 'rspec-its'
8
8
  gem 'rake'
9
9
  gem 'redcarpet', :platform => :ruby
data/README.md CHANGED
@@ -21,11 +21,11 @@ $ gem install govdelivery-tms
21
21
 
22
22
  Connecting
23
23
  ----------
24
- Loading an instance of `TMS::Client` will automatically connect to the API to query the available resources for your account.
24
+ Loading an instance of `GovDelivery::TMS::Client` will automatically connect to the API to query the available resources for your account.
25
25
 
26
26
  ```ruby
27
27
  # default api root endpoint is https://tms.govdelivery.com
28
- client = TMS::Client.new('auth_token', :api_root => 'https://stage-tms.govdelivery.com')
28
+ client = GovDelivery::TMS::Client.new('auth_token', :api_root => 'https://stage-tms.govdelivery.com')
29
29
  ```
30
30
 
31
31
  Messages
@@ -51,13 +51,13 @@ message.post # true
51
51
  message.recipients.collection.detect{|r| r.errors } # {"phone"=>["is not a number"]}
52
52
  # save succeeded, but we have one bad recipient
53
53
  message.href # "/messages/sms/87"
54
- message.get # <TMS::SmsMessage href=/messages/sms/87 attributes={...}>
54
+ message.get # <GovDelivery::TMS::SmsMessage href=/messages/sms/87 attributes={...}>
55
55
  ```
56
56
 
57
57
  ### Retrieving Inbound SMS Messages
58
58
  ```ruby
59
- client.inbound_sms_messages.get # <TMS::InboundSmsMessages href=/inbound/sms attributes={...}>
60
- inbound_sms = client.inbound_sms_messages.collection.first # <TMS::InboundSmsMessage href=/inbound/sms/10041 attributes={...}>
59
+ client.inbound_sms_messages.get # <GovDelivery::TMS::InboundSmsMessages href=/inbound/sms attributes={...}>
60
+ inbound_sms = client.inbound_sms_messages.collection.first # <GovDelivery::TMS::InboundSmsMessage href=/inbound/sms/10041 attributes={...}>
61
61
  inbound_sms.to # "+15559999999"
62
62
  inbound_sms.from # "+15005550006"
63
63
  inbound_sms.attributes # {:from=>"+15005550006", :to=>"+15559999999", :body=>"test", :command_status=>"success", :keyword_response=>"kwidjebo", :created_at=>"2014-11-05T17:15:01Z"}
@@ -76,7 +76,7 @@ message.post # true
76
76
  message.recipients.collection.detect{|r| r.errors } # {"email"=>["can't be blank"]}
77
77
  # save succeeded, but we have one bad recipient
78
78
  message.href # "/messages/email/87"
79
- message.get # <TMS::EmailMessage href=/messages/email/88 attributes={...}>
79
+ message.get # <GovDelivery::TMS::EmailMessage href=/messages/email/88 attributes={...}>
80
80
  ```
81
81
 
82
82
  #### Sending an Email with Macros
@@ -256,11 +256,11 @@ Logging
256
256
 
257
257
  Any instance of a [Logger](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html "Ruby Logger")-like class can be passed in to the client; incoming and outgoing request information will then be logged to that instance.
258
258
 
259
- The example below configures `TMS::Client` to log to `STDOUT`:
259
+ The example below configures `GovDelivery::TMS::Client` to log to `STDOUT`:
260
260
 
261
261
  ```ruby
262
262
  logger = Logger.new(STDOUT)
263
- client = TMS::Client.new('auth_token', :logger => logger)
263
+ client = GovDelivery::TMS::Client.new('auth_token', :logger => logger)
264
264
  ```
265
265
 
266
266
  ActionMailer integration
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "govdelivery-tms/version"
3
+ require "govdelivery/tms/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "govdelivery-tms"
7
- s.version = TMS::VERSION
7
+ s.version = GovDelivery::TMS::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["GovDelivery"]
10
10
  s.email = ["support@govdelivery.com"]
@@ -1,11 +1,11 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  module Base
3
3
  def self.included(base)
4
- base.send(:include, TMS::Util::HalLinkParser)
4
+ base.send(:include, GovDelivery::TMS::Util::HalLinkParser)
5
5
  base.extend(ClassMethods)
6
6
  base.send(:include, InstanceMethods)
7
- base.send(:include, TMS::CoreExt)
8
- base.send(:extend, TMS::CoreExt)
7
+ base.send(:include, GovDelivery::TMS::CoreExt)
8
+ base.send(:extend, GovDelivery::TMS::CoreExt)
9
9
  end
10
10
 
11
11
  attr_accessor :client, :href, :errors, :new_record
@@ -1,12 +1,12 @@
1
1
  require 'logger'
2
2
  # The client class to connect and talk to the TMS REST API.
3
- class TMS::Client
4
- include TMS::Util::HalLinkParser
5
- include TMS::CoreExt
3
+ class GovDelivery::TMS::Client
4
+ include GovDelivery::TMS::Util::HalLinkParser
5
+ include GovDelivery::TMS::CoreExt
6
6
 
7
7
  attr_accessor :connection, :href, :api_root, :logger
8
8
 
9
- DEFAULTS = {:api_root => 'https://tms.govdelivery.com', :logger => nil}.freeze
9
+ DEFAULTS = {api_root: 'https://tms.govdelivery.com', logger: nil}.freeze
10
10
 
11
11
  # Create a new client and issue a request for the available resources for a given account.
12
12
  #
@@ -30,7 +30,7 @@ class TMS::Client
30
30
  end
31
31
 
32
32
  def connect!(auth_token, options={})
33
- self.connection = TMS::Connection.new({:auth_token => auth_token, :api_root => api_root, :logger => logger}.merge!(options))
33
+ self.connection = GovDelivery::TMS::Connection.new({auth_token: auth_token, api_root: api_root, logger: logger}.merge!(options))
34
34
  end
35
35
 
36
36
  def discover!
@@ -42,11 +42,11 @@ class TMS::Client
42
42
  response = raw_connection.get(href)
43
43
  case response.status
44
44
  when 500..599
45
- raise TMS::Request::Error.new(response.status)
45
+ raise GovDelivery::TMS::Request::Error.new(response.status)
46
46
  when 401..499
47
- raise TMS::Request::Error.new(response.status)
47
+ raise GovDelivery::TMS::Request::Error.new(response.status)
48
48
  when 202
49
- raise TMS::Request::InProgress.new(response.body['message'])
49
+ raise GovDelivery::TMS::Request::InProgress.new(response.body['message'])
50
50
  else
51
51
  return response
52
52
  end
@@ -74,7 +74,7 @@ class TMS::Client
74
74
  when 200...299
75
75
  return response
76
76
  else
77
- raise TMS::Request::Error.new(response.status)
77
+ raise GovDelivery::TMS::Request::Error.new(response.status)
78
78
  end
79
79
  end
80
80
 
@@ -1,10 +1,10 @@
1
- module TMS::CollectionResource
1
+ module GovDelivery::TMS::CollectionResource
2
2
  def self.included(base)
3
3
  base.send(:include, InstanceMethods)
4
4
  end
5
5
 
6
6
  module InstanceMethods
7
- include TMS::Base
7
+ include GovDelivery::TMS::Base
8
8
  attr_accessor :collection
9
9
 
10
10
  def initialize(client, href, items=nil)
@@ -1,4 +1,4 @@
1
- class TMS::Connection
1
+ class GovDelivery::TMS::Connection
2
2
  attr_accessor :auth_token, :api_root, :connection, :logger
3
3
 
4
4
  def get(href)
@@ -18,12 +18,12 @@ class TMS::Connection
18
18
  end
19
19
 
20
20
  def setup_connection
21
- self.connection = Faraday.new(:url => self.api_root) do |faraday|
22
- faraday.use TMS::Logger, self.logger if self.logger
21
+ self.connection = Faraday.new(url: self.api_root) do |faraday|
22
+ faraday.use GovDelivery::TMS::Logger, self.logger if self.logger
23
23
  faraday.request :json
24
24
  faraday.headers['X-AUTH-TOKEN'] = auth_token
25
25
  faraday.headers[:user_agent] = "GovDelivery Ruby TMS::Client #{TMS::VERSION}"
26
- faraday.response :json, :content_type => /\bjson$/
26
+ faraday.response :json, content_type: /\bjson$/
27
27
  faraday.adapter :net_http
28
28
  end
29
29
  end
@@ -1,4 +1,4 @@
1
- module TMS
1
+ module GovDelivery::TMS
2
2
  module Request
3
3
  # The generic TMS error class
4
4
  class Error < StandardError
@@ -0,0 +1,219 @@
1
+ module GovDelivery::TMS::InstanceResource
2
+ def self.included(base)
3
+ base.send(:include, GovDelivery::TMS::Base)
4
+ base.extend(ClassMethods)
5
+ base.send(:include, InstanceMethods)
6
+ end
7
+
8
+ attr_accessor :response
9
+
10
+ module ClassMethods
11
+ ##
12
+ # Writeable attributes are sent on POST/PUT.
13
+ #
14
+ def writeable_attributes(*attrs)
15
+ @writeable_attributes ||= []
16
+ if attrs.any?
17
+ @writeable_attributes.map!(&:to_sym).concat(attrs).uniq! if attrs.any?
18
+ setup_attributes(@writeable_attributes, false)
19
+ end
20
+ @writeable_attributes
21
+ end
22
+
23
+ ##
24
+ # Linkable attributes are sent on POST/PUT.
25
+ #
26
+ def linkable_attributes(*attrs)
27
+ @linkable_attributes ||= []
28
+ if attrs.any?
29
+ @linkable_attributes.map!(&:to_sym).concat(attrs).uniq! if attrs.any?
30
+ end
31
+ @linkable_attributes
32
+ end
33
+
34
+ ##
35
+ # Readonly attributes don't get POSTed.
36
+ # (timestamps are included by default)
37
+ #
38
+ def readonly_attributes(*attrs)
39
+ @readonly_attributes ||= [:created_at, :updated_at, :completed_at]
40
+ if attrs.any?
41
+ @readonly_attributes.map!(&:to_sym).concat(attrs).uniq!
42
+ setup_attributes(@readonly_attributes, true)
43
+ end
44
+ @readonly_attributes
45
+ end
46
+
47
+ ##
48
+ # For collections that are represented as attributes (i.e. inline, no href)
49
+ #
50
+ # @example
51
+ # collection_attributes :recipients
52
+ #
53
+ def collection_attributes(*attrs)
54
+ @collection_attributes ||= []
55
+ if attrs.any?
56
+ @collection_attributes.map!(&:to_sym).concat(attrs).uniq!
57
+ @collection_attributes.each { |a| setup_collection(a) }
58
+ end
59
+ @collection_attributes
60
+ end
61
+
62
+ def custom_class_names
63
+ @custom_class_names ||= {}
64
+ end
65
+
66
+ ##
67
+ # For collections that are represented as attributes (i.e. inline, no href)
68
+ # and that have a class name other than the one we would infer.
69
+ #
70
+ # @example
71
+ # collection_attributes :recipients, 'EmailRecipient'
72
+ #
73
+ def collection_attribute(attr, tms_class)
74
+ @collection_attributes ||= []
75
+ @collection_attributes.push(attr).uniq!
76
+ setup_collection(attr, GovDelivery::TMS.const_get(tms_class))
77
+ end
78
+
79
+ ##
80
+ # Read-only collection attributes don't get POSTed.
81
+ # Use this for collections that are represented as attributes, but cannot be modified.
82
+ #
83
+ # @example
84
+ # readonly_collection_attribute :opens
85
+ #
86
+ def readonly_collection_attribute(attr, tms_class)
87
+ @readonly_collection_attributes ||= []
88
+ @readonly_collection_attributes.push(attr).uniq!
89
+ setup_collection(attr, GovDelivery::TMS.const_get(tms_class))
90
+ end
91
+
92
+ def setup_attributes(attrs, readonly=false)
93
+ attrs.map(&:to_sym).each do |property|
94
+ self.send :define_method, :"#{property}=", &lambda { |v| @attributes[property] = v } unless readonly
95
+ self.send :define_method, property.to_sym, &lambda { @attributes[property] }
96
+ end
97
+ end
98
+
99
+ def setup_collection(property, klass=nil)
100
+ if klass
101
+ custom_class_names[property] = klass
102
+ else
103
+ klass ||= GovDelivery::TMS.const_get(property.to_s.capitalize)
104
+ end
105
+
106
+ self.send :define_method, property.to_sym, &lambda { @attributes[property] ||= klass.new(self.client, nil, nil) }
107
+ end
108
+ end
109
+
110
+ module InstanceMethods
111
+ attr_reader :links
112
+
113
+ def initialize(client, href=nil, attrs=nil)
114
+ super(client, href)
115
+ @attributes = {}
116
+ @links = {}
117
+ set_attributes_from_hash(attrs) if attrs
118
+ end
119
+
120
+ def attributes
121
+ @attributes
122
+ end
123
+
124
+ def get
125
+ raise GovDelivery::TMS::Errors::InvalidGet if self.new_record?
126
+ process_response(client.get(self.href), :get) && self
127
+ end
128
+ alias_method :get!, :get
129
+
130
+ def post
131
+ self.errors = nil
132
+ process_response(client.post(self), :post)
133
+ end
134
+
135
+ def post!
136
+ self.post or raise GovDelivery::TMS::Errors::InvalidPost.new(self)
137
+ end
138
+
139
+ def put
140
+ process_response(client.put(self), :put)
141
+ end
142
+
143
+ def put!
144
+ process_response(client.put(self), :put) or raise GovDelivery::TMS::Errors::InvalidPut.new(self)
145
+ end
146
+
147
+ def delete
148
+ process_response(client.delete(self.href), :delete)
149
+ end
150
+
151
+ def delete!
152
+ process_response(client.delete(self.href), :delete) or raise GovDelivery::TMS::Errors::InvalidDelete.new(self)
153
+ end
154
+
155
+ def to_s
156
+ "<#{self.class.inspect}#{' href=' + self.href if self.href} attributes=#{@attributes.inspect}>"
157
+ end
158
+
159
+ def to_json
160
+ json_hash = {}
161
+ self.class.writeable_attributes.each do |attr|
162
+ json_hash[attr] = self.send(attr)
163
+ end
164
+ self.class.collection_attributes.each do |coll|
165
+ json_hash[coll] = self.send(coll).to_json
166
+ end
167
+ self.class.linkable_attributes.each do |attr|
168
+ json_hash[:_links] ||= {}
169
+ json_hash[:_links][attr] = @links[attr]
170
+ end
171
+ json_hash
172
+ end
173
+
174
+ protected
175
+
176
+ def relation_class(rel)
177
+ self.class.custom_class_names[rel.to_sym] || super
178
+ end
179
+
180
+ def process_response(response, method)
181
+ self.response = response
182
+ error_class = GovDelivery::TMS::Errors.const_get("Invalid#{method.to_s.capitalize}")
183
+ case response.status
184
+ when 204
185
+ return true
186
+ when 200..299
187
+ set_attributes_from_hash(response.body) if response.body.is_a?(Hash)
188
+ @links = {}
189
+ self.new_record=false
190
+ return true
191
+ when 401
192
+ raise error_class.new("401 Not Authorized")
193
+ when 404
194
+ raise(error_class.new("Can't POST to #{self.href}"))
195
+ when 500..599
196
+ raise(GovDelivery::TMS::Errors::ServerError.new(response))
197
+ else # 422?
198
+ if response.body['errors']
199
+ self.errors = response.body['errors']
200
+ end
201
+ end
202
+ return false
203
+ end
204
+
205
+ def set_attributes_from_hash(hash)
206
+ hash.reject { |k, _| k=~/^_/ }.each do |property, value|
207
+ if self.class.collection_attributes.include?(property.to_sym)
208
+ klass = self.class.custom_class_names[property] || GovDelivery::TMS.const_get(property.to_s.capitalize)
209
+ @attributes[property.to_sym] = klass.new(client, nil, value)
210
+ else
211
+ @attributes[property.to_sym] = value
212
+ end
213
+ end
214
+ self.errors = hash['errors']
215
+ parse_links(hash['_links'])
216
+ end
217
+
218
+ end
219
+ end
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class Logger < Faraday::Response::Middleware #:nodoc:
3
3
  extend Forwardable
4
4
 
@@ -1,7 +1,7 @@
1
1
  require 'govdelivery-tms'
2
2
  require 'mail'
3
3
  require 'mail/check_delivery_params'
4
- module TMS
4
+ module GovDelivery::TMS
5
5
  module Mail
6
6
  # Use TMS from the mail gem or ActionMailer as a delivery method.
7
7
  #
@@ -24,7 +24,7 @@ module TMS
24
24
  attr_accessor :settings
25
25
 
26
26
  def deliver!(mail)
27
- raise TMS::Errors::NoRelation.new('email_messages', client) unless client.respond_to?(:email_messages)
27
+ raise GovDelivery::TMS::Errors::NoRelation.new('email_messages', client) unless client.respond_to?(:email_messages)
28
28
 
29
29
  envelope_from = mail.return_path || mail.sender || mail.from_addrs.first
30
30
 
@@ -38,26 +38,26 @@ module TMS
38
38
  end.decoded
39
39
 
40
40
  tms_message = client.email_messages.build(
41
- :from_name => mail[:from].display_names.first,
42
- :subject => mail.subject,
43
- :body => body
41
+ from_name: mail[:from].display_names.first,
42
+ subject: mail.subject,
43
+ body: body
44
44
  )
45
45
 
46
- mail.to.each { |recip| tms_message.recipients.build(:email => recip) }
46
+ mail.to.each { |recip| tms_message.recipients.build(email: recip) }
47
47
  tms_message.post!
48
48
  tms_message
49
49
  end
50
50
 
51
51
  def client
52
- @client ||= TMS::Client.new(settings[:auth_token], settings)
52
+ @client ||= GovDelivery::TMS::Client.new(settings[:auth_token], settings)
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
58
  if defined?(ActionMailer)
59
- ActionMailer::Base.add_delivery_method :govdelivery_tms, TMS::Mail::DeliveryMethod, {
60
- :auth_token => nil,
61
- :logger => ActionMailer::Base.logger,
62
- :api_root => TMS::Client::DEFAULTS[:api_root]}
59
+ ActionMailer::Base.add_delivery_method :govdelivery_tms, GovDelivery::TMS::Mail::DeliveryMethod, {
60
+ auth_token: nil,
61
+ logger: ActionMailer::Base.logger,
62
+ api_root: GovDelivery::TMS::Client::DEFAULTS[:api_root]}
63
63
  end
@@ -0,0 +1,98 @@
1
+ class GovDelivery::TMS::Emails
2
+ include GovDelivery::TMS::CollectionResource
3
+ end
4
+
5
+ class GovDelivery::TMS::SmsMessages
6
+ include GovDelivery::TMS::CollectionResource
7
+ end
8
+
9
+ class GovDelivery::TMS::EmailMessages
10
+ include GovDelivery::TMS::CollectionResource
11
+ end
12
+
13
+ class GovDelivery::TMS::Recipients
14
+ include GovDelivery::TMS::CollectionResource
15
+ end
16
+
17
+ class GovDelivery::TMS::EmailRecipients
18
+ include GovDelivery::TMS::CollectionResource
19
+ end
20
+
21
+ class GovDelivery::TMS::EmailRecipientOpens
22
+ include GovDelivery::TMS::CollectionResource
23
+ end
24
+
25
+ class GovDelivery::TMS::EmailRecipientClicks
26
+ include GovDelivery::TMS::CollectionResource
27
+ end
28
+
29
+ # A collection of Keyword objects.
30
+ #
31
+ # @example
32
+ # keywords = client.keywords.get
33
+ #
34
+ class GovDelivery::TMS::Keywords
35
+ include GovDelivery::TMS::CollectionResource
36
+ end
37
+
38
+ class GovDelivery::TMS::InboundSmsMessages
39
+ include GovDelivery::TMS::CollectionResource
40
+ end
41
+
42
+ # A collection of CommandType instances.
43
+ # This resource changes infrequently. It may be used to dynamically construct a
44
+ # user interface for configuring arbitrary SMS keywords for an account.
45
+ #
46
+ # This resource is read-only.
47
+ #
48
+ # @example
49
+ # client.command_types.get
50
+ # client.command_types.collection.each {|at| ... }
51
+ class GovDelivery::TMS::CommandTypes
52
+ include GovDelivery::TMS::CollectionResource
53
+ end
54
+
55
+ class GovDelivery::TMS::Commands
56
+ include GovDelivery::TMS::CollectionResource
57
+ end
58
+
59
+ class GovDelivery::TMS::CommandActions
60
+ include GovDelivery::TMS::CollectionResource
61
+ end
62
+
63
+ class GovDelivery::TMS::IpawsEventCodes
64
+ include GovDelivery::TMS::CollectionResource
65
+ end
66
+
67
+ class GovDelivery::TMS::IpawsCategories
68
+ include GovDelivery::TMS::CollectionResource
69
+ end
70
+
71
+ class GovDelivery::TMS::IpawsResponseTypes
72
+ include GovDelivery::TMS::CollectionResource
73
+ end
74
+
75
+ class GovDelivery::TMS::IpawsAlerts
76
+ include GovDelivery::TMS::CollectionResource
77
+ end
78
+
79
+ class GovDelivery::TMS::IpawsNwemAreas
80
+ include GovDelivery::TMS::CollectionResource
81
+ end
82
+
83
+ class GovDelivery::TMS::Webhooks
84
+ include GovDelivery::TMS::CollectionResource
85
+ end
86
+
87
+ # A collection of Email Template objects.
88
+ #
89
+ # @example
90
+ # email_template = client.email_template.get
91
+ #
92
+ class GovDelivery::TMS::EmailTemplates
93
+ include GovDelivery::TMS::CollectionResource
94
+ end
95
+
96
+ class GovDelivery::TMS::FromAddresses
97
+ include GovDelivery::TMS::CollectionResource
98
+ end
@@ -1,11 +1,11 @@
1
- module TMS #:nodoc:
2
- # A command is a combination of behavior and parameters that should be executed
1
+ module GovDelivery::TMS #:nodoc:
2
+ # A command is a combination of behavior and parameters that should be executed
3
3
  # when an incoming SMS message matches the associated Keyword.
4
4
  #
5
- # @attr name [String] The name of the command. This will default to the command_type if not supplied.
6
- # @attr command_type [String] The type of this command. A list of valid types can be found by querying the CommandType list.
7
- # @attr params [Hash] A Hash of string/string pairs used as configuration for this command.
8
- #
5
+ # @attr name [String] The name of the command. This will default to the command_type if not supplied.
6
+ # @attr command_type [String] The type of this command. A list of valid types can be found by querying the CommandType list.
7
+ # @attr params [Hash] A Hash of string/string pairs used as configuration for this command.
8
+ #
9
9
  # @example
10
10
  # command = keyword.commands.build(:name => "subscribe to news", :command_type => "dcm_subscribe", :dcm_account_code => "NEWS", :dcm_topic_codes => "NEWS_1, NEWS_2")
11
11
  # command.post
@@ -17,7 +17,7 @@ module TMS #:nodoc:
17
17
 
18
18
  # @!parse attr_accessor :name, :command_type, :params
19
19
  writeable_attributes :name, :command_type, :params
20
-
20
+
21
21
  # @!parse attr_reader :created_at, :updated_at
22
22
  readonly_attributes :created_at, :updated_at
23
23
 
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  # CommandAction object represent the results of Commands for a particular input (e.g. an incoming SMS message)
3
3
  #
4
4
  # This resource is read-only.
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  # CommandType is a pair of values (name, string_fields, array_fields) that can be attached
3
3
  # to a Keyword (in a Command object).
4
4
  #
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  # An EmailMessage is used to create and send a email to a collection of EmailRecipient
3
3
  # objects. Certain metrics are available after the email is sent, including
4
4
  # the collection of recipients who clicked or opened the email.
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  # An EmailRecipient is used in conjunction with an EmailMessage to send email.
3
3
  #
4
4
  # @attr email [String] The recipient email address
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class EmailRecipientClick
3
3
  include InstanceResource
4
4
 
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class EmailRecipientOpen
3
3
  include InstanceResource
4
4
 
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class EmailTemplate
3
3
  include InstanceResource
4
4
 
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class FromAddress
3
3
  include InstanceResource
4
4
 
@@ -1,4 +1,4 @@
1
- module TMS #:nodoc:
1
+ module GovDelivery::TMS #:nodoc:
2
2
  class InboundSmsMessage
3
3
  include InstanceResource
4
4
 
@@ -1,4 +1,4 @@
1
- module TMS
1
+ module GovDelivery::TMS
2
2
  class IpawsAcknowledgement
3
3
 
4
4
  include InstanceResource
@@ -1,4 +1,4 @@
1
- module TMS
1
+ module GovDelivery::TMS
2
2
  class IpawsAlert
3
3
 
4
4
  include InstanceResource