File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -22,4 +22,33 @@ def expunge_content(app_id, msg_id)
22
22
return @api . v1_message_expunge_content ( app_id , msg_id )
23
23
end
24
24
end
25
+
26
+ # Creates a [`MessageIn`] with the payload already being serialized.
27
+ #
28
+ # The payload is not normalized on the server (usually whitespace outside
29
+ # of string literals, unnecessarily escaped characters in string and such
30
+ # are fixed up by the server), and is not even required to be JSON.
31
+ #
32
+ # `attributes[:payload]` must be a string. An extra attribute `content_type`
33
+ # is accepted that sets the `content-type` header of the payload, overwriting
34
+ # the default of `application/json` if specified. Other than that, the
35
+ # attributes are forwarded [`MessageIn.new`], so all the same ones are
36
+ # accepted.
37
+ def message_in_raw ( attributes = { } )
38
+ if !attributes . key? ( :transformations_params )
39
+ attributes [ :transformations_params ] = { }
40
+ end
41
+ attributes [ :transformations_params ] [ :rawPayload ] = attributes [ :payload ]
42
+ attributes [ :payload ] = { }
43
+
44
+ content_type = attributes . delete ( :content_type )
45
+ if content_type != nil
46
+ if !attributes [ :transformations_params ] key? ( :headers )
47
+ attributes [ :transformations_params ] [ :headers ] = { }
48
+ end
49
+ attributes [ :transformations_params ] [ :headers ] [ :'content-type' ] = content_type
50
+ end
51
+
52
+ return MessageIn . new ( attributes )
53
+ end
25
54
end
You can’t perform that action at this time.
0 commit comments