You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/ejiaofei/query_txproduct.go

40 lines
1.2 KiB

package ejiaofei
import (
"context"
"encoding/xml"
"fmt"
"github.com/dtapps/go-library/utils/gorequest"
"net/http"
)
type QueryTxProductResponse struct {
XMLName xml.Name `xml:"response"`
Error string `xml:"error"` // 错误提示
}
type QueryTxProductResult struct {
Result QueryTxProductResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newQueryTxProductResult(result QueryTxProductResponse, body []byte, http gorequest.Response) *QueryTxProductResult {
return &QueryTxProductResult{Result: result, Body: body, Http: http}
}
// QueryTxProduct 可充值腾讯产品查询
func (c *Client) QueryTxProduct(ctx context.Context) (*QueryTxProductResult, error) {
// 签名
c.config.signStr = fmt.Sprintf("userid%vpwd%v", c.GetUserId(), c.GetPwd())
// 请求
request, err := c.request(ctx, apiUrl+"/queryTXproduct.do", map[string]interface{}{}, http.MethodGet)
if err != nil {
return newQueryTxProductResult(QueryTxProductResponse{}, request.ResponseBody, request), err
}
// 定义
var response QueryTxProductResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newQueryTxProductResult(response, request.ResponseBody, request), err
}