Skip to content

Commit

Permalink
Merge pull request #14 from gildas/release/0.9.0
Browse files Browse the repository at this point in the history
Merge release/0.9.0
  • Loading branch information
gildas authored May 21, 2024
2 parents 1f1edfa + 5d88334 commit 16de361
Show file tree
Hide file tree
Showing 21 changed files with 660 additions and 327 deletions.
16 changes: 16 additions & 0 deletions biography.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
package gcloudcx

import "github.com/gildas/go-logger"

// Biography describes a User's biography
type Biography struct {
Biography string `json:"biography"`
Interests []string `json:"interests"`
Hobbies []string `json:"hobbies"`
Spouse string `json:"spouse"`
}

// Redact redacts sensitive data
//
// implements logger.Redactable
func (biography Biography) Redact() interface{} {
redacted := biography
if len(biography.Biography) > 0 {
redacted.Biography = logger.RedactWithHash(biography.Biography)
}
if len(biography.Spouse) > 0 {
redacted.Spouse = logger.RedactWithHash(biography.Spouse)
}
return &redacted
}
4 changes: 1 addition & 3 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (suite *ClientSuite) TestShouldFailLoginWithInvalidClientCredentialsSecret(
suite.Require().Error(err, "Login should have failed")
suite.Logger.Errorf("Expected Error", err)
suite.Assert().NotErrorIs(err, errors.RuntimeError)
suite.Assert().ErrorIs(err, gcloudcx.BadCredentialsError)

var apiError gcloudcx.APIError
suite.Require().ErrorAs(err, &apiError, "Error should be an APIError")
Expand All @@ -160,13 +159,12 @@ func (suite *ClientSuite) TestShouldFailLoginWithInvalidClientCredentialsClientI
Logger: suite.Logger,
}).SetAuthorizationGrant(&gcloudcx.ClientCredentialsGrant{
ClientID: uuid.New(), // The chances of this being a valid Client ID are very low
Secret: core.GetEnvAsString("PURECLOUD_CLIENTSECRET", "s3cr3t"),
Secret: "s3cr3t",
})
err := client.Login(context.Background())
suite.Require().Error(err, "Login should have failed")
suite.Logger.Errorf("Expected Error", err)
suite.Assert().NotErrorIs(err, errors.RuntimeError)
suite.Assert().ErrorIs(err, gcloudcx.BadCredentialsError)

var apiError gcloudcx.APIError
suite.Require().ErrorAs(err, &apiError, "Error should be an APIError")
Expand Down
16 changes: 16 additions & 0 deletions contact.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gcloudcx

import "github.com/gildas/go-logger"

// Contact describes something that can be contacted
type Contact struct {
Type string `json:"type"` // PRIMARY, WORK, WORK2, WORK3, WORK4, HOME, MOBILE, MAIN
Expand All @@ -15,3 +17,17 @@ type Contact struct {
func (contact Contact) String() string {
return contact.Display
}

// Redact redacts sensitive data
//
// implements logger.Redactable
func (contact Contact) Redact() interface{} {
redacted := contact
if len(contact.Display) > 0 {
redacted.Display = logger.RedactWithHash(contact.Display)
}
if len(contact.Address) > 0 {
redacted.Address = logger.RedactWithHash(contact.Address)
}
return redacted
}
24 changes: 13 additions & 11 deletions examples/OpenMessaging/chat-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,21 @@ func (server *ChatServer) Start(config *Config) {
log := server.Logger.Child(nil, "sendCX", "chat", message.Chat.ID, "message", message.ID)

log.Debugf("Sending message to GENESYS Cloud")
inboundResult, err := config.Integration.SendInboundMessage(
inboundResult, err := config.Integration.SendInboundTextMessage(
context.Background(),
&gcloudcx.OpenMessageFrom{
ID: message.UserID,
Type: "email",
Firstname: "Bob",
Lastname: "Minion",
Nickname: "",
gcloudcx.OpenMessageText{
Channel: gcloudcx.OpenMessageChannel{
MessageID: message.ID,
From: &gcloudcx.OpenMessageFrom{
ID: message.UserID,
Type: "email",
Firstname: "Bob",
Lastname: "Minion",
Nickname: "",
},
},
Text: message.Content,
},
message.ID,
message.Content,
nil,
nil,
)
if err != nil {
Log.Errorf("Failed to send inbound", err)
Expand Down
48 changes: 24 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/gildas/go-core v0.5.8
github.com/gildas/go-errors v0.3.6
github.com/gildas/go-logger v1.6.15
github.com/gildas/go-request v0.9.4
github.com/gildas/go-logger v1.7.1
github.com/gildas/go-request v0.9.5
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/gorilla/securecookie v1.1.2
github.com/gorilla/websocket v1.5.1
github.com/joho/godotenv v1.5.1
github.com/matoous/go-nanoid/v2 v2.0.0
github.com/matoous/go-nanoid/v2 v2.1.0
github.com/stretchr/testify v1.9.0
)

require (
cloud.google.com/go v0.112.2 // indirect
cloud.google.com/go/auth v0.3.0 // indirect
cloud.google.com/go v0.113.0 // indirect
cloud.google.com/go/auth v0.4.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/logging v1.9.0 // indirect
cloud.google.com/go/logging v1.10.0 // indirect
cloud.google.com/go/longrunning v0.5.7 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -45,23 +45,23 @@ require (
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.177.0 // indirect
google.golang.org/genproto v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/api v0.181.0 // indirect
google.golang.org/genproto v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 16de361

Please sign in to comment.