From 4d501a437c7d4b65d8f766cb38c28821364f6371 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 13:57:22 +0700 Subject: [PATCH] build authsms --- client/withdraw.go | 39 +++++++++++++++++++++++++++++++++++++++ model/bank_request.go | 11 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 client/withdraw.go create mode 100644 model/bank_request.go diff --git a/client/withdraw.go b/client/withdraw.go new file mode 100644 index 0000000..006d7a7 --- /dev/null +++ b/client/withdraw.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "errors" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Withdraw ... +type Withdraw struct{} + +// GetWithdraw ... +func GetWithdraw() Withdraw { + return Withdraw{} +} + +// GetSupplierCash ... +func (o Withdraw) GetSupplierCash(p model.WithdrawSupplierCashReq) (*model.WithdrawSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Withdraw.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.WithdrawSupplierCashRes `json:"data"` + Error string `json:"error"` + } + ) + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return &r.Data, nil +} diff --git a/model/bank_request.go b/model/bank_request.go new file mode 100644 index 0000000..3b76615 --- /dev/null +++ b/model/bank_request.go @@ -0,0 +1,11 @@ +package model + +type CheckBankAndBranchByIDRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} + +type GetBankInfoRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +}