From b3b3ec11af6111bef95011905e2e9b6cd9c1d393 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 18 Jul 2023 12:10:11 +0530 Subject: [PATCH 01/19] SMS-6060 WhatsApp message support in Go SDK --- messages.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/messages.go b/messages.go index 59bbec0..3ddfe60 100644 --- a/messages.go +++ b/messages.go @@ -23,8 +23,9 @@ type MessageCreateParams struct { MediaUrls []string `json:"media_urls,omitempty" url:"media_urls,omitempty"` MediaIds []string `json:"media_ids,omitempty" url:"media_ids,omitempty"` // Either one of src and powerpackuuid should be given - PowerpackUUID string `json:"powerpack_uuid,omitempty" url:"powerpack_uuid,omitempty"` - MessageExpiry int `json:"message_expiry,omitempty" url:"message_expiry,omitempty"` + PowerpackUUID string `json:"powerpack_uuid,omitempty" url:"powerpack_uuid,omitempty"` + MessageExpiry int `json:"message_expiry,omitempty" url:"message_expiry,omitempty"` + Template *Template `json:"template,omitempty" url:"template,omitempty"` } type Message struct { @@ -48,6 +49,9 @@ type Message struct { TendlcCampaignID string `json:"tendlc_campaign_id" url:"tendlc_campaign_id,omitempty"` TendlcRegistrationStatus string `json:"tendlc_registration_status" url:"tendlc_registration_status,omitempty"` DestinationCountryISO2 string `json:"destination_country_iso2" url:"destination_country_iso2,omitempty"` + ConversationID string `json:"conversation_id" url:"conversation_id,omitempty"` + ConversationOrigin string `json:"conversation_origin" url:"conversation_origin,omitempty"` + ConversationExpiry string `json:"conversation_expiration_timestamp" url:"conversation_expiration_timestamp,omitempty"` } // Stores response for ending a message. @@ -101,6 +105,48 @@ type MessageListParams struct { TendlcCampaignID string `url:"tendlc_campaign_id,omitempty"` TendlcRegistrationStatus string `url:"tendlc_registration_status,omitempty"` DestinationCountryISO2 string `url:"destination_country_iso2,omitempty"` + MessageType string `url:"message_type,omitempty,enum:sms,mms,whatsapp"` + ConversationID string `url:"conversation_id,omitempty"` + ConversationOrigin string `url:"conversation_origin,omitempty,enum:service,utility,authentication,marketing"` +} + +type Template struct { + Name string `mapstructure:"name" json:"name" validate:"required"` + Language string `mapstructure:"language" json:"language" validate:"required"` + Components []Component `mapstructure:"components" json:"components"` +} +type Component struct { + Type string `mapstructure:"type" json:"type" validate:"required"` + SubType string `mapstructure:"sub_type" json:"sub_type,omitempty"` + Index string `mapstructure:"index" json:"index,omitempty"` + Parameters []Parameter `mapstructure:"parameters" json:"parameters"` +} + +type Parameter struct { + Type string `mapstructure:"type" json:"type" validate:"required"` + Text string `mapstructure:"text" json:"text,omitempty"` + Media string `mapstructure:"media" json:"media,omitempty"` + Currency *Currency `mapstructure:"currency" json:"currency,omitempty"` + DateTime *DateTime `mapstructure:"date_time" json:"date_time,omitempty"` +} + +type Currency struct { + CurrencyCode string `mapstructure:"currency_code" json:"currency_code" validate:"required"` + Amount1000 int `mapstructure:"amount_1000" json:"amount_1000" validate:"required"` +} + +type HSMDateTimeComponent struct { + DayOfWeek string `mapstructure:"day_of_week" json:"day_of_week,omitempty"` + Year int `mapstructure:"year" json:"year,omitempty"` + Month int `mapstructure:"month" json:"month,omitempty"` + DayOfMonth int `mapstructure:"day_of_month" json:"day_of_month,omitempty"` + Hour int `mapstructure:"hour" json:"hour,omitempty"` + Minute int `mapstructure:"minute" json:"minute,omitempty"` + Calendar string `mapstructure:"calendar" json:"calendar,omitempty"` +} + +type DateTime struct { + Component *HSMDateTimeComponent `mapstructure:"component" json:"component" validate:"required"` } func (service *MessageService) List(params MessageListParams) (response *MessageList, err error) { From 48a88015376ab558bba024bc70c4f5421b869f31 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 18 Jul 2023 20:50:01 +0530 Subject: [PATCH 02/19] SMS-6060 adding proper template validation --- utils.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/utils.go b/utils.go index 96353ad..b028039 100644 --- a/utils.go +++ b/utils.go @@ -6,11 +6,14 @@ import ( "crypto/sha1" "crypto/sha256" "encoding/base64" + "encoding/json" "fmt" "net/url" "reflect" "sort" "strings" + + validator "github.com/go-playground/validator/v10" ) func Numbers(numbers ...string) string { @@ -171,6 +174,60 @@ func ValidateSignatureV3(uri, nonce, method, signature, authToken string, params return Find(ComputeSignatureV3(authToken, uri, method, nonce, parameters), multipleSignatures) } +func CreateWhatsappTemplate(templateData string) (template Template, err error) { + err = json.Unmarshal([]byte(templateData), &template) + if err != nil { + return + } + err = validateWhatsappTemplate(template) + if err !=nil{ + return + } + return +} + +func validateWhatsappTemplate(template Template) (err error) { + validate := validator.New() + err = validate.Struct(template) + if err != nil { + return + } + if template.Components != nil { + for _, component := range template.Components { + err = validate.Struct(component) + if err != nil { + return + } + if component.Parameters != nil { + for _, parameter := range component.Parameters { + err = validate.Struct(parameter) + if err != nil { + return + } + if parameter.Currency != nil { + err = validate.Struct(parameter.Currency) + if err != nil { + return + } + } + if parameter.DateTime != nil { + err = validate.Struct(parameter.DateTime) + if err != nil { + return + } + err = validate.Struct(parameter.DateTime.Component) + if err != nil { + return + } + } + } + } + + } + } + return +} + func Find(val string, slice []string) bool { for _, item := range slice { if item == val { From 6b2e5d71ef8857db9ac6e68dec143d019519d650 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 18 Jul 2023 21:05:40 +0530 Subject: [PATCH 03/19] SMS-6060 adding go.mod and go.sum --- go.mod | 5 +++-- go.sum | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 0f67aa9..373de43 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/plivo/plivo-go/v7 go 1.13 require ( + github.com/go-playground/validator/v10 v10.14.1 // indirect github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 - github.com/stretchr/testify v1.7.0 - golang.org/x/text v0.7.0 + github.com/stretchr/testify v1.8.2 + golang.org/x/text v0.8.0 ) diff --git a/go.sum b/go.sum index 37e31f6..10936de 100644 --- a/go.sum +++ b/go.sum @@ -1,40 +1,73 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= +github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -42,3 +75,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 97b81a82c16bd80fac37487fb083749afc6e8bd3 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 18 Jul 2023 21:20:53 +0530 Subject: [PATCH 04/19] SMS-6060 updating go.mod and go.sum --- go.mod | 2 +- go.sum | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 373de43..807f3c1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/plivo/plivo-go/v7 go 1.13 require ( - github.com/go-playground/validator/v10 v10.14.1 // indirect + github.com/go-playground/validator/v10 v10.14.1 github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 10936de..58cdb2f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,9 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -23,10 +24,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -60,7 +60,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= @@ -73,6 +72,6 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From bb6d824e04c9b585a51d2107b2d4df1f3c7b6f0c Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 02:01:29 +0530 Subject: [PATCH 05/19] SMS-6060 adding unit test and version bump --- CHANGELOG.md | 7 ++++++ baseclient.go | 2 +- utils_test.go | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 734c187..abf88e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log + +## [7.32.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-07-19) +**Feature - WhatsApp message support ** +- Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) +- Added new parameters `conversation_id`, `conversation_name`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) +- Added `message_state` filter in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) + ## [7.31.0](https://github.com/plivo/plivo-go/tree/v7.31.0) (2023-06-02) **Feature - CNAM Lookup** - Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API] diff --git a/baseclient.go b/baseclient.go index 3223289..97a1c54 100644 --- a/baseclient.go +++ b/baseclient.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-querystring/query" ) -const sdkVersion = "7.31.0" +const sdkVersion = "7.32.0" const lookupBaseUrl = "lookup.plivo.com" diff --git a/utils_test.go b/utils_test.go index d464f73..ac7bc7c 100644 --- a/utils_test.go +++ b/utils_test.go @@ -174,3 +174,64 @@ func TestValidateSignatureV3Pass4(t *testing.T) { ), ) } + +func TestCreateWhatsappTemplatePass(t *testing.T){ + template_data := `{ + "name": "plivo_verification", + "language": "en_US", + "components": [ + { + "type": "body", + "parameters": [ + { + "type": "text", + "text": "J$FpnYnP" + } + ] + }, + { + "type": "button", + "sub_type": "url", + "index": "0", + "parameters": [ + { + "type": "text", + "text": "J$FpnYnP" + } + ] + } + ] + }` + template := Template{ + Name: "plivo_verification", + Language: "en_US", + Components: []Component{ + { + Type: "body", + Parameters: []Parameter{ + { + Type: "text", + Text: "J$FpnYnP", + }, + }, + }, + { + Type: "button", + SubType: "url", + Index: "0", + Parameters: []Parameter{ + { + Type: "text", + Text: "J$FpnYnP", + }, + }, + }, + }, + } + templateCreated, _ := CreateWhatsappTemplate(template_data) + assert.Equal(t, template, templateCreated) +} + + + + From 06bebad114cc7ebab8fc4f4c747c80265fee2cfd Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 02:13:35 +0530 Subject: [PATCH 06/19] SMS-6060 update log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb1363..7df8277 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log -## [7.32.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-07-19) +## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-07-19) **Feature - WhatsApp message support ** - Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) - Added new parameters `conversation_id`, `conversation_name`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) From 7f9b47e714d35c4011cd0a8d4b434441e9bb36fd Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 02:14:05 +0530 Subject: [PATCH 07/19] update log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df8277..2ea750e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log -## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-07-19) +## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.33.0) (2023-07-19) **Feature - WhatsApp message support ** - Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) - Added new parameters `conversation_id`, `conversation_name`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) From 990ff9f05406c51f278a5def6a548fc2d5c0de1a Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 02:55:54 +0530 Subject: [PATCH 08/19] SMS-6060 go mod and go sum change --- CHANGELOG.md | 4 ++-- go.mod | 3 ++- go.sum | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea750e..0e7aa5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ ## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.33.0) (2023-07-19) **Feature - WhatsApp message support ** - Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) -- Added new parameters `conversation_id`, `conversation_name`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) -- Added `message_state` filter in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) +- Added new parameters `conversation_id`, `conversation_origin`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) +- Added new filters `message_type`,`conversation_id`, `conversation_origin` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) ## [7.32.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-06-28) **Audio Streaming** diff --git a/go.mod b/go.mod index 807f3c1..55bf886 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,6 @@ require ( github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 github.com/stretchr/testify v1.8.2 - golang.org/x/text v0.8.0 + golang.org/x/net v0.12.0 // indirect + golang.org/x/text v0.11.0 ) diff --git a/go.sum b/go.sum index 58cdb2f..037c8e7 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -41,6 +43,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -52,10 +57,15 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -63,6 +73,9 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= From 3cf1fb7bd392d17050ef83d61022c665a96d57bc Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 03:12:16 +0530 Subject: [PATCH 09/19] go sum change --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index 037c8e7..8ed9fb3 100644 --- a/go.sum +++ b/go.sum @@ -31,7 +31,6 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= @@ -41,7 +40,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= @@ -55,7 +53,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= @@ -71,7 +68,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= From 10d6faef2af2f2fe3ba1461475c10461c74304c2 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 03:26:52 +0530 Subject: [PATCH 10/19] SMS-6060 go validitor version downgarde --- go.mod | 6 ++++-- go.sum | 26 ++++---------------------- utils.go | 2 +- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 55bf886..99c47a5 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,12 @@ module github.com/plivo/plivo-go/v7 go 1.13 require ( - github.com/go-playground/validator/v10 v10.14.1 + github.com/go-playground/universal-translator v0.18.1 // indirect github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 + github.com/leodido/go-urn v1.2.4 // indirect github.com/stretchr/testify v1.8.2 - golang.org/x/net v0.12.0 // indirect golang.org/x/text v0.11.0 + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect + gopkg.in/go-playground/validator.v9 v9.31.0 ) diff --git a/go.sum b/go.sum index 8ed9fb3..0fadcb6 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= -github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= @@ -31,19 +25,12 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -53,23 +40,14 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -81,6 +59,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= +gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/utils.go b/utils.go index b028039..834cebf 100644 --- a/utils.go +++ b/utils.go @@ -13,7 +13,7 @@ import ( "sort" "strings" - validator "github.com/go-playground/validator/v10" + validator "gopkg.in/go-playground/validator.v9" ) func Numbers(numbers ...string) string { From 0bc9ae2fc05b9a909501970ee9565bd59586a132 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 19 Jul 2023 03:32:41 +0530 Subject: [PATCH 11/19] SMS-6060 go universal-translator --- go.mod | 3 ++- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 99c47a5..b14b0aa 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,8 @@ module github.com/plivo/plivo-go/v7 go 1.13 require ( - github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.16.0 // indirect github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 github.com/leodido/go-urn v1.2.4 // indirect diff --git a/go.sum b/go.sum index 0fadcb6..f8747fd 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= From 1c4656ea1c27a0e2b789bc282e66afec7465a6ed Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 25 Jul 2023 14:08:18 +0530 Subject: [PATCH 12/19] version upgrade --- .github/workflows/test.yml | 2 +- go.mod | 16 +++++++++++----- go.sum | 36 ++---------------------------------- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf8ed62..728fcfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: unittest: strategy: matrix: - go-version: [1.13, 1.14, 1.15, 1.16, 1.17] + go-version: [1.13, 1.14, 1.15, 1.16, 1.17, 1.19] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/go.mod b/go.mod index b14b0aa..f6098b0 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,21 @@ module github.com/plivo/plivo-go/v7 -go 1.13 +go 1.19 require ( - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.16.0 // indirect github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 github.com/google/go-querystring v1.1.0 - github.com/leodido/go-urn v1.2.4 // indirect github.com/stretchr/testify v1.8.2 golang.org/x/text v0.11.0 - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index f8747fd..7fb359d 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= @@ -22,40 +22,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From fa7882265329387122d383133b72e9c6c500fd77 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 25 Jul 2023 15:55:31 +0530 Subject: [PATCH 13/19] SMS-6060 version upgrade changes --- CHANGELOG.md | 3 ++- baseclient.go | 8 ++++---- compliance_documents.go | 4 ++-- testutils_test.go | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7aa5b..65e617a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ ## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.33.0) (2023-07-19) -**Feature - WhatsApp message support ** +**Feature - WhatsApp message support and golang version upgrade** - Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) - Added new parameters `conversation_id`, `conversation_origin`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) - Added new filters `message_type`,`conversation_id`, `conversation_origin` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) +- Did version upgrade of golang from 1.13 to 1.19 ## [7.32.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-06-28) **Audio Streaming** diff --git a/baseclient.go b/baseclient.go index ee70238..598f498 100644 --- a/baseclient.go +++ b/baseclient.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -121,15 +121,15 @@ func (client *BaseClient) ExecuteRequest(request *http.Request, body interface{} } } } - bodyCopy, _ := ioutil.ReadAll(request.Body) - request.Body = ioutil.NopCloser(bytes.NewReader(bodyCopy)) + bodyCopy, _ := io.ReadAll(request.Body) + request.Body = io.NopCloser(bytes.NewReader(bodyCopy)) response, err := client.httpClient.Do(request) if err != nil { return } - data, err := ioutil.ReadAll(response.Body) + data, err := io.ReadAll(response.Body) if err == nil && data != nil && len(data) > 0 { if isVoiceRequest && response.StatusCode >= 500 { if extra[0]["retry"] == 2 { diff --git a/compliance_documents.go b/compliance_documents.go index ee60261..2eabf4b 100644 --- a/compliance_documents.go +++ b/compliance_documents.go @@ -3,7 +3,7 @@ package plivo import ( "bytes" "fmt" - "io/ioutil" + "io" "mime/multipart" "net/http" "os" @@ -171,7 +171,7 @@ func newfileUploadRequest(uri string, params map[string]string, paramName, path if err != nil { return nil, err } - fileContents, err := ioutil.ReadAll(file) + fileContents, err := io.ReadAll(file) if err != nil { return nil, err } diff --git a/testutils_test.go b/testutils_test.go index ab57283..6146324 100644 --- a/testutils_test.go +++ b/testutils_test.go @@ -2,7 +2,7 @@ package plivo import ( "fmt" - "io/ioutil" + "os" "log" "net/http" "net/http/httptest" @@ -37,7 +37,7 @@ func expectResponse(fixturePath string, statusCode int) { fixturePathRunes := []rune(fixturePath) fixturePathRunes[0] = unicode.ToLower(fixturePathRunes[0]) fullFixturePath := fmt.Sprintf("fixtures/%s", string(fixturePathRunes)) - contents, err := ioutil.ReadFile(fullFixturePath) + contents, err := os.ReadFile(fullFixturePath) if err != nil { panic(err) } From e630c206748fb7d4e7bcf11401bd74991bec74a8 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Tue, 25 Jul 2023 17:14:57 +0530 Subject: [PATCH 14/19] SMS-6060 changing currency and datetime model --- messages.go | 13 ++----------- utils.go | 4 ---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/messages.go b/messages.go index 3ddfe60..f608fb2 100644 --- a/messages.go +++ b/messages.go @@ -131,22 +131,13 @@ type Parameter struct { } type Currency struct { + FallbackValue string `mapstructure:"fallback_value" json:"fallback_value" validate:"required"` CurrencyCode string `mapstructure:"currency_code" json:"currency_code" validate:"required"` Amount1000 int `mapstructure:"amount_1000" json:"amount_1000" validate:"required"` } -type HSMDateTimeComponent struct { - DayOfWeek string `mapstructure:"day_of_week" json:"day_of_week,omitempty"` - Year int `mapstructure:"year" json:"year,omitempty"` - Month int `mapstructure:"month" json:"month,omitempty"` - DayOfMonth int `mapstructure:"day_of_month" json:"day_of_month,omitempty"` - Hour int `mapstructure:"hour" json:"hour,omitempty"` - Minute int `mapstructure:"minute" json:"minute,omitempty"` - Calendar string `mapstructure:"calendar" json:"calendar,omitempty"` -} - type DateTime struct { - Component *HSMDateTimeComponent `mapstructure:"component" json:"component" validate:"required"` + FallbackValue string `mapstructure:"fallback_value" json:"fallback_value" validate:"required"` } func (service *MessageService) List(params MessageListParams) (response *MessageList, err error) { diff --git a/utils.go b/utils.go index 834cebf..8bea28d 100644 --- a/utils.go +++ b/utils.go @@ -215,10 +215,6 @@ func validateWhatsappTemplate(template Template) (err error) { if err != nil { return } - err = validate.Struct(parameter.DateTime.Component) - if err != nil { - return - } } } } From fd2722228b3cd901d57d4bcef2f1846c9385954c Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 26 Jul 2023 22:42:12 +0530 Subject: [PATCH 15/19] SMS-6060 downgrading version --- .github/workflows/test.yml | 2 +- baseclient.go | 8 ++++---- compliance_documents.go | 4 ++-- go.mod | 18 ++++++----------- go.sum | 40 ++++++++++++++++++++++++++++++++++---- testutils_test.go | 4 ++-- 6 files changed, 51 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 728fcfb..bf8ed62 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: unittest: strategy: matrix: - go-version: [1.13, 1.14, 1.15, 1.16, 1.17, 1.19] + go-version: [1.13, 1.14, 1.15, 1.16, 1.17] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/baseclient.go b/baseclient.go index 598f498..ee70238 100644 --- a/baseclient.go +++ b/baseclient.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io" + "io/ioutil" "net/http" "net/url" "reflect" @@ -121,15 +121,15 @@ func (client *BaseClient) ExecuteRequest(request *http.Request, body interface{} } } } - bodyCopy, _ := io.ReadAll(request.Body) - request.Body = io.NopCloser(bytes.NewReader(bodyCopy)) + bodyCopy, _ := ioutil.ReadAll(request.Body) + request.Body = ioutil.NopCloser(bytes.NewReader(bodyCopy)) response, err := client.httpClient.Do(request) if err != nil { return } - data, err := io.ReadAll(response.Body) + data, err := ioutil.ReadAll(response.Body) if err == nil && data != nil && len(data) > 0 { if isVoiceRequest && response.StatusCode >= 500 { if extra[0]["retry"] == 2 { diff --git a/compliance_documents.go b/compliance_documents.go index 2eabf4b..ee60261 100644 --- a/compliance_documents.go +++ b/compliance_documents.go @@ -3,7 +3,7 @@ package plivo import ( "bytes" "fmt" - "io" + "io/ioutil" "mime/multipart" "net/http" "os" @@ -171,7 +171,7 @@ func newfileUploadRequest(uri string, params map[string]string, paramName, path if err != nil { return nil, err } - fileContents, err := io.ReadAll(file) + fileContents, err := ioutil.ReadAll(file) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index f6098b0..a9e6116 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,15 @@ module github.com/plivo/plivo-go/v7 -go 1.19 +go 1.13 require ( - github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.16.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 github.com/google/go-querystring v1.1.0 + github.com/leodido/go-urn v1.2.4 // indirect github.com/stretchr/testify v1.8.2 golang.org/x/text v0.11.0 - gopkg.in/go-playground/validator.v9 v9.31.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + gopkg.in/go-playground/validator.v9 v9.31.0 ) diff --git a/go.sum b/go.sum index 7fb359d..2d64d31 100644 --- a/go.sum +++ b/go.sum @@ -3,10 +3,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= -github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -22,8 +22,40 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/testutils_test.go b/testutils_test.go index 6146324..ab57283 100644 --- a/testutils_test.go +++ b/testutils_test.go @@ -2,7 +2,7 @@ package plivo import ( "fmt" - "os" + "io/ioutil" "log" "net/http" "net/http/httptest" @@ -37,7 +37,7 @@ func expectResponse(fixturePath string, statusCode int) { fixturePathRunes := []rune(fixturePath) fixturePathRunes[0] = unicode.ToLower(fixturePathRunes[0]) fullFixturePath := fmt.Sprintf("fixtures/%s", string(fixturePathRunes)) - contents, err := os.ReadFile(fullFixturePath) + contents, err := ioutil.ReadFile(fullFixturePath) if err != nil { panic(err) } From e0320e64bcb876542d49d10798db299025115f8d Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 26 Jul 2023 22:45:45 +0530 Subject: [PATCH 16/19] SMS-6060 updating CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65e617a..8025bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,11 @@ ## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.33.0) (2023-07-19) -**Feature - WhatsApp message support and golang version upgrade** +**Feature - WhatsApp message support** - Added new param `template` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) - Added new parameters `conversation_id`, `conversation_origin`,`conversation_expiry` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) - Added new filters `message_type`,`conversation_id`, `conversation_origin` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) -- Did version upgrade of golang from 1.13 to 1.19 + ## [7.32.0](https://github.com/plivo/plivo-go/tree/v7.32.0) (2023-06-28) **Audio Streaming** From ef36acc100a5120e6cd3e602ae2987d678783302 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Fri, 4 Aug 2023 12:40:23 +0530 Subject: [PATCH 17/19] SMS-6060 adding versioning and unit tests --- fixtures/messageGetResponse.json | 6 +- fixtures/messageListResponse.json | 100 ++++++++++++++++++++++++------ messages.go | 52 ++++++++-------- messages_test.go | 12 ++++ 4 files changed, 123 insertions(+), 47 deletions(-) diff --git a/fixtures/messageGetResponse.json b/fixtures/messageGetResponse.json index 3516e91..58fcfde 100644 --- a/fixtures/messageGetResponse.json +++ b/fixtures/messageGetResponse.json @@ -16,5 +16,9 @@ "is_domestic": false, "dlt_entity_id": "1234", "dlt_template_id": "5678", - "dlt_template_category": "service_implicit" + "dlt_template_category": "service_implicit", + "conversation_id": "9876", + "conversation_origin": "utility", + "conversation_expiration_timestamp": "2023-08-03 23:02:00+05:30" + } diff --git a/fixtures/messageListResponse.json b/fixtures/messageListResponse.json index c781540..2481ad8 100644 --- a/fixtures/messageListResponse.json +++ b/fixtures/messageListResponse.json @@ -24,7 +24,10 @@ "is_domestic": false, "dlt_entity_id": "1111", "dlt_template_id": "2222", - "dlt_template_category": "promotional" + "dlt_template_category": "promotional", + "conversation_id": "0079", + "conversation_origin": "marketing", + "conversation_expiration_timestamp": "2023-08-03 23:02:00+05:30" }, { "error_code": null, @@ -43,7 +46,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -62,7 +68,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -81,7 +90,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -100,7 +112,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -119,7 +134,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -138,7 +156,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -157,7 +178,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -176,7 +200,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -195,7 +222,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -214,7 +244,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -233,7 +266,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -252,7 +288,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -271,7 +310,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -290,7 +332,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -309,7 +354,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -328,7 +376,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -347,7 +398,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -366,7 +420,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -385,7 +442,10 @@ "is_domestic": false, "dlt_entity_id": "", "dlt_template_id": "", - "dlt_template_category": "" + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" } ] } diff --git a/messages.go b/messages.go index 72ea345..4754483 100644 --- a/messages.go +++ b/messages.go @@ -32,32 +32,32 @@ type MessageCreateParams struct { } type Message struct { - ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"` - ToNumber string `json:"to_number,omitempty" url:"to_number,omitempty"` - FromNumber string `json:"from_number,omitempty" url:"from_number,omitempty"` - CloudRate string `json:"cloud_rate,omitempty" url:"cloud_rate,omitempty"` - MessageType string `json:"message_type,omitempty" url:"message_type,omitempty"` - ResourceURI string `json:"resource_uri,omitempty" url:"resource_uri,omitempty"` - CarrierRate string `json:"carrier_rate,omitempty" url:"carrier_rate,omitempty"` - MessageDirection string `json:"message_direction,omitempty" url:"message_direction,omitempty"` - MessageState string `json:"message_state,omitempty" url:"message_state,omitempty"` - TotalAmount string `json:"total_amount,omitempty" url:"total_amount,omitempty"` - MessageUUID string `json:"message_uuid,omitempty" url:"message_uuid,omitempty"` - MessageTime string `json:"message_time,omitempty" url:"message_time,omitempty"` - ErrorCode string `json:"error_code,omitempty" url:"error_code,omitempty"` - PowerpackID string `json:"powerpack_id,omitempty" url:"powerpack_id,omitempty"` - RequesterIP string `json:"requester_ip,omitempty" url:"requester_ip,omitempty"` - IsDomestic *bool `json:"is_domestic,omitempty" url:"is_domestic,omitempty"` - ReplacedSender string `json:"replaced_sender,omitempty" url:"replaced_sender,omitempty"` - TendlcCampaignID string `json:"tendlc_campaign_id" url:"tendlc_campaign_id,omitempty"` - TendlcRegistrationStatus string `json:"tendlc_registration_status" url:"tendlc_registration_status,omitempty"` - DestinationCountryISO2 string `json:"destination_country_iso2" url:"destination_country_iso2,omitempty"` - ConversationID string `json:"conversation_id" url:"conversation_id,omitempty"` - ConversationOrigin string `json:"conversation_origin" url:"conversation_origin,omitempty"` - ConversationExpiry string `json:"conversation_expiration_timestamp" url:"conversation_expiration_timestamp,omitempty"` - DLTEntityID string `json:"dlt_entity_id" url:"dlt_entity_id,omitempty"` - DLTTemplateID string `json:"dlt_template_id" url:"dlt_template_id,omitempty"` - DLTTemplateCategory string `json:"dlt_template_category" url:"dlt_template_category,omitempty"` + ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"` + ToNumber string `json:"to_number,omitempty" url:"to_number,omitempty"` + FromNumber string `json:"from_number,omitempty" url:"from_number,omitempty"` + CloudRate string `json:"cloud_rate,omitempty" url:"cloud_rate,omitempty"` + MessageType string `json:"message_type,omitempty" url:"message_type,omitempty"` + ResourceURI string `json:"resource_uri,omitempty" url:"resource_uri,omitempty"` + CarrierRate string `json:"carrier_rate,omitempty" url:"carrier_rate,omitempty"` + MessageDirection string `json:"message_direction,omitempty" url:"message_direction,omitempty"` + MessageState string `json:"message_state,omitempty" url:"message_state,omitempty"` + TotalAmount string `json:"total_amount,omitempty" url:"total_amount,omitempty"` + MessageUUID string `json:"message_uuid,omitempty" url:"message_uuid,omitempty"` + MessageTime string `json:"message_time,omitempty" url:"message_time,omitempty"` + ErrorCode string `json:"error_code,omitempty" url:"error_code,omitempty"` + PowerpackID string `json:"powerpack_id,omitempty" url:"powerpack_id,omitempty"` + RequesterIP string `json:"requester_ip,omitempty" url:"requester_ip,omitempty"` + IsDomestic *bool `json:"is_domestic,omitempty" url:"is_domestic,omitempty"` + ReplacedSender string `json:"replaced_sender,omitempty" url:"replaced_sender,omitempty"` + TendlcCampaignID string `json:"tendlc_campaign_id" url:"tendlc_campaign_id,omitempty"` + TendlcRegistrationStatus string `json:"tendlc_registration_status" url:"tendlc_registration_status,omitempty"` + DestinationCountryISO2 string `json:"destination_country_iso2" url:"destination_country_iso2,omitempty"` + ConversationID string `json:"conversation_id" url:"conversation_id,omitempty"` + ConversationOrigin string `json:"conversation_origin" url:"conversation_origin,omitempty"` + ConversationExpirationTimestamp string `json:"conversation_expiration_timestamp" url:"conversation_expiration_timestamp,omitempty"` + DLTEntityID string `json:"dlt_entity_id" url:"dlt_entity_id,omitempty"` + DLTTemplateID string `json:"dlt_template_id" url:"dlt_template_id,omitempty"` + DLTTemplateCategory string `json:"dlt_template_category" url:"dlt_template_category,omitempty"` } // Stores response for ending a message. diff --git a/messages_test.go b/messages_test.go index ba6b2c3..1a46751 100644 --- a/messages_test.go +++ b/messages_test.go @@ -26,6 +26,14 @@ func TestMessageService_List(t *testing.T) { assert.Equal(resp.Objects[19].DLTTemplateID, "") assert.Equal(resp.Objects[19].DLTTemplateCategory, "") + assert.Equal(resp.Objects[0].ConversationID, "0079"); + assert.Equal(resp.Objects[0].ConversationOrigin, "marketing"); + assert.Equal(resp.Objects[0].ConversationExpirationTimestamp, "2023-08-03 23:02:00+05:30"); + + assert.Equal(resp.Objects[19].ConversationID, ""); + assert.Equal(resp.Objects[19].ConversationOrigin, ""); + assert.Equal(resp.Objects[19].ConversationExpirationTimestamp, ""); + assert.NotNil(resp.Meta) cl := client.httpClient client.httpClient = nil @@ -50,6 +58,10 @@ func TestMessageService_Get(t *testing.T) { assert.Equal(resp.DLTTemplateID, "5678") assert.Equal(resp.DLTTemplateCategory, "service_implicit") + assert.Equal(resp.ConversationID, "9876"); + assert.Equal(resp.ConversationOrigin, "utility"); + assert.Equal(resp.ConversationExpirationTimestamp, "2023-08-03 23:02:00+05:30"); + cl := client.httpClient client.httpClient = nil resp, err = client.Messages.Get(uuid) From 6f4d0bd52946f1e687ed8ca23e4c7629a84b5aaa Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Mon, 7 Aug 2023 16:53:08 +0530 Subject: [PATCH 18/19] updating Changelog.md file --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 290d81e..06180d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## [7.35.0](https://github.com/plivo/plivo-go/tree/v7.35.0) (2023-08-07) **Feature - WhatsApp message support** - Added new param `template` and new message_type `whatsapp` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) -- Added new parameters `conversationID`, `conversationOrigin`,`conversationExpirationTimestamp` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) reponse -- Added new filters including `message_states` (`read`,`deleted`) `message_type`(`whatsapp`),`conversation_id`, `conversation_origin` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) +- Added new `message_states` (`read`) `message_type`(`whatsapp`),`conversation_id`, `conversation_origin`, 'conversation_expiry_timestamp' in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) response + ## [7.34.0](https://github.com/plivo/plivo-go/tree/v7.34.0) (2023-08-03) **Feature - DLT parameters** From 81589830fb3588905a207562190c55030221fc42 Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Mon, 7 Aug 2023 17:07:54 +0530 Subject: [PATCH 19/19] updating Changelog.md file --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06180d8..681ee4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [7.35.0](https://github.com/plivo/plivo-go/tree/v7.35.0) (2023-08-07) **Feature - WhatsApp message support** - Added new param `template` and new message_type `whatsapp` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) -- Added new `message_states` (`read`) `message_type`(`whatsapp`),`conversation_id`, `conversation_origin`, 'conversation_expiry_timestamp' in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) response +- Added new `message_states` (`read`) `message_type`(`whatsapp`),`conversation_id`, `conversation_origin`, `conversation_expiry_timestamp` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) response ## [7.34.0](https://github.com/plivo/plivo-go/tree/v7.34.0) (2023-08-03)