6 "github.com/vapor/errors"
7 "github.com/vapor/toolbar/common"
10 // Node can invoke the api which provide by the full node server
15 // NewNode create a api client with target server
16 func NewNode(hostPort string) *Node {
17 return &Node{hostPort: hostPort}
20 type response struct {
21 Status string `json:"status"`
22 Data json.RawMessage `json:"data"`
23 ErrDetail string `json:"error_detail"`
26 func (n *Node) request(path string, payload []byte, respData interface{}) error {
28 if err := common.Post(n.hostPort+path, payload, resp); err != nil {
32 if resp.Status != "success" {
33 return errors.New(resp.ErrDetail)
36 return json.Unmarshal(resp.Data, respData)