govdelivery-tms 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -5
  3. data/README.md +0 -32
  4. data/Rakefile +4 -6
  5. data/govdelivery-tms.gemspec +15 -15
  6. data/lib/govdelivery-tms.rb +0 -9
  7. data/lib/govdelivery/tms/base.rb +4 -6
  8. data/lib/govdelivery/tms/client.rb +15 -16
  9. data/lib/govdelivery/tms/collection_resource.rb +7 -8
  10. data/lib/govdelivery/tms/connection.rb +4 -4
  11. data/lib/govdelivery/tms/errors.rb +7 -8
  12. data/lib/govdelivery/tms/instance_resource.rb +34 -39
  13. data/lib/govdelivery/tms/link_header.rb +27 -28
  14. data/lib/govdelivery/tms/mail/delivery_method.rb +11 -14
  15. data/lib/govdelivery/tms/resource/collections.rb +0 -20
  16. data/lib/govdelivery/tms/resource/command.rb +1 -2
  17. data/lib/govdelivery/tms/resource/command_action.rb +1 -1
  18. data/lib/govdelivery/tms/resource/command_type.rb +8 -9
  19. data/lib/govdelivery/tms/resource/email_message.rb +0 -1
  20. data/lib/govdelivery/tms/resource/email_recipient.rb +1 -1
  21. data/lib/govdelivery/tms/resource/from_address.rb +1 -1
  22. data/lib/govdelivery/tms/resource/inbound_sms_message.rb +1 -1
  23. data/lib/govdelivery/tms/resource/keyword.rb +6 -7
  24. data/lib/govdelivery/tms/resource/recipient.rb +1 -1
  25. data/lib/govdelivery/tms/resource/sms_message.rb +0 -1
  26. data/lib/govdelivery/tms/util/core_ext.rb +3 -3
  27. data/lib/govdelivery/tms/util/hal_link_parser.rb +11 -12
  28. data/lib/govdelivery/tms/version.rb +1 -1
  29. data/spec/client_spec.rb +6 -6
  30. data/spec/command_types_spec.rb +14 -14
  31. data/spec/email_message_spec.rb +42 -45
  32. data/spec/email_template_spec.rb +49 -51
  33. data/spec/errors_spec.rb +3 -3
  34. data/spec/from_address_spec.rb +37 -36
  35. data/spec/inbound_sms_messages_spec.rb +2 -2
  36. data/spec/instance_resource_spec.rb +4 -6
  37. data/spec/keyword_spec.rb +8 -10
  38. data/spec/keywords_spec.rb +4 -4
  39. data/spec/mail/delivery_method_spec.rb +8 -9
  40. data/spec/sms_message_spec.rb +9 -11
  41. data/spec/sms_messages_spec.rb +3 -3
  42. data/spec/spec_helper.rb +4 -5
  43. data/spec/tms_spec.rb +3 -3
  44. metadata +34 -64
  45. data/lib/govdelivery/tms/resource/ipaws_acknowledgement.rb +0 -9
  46. data/lib/govdelivery/tms/resource/ipaws_alert.rb +0 -38
  47. data/lib/govdelivery/tms/resource/ipaws_category.rb +0 -7
  48. data/lib/govdelivery/tms/resource/ipaws_cog_profile.rb +0 -29
  49. data/lib/govdelivery/tms/resource/ipaws_event_code.rb +0 -7
  50. data/lib/govdelivery/tms/resource/ipaws_nwem_area.rb +0 -18
  51. data/lib/govdelivery/tms/resource/ipaws_nwem_authorization.rb +0 -9
  52. data/lib/govdelivery/tms/resource/ipaws_nwem_auxilary_data.rb +0 -8
  53. data/lib/govdelivery/tms/resource/ipaws_response_type.rb +0 -7
  54. data/lib/govdelivery/tms/resource/ipaws_static_resource.rb +0 -8
  55. data/spec/ipaws_acknowledgement_spec.rb +0 -16
  56. data/spec/ipaws_alerts_spec.rb +0 -192
  57. data/spec/ipaws_cog_profile_spec.rb +0 -75
  58. data/spec/ipaws_event_codes_spec.rb +0 -35
  59. data/spec/ipaws_nwem_areas_spec.rb +0 -58
  60. data/spec/ipaws_nwem_authorization_spec.rb +0 -16
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fdf82ccfb0673c58b8eb65e498cb81fc4840859a
4
+ data.tar.gz: e0061974613e76215c69fd7dff98f7eea1b6033f
5
+ SHA512:
6
+ metadata.gz: 1585d7cb1099b43919f268a91ed155e97b30f0394d37cb3863ff933e402bce6ce6ea58438ce9586a2f88f8d9f53d3f36911846b085f1c9cf19714afe9ea2dbb9
7
+ data.tar.gz: 69cf8905b65b09871ddf2f0b303e05ec83cc3c170b4b0aa71f0bf3dcce713e7b5650abcc9209e7ee1627a56875453e096520bf9b3da69361224a1d4c4515a609
data/Gemfile CHANGED
@@ -1,14 +1,13 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  group :development, :test do
5
- gem "appraisal"
5
+ gem 'appraisal'
6
6
  gem 'rspec', '~> 3.2.0'
7
7
  gem 'rspec-its'
8
8
  gem 'rake'
9
- gem 'redcarpet', :platform => :ruby
9
+ gem 'redcarpet', platform: :ruby
10
10
  gem 'yard'
11
11
  gem 'mail'
12
- gem 'rubygems-tasks', :git => 'https://github.com/postmodern/rubygems-tasks.git', :platform => :ruby
12
+ gem 'rubygems-tasks', git: 'https://github.com/postmodern/rubygems-tasks.git', platform: :ruby
13
13
  end
14
-
data/README.md CHANGED
@@ -91,38 +91,6 @@ message.recipients.build(:email=>'bill@example.com')
91
91
  message.post
92
92
  ```
93
93
 
94
- ### Obtaining IPAWS Ack ###
95
- ```ruby
96
- client.ipaws_acknowledgement.get
97
- client.ipaws_acknowledgement.ACK # "PONG"
98
- ```
99
-
100
- ### Obtaining IPAWS COG Profile
101
- ```ruby
102
- client.ipaws_cog_profile.get
103
- client.ipaws_cog_profile.attributes # {:cogid=>"120082", :name=>"GovDelivery" ... }
104
- ```
105
-
106
- ### Determining NWEM COG Authorization ###
107
- ```ruby
108
- client.ipaws_nwem_authorization.get
109
- client.ipaws_nwem_authorization.cogid # true
110
- ```
111
-
112
- ### Obtaining NWEM Auxilary Data (Authorized areas) ###
113
- ```ruby
114
- client.ipaws_nwem_areas.get
115
- client.ipaws_nwem_areas.collection.first.countyFipsCd # "51013"
116
- ```
117
-
118
- ### Sending an IPAWS Alert ###
119
- ```ruby
120
- alert = client.ipaws_alerts.build({ identifier: "CAP12-TEST-12345", sender: 'test@open.com' ...})
121
- alert.post # true
122
- alert.ipaws_response # { "identifier"=>"CAP12-TEST-1397743203", "statuses"=> [{"CHANNELNAME"=>"CAPEXCH" ... }]}
123
- ```
124
-
125
-
126
94
  Webhooks
127
95
  -------
128
96
  ### POST to a URL when a recipient is blacklisted (i.e. to remove from your list)
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "rubygems"
2
- require "bundler/setup"
3
- require "bundler/gem_tasks"
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
  unless defined?(JRUBY_VERSION)
6
6
  require 'rubygems/tasks'
@@ -15,6 +15,4 @@ end
15
15
 
16
16
  RSpec::Core::RakeTask.new(:spec)
17
17
 
18
-
19
- task :default => :spec
20
-
18
+ task default: :spec
@@ -1,30 +1,30 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "govdelivery/tms/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'govdelivery/tms/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "govdelivery-tms"
6
+ s.name = 'govdelivery-tms'
7
7
  s.version = GovDelivery::TMS::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["GovDelivery"]
10
- s.email = ["support@govdelivery.com"]
11
- s.homepage = "http://govdelivery.com"
12
- s.summary = %q{A ruby client to interact with the GovDelivery TMS REST API.}
13
- s.description = %q{A reference implementation, written in Ruby,
9
+ s.authors = ['GovDelivery']
10
+ s.email = ['support@govdelivery.com']
11
+ s.homepage = 'http://govdelivery.com'
12
+ s.summary = 'A ruby client to interact with the GovDelivery TMS REST API.'
13
+ s.description = "A reference implementation, written in Ruby,
14
14
  to interact with GovDelivery's TMS API. The client is
15
- compatible with Ruby 1.9 and 2.0. }
15
+ compatible with Ruby 1.9 and 2.0. "
16
16
 
17
- s.add_runtime_dependency "activesupport"
18
- s.add_runtime_dependency "faraday"
19
- s.add_runtime_dependency "faraday_middleware"
17
+ s.add_runtime_dependency 'activesupport'
18
+ s.add_runtime_dependency 'faraday'
19
+ s.add_runtime_dependency 'faraday_middleware'
20
20
 
21
- s.files = %w{
21
+ s.files = %w(
22
22
  Gemfile
23
23
  README.md
24
24
  Rakefile
25
25
  govdelivery-tms.gemspec
26
- } + Dir["lib/**/*"]
26
+ ) + Dir['lib/**/*']
27
27
 
28
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
- s.require_paths = ["lib"]
29
+ s.require_paths = ['lib']
30
30
  end
@@ -33,13 +33,4 @@ require 'govdelivery/tms/resource/command_type'
33
33
  require 'govdelivery/tms/resource/command_action'
34
34
  require 'govdelivery/tms/resource/command'
35
35
  require 'govdelivery/tms/resource/keyword'
36
- require 'govdelivery/tms/resource/ipaws_static_resource'
37
- require 'govdelivery/tms/resource/ipaws_category'
38
- require 'govdelivery/tms/resource/ipaws_event_code'
39
- require 'govdelivery/tms/resource/ipaws_response_type'
40
- require 'govdelivery/tms/resource/ipaws_acknowledgement'
41
- require 'govdelivery/tms/resource/ipaws_cog_profile'
42
- require 'govdelivery/tms/resource/ipaws_nwem_authorization'
43
- require 'govdelivery/tms/resource/ipaws_nwem_area'
44
- require 'govdelivery/tms/resource/ipaws_alert'
45
36
  require 'govdelivery/tms/resource/webhook'
@@ -23,15 +23,13 @@ module GovDelivery::TMS #:nodoc:
23
23
  end
24
24
 
25
25
  def new_record?
26
- !!self.new_record
26
+ !!new_record
27
27
  end
28
28
 
29
29
  def href=(href)
30
- self.new_record=false
31
- @href=href
30
+ self.new_record = false
31
+ @href = href
32
32
  end
33
33
  end
34
-
35
34
  end
36
-
37
- end
35
+ end
@@ -6,7 +6,7 @@ class GovDelivery::TMS::Client
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
  #
@@ -29,8 +29,8 @@ class GovDelivery::TMS::Client
29
29
  discover!
30
30
  end
31
31
 
32
- def connect!(auth_token, options={})
33
- self.connection = GovDelivery::TMS::Connection.new({auth_token: auth_token, api_root: api_root, logger: logger}.merge!(options))
32
+ def connect!(auth_token, 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!
@@ -41,14 +41,14 @@ class GovDelivery::TMS::Client
41
41
  def get(href)
42
42
  response = raw_connection.get(href)
43
43
  case response.status
44
- when 500..599
45
- raise GovDelivery::TMS::Request::Error.new(response.status)
46
- when 401..499
47
- raise GovDelivery::TMS::Request::Error.new(response.status)
48
- when 202
49
- raise GovDelivery::TMS::Request::InProgress.new(response.body['message'])
50
- else
51
- return response
44
+ when 500..599
45
+ fail GovDelivery::TMS::Request::Error.new(response.status)
46
+ when 401..499
47
+ fail GovDelivery::TMS::Request::Error.new(response.status)
48
+ when 202
49
+ fail GovDelivery::TMS::Request::InProgress.new(response.body['message'])
50
+ else
51
+ return response
52
52
  end
53
53
  end
54
54
 
@@ -71,10 +71,10 @@ class GovDelivery::TMS::Client
71
71
  def delete(href)
72
72
  response = raw_connection.delete(href)
73
73
  case response.status
74
- when 200...299
75
- return response
76
- else
77
- raise GovDelivery::TMS::Request::Error.new(response.status)
74
+ when 200...299
75
+ return response
76
+ else
77
+ fail GovDelivery::TMS::Request::Error.new(response.status)
78
78
  end
79
79
  end
80
80
 
@@ -93,5 +93,4 @@ class GovDelivery::TMS::Client
93
93
  logger.level = debug ? Logger::DEBUG : Logger::INFO
94
94
  logger
95
95
  end
96
-
97
96
  end
@@ -7,31 +7,30 @@ module GovDelivery::TMS::CollectionResource
7
7
  include GovDelivery::TMS::Base
8
8
  attr_accessor :collection
9
9
 
10
- def initialize(client, href, items=nil)
10
+ def initialize(client, href, items = nil)
11
11
  super(client, href)
12
12
  if items
13
13
  initialize_collection_from_items(items)
14
14
  else
15
15
  self.collection = []
16
16
  end
17
-
18
17
  end
19
18
 
20
19
  def get
21
20
  response = client.get(href)
22
21
  initialize_collection_from_items(response.body)
23
- #setup page links from header
22
+ # setup page links from header
24
23
  links = LinkHeader.parse(response.headers['link']).to_a.collect do |a|
25
- {a[1][0].last => a[0]}
24
+ { a[1][0].last => a[0] }
26
25
  end
27
26
  parse_links(links)
28
27
  self
29
28
  end
30
29
 
31
- def build(attributes=nil)
32
- thing = instance_class(self.class).new(client, self.href, attributes || {})
30
+ def build(attributes = nil)
31
+ thing = instance_class(self.class).new(client, href, attributes || {})
33
32
  thing.new_record = true
34
- self.collection << thing
33
+ collection << thing
35
34
  thing
36
35
  end
37
36
 
@@ -40,7 +39,7 @@ module GovDelivery::TMS::CollectionResource
40
39
  end
41
40
 
42
41
  def to_s
43
- "<#{self.class.inspect} href=#{self.href} collection=#{self.collection.inspect}>"
42
+ "<#{self.class.inspect} href=#{href} collection=#{collection.inspect}>"
44
43
  end
45
44
 
46
45
  private
@@ -4,13 +4,13 @@ class GovDelivery::TMS::Connection
4
4
  def get(href)
5
5
  resp = connection.get("#{href}.json")
6
6
  if resp.status != 200
7
- raise RecordNotFound.new("Could not find resource at #{href} (status #{resp.status})")
7
+ fail RecordNotFound.new("Could not find resource at #{href} (status #{resp.status})")
8
8
  else
9
9
  resp.body
10
10
  end
11
11
  end
12
12
 
13
- def initialize(opts={})
13
+ def initialize(opts = {})
14
14
  self.auth_token = opts[:auth_token]
15
15
  self.api_root = opts[:api_root]
16
16
  self.logger = opts[:logger]
@@ -18,8 +18,8 @@ class GovDelivery::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 GovDelivery::TMS::Logger, self.logger if self.logger
21
+ self.connection = Faraday.new(url: api_root) do |faraday|
22
+ faraday.use GovDelivery::TMS::Logger, logger if logger
23
23
  faraday.request :json
24
24
  faraday.headers['X-AUTH-TOKEN'] = auth_token
25
25
  faraday.headers[:user_agent] = "GovDelivery Ruby GovDelivery::TMS::Client #{GovDelivery::TMS::VERSION}"
@@ -1,18 +1,18 @@
1
1
  module GovDelivery::TMS
2
2
  module Request
3
- # The generic TMS error class
3
+ # The generic TMS error class
4
4
  class Error < StandardError
5
5
  attr_reader :code
6
6
 
7
7
  def initialize(code)
8
8
  super("HTTP Error: #{code}")
9
- @code=code
9
+ @code = code
10
10
  end
11
11
  end
12
12
 
13
13
  # Raised when a recipient list is still being constructed and a request is made to view the
14
14
  # recipient list for a message.
15
- class InProgress < StandardError;end
15
+ class InProgress < StandardError; end
16
16
  end
17
17
 
18
18
  module Errors
@@ -22,8 +22,8 @@ module GovDelivery::TMS
22
22
  end
23
23
  end
24
24
  class NoRelation < StandardError
25
- def initialize(rel=nil, obj=nil)
26
- message = "no link relation "
25
+ def initialize(rel = nil, obj = nil)
26
+ message = 'no link relation '
27
27
  message << "'#{rel}' " if rel
28
28
  message << 'is available'
29
29
  message << " for #{obj}" if obj
@@ -40,7 +40,6 @@ module GovDelivery::TMS
40
40
  else
41
41
  super(record_or_string)
42
42
  end
43
-
44
43
  end
45
44
  end
46
45
  class InvalidPost < InvalidVerb
@@ -50,9 +49,9 @@ module GovDelivery::TMS
50
49
  class InvalidDelete < InvalidVerb
51
50
  end
52
51
  class InvalidGet < StandardError
53
- def initialize(message=nil)
52
+ def initialize(message = nil)
54
53
  super(message || "Can't GET a resource after an invalid POST; either create a new object or fix errors")
55
54
  end
56
55
  end
57
56
  end
58
- end
57
+ end
@@ -89,41 +89,39 @@ module GovDelivery::TMS::InstanceResource
89
89
  setup_collection(attr, GovDelivery::TMS.const_get(tms_class))
90
90
  end
91
91
 
92
- def setup_attributes(attrs, readonly=false)
92
+ def setup_attributes(attrs, readonly = false)
93
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] }
94
+ send :define_method, :"#{property}=", &lambda { |v| @attributes[property] = v } unless readonly
95
+ send :define_method, property.to_sym, &lambda { @attributes[property] }
96
96
  end
97
97
  end
98
98
 
99
- def setup_collection(property, klass=nil)
99
+ def setup_collection(property, klass = nil)
100
100
  if klass
101
101
  custom_class_names[property] = klass
102
102
  else
103
103
  klass ||= GovDelivery::TMS.const_get(property.to_s.capitalize)
104
104
  end
105
105
 
106
- self.send :define_method, property.to_sym, &lambda { @attributes[property] ||= klass.new(self.client, nil, nil) }
106
+ send :define_method, property.to_sym, &lambda { @attributes[property] ||= klass.new(self.client, nil, nil) }
107
107
  end
108
108
  end
109
109
 
110
110
  module InstanceMethods
111
111
  attr_reader :links
112
112
 
113
- def initialize(client, href=nil, attrs=nil)
113
+ def initialize(client, href = nil, attrs = nil)
114
114
  super(client, href)
115
115
  @attributes = {}
116
116
  @links = {}
117
117
  set_attributes_from_hash(attrs) if attrs
118
118
  end
119
119
 
120
- def attributes
121
- @attributes
122
- end
120
+ attr_reader :attributes
123
121
 
124
122
  def get
125
- raise GovDelivery::TMS::Errors::InvalidGet if self.new_record?
126
- process_response(client.get(self.href), :get) && self
123
+ fail GovDelivery::TMS::Errors::InvalidGet if self.new_record?
124
+ process_response(client.get(href), :get) && self
127
125
  end
128
126
  alias_method :get!, :get
129
127
 
@@ -133,7 +131,7 @@ module GovDelivery::TMS::InstanceResource
133
131
  end
134
132
 
135
133
  def post!
136
- self.post or raise GovDelivery::TMS::Errors::InvalidPost.new(self)
134
+ post || fail(GovDelivery::TMS::Errors::InvalidPost.new(self))
137
135
  end
138
136
 
139
137
  def put
@@ -141,28 +139,28 @@ module GovDelivery::TMS::InstanceResource
141
139
  end
142
140
 
143
141
  def put!
144
- process_response(client.put(self), :put) or raise GovDelivery::TMS::Errors::InvalidPut.new(self)
142
+ process_response(client.put(self), :put) || fail(GovDelivery::TMS::Errors::InvalidPut.new(self))
145
143
  end
146
144
 
147
145
  def delete
148
- process_response(client.delete(self.href), :delete)
146
+ process_response(client.delete(href), :delete)
149
147
  end
150
148
 
151
149
  def delete!
152
- process_response(client.delete(self.href), :delete) or raise GovDelivery::TMS::Errors::InvalidDelete.new(self)
150
+ process_response(client.delete(href), :delete) || fail(GovDelivery::TMS::Errors::InvalidDelete.new(self))
153
151
  end
154
152
 
155
153
  def to_s
156
- "<#{self.class.inspect}#{' href=' + self.href if self.href} attributes=#{@attributes.inspect}>"
154
+ "<#{self.class.inspect}#{' href=' + href if href} attributes=#{@attributes.inspect}>"
157
155
  end
158
156
 
159
157
  def to_json
160
158
  json_hash = {}
161
159
  self.class.writeable_attributes.each do |attr|
162
- json_hash[attr] = self.send(attr)
160
+ json_hash[attr] = send(attr)
163
161
  end
164
162
  self.class.collection_attributes.each do |coll|
165
- json_hash[coll] = self.send(coll).to_json
163
+ json_hash[coll] = send(coll).to_json
166
164
  end
167
165
  self.class.linkable_attributes.each do |attr|
168
166
  json_hash[:_links] ||= {}
@@ -181,29 +179,27 @@ module GovDelivery::TMS::InstanceResource
181
179
  self.response = response
182
180
  error_class = GovDelivery::TMS::Errors.const_get("Invalid#{method.to_s.capitalize}")
183
181
  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
182
+ when 204
183
+ return true
184
+ when 200..299
185
+ set_attributes_from_hash(response.body) if response.body.is_a?(Hash)
186
+ @links = {}
187
+ self.new_record = false
188
+ return true
189
+ when 401
190
+ fail error_class.new('401 Not Authorized')
191
+ when 404
192
+ fail(error_class.new("Can't POST to #{href}"))
193
+ when 500..599
194
+ fail(GovDelivery::TMS::Errors::ServerError.new(response))
195
+ else # 422?
196
+ self.errors = response.body['errors'] if response.body['errors']
201
197
  end
202
- return false
198
+ false
203
199
  end
204
200
 
205
201
  def set_attributes_from_hash(hash)
206
- hash.reject { |k, _| k=~/^_/ }.each do |property, value|
202
+ hash.reject { |k, _| k =~ /^_/ }.each do |property, value|
207
203
  if self.class.collection_attributes.include?(property.to_sym)
208
204
  klass = self.class.custom_class_names[property] || GovDelivery::TMS.const_get(property.to_s.capitalize)
209
205
  @attributes[property.to_sym] = klass.new(client, nil, value)
@@ -214,6 +210,5 @@ module GovDelivery::TMS::InstanceResource
214
210
  self.errors = hash['errors']
215
211
  parse_links(hash['_links'])
216
212
  end
217
-
218
213
  end
219
- end
214
+ end