api_activity.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 营销加价购对外API
  4. //
  5. // 指定服务商可通过该接口报名加价购活动、查询某个区域内的加价购活动列表、锁定加价活动购资格以及解锁加价购活动资格。
  6. //
  7. // API version: 1.4.0
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package retailstore
  10. import (
  11. "context"
  12. "fmt"
  13. nethttp "net/http"
  14. neturl "net/url"
  15. "strings"
  16. "github.com/wechatpay-apiv3/wechatpay-go/core"
  17. "github.com/wechatpay-apiv3/wechatpay-go/core/consts"
  18. "github.com/wechatpay-apiv3/wechatpay-go/services"
  19. )
  20. type ActivityApiService services.Service
  21. // ApplyActivity 门店报名品牌加价购活动
  22. //
  23. // 接口介绍:该接口为服务商替门店报名品牌加价购活动专用接口。
  24. // 使用对象:指定服务商。
  25. func (a *ActivityApiService) ApplyActivity(ctx context.Context, req ApplyActivityRequest) (resp *ApplyActivityResponse, result *core.APIResult, err error) {
  26. var (
  27. localVarHTTPMethod = nethttp.MethodPost
  28. localVarPostBody interface{}
  29. localVarQueryParams neturl.Values
  30. localVarHeaderParams = nethttp.Header{}
  31. )
  32. // Make sure Path Params are properly set
  33. if req.ActivityId == nil {
  34. return nil, nil, fmt.Errorf("field `ActivityId` is required and must be specified in ApplyActivityRequest")
  35. }
  36. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/goods-subsidy-activity/activity/{activity_id}/apply"
  37. // Build Path with Path Params
  38. localVarPath = strings.Replace(localVarPath, "{"+"activity_id"+"}", neturl.PathEscape(core.ParameterToString(*req.ActivityId, "")), -1)
  39. // Make sure All Required Params are properly set
  40. // Setup Body Params
  41. localVarPostBody = &ApplyActivityBody{
  42. CallerMerchantId: req.CallerMerchantId,
  43. ApplyInfos: req.ApplyInfos,
  44. }
  45. // Determine the Content-Type Header
  46. localVarHTTPContentTypes := []string{"application/json"}
  47. // Setup Content-Type
  48. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  49. // Perform Http Request
  50. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  51. if err != nil {
  52. return nil, result, err
  53. }
  54. // Extract ApplyActivityResponse from Http Response
  55. resp = new(ApplyActivityResponse)
  56. err = core.UnMarshalResponse(result.Response, resp)
  57. if err != nil {
  58. return nil, result, err
  59. }
  60. return resp, result, nil
  61. }
  62. // ListActsByArea 按区域查询品牌加价购活动
  63. //
  64. // 接口介绍:该接口为服务商查询门店报名的品牌加价购活动的专用接口。
  65. // 使用对象:指定服务商。
  66. func (a *ActivityApiService) ListActsByArea(ctx context.Context, req ListActsByAreaRequest) (resp *ListActsByAreaResponse, result *core.APIResult, err error) {
  67. var (
  68. localVarHTTPMethod = nethttp.MethodGet
  69. localVarPostBody interface{}
  70. localVarQueryParams neturl.Values
  71. localVarHeaderParams = nethttp.Header{}
  72. )
  73. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/goods-subsidy-activity/activities"
  74. // Make sure All Required Params are properly set
  75. if req.CityId == nil {
  76. return nil, nil, fmt.Errorf("field `CityId` is required and must be specified in ListActsByAreaRequest")
  77. }
  78. if req.Offset == nil {
  79. return nil, nil, fmt.Errorf("field `Offset` is required and must be specified in ListActsByAreaRequest")
  80. }
  81. if req.Limit == nil {
  82. return nil, nil, fmt.Errorf("field `Limit` is required and must be specified in ListActsByAreaRequest")
  83. }
  84. // Setup Query Params
  85. localVarQueryParams = neturl.Values{}
  86. localVarQueryParams.Add("city_id", core.ParameterToString(*req.CityId, ""))
  87. localVarQueryParams.Add("offset", core.ParameterToString(*req.Offset, ""))
  88. localVarQueryParams.Add("limit", core.ParameterToString(*req.Limit, ""))
  89. // Determine the Content-Type Header
  90. localVarHTTPContentTypes := []string{}
  91. // Setup Content-Type
  92. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  93. // Perform Http Request
  94. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  95. if err != nil {
  96. return nil, result, err
  97. }
  98. // Extract ListActsByAreaResponse from Http Response
  99. resp = new(ListActsByAreaResponse)
  100. err = core.UnMarshalResponse(result.Response, resp)
  101. if err != nil {
  102. return nil, result, err
  103. }
  104. return resp, result, nil
  105. }