Skip to content

Commit 624f6fb

Browse files
author
Gildas Cherruel
committed
Merge branch 'release/0.8.6'
2 parents f292e35 + a61405e commit 624f6fb

9 files changed

+206
-31
lines changed

error.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ var (
5656
ChatInvalidQueueError = APIError{Status: 400, Code: "chat.error.invalid.queue", Message: "The specified queue is not valid."}
5757
// ChatCreateConversationRequestRoutingTargetError means the routing target is not valid
5858
ChatCreateConversationRequestRoutingTargetError = APIError{Status: 400, Code: "chat.error.createconversationrequest.routingtarget", Message: "The routing target is not valid."}
59+
// MessageExpired means the message has expired
60+
MessageExpired = APIError{Status: 400, Code: "message.expired", Message: "%s"}
61+
// RateLimited means the request was rate limited
62+
RateLimited = APIError{Status: 429, Code: "rate.limited", Message: "%s"}
63+
// MessageNotAllowed means the message is not allowed
64+
MessageNotAllowed = APIError{Status: 400, Code: "message.not.allowed", Message: "%s"}
65+
// GeneralError means the request failed for a general reason
66+
GeneralError = APIError{Status: 400, Code: "general.error", Message: "%s"}
67+
// UnsupportedMessage means the message is not supported
68+
UnsupportedMessage = APIError{Status: 400, Code: "unsupported.message", Message: "%s"}
69+
// UnknownMessage means the message is unknown
70+
UnknownMessage = APIError{Status: 400, Code: "unknown.message", Message: "%s"}
71+
// InvalidMessageStructure means the message structure is invalid
72+
InvalidMessageStructure = APIError{Status: 400, Code: "invalid.message.structure", Message: "%s"}
73+
// InvalidDestination means the destination is invalid
74+
InvalidDestination = APIError{Status: 400, Code: "invalid.destination", Message: "%s"}
75+
// ServerError means the server failed
76+
ServerError = APIError{Status: 500, Code: "server.error", Message: "%s"}
77+
// MediaTypeNotAllowed means the media type is not allowed
78+
MediaTypeNotAllowed = APIError{Status: 415, Code: "media.type.not.allowed", Message: "%s"}
79+
// InvalidMediaContentLength means the media content length is invalid
80+
InvalidMediaContentLength = APIError{Status: 400, Code: "invalid.media.content.length", Message: "%s"}
81+
// RecipientOptedOut means the recipient opted out
82+
RecipientOptedOut = APIError{Status: 400, Code: "recipient.opted.out", Message: "%s"}
5983
)
6084

6185
// APIError represents an error from the Gcloud API

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/Masterminds/sprig/v3 v3.2.3
77
github.com/gildas/go-core v0.5.4
8-
github.com/gildas/go-errors v0.3.5
8+
github.com/gildas/go-errors v0.3.6
99
github.com/gildas/go-logger v1.6.7
1010
github.com/gildas/go-request v0.7.17
1111
github.com/google/uuid v1.3.0
@@ -40,17 +40,17 @@ require (
4040
github.com/shopspring/decimal v1.3.1 // indirect
4141
github.com/spf13/cast v1.5.1 // indirect
4242
go.opencensus.io v0.24.0 // indirect
43-
golang.org/x/crypto v0.11.0 // indirect
44-
golang.org/x/net v0.12.0 // indirect
45-
golang.org/x/oauth2 v0.10.0 // indirect
43+
golang.org/x/crypto v0.12.0 // indirect
44+
golang.org/x/net v0.14.0 // indirect
45+
golang.org/x/oauth2 v0.11.0 // indirect
4646
golang.org/x/sync v0.3.0 // indirect
47-
golang.org/x/sys v0.10.0 // indirect
48-
golang.org/x/text v0.11.0 // indirect
47+
golang.org/x/sys v0.11.0 // indirect
48+
golang.org/x/text v0.12.0 // indirect
4949
google.golang.org/api v0.134.0 // indirect
5050
google.golang.org/appengine v1.6.7 // indirect
51-
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf // indirect
52-
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf // indirect
53-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
51+
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
52+
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
53+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
5454
google.golang.org/grpc v1.57.0 // indirect
5555
google.golang.org/protobuf v1.31.0 // indirect
5656
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0X
4242
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
4343
github.com/gildas/go-core v0.5.4 h1:GhMtsbwV5eChHoq59XAFsh1CZbGq54WZdi4YiFn5JCA=
4444
github.com/gildas/go-core v0.5.4/go.mod h1:sdTtiR554uLj/w+GNZq2dcSv5ImfGtp19LzAudezNNI=
45-
github.com/gildas/go-errors v0.3.5 h1:0reR46pAtyzqYqBIdPqxfBW9/zuQ/U0cULKFNFguffA=
46-
github.com/gildas/go-errors v0.3.5/go.mod h1:jqH4hy2BzpU3mdjkUYJhkZvEkn56cWRjWVgz/HNqglQ=
45+
github.com/gildas/go-errors v0.3.6 h1:/loKTkq/t+eoIcULhKAwd0WBRPHgZxhkd3l+m/uw15c=
46+
github.com/gildas/go-errors v0.3.6/go.mod h1:jqH4hy2BzpU3mdjkUYJhkZvEkn56cWRjWVgz/HNqglQ=
4747
github.com/gildas/go-logger v1.6.7 h1:xcsJqA8DYZrPYlvTGYFvdyA1impZFJNtUK0jcElqHAc=
4848
github.com/gildas/go-logger v1.6.7/go.mod h1:wLtie4EINirm5khHTvCBcvAoQcqIdcQ96fB9JX+hzu4=
4949
github.com/gildas/go-request v0.7.17 h1:MYNl1dqL9usiZIJuR1Y6cx7AkKjmXFoKYrn1HK8mzHY=
@@ -146,8 +146,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
146146
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
147147
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
148148
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
149-
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
150-
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
149+
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
150+
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
151151
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
152152
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
153153
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -167,12 +167,12 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
167167
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
168168
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
169169
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
170-
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
171-
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
170+
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
171+
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
172172
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
173173
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
174-
golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8=
175-
golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI=
174+
golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU=
175+
golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk=
176176
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
177177
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
178178
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -191,8 +191,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
191191
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
192192
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
193193
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
194-
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
195-
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
194+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
195+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
196196
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
197197
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
198198
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -203,8 +203,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
203203
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
204204
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
205205
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
206-
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
207-
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
206+
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
207+
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
208208
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
209209
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
210210
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -225,12 +225,12 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
225225
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
226226
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
227227
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
228-
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf h1:v5Cf4E9+6tawYrs/grq1q1hFpGtzlGFzgWHqwt6NFiU=
229-
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
230-
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf h1:xkVZ5FdZJF4U82Q/JS+DcZA83s/GRVL+QrFMlexk9Yo=
231-
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:5DZzOUPCLYL3mNkQ0ms0F3EuUNZ7py1Bqeq6sxzI7/Q=
232-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf h1:guOdSPaeFgN+jEJwTo1dQ71hdBm+yKSCCKuTRkJzcVo=
233-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
228+
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g=
229+
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
230+
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 h1:nIgk/EEq3/YlnmVVXVnm14rC2oxgs1o0ong4sD/rd44=
231+
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5/go.mod h1:5DZzOUPCLYL3mNkQ0ms0F3EuUNZ7py1Bqeq6sxzI7/Q=
232+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 h1:eSaPbMR4T7WfH9FvABk36NBMacoTUKdWCvV0dx+KfOg=
233+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
234234
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
235235
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
236236
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=

openmessaging_integration.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ func (integration *OpenMessagingIntegration) SendInboundMessageWithAttachment(co
260260
//
261261
// Valid status values are: Delivered, Failed, Published, Read, Removed, and Sent.
262262
//
263+
// Genesys Cloud will return a receipt from this request. If the returned receipt has a Failed status, the return error contains the reason(s) for the failure.
264+
//
263265
// See https://developer.genesys.cloud/api/digital/openmessaging/inboundMessages#send-an-inbound-open-message
264266
func (integration *OpenMessagingIntegration) SendInboundReceipt(context context.Context, to *OpenMessageTo, messageID, status string, reasons []StatusReason, attributes map[string]string, metadata map[string]string) (id string, err error) {
265267
if integration.ID == uuid.Nil {
@@ -268,7 +270,7 @@ func (integration *OpenMessagingIntegration) SendInboundReceipt(context context.
268270
if len(messageID) == 0 {
269271
return "", errors.ArgumentMissing.With("messageID")
270272
}
271-
result := OpenMessageText{}
273+
result := OpenMessageReceipt{}
272274
err = integration.client.Post(
273275
integration.logger.ToContext(context),
274276
"/conversations/messages/inbound/open",
@@ -286,6 +288,12 @@ func (integration *OpenMessagingIntegration) SendInboundReceipt(context context.
286288
},
287289
&result,
288290
)
291+
if err != nil {
292+
return "", err
293+
}
294+
if result.IsFailed() {
295+
return "", result.AsError()
296+
}
289297
return result.ID, err
290298
}
291299

openmessaging_message_receipt.go

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gcloudcx
33
import (
44
"encoding/json"
55

6+
"github.com/gildas/go-core"
67
"github.com/gildas/go-errors"
78
)
89

@@ -13,14 +14,14 @@ type OpenMessageReceipt struct {
1314
ID string `json:"id,omitempty"` // Can be anything, message ID this receipt relates to
1415
Channel *OpenMessageChannel `json:"channel"`
1516
Direction string `json:"direction"` // Can be "Inbound" or "Outbound"
16-
Status string `json:"status"` // Can be "Published" (Inbound), "Delivered" (Outbound), "Failed"
17+
Status string `json:"status"` // Can be "Published" (Inbound), "Delivered" (Outbound), "Sent", "Read", "Failed", "Removed"
1718
Reasons []StatusReason `json:"reasons,omitempty"` // Contains the reason for the failure
1819
FinalReceipt bool `json:"isFinalReceipt"` // True if this is the last receipt about this message ID
1920
Metadata map[string]string `json:"metadata,omitempty"`
2021
}
2122

2223
type StatusReason struct {
23-
Code string `json:"code,omitempty"`
24+
Code string `json:"code,omitempty"` // MessageExpired, RateLimited, MessageNotAllowed, GeneralError, UnsupportedMessage, UnknownMessage, InvalidMessageStructure, InvalidDestination, ServerError, MediaTypeNotAllowed, InvalidMediaContentLength, RecipientOptedOut
2425
Message string `json:"message"`
2526
}
2627

@@ -48,6 +49,45 @@ func (message OpenMessageReceipt) IsFailed() bool {
4849
return message.Status == "Failed"
4950
}
5051

52+
// AsError converts this to an error
53+
func (reason StatusReason) AsError() error {
54+
switch reason.Code {
55+
case "MessageExpired":
56+
return MessageExpired.With(reason.Message)
57+
case "RateLimited":
58+
return RateLimited.With(reason.Message)
59+
case "MessageNotAllowed":
60+
return MessageNotAllowed.With(reason.Message)
61+
case "GeneralError":
62+
return GeneralError.With(reason.Message)
63+
case "UnsupportedMessage":
64+
return UnsupportedMessage.With(reason.Message)
65+
case "UnknownMessage":
66+
return UnknownMessage.With(reason.Message)
67+
case "InvalidMessageStructure":
68+
return InvalidMessageStructure.With(reason.Message)
69+
case "InvalidDestination":
70+
return InvalidDestination.With(reason.Message)
71+
case "ServerError":
72+
return ServerError.With(reason.Message)
73+
case "MediaTypeNotAllowed":
74+
return MediaTypeNotAllowed.With(reason.Message)
75+
case "InvalidMediaContentLength":
76+
return InvalidMediaContentLength.With(reason.Message)
77+
case "RecipientOptedOut":
78+
return RecipientOptedOut.With(reason.Message)
79+
}
80+
return GeneralError.With(reason.Message)
81+
}
82+
83+
// AsError converts this to an error
84+
func (message OpenMessageReceipt) AsError() error {
85+
if !message.IsFailed() {
86+
return nil
87+
}
88+
return errors.Join(core.Map(message.Reasons, func(reason StatusReason) error { return reason.AsError() })...)
89+
}
90+
5191
// Redact redacts sensitive data
5292
//
5393
// implements logger.Redactable

openmessaging_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,29 @@ func (suite *OpenMessagingSuite) TestCanUnmarshalOpenMessageStructuredWithParame
309309
suite.Assert().Equal("Happy", value)
310310
}
311311

312+
func (suite *OpenMessagingSuite) TestCanUnmarshalReceipt() {
313+
var receipt gcloudcx.OpenMessageReceipt
314+
err := suite.UnmarshalData("response-inbound-receipt.json", &receipt)
315+
suite.Require().NoErrorf(err, "Failed to unmarshal OpenMessageReceipt. %s", err)
316+
suite.Assert().False(receipt.IsFailed(), "Receipt should not be failed")
317+
suite.Assert().Equal("Delivered", receipt.Status)
318+
suite.Assert().Equal("Outbound", receipt.Direction)
319+
suite.Assert().Equal("c8e53e498891dfc9400c79a278cc1863", receipt.ID)
320+
}
321+
322+
func (suite *OpenMessagingSuite) TestCanUnmarshalReceiptWithErrors() {
323+
var receipt gcloudcx.OpenMessageReceipt
324+
err := suite.UnmarshalData("response-inbound-receipt-errors.json", &receipt)
325+
suite.Require().NoErrorf(err, "Failed to unmarshal OpenMessageReceipt. %s", err)
326+
suite.Assert().True(receipt.IsFailed(), "Receipt should be failed")
327+
suite.Assert().Equal("Outbound", receipt.Direction)
328+
suite.Assert().Equal("c8e53e498891dfc9400c79a278cc1863", receipt.ID)
329+
err = receipt.AsError()
330+
suite.Require().Error(err, "Receipt should be convert to an error")
331+
suite.ErrorIs(err, gcloudcx.GeneralError, "Receipt should convert to a GeneralError")
332+
suite.ErrorIs(err, gcloudcx.RateLimited, "Receipt should convert to a RateLimited")
333+
}
334+
312335
func (suite *OpenMessagingSuite) TestCanRedactOpenMessage() {
313336
message := gcloudcx.OpenMessageText{
314337
ID: "12345678",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"id": "c8e53e498891dfc9400c79a278cc1863",
3+
"channel": {
4+
"id": "a9d478ff-da37-4d41-88e8-01536aee464a",
5+
"platform": "Open",
6+
"type": "Private",
7+
"messageId": "c8e53e498891dfc9400c79a278cc1863",
8+
"to": {
9+
"id": "52b5eb487cebd87aa1dd4a5522852996|97147047050"
10+
},
11+
"from": {
12+
"id": "a9d478ff-da37-4d41-88e8-01536aee464a",
13+
"idType": "Opaque"
14+
},
15+
"time": "2023-08-03T13:06:05Z",
16+
"metadata": {
17+
"customAttributes": {
18+
"gum-tenantId": "722320d4-5ff7-4bd8-9cbb-94b7445b8273"
19+
}
20+
}
21+
},
22+
"type": "Receipt",
23+
"status": "Failed",
24+
"reasons": [
25+
{
26+
"code": "GeneralError",
27+
"message": "some general error"
28+
},
29+
{
30+
"code": "RateLimited",
31+
"message": "you have reached your limit"
32+
}
33+
],
34+
"isFinalReceipt": false,
35+
"direction": "Outbound",
36+
"metadata": {
37+
"gum-correlationId": "a7a1fc65-a368-4042-a227-c04b043796bc",
38+
"type": "delivery"
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"id": "c8e53e498891dfc9400c79a278cc1863",
3+
"channel": {
4+
"id": "a9d478ff-da37-4d41-88e8-01536aee464a",
5+
"platform": "Open",
6+
"type": "Private",
7+
"messageId": "c8e53e498891dfc9400c79a278cc1863",
8+
"to": {
9+
"id": "52b5eb487cebd87aa1dd4a5522852996|97147047050"
10+
},
11+
"from": {
12+
"id": "a9d478ff-da37-4d41-88e8-01536aee464a",
13+
"idType": "Opaque"
14+
},
15+
"time": "2023-08-03T13:06:05Z",
16+
"metadata": {
17+
"customAttributes": {
18+
"gum-tenantId": "722320d4-5ff7-4bd8-9cbb-94b7445b8273"
19+
}
20+
}
21+
},
22+
"type": "Receipt",
23+
"status": "Delivered",
24+
"reasons": [
25+
{
26+
"code": "GeneralError",
27+
"message": ""
28+
},
29+
{
30+
"code": "GeneralError",
31+
"message": ""
32+
}
33+
],
34+
"isFinalReceipt": false,
35+
"direction": "Outbound",
36+
"metadata": {
37+
"gum-correlationId": "a7a1fc65-a368-4042-a227-c04b043796bc",
38+
"type": "delivery"
39+
}
40+
}

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package gcloudcx
44
var commit string
55

66
// VERSION is the version of this application
7-
var VERSION = "0.8.4" + commit
7+
var VERSION = "0.8.6" + commit
88

99
// APP is the name of the application
1010
const APP string = "GCloudCX Client"

0 commit comments

Comments
 (0)