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" ) type Seller struct{} func GetSeller() Seller { return Seller{} } func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) { msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseSellerInfo `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 } func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) { msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseListSellerInfo `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 } func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) { msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseListSellerInfoSupportChat `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 } func (s Seller) CheckAndInsertCashflows(p model.CheckAndInsertCashflowsRequest) (*model.ResponseCheckAndInsertCashflows, error) { msg, err := natsio.GetServer().Request(subject.Seller.CheckAndInsertCashflows, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseCheckAndInsertCashflows `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 } func (s Seller) UpdateSellerAffiliateStatistic(p model.UpdateSellerAffiliateStatisticRequest) (*model.ResponseUpdateSellerAffiliateStatistic, error) { msg, err := natsio.GetServer().Request(subject.Seller.UpdateSellerAffiliateStatistic, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseUpdateSellerAffiliateStatistic `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 } func (s Seller) UpdateSellerSavingCampaignStatistic(p model.UpdateSellerSavingCampaignStatisticRequest) (*model.ResponseUpdateSellerSavingCampaignStatistic, error) { msg, err := natsio.GetServer().Request(subject.Seller.UpdateSellerSavingCampaignStatistic, toBytes(p)) if err != nil { return nil, err } var r struct { Data *model.ResponseUpdateSellerSavingCampaignStatistic `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 }