Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: WhatsApp order details #168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion core/handlers/msg_wpp_created_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestMsgWppCreated(t *testing.T) {
nil,
"nil",
"",
nil,
true,
),
},
Expand All @@ -64,6 +65,7 @@ func TestMsgWppCreated(t *testing.T) {
nil,
"nil",
"",
nil,
true,
),
},
Expand All @@ -80,11 +82,12 @@ func TestMsgWppCreated(t *testing.T) {
nil,
"nil",
"",
nil,
true,
),
},
testdata.Bob: []flows.Action{
actions.NewSendWppMsg(handlers.NewActionUUID(), "", "", "", "Text", "footer", []flows.ListItems{}, "Menu", nil, "", "", "", nil, "", "", false),
actions.NewSendWppMsg(handlers.NewActionUUID(), "", "", "", "Text", "footer", []flows.ListItems{}, "Menu", nil, "", "", "", nil, "", "", nil, false),
},
testdata.Cathy: []flows.Action{
actions.NewSendWppMsg(
Expand All @@ -99,6 +102,50 @@ func TestMsgWppCreated(t *testing.T) {
map[string]interface{}{"uuid": testdata.Cathy.UUID, "extra": "[\"foo\", \"bar\"]"},
"WELCOME_SCREEN",
"published",
nil,
true,
),
},
testdata.Cathy: []flows.Action{
actions.NewSendWppMsg(
handlers.NewActionUUID(),
"text", "Hi", "", "Hi there.", "footer",
[]flows.ListItems{},
"",
nil,
"order_details",
"",
"",
nil,
"",
"",
&flows.OrderDetails{
ReferenceID: "5278474598478",
Items: "[{\"retaler_id\":\"12345\",\"name\":\"item1\",\"amount\":\"1025\",\"quantity\":\"10\",\"sale_amount\":\"859\"}]",
Tax: &flows.OrderAmountWithDescription{
Value: "10.00",
Description: "Tax",
},
Shipping: &flows.OrderAmountWithDescription{
Value: "5.00",
Description: "Shipping",
},
Discount: &flows.OrderDiscount{
Value: "2.00",
Description: "Discount",
ProgramName: "Program",
},
PaymentSettings: &flows.OrderPaymentSettings{
Type: "digital-goods",
PaymentLink: "https://foo.bar",
PixConfig: &flows.OrderPixConfig{
Key: "pix_key@email.com",
KeyType: "email",
MerchantName: "Merchant",
Code: "123456",
},
},
},
true,
),
},
Expand Down
4 changes: 4 additions & 0 deletions core/models/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ func newOutgoingMsgWpp(rt *runtime.Runtime, org *Org, channel *Channel, contactI
"flow_mode": msgWpp.FlowMessage().FlowMode,
}
}
if msgWpp.InteractionType() == "order_details" {
metadata["interaction_type"] = msgWpp.InteractionType()
metadata["order_details_message"] = msgWpp.OrderDetailsMessage()
}
if msgWpp.TextLanguage != "" {
metadata["text_language"] = msgWpp.TextLanguage
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ go 1.17

replace github.com/nyaruka/gocommon => github.com/Ilhasoft/gocommon v1.16.2-weni

replace github.com/nyaruka/goflow => github.com/weni-ai/goflow v1.1.0
replace github.com/nyaruka/goflow => github.com/weni-ai/goflow v1.2.0-3-develop
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,8 @@ github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLD
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
github.com/weni-ai/goflow v1.0.0 h1:19Zm8owCQWoFb+fWUxiKpWyB+KysxwJzk7ZwNolSjlo=
github.com/weni-ai/goflow v1.0.0/go.mod h1:o0xaVWP9qNcauBSlcNLa79Fm2oCPV+BDpheFRa/D40c=
github.com/weni-ai/goflow v1.1.0 h1:/UC432ghh6fkhb05Z6c/JxGWf8ej5CNVF67t9gZcIVU=
github.com/weni-ai/goflow v1.1.0/go.mod h1:o0xaVWP9qNcauBSlcNLa79Fm2oCPV+BDpheFRa/D40c=
github.com/weni-ai/goflow v1.2.0-3-develop h1:FPYaStI9M/RPYJjHEIbY7/e/roKKg+CZoLdIxMGqVv4=
github.com/weni-ai/goflow v1.2.0-3-develop/go.mod h1:o0xaVWP9qNcauBSlcNLa79Fm2oCPV+BDpheFRa/D40c=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
Loading