From 1edc683dd5e5afec7a97139d861d8892ecab458e Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 9 Jan 2023 15:56:46 +0700 Subject: [PATCH] add subject process product req --- client/product.go | 17 +++++++++++++++++ subject/product.go | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/product.go b/client/product.go index 340ba21..a581b9d 100644 --- a/client/product.go +++ b/client/product.go @@ -33,3 +33,20 @@ func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error { } return nil } + +func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error { + msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, toBytes(p)) + if err != nil { + return err + } + var r struct { + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return err + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} diff --git a/subject/product.go b/subject/product.go index 3911ecb..348aca9 100644 --- a/subject/product.go +++ b/subject/product.go @@ -8,7 +8,9 @@ func getProductValue(val string) string { } var Product = struct { - ApplyRequest string + ApplyRequest string + ProcessApplyRequest string }{ - ApplyRequest: getProductValue("apply_request"), + ApplyRequest: getProductValue("apply_request"), + ProcessApplyRequest: getProductValue("process_apply_request"), }