@@ -54,17 +54,25 @@ class Client
54
54
let ( :md5_of_attributes ) { '756d7f4338696745d063b420a2f7e502' }
55
55
56
56
before ( :each ) do
57
- response_body = <<-XML
58
- <SendMessageResponse>
59
- <SendMessageResult>
60
- <MD5OfMessageBody>900150983cd24fb0d6963f7d28e17f72</MD5OfMessageBody>
61
- <MD5OfMessageAttributes>#{ md5_of_attributes } </MD5OfMessageAttributes>
62
- <MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId>
63
-
64
- </SendMessageResult>
65
- </SendMessageResponse>
66
- XML
67
-
57
+ if client . config . api . metadata [ 'protocol' ] == 'json'
58
+ response_body = <<-JSON
59
+ {
60
+ "MD5OfMessageAttributes": "#{ md5_of_attributes } ",
61
+ "MD5OfMessageBody": "900150983cd24fb0d6963f7d28e17f72",
62
+ "MessageId": "5fea7756-0ea4-451a-a703-a558b933e274"
63
+ }
64
+ JSON
65
+ else
66
+ response_body = <<-XML
67
+ <SendMessageResponse>
68
+ <SendMessageResult>
69
+ <MD5OfMessageBody>900150983cd24fb0d6963f7d28e17f72</MD5OfMessageBody>
70
+ <MD5OfMessageAttributes>#{ md5_of_attributes } </MD5OfMessageAttributes>
71
+ <MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId>
72
+ </SendMessageResult>
73
+ </SendMessageResponse>
74
+ XML
75
+ end
68
76
69
77
client . handle ( step : :send ) do |context |
70
78
context . http_response . signal_done (
@@ -159,22 +167,42 @@ class Client
159
167
describe '#send_message_batch' do
160
168
161
169
before ( :each ) do
162
- client . handle ( step : :send ) do |context |
163
- context . http_response . signal_done (
164
- status_code : 200 ,
165
- headers : { } ,
166
- body :<<-XML )
167
- <SendMessageBatchResponse>
168
- <SendMessageBatchResult>
169
- <SendMessageBatchResultEntry>
170
- <Id>msg-id</Id>
171
- <MD5OfMessageBody>900150983cd24fb0d6963f7d28e17f72</MD5OfMessageBody>
172
- <MD5OfMessageAttributes>756d7f4338696745d063b420a2f7e502</MD5OfMessageAttributes>
173
- </SendMessageBatchResultEntry>
174
- </SendMessageBatchResult>
175
- </SendMessageBatchResponse>
176
- XML
177
- Seahorse ::Client ::Response . new ( context : context )
170
+ if client . config . api . metadata [ 'protocol' ] == 'json'
171
+ client . handle ( step : :send ) do |context |
172
+ context . http_response . signal_done (
173
+ status_code : 200 ,
174
+ headers : { } ,
175
+ body :<<-JSON )
176
+ {
177
+ "Successful": [
178
+ {
179
+ "Id": "msg-id",
180
+ "MD5OfMessageBody": "900150983cd24fb0d6963f7d28e17f72",
181
+ "MD5OfMessageAttributes": "756d7f4338696745d063b420a2f7e502"
182
+ }
183
+ ]
184
+ }
185
+ JSON
186
+ Seahorse ::Client ::Response . new ( context : context )
187
+ end
188
+ else
189
+ client . handle ( step : :send ) do |context |
190
+ context . http_response . signal_done (
191
+ status_code : 200 ,
192
+ headers : { } ,
193
+ body :<<-XML )
194
+ <SendMessageBatchResponse>
195
+ <SendMessageBatchResult>
196
+ <SendMessageBatchResultEntry>
197
+ <Id>msg-id</Id>
198
+ <MD5OfMessageBody>900150983cd24fb0d6963f7d28e17f72</MD5OfMessageBody>
199
+ <MD5OfMessageAttributes>756d7f4338696745d063b420a2f7e502</MD5OfMessageAttributes>
200
+ </SendMessageBatchResultEntry>
201
+ </SendMessageBatchResult>
202
+ </SendMessageBatchResponse>
203
+ XML
204
+ Seahorse ::Client ::Response . new ( context : context )
205
+ end
178
206
end
179
207
end
180
208
@@ -225,20 +253,39 @@ class Client
225
253
end
226
254
227
255
it 'skips failed errors' do
228
- client . handle ( step : :send ) do |context |
229
- context . http_response . signal_done (
230
- status_code : 200 ,
231
- headers : { } ,
232
- body :<<-XML )
233
- <SendMessageBatchResponse>
234
- <SendMessageBatchResult>
235
- <BatchResultErrorEntry>
236
- <Id>msg-id</Id>
237
- </BatchResultErrorEntry>
238
- </SendMessageBatchResult>
239
- </SendMessageBatchResponse>
240
- XML
241
- Seahorse ::Client ::Response . new ( context : context )
256
+ if client . config . api . metadata [ 'protocol' ] == 'json'
257
+ client . handle ( step : :send ) do |context |
258
+ context . http_response . signal_done (
259
+ status_code : 200 ,
260
+ headers : { } ,
261
+ body :<<-JSON )
262
+ {
263
+ "Successful": [],
264
+ "Failed": [
265
+ {
266
+ "Id": "msg-id"
267
+ }
268
+ ]
269
+ }
270
+ JSON
271
+ Seahorse ::Client ::Response . new ( context : context )
272
+ end
273
+ else
274
+ client . handle ( step : :send ) do |context |
275
+ context . http_response . signal_done (
276
+ status_code : 200 ,
277
+ headers : { } ,
278
+ body :<<-XML )
279
+ <SendMessageBatchResponse>
280
+ <SendMessageBatchResult>
281
+ <BatchResultErrorEntry>
282
+ <Id>msg-id</Id>
283
+ </BatchResultErrorEntry>
284
+ </SendMessageBatchResult>
285
+ </SendMessageBatchResponse>
286
+ XML
287
+ Seahorse ::Client ::Response . new ( context : context )
288
+ end
242
289
end
243
290
expect {
244
291
client . send_message_batch (
0 commit comments