第三方api接口
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.

52 lines
2.0 KiB

  1. package yibao_pay
  2. import (
  3. "github.com/yop-platform/yop-go-sdk/yop/client"
  4. "github.com/yop-platform/yop-go-sdk/yop/constants"
  5. "github.com/yop-platform/yop-go-sdk/yop/request"
  6. "github.com/yop-platform/yop-go-sdk/yop/response"
  7. "github.com/yop-platform/yop-go-sdk/yop/utils"
  8. "os"
  9. )
  10. func GetSend(method, appId, isvPriKey string, param map[string]string) (*response.YopResponse, error) {
  11. var priKey = request.IsvPriKey{Value: isvPriKey, CertType: request.RSA2048}
  12. var yopRequest = request.NewYopRequest(constants.GET_HTTP_METHOD, method)
  13. yopRequest.AppId = appId
  14. yopRequest.IsvPriKey = priKey
  15. for k, v := range param {
  16. yopRequest.AddParam(k, v)
  17. }
  18. yopResp, err := client.DefaultClient.Request(yopRequest)
  19. return yopResp, err
  20. }
  21. func PostFormSend(method, appId, isvPriKey string, param map[string]string) (*response.YopResponse, error) {
  22. var priKey = request.IsvPriKey{Value: isvPriKey, CertType: request.RSA2048}
  23. var yopRequest = request.NewYopRequest(constants.POST_HTTP_METHOD, method)
  24. yopRequest.AppId = appId
  25. yopRequest.IsvPriKey = priKey
  26. for k, v := range param {
  27. yopRequest.AddParam(k, v)
  28. }
  29. yopResp, err := client.DefaultClient.Request(yopRequest)
  30. return yopResp, err
  31. }
  32. func PostJsonSend(method, appId, isvPriKey string, params map[string]interface{}) (*response.YopResponse, error) {
  33. var priKey = request.IsvPriKey{Value: isvPriKey, CertType: request.RSA2048}
  34. var yopRequest = request.NewYopRequest(constants.POST_HTTP_METHOD, method)
  35. yopRequest.AppId = appId
  36. yopRequest.IsvPriKey = priKey
  37. yopRequest.Content = utils.ParseToJsonStr(params)
  38. yopResp, err := client.DefaultClient.Request(yopRequest)
  39. return yopResp, err
  40. }
  41. func FileUploadSend(method, appId, isvPriKey string, name string, f *os.File) (*response.YopResponse, error) {
  42. var priKey = request.IsvPriKey{Value: isvPriKey, CertType: request.RSA2048}
  43. var yopRequest = request.NewYopRequest(constants.POST_HTTP_METHOD, method)
  44. yopRequest.AppId = appId
  45. yopRequest.IsvPriKey = priKey
  46. yopRequest.AddFile(name, f)
  47. yopResp, err := client.DefaultClient.Request(yopRequest)
  48. return yopResp, err
  49. }