32 lines
825 B
Go
32 lines
825 B
Go
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"
|
|
)
|
|
|
|
// Campaign ...
|
|
type Campaign struct{}
|
|
|
|
// GetCampaignTransaction ...
|
|
func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) (*model.ResponseCampaignTransactionAll, error) {
|
|
msg, err := natsio.GetServer().Request(subject.Campaign.GetListCampaignTransactionAdminInfoByIDs, toBytes(p))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var r struct {
|
|
Data *model.ResponseCampaignTransactionAll `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
|
|
}
|