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
@@ -1,9 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsAcknowledgement
3
-
4
- include InstanceResource
5
-
6
- readonly_attributes :ACK
7
-
8
- end
9
- end
@@ -1,38 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsAlert
3
-
4
- include InstanceResource
5
-
6
- writeable_attributes(
7
- :identifier,
8
- :sender,
9
- :sent,
10
- :status,
11
- :msgType,
12
- :source,
13
- :scope,
14
- :restriction,
15
- :addresses,
16
- :code,
17
- :note,
18
- :references,
19
- :incidents,
20
- :info
21
- )
22
-
23
- attr_accessor :ipaws_response
24
-
25
- def process_response(response, method)
26
- # All IPAWS responses are 200, even if there are errors.
27
- # Capture the IPAWS response on a 200 response to POST (create alert)
28
- if method == :post && response.status == 200
29
- self.ipaws_response = response.body
30
- true
31
- else
32
- self.ipaws_response = nil
33
- super
34
- end
35
- end
36
-
37
- end
38
- end
@@ -1,7 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsCategory
3
-
4
- include IpawsStaticResource
5
-
6
- end
7
- end
@@ -1,29 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsCogProfile
3
-
4
- include InstanceResource
5
-
6
- readonly_attributes(
7
- :cogid,
8
- :name,
9
- :description,
10
- :categoryName,
11
- :organizationName,
12
- :cogEnabled,
13
- :caeAuthorized,
14
- :caeCmasAuthorized,
15
- :eanAuthorized,
16
- :allEventCode,
17
- :allGeoCode,
18
- :easAuthorized,
19
- :cmasAlertAuthorized,
20
- :cmamTextAuthorized,
21
- :publicAlertAuthorized,
22
- :broadcastAuthorized,
23
- :email,
24
- :eventCodes,
25
- :geoCodes
26
- )
27
-
28
- end
29
- end
@@ -1,7 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsEventCode
3
-
4
- include IpawsStaticResource
5
-
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsNwemArea
3
-
4
- include InstanceResource
5
-
6
- readonly_attributes(
7
- :countyFipsCd,
8
- :countyName,
9
- :geoType,
10
- :stateCd,
11
- :stateFips,
12
- :stateName,
13
- :zoneCd,
14
- :zoneName
15
- )
16
-
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsNwemAuthorization
3
-
4
- include InstanceResource
5
-
6
- readonly_attributes :cogid
7
-
8
- end
9
- end
@@ -1,8 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsNwemAuxilaryData
3
-
4
- include InstanceResource
5
- include IpawsResponse
6
-
7
- end
8
- end
@@ -1,7 +0,0 @@
1
- module GovDelivery::TMS
2
- class IpawsResponseType
3
-
4
- include IpawsStaticResource
5
-
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- module GovDelivery::TMS
2
- module IpawsStaticResource
3
- def self.included(base)
4
- base.send(:include, GovDelivery::TMS::InstanceResource)
5
- base.readonly_attributes :value, :description, :cap_exchange, :core_ipaws_profile, :nwem, :eas_and_public, :cmas
6
- end
7
- end
8
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GovDelivery::TMS::IpawsAcknowledgement do
4
-
5
- it 'gets IPAWS acknowledgement from client' do
6
- client = double(:client)
7
- response_body = { "ACK" => "PONG" }
8
- ipaws_acknowledgement = GovDelivery::TMS::IpawsAcknowledgement.new(client, '/ipaws/acknowledgement', {})
9
- expect(ipaws_acknowledgement.client).to receive('get').with(ipaws_acknowledgement.href).and_return(
10
- double('response', status: 200, body: response_body)
11
- )
12
- expect(ipaws_acknowledgement.get).to eq(ipaws_acknowledgement)
13
- expect(ipaws_acknowledgement.ACK).to eq("PONG")
14
- end
15
-
16
- end
@@ -1,192 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GovDelivery::TMS::IpawsAlert do
4
-
5
- it 'post new IPAWS alerts to client, and capture status response from IPAWS' do
6
- client = double(:client)
7
-
8
- response_body = {
9
- "identifier"=>"CAP12-TEST-1397743203",
10
- "statuses"=> [
11
- {
12
- "CHANNELNAME"=>"CAPEXCH",
13
- "STATUSITEMID"=>"200",
14
- "ERROR"=>"N",
15
- "STATUS"=>"Ack"
16
- },
17
- {
18
- "CHANNELNAME"=>"CAPEXCH",
19
- "STATUSITEMID"=>"202",
20
- "ERROR"=>"N",
21
- "STATUS"=>"alert-signature-is-valid"
22
- },
23
- {
24
- "CHANNELNAME"=>"IPAWS",
25
- "STATUSITEMID"=>"300",
26
- "ERROR"=>"N",
27
- "STATUS"=>"Ack"
28
- },
29
- {
30
- "CHANNELNAME"=>"NWEM",
31
- "STATUSITEMID"=>"401",
32
- "ERROR"=>"N",
33
- "STATUS"=>"message-not-disseminated-as-NWEM"
34
- },
35
- {
36
- "CHANNELNAME"=>"EAS",
37
- "STATUSITEMID"=>"501",
38
- "ERROR"=>"N",
39
- "STATUS"=>"message-not-disseminated-as-EAS"
40
- },
41
- {
42
- "CHANNELNAME"=>"CMAS",
43
- "STATUSITEMID"=>"600",
44
- "ERROR"=>"N",
45
- "STATUS"=>"Ack"
46
- },
47
- {
48
- "CHANNELNAME"=>"PUBLIC",
49
- "STATUSITEMID"=>"800",
50
- "ERROR"=>"N",
51
- "STATUS"=>"Ack"
52
- }
53
- ]
54
- }
55
-
56
- alert_attributes = {
57
- identifier: "CAP12-TEST-123",
58
- sender: 'test@open.com',
59
- sent: "2014-04-18T15:02:26-05:00",
60
- status: 'Actual',
61
- msgType: 'Alert',
62
- source: 'IPAWS-TEST',
63
- scope: 'Public',
64
- addresses: '999',
65
- code: ['IPAWSv1.0'],
66
- note: 'test',
67
- incidents: 'IPAWS-9999',
68
- info: [
69
- {
70
- language: 'en-US',
71
- category: ['Safety'],
72
- event: 'CIVIL EMERGENCY MESSAGE',
73
- responseType: ['Shelter'],
74
- urgency: 'Immediate',
75
- severity: 'Extreme',
76
- certainty: 'Observed',
77
- audience: 'Public',
78
- eventCode: [
79
- { valueName: 'SAME', value: 'SVR'}
80
- ],
81
- effective: "2014-04-18T15:02:26-05:00",
82
- expires: "2014-04-18T15:02:26-05:00",
83
- senderName: 'IPAWS-Test',
84
- headline: 'FLash Flood Warning',
85
- description: 'Severe Weather Warning - Flooding',
86
- instruction: 'Take Shelter',
87
- parameter: [
88
- { valueName: 'timezone', value: 'CST' }
89
- ],
90
- area: [
91
- {
92
- areaDesc: 'Fairfax County',
93
- geocode: { valueName: 'SAME', value: '039035' }
94
- }
95
- ]
96
- }
97
- ]
98
- }
99
-
100
- alerts = GovDelivery::TMS::IpawsAlerts.new(client, '/ipaws/alerts')
101
- alert = alerts.build(alert_attributes)
102
-
103
- expect(alert.identifier).to eq("CAP12-TEST-123")
104
- expect(alert.sender).to eq('test@open.com')
105
- expect(alert.sent).to eq("2014-04-18T15:02:26-05:00")
106
- expect(alert.status).to eq('Actual')
107
- expect(alert.msgType).to eq('Alert')
108
- expect(alert.source).to eq('IPAWS-TEST')
109
- expect(alert.scope).to eq('Public')
110
- expect(alert.addresses).to eq('999')
111
- expect(alert.code).to eq(['IPAWSv1.0'])
112
- expect(alert.note).to eq('test')
113
- expect(alert.incidents).to eq('IPAWS-9999')
114
- expect(alert.info).to eq([
115
- {
116
- language: 'en-US',
117
- category: ['Safety'],
118
- event: 'CIVIL EMERGENCY MESSAGE',
119
- responseType: ['Shelter'],
120
- urgency: 'Immediate',
121
- severity: 'Extreme',
122
- certainty: 'Observed',
123
- audience: 'Public',
124
- eventCode: [
125
- { valueName: 'SAME', value: 'SVR'}
126
- ],
127
- effective: "2014-04-18T15:02:26-05:00",
128
- expires: "2014-04-18T15:02:26-05:00",
129
- senderName: 'IPAWS-Test',
130
- headline: 'FLash Flood Warning',
131
- description: 'Severe Weather Warning - Flooding',
132
- instruction: 'Take Shelter',
133
- parameter: [
134
- { valueName: 'timezone', value: 'CST' }
135
- ],
136
- area: [
137
- {
138
- areaDesc: 'Fairfax County',
139
- geocode: { valueName: 'SAME', value: '039035' }
140
- }
141
- ]
142
- }
143
- ])
144
-
145
- expect(alert.client).to receive('post').with(alert).and_return(double('response', status: 200, body: response_body))
146
- expect(alert.post).to eq(true)
147
- expect(alert.ipaws_response).to eq(response_body)
148
-
149
- expect(alert.identifier).to eq("CAP12-TEST-123")
150
- expect(alert.sender).to eq('test@open.com')
151
- expect(alert.sent).to eq("2014-04-18T15:02:26-05:00")
152
- expect(alert.status).to eq('Actual')
153
- expect(alert.msgType).to eq('Alert')
154
- expect(alert.source).to eq('IPAWS-TEST')
155
- expect(alert.scope).to eq('Public')
156
- expect(alert.addresses).to eq('999')
157
- expect(alert.code).to eq(['IPAWSv1.0'])
158
- expect(alert.note).to eq('test')
159
- expect(alert.incidents).to eq('IPAWS-9999')
160
- expect(alert.info).to eq([
161
- {
162
- language: 'en-US',
163
- category: ['Safety'],
164
- event: 'CIVIL EMERGENCY MESSAGE',
165
- responseType: ['Shelter'],
166
- urgency: 'Immediate',
167
- severity: 'Extreme',
168
- certainty: 'Observed',
169
- audience: 'Public',
170
- eventCode: [
171
- { valueName: 'SAME', value: 'SVR'}
172
- ],
173
- effective: "2014-04-18T15:02:26-05:00",
174
- expires: "2014-04-18T15:02:26-05:00",
175
- senderName: 'IPAWS-Test',
176
- headline: 'FLash Flood Warning',
177
- description: 'Severe Weather Warning - Flooding',
178
- instruction: 'Take Shelter',
179
- parameter: [
180
- { valueName: 'timezone', value: 'CST' }
181
- ],
182
- area: [
183
- {
184
- areaDesc: 'Fairfax County',
185
- geocode: { valueName: 'SAME', value: '039035' }
186
- }
187
- ]
188
- }
189
- ])
190
- end
191
-
192
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GovDelivery::TMS::IpawsCogProfile do
4
-
5
- it 'gets IPAWS cog profile from client' do
6
- client = double(:client)
7
- response_body = {
8
- "cogid"=>"120082",
9
- "name"=>"GovDelivery",
10
- "description"=>"GovDelivery",
11
- "categoryName"=>"IPAWS-OPEN",
12
- "organizationName"=>"CIV",
13
- "cogEnabled"=>"Y",
14
- "caeAuthorized"=>"Y",
15
- "caeCmasAuthorized"=>"Y",
16
- "eanAuthorized"=>"N",
17
- "allEventCode"=>"N",
18
- "allGeoCode"=>"N",
19
- "easAuthorized"=>"Y",
20
- "cmasAlertAuthorized"=>"Y",
21
- "cmamTextAuthorized"=>"Y",
22
- "publicAlertAuthorized"=>"Y",
23
- "broadcastAuthorized"=>"N",
24
- "email"=>"joe.bloom@govdelivery.com",
25
- "eventCodes" => [
26
- {"ALL"=>"FRW"},
27
- {"ALL"=>"SVR"},
28
- {"ALL"=>"SPW"},
29
- {"ALL"=>"LAE"},
30
- {"ALL"=>"CAE"},
31
- {"ALL"=>"WSW"},
32
- {"ALL"=>"CEM"}
33
- ],
34
- "geoCodes" => [
35
- {"SAME"=>"039035"}
36
- ]
37
- }
38
- cog_profile = GovDelivery::TMS::IpawsCogProfile.new(client, '/ipaws/cog_profile', {})
39
- expect(cog_profile.client).to receive('get').with(cog_profile.href).and_return(
40
- double('response', status: 200, body: response_body)
41
- )
42
- expect(cog_profile.get).to eq(cog_profile)
43
- expect(cog_profile.cogid).to eq("120082")
44
-
45
- expect(cog_profile.name).to eq("GovDelivery")
46
- expect(cog_profile.description).to eq("GovDelivery")
47
- expect(cog_profile.categoryName).to eq("IPAWS-OPEN")
48
- expect(cog_profile.organizationName).to eq("CIV")
49
- expect(cog_profile.cogEnabled).to eq("Y")
50
- expect(cog_profile.caeAuthorized).to eq("Y")
51
- expect(cog_profile.caeCmasAuthorized).to eq("Y")
52
- expect(cog_profile.eanAuthorized).to eq("N")
53
- expect(cog_profile.allEventCode).to eq("N")
54
- expect(cog_profile.allGeoCode).to eq("N")
55
- expect(cog_profile.easAuthorized).to eq("Y")
56
- expect(cog_profile.cmasAlertAuthorized).to eq("Y")
57
- expect(cog_profile.cmamTextAuthorized).to eq("Y")
58
- expect(cog_profile.publicAlertAuthorized).to eq("Y")
59
- expect(cog_profile.broadcastAuthorized).to eq("N")
60
- expect(cog_profile.email).to eq("joe.bloom@govdelivery.com")
61
- expect(cog_profile.eventCodes).to eq([
62
- {"ALL"=>"FRW"},
63
- {"ALL"=>"SVR"},
64
- {"ALL"=>"SPW"},
65
- {"ALL"=>"LAE"},
66
- {"ALL"=>"CAE"},
67
- {"ALL"=>"WSW"},
68
- {"ALL"=>"CEM"}
69
- ])
70
- expect(cog_profile.geoCodes).to eq([
71
- {"SAME"=>"039035"}
72
- ])
73
- end
74
-
75
- end