AssetClient.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright 2018 JDCLOUD.COM
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // NOTE: This class is auto generated by the jdcloud code generator program.
  16. package client
  17. import (
  18. "github.com/jdcloud-api/jdcloud-sdk-go/core"
  19. asset "github.com/jdcloud-api/jdcloud-sdk-go/services/asset/apis"
  20. "encoding/json"
  21. "errors"
  22. )
  23. type AssetClient struct {
  24. core.JDCloudClient
  25. }
  26. func NewAssetClient(credential *core.Credential) *AssetClient {
  27. if credential == nil {
  28. return nil
  29. }
  30. config := core.NewConfig()
  31. config.SetEndpoint("asset.jdcloud-api.com")
  32. return &AssetClient{
  33. core.JDCloudClient{
  34. Credential: *credential,
  35. Config: *config,
  36. ServiceName: "asset",
  37. Revision: "0.0.3",
  38. Logger: core.NewDefaultLogger(core.LogInfo),
  39. }}
  40. }
  41. func (c *AssetClient) SetConfig(config *core.Config) {
  42. c.Config = *config
  43. }
  44. func (c *AssetClient) SetLogger(logger core.Logger) {
  45. c.Logger = logger
  46. }
  47. func (c *AssetClient) DisableLogger() {
  48. c.Logger = core.NewDummyLogger()
  49. }
  50. /* 查询账户金额(总金额、可用金额、冻结金额、可提现金额、提现中金额) */
  51. func (c *AssetClient) DescribeAccountAmount(request *asset.DescribeAccountAmountRequest) (*asset.DescribeAccountAmountResponse, error) {
  52. if request == nil {
  53. return nil, errors.New("Request object is nil. ")
  54. }
  55. resp, err := c.Send(request, c.ServiceName)
  56. if err != nil {
  57. return nil, err
  58. }
  59. jdResp := &asset.DescribeAccountAmountResponse{}
  60. err = json.Unmarshal(resp, jdResp)
  61. if err != nil {
  62. c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
  63. return nil, err
  64. }
  65. return jdResp, err
  66. }
  67. /* 设置余额预警信息 */
  68. func (c *AssetClient) ModifyBalanceWarningInfo(request *asset.ModifyBalanceWarningInfoRequest) (*asset.ModifyBalanceWarningInfoResponse, error) {
  69. if request == nil {
  70. return nil, errors.New("Request object is nil. ")
  71. }
  72. resp, err := c.Send(request, c.ServiceName)
  73. if err != nil {
  74. return nil, err
  75. }
  76. jdResp := &asset.ModifyBalanceWarningInfoResponse{}
  77. err = json.Unmarshal(resp, jdResp)
  78. if err != nil {
  79. c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
  80. return nil, err
  81. }
  82. return jdResp, err
  83. }