models.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 微信支付平台证书下载服务
  4. //
  5. // 为了确保在定期更换平台证书时,不影响商户使用微信支付的各种功能,微信支付提供API接口供商户下载最新的平台证书。 商户可使用该接口实现平台证书的平滑切换。
  6. //
  7. // API version: 1.0.0
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package certificates
  10. import (
  11. "encoding/json"
  12. "fmt"
  13. "time"
  14. )
  15. // Certificate 微信支付平台证书信息
  16. type Certificate struct {
  17. // 证书序列号
  18. SerialNo *string `json:"serial_no"`
  19. // 证书有效期开始时间
  20. EffectiveTime *time.Time `json:"effective_time"`
  21. // 证书过期时间
  22. ExpireTime *time.Time `json:"expire_time"`
  23. // 为了保证安全性,微信支付在回调通知和平台证书下载接口中,对关键信息进行了AES-256-GCM加密
  24. EncryptCertificate *EncryptCertificate `json:"encrypt_certificate"`
  25. }
  26. func (o Certificate) MarshalJSON() ([]byte, error) {
  27. toSerialize := map[string]interface{}{}
  28. if o.SerialNo == nil {
  29. return nil, fmt.Errorf("field `SerialNo` is required and must be specified in Certificate")
  30. }
  31. toSerialize["serial_no"] = o.SerialNo
  32. if o.EffectiveTime == nil {
  33. return nil, fmt.Errorf("field `EffectiveTime` is required and must be specified in Certificate")
  34. }
  35. toSerialize["effective_time"] = o.EffectiveTime.Format(time.RFC3339)
  36. if o.ExpireTime == nil {
  37. return nil, fmt.Errorf("field `ExpireTime` is required and must be specified in Certificate")
  38. }
  39. toSerialize["expire_time"] = o.ExpireTime.Format(time.RFC3339)
  40. if o.EncryptCertificate == nil {
  41. return nil, fmt.Errorf("field `EncryptCertificate` is required and must be specified in Certificate")
  42. }
  43. toSerialize["encrypt_certificate"] = o.EncryptCertificate
  44. return json.Marshal(toSerialize)
  45. }
  46. func (o Certificate) String() string {
  47. var ret string
  48. if o.SerialNo == nil {
  49. ret += "SerialNo:<nil>, "
  50. } else {
  51. ret += fmt.Sprintf("SerialNo:%v, ", *o.SerialNo)
  52. }
  53. if o.EffectiveTime == nil {
  54. ret += "EffectiveTime:<nil>, "
  55. } else {
  56. ret += fmt.Sprintf("EffectiveTime:%v, ", *o.EffectiveTime)
  57. }
  58. if o.ExpireTime == nil {
  59. ret += "ExpireTime:<nil>, "
  60. } else {
  61. ret += fmt.Sprintf("ExpireTime:%v, ", *o.ExpireTime)
  62. }
  63. ret += fmt.Sprintf("EncryptCertificate:%v", o.EncryptCertificate)
  64. return fmt.Sprintf("Certificate{%s}", ret)
  65. }
  66. func (o Certificate) Clone() *Certificate {
  67. ret := Certificate{}
  68. if o.SerialNo != nil {
  69. ret.SerialNo = new(string)
  70. *ret.SerialNo = *o.SerialNo
  71. }
  72. if o.EffectiveTime != nil {
  73. ret.EffectiveTime = new(time.Time)
  74. *ret.EffectiveTime = *o.EffectiveTime
  75. }
  76. if o.ExpireTime != nil {
  77. ret.ExpireTime = new(time.Time)
  78. *ret.ExpireTime = *o.ExpireTime
  79. }
  80. if o.EncryptCertificate != nil {
  81. ret.EncryptCertificate = o.EncryptCertificate.Clone()
  82. }
  83. return &ret
  84. }
  85. // DownloadCertificatesResponse
  86. type DownloadCertificatesResponse struct {
  87. // 平台证书列表
  88. Data []Certificate `json:"data,omitempty"`
  89. }
  90. func (o DownloadCertificatesResponse) MarshalJSON() ([]byte, error) {
  91. toSerialize := map[string]interface{}{}
  92. if o.Data != nil {
  93. toSerialize["data"] = o.Data
  94. }
  95. return json.Marshal(toSerialize)
  96. }
  97. func (o DownloadCertificatesResponse) String() string {
  98. var ret string
  99. ret += fmt.Sprintf("Data:%v", o.Data)
  100. return fmt.Sprintf("DownloadCertificatesResponse{%s}", ret)
  101. }
  102. func (o DownloadCertificatesResponse) Clone() *DownloadCertificatesResponse {
  103. ret := DownloadCertificatesResponse{}
  104. if o.Data != nil {
  105. ret.Data = make([]Certificate, len(o.Data))
  106. for i, item := range o.Data {
  107. ret.Data[i] = *item.Clone()
  108. }
  109. }
  110. return &ret
  111. }
  112. // EncryptCertificate 为了保证安全性,微信支付在回调通知和平台证书下载接口中,对关键信息进行了AES-256-GCM加密
  113. type EncryptCertificate struct {
  114. // 加密所使用的算法,目前可能取值仅为 AEAD_AES_256_GCM
  115. Algorithm *string `json:"algorithm"`
  116. // 加密所使用的随机字符串
  117. Nonce *string `json:"nonce"`
  118. // 附加数据包(可能为空)
  119. AssociatedData *string `json:"associated_data"`
  120. // 证书内容密文,解密后会获得证书完整内容
  121. Ciphertext *string `json:"ciphertext"`
  122. }
  123. func (o EncryptCertificate) MarshalJSON() ([]byte, error) {
  124. toSerialize := map[string]interface{}{}
  125. if o.Algorithm == nil {
  126. return nil, fmt.Errorf("field `Algorithm` is required and must be specified in EncryptCertificate")
  127. }
  128. toSerialize["algorithm"] = o.Algorithm
  129. if o.Nonce == nil {
  130. return nil, fmt.Errorf("field `Nonce` is required and must be specified in EncryptCertificate")
  131. }
  132. toSerialize["nonce"] = o.Nonce
  133. if o.AssociatedData == nil {
  134. return nil, fmt.Errorf("field `AssociatedData` is required and must be specified in EncryptCertificate")
  135. }
  136. toSerialize["associated_data"] = o.AssociatedData
  137. if o.Ciphertext == nil {
  138. return nil, fmt.Errorf("field `Ciphertext` is required and must be specified in EncryptCertificate")
  139. }
  140. toSerialize["ciphertext"] = o.Ciphertext
  141. return json.Marshal(toSerialize)
  142. }
  143. func (o EncryptCertificate) String() string {
  144. var ret string
  145. if o.Algorithm == nil {
  146. ret += "Algorithm:<nil>, "
  147. } else {
  148. ret += fmt.Sprintf("Algorithm:%v, ", *o.Algorithm)
  149. }
  150. if o.Nonce == nil {
  151. ret += "Nonce:<nil>, "
  152. } else {
  153. ret += fmt.Sprintf("Nonce:%v, ", *o.Nonce)
  154. }
  155. if o.AssociatedData == nil {
  156. ret += "AssociatedData:<nil>, "
  157. } else {
  158. ret += fmt.Sprintf("AssociatedData:%v, ", *o.AssociatedData)
  159. }
  160. if o.Ciphertext == nil {
  161. ret += "Ciphertext:<nil>"
  162. } else {
  163. ret += fmt.Sprintf("Ciphertext:%v", *o.Ciphertext)
  164. }
  165. return fmt.Sprintf("EncryptCertificate{%s}", ret)
  166. }
  167. func (o EncryptCertificate) Clone() *EncryptCertificate {
  168. ret := EncryptCertificate{}
  169. if o.Algorithm != nil {
  170. ret.Algorithm = new(string)
  171. *ret.Algorithm = *o.Algorithm
  172. }
  173. if o.Nonce != nil {
  174. ret.Nonce = new(string)
  175. *ret.Nonce = *o.Nonce
  176. }
  177. if o.AssociatedData != nil {
  178. ret.AssociatedData = new(string)
  179. *ret.AssociatedData = *o.AssociatedData
  180. }
  181. if o.Ciphertext != nil {
  182. ret.Ciphertext = new(string)
  183. *ret.Ciphertext = *o.Ciphertext
  184. }
  185. return &ret
  186. }