api_relations.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 微工卡接口文档
  4. //
  5. // 服务商通过本API文档提供的接口,查询商户和微工卡的授权关系、生成预授权的token口令、核身预下单、核身结果的查询等。
  6. //
  7. // API version: 1.5.2
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package payrollcard
  10. import (
  11. "context"
  12. "fmt"
  13. nethttp "net/http"
  14. neturl "net/url"
  15. "strings"
  16. "git.nanodreamtech.com/sg/wechatpay-go/core"
  17. "git.nanodreamtech.com/sg/wechatpay-go/core/consts"
  18. "git.nanodreamtech.com/sg/wechatpay-go/services"
  19. )
  20. type RelationsApiService services.Service
  21. // GetRelation 查询微工卡授权关系
  22. //
  23. // 查询商户和微信支付用户的微工卡授权关系
  24. func (a *RelationsApiService) GetRelation(ctx context.Context, req GetRelationRequest) (resp *RelationEntity, result *core.APIResult, err error) {
  25. var (
  26. localVarHTTPMethod = nethttp.MethodGet
  27. localVarPostBody interface{}
  28. localVarQueryParams neturl.Values
  29. localVarHeaderParams = nethttp.Header{}
  30. )
  31. // Make sure Path Params are properly set
  32. if req.Openid == nil {
  33. return nil, nil, fmt.Errorf("field `Openid` is required and must be specified in GetRelationRequest")
  34. }
  35. localVarPath := consts.WechatPayAPIServer + "/v3/payroll-card/relations/{openid}"
  36. // Build Path with Path Params
  37. localVarPath = strings.Replace(localVarPath, "{"+"openid"+"}", neturl.PathEscape(core.ParameterToString(*req.Openid, "")), -1)
  38. // Make sure All Required Params are properly set
  39. if req.SubMchid == nil {
  40. return nil, nil, fmt.Errorf("field `SubMchid` is required and must be specified in GetRelationRequest")
  41. }
  42. // Setup Query Params
  43. localVarQueryParams = neturl.Values{}
  44. localVarQueryParams.Add("sub_mchid", core.ParameterToString(*req.SubMchid, ""))
  45. if req.Appid != nil {
  46. localVarQueryParams.Add("appid", core.ParameterToString(*req.Appid, ""))
  47. }
  48. if req.SubAppid != nil {
  49. localVarQueryParams.Add("sub_appid", core.ParameterToString(*req.SubAppid, ""))
  50. }
  51. // Determine the Content-Type Header
  52. localVarHTTPContentTypes := []string{}
  53. // Setup Content-Type
  54. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  55. // Perform Http Request
  56. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  57. if err != nil {
  58. return nil, result, err
  59. }
  60. // Extract RelationEntity from Http Response
  61. resp = new(RelationEntity)
  62. err = core.UnMarshalResponse(result.Response, resp)
  63. if err != nil {
  64. return nil, result, err
  65. }
  66. return resp, result, nil
  67. }