-
Notifications
You must be signed in to change notification settings - Fork 1
/
subscription_group_bank_account.go
150 lines (143 loc) · 7.38 KB
/
subscription_group_bank_account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package models
import (
"encoding/json"
)
// SubscriptionGroupBankAccount represents a SubscriptionGroupBankAccount struct.
type SubscriptionGroupBankAccount struct {
// (Required when creating a subscription with ACH or GoCardless) The name of the bank where the customer’s account resides
BankName *string `json:"bank_name,omitempty"`
// (Required when creating a subscription with ACH. Required when creating a subscription with GoCardless and bank_iban is blank) The customerʼs bank account number
BankAccountNumber *string `json:"bank_account_number,omitempty"`
// (Required when creating a subscription with ACH. Optional when creating a subscription with GoCardless). The routing number of the bank. It becomes bank_code while passing via GoCardless API
BankRoutingNumber *string `json:"bank_routing_number,omitempty"`
// (Optional when creating a subscription with GoCardless). International Bank Account Number. Alternatively, local bank details can be provided
BankIban *string `json:"bank_iban,omitempty"`
// (Optional when creating a subscription with GoCardless) Branch code. Alternatively, an IBAN can be provided
BankBranchCode *string `json:"bank_branch_code,omitempty"`
// Defaults to checking
BankAccountType *BankAccountType `json:"bank_account_type,omitempty"`
// Defaults to personal
BankAccountHolderType *BankAccountHolderType `json:"bank_account_holder_type,omitempty"`
PaymentType *PaymentType `json:"payment_type,omitempty"`
BillingAddress *string `json:"billing_address,omitempty"`
BillingCity *string `json:"billing_city,omitempty"`
BillingState *string `json:"billing_state,omitempty"`
BillingZip *string `json:"billing_zip,omitempty"`
BillingCountry *string `json:"billing_country,omitempty"`
ChargifyToken *string `json:"chargify_token,omitempty"`
// The vault that stores the payment profile with the provided vault_token.
CurrentVault *BankAccountVault `json:"current_vault,omitempty"`
GatewayHandle *string `json:"gateway_handle,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for SubscriptionGroupBankAccount.
// It customizes the JSON marshaling process for SubscriptionGroupBankAccount objects.
func (s SubscriptionGroupBankAccount) MarshalJSON() (
[]byte,
error) {
return json.Marshal(s.toMap())
}
// toMap converts the SubscriptionGroupBankAccount object to a map representation for JSON marshaling.
func (s SubscriptionGroupBankAccount) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, s.AdditionalProperties)
if s.BankName != nil {
structMap["bank_name"] = s.BankName
}
if s.BankAccountNumber != nil {
structMap["bank_account_number"] = s.BankAccountNumber
}
if s.BankRoutingNumber != nil {
structMap["bank_routing_number"] = s.BankRoutingNumber
}
if s.BankIban != nil {
structMap["bank_iban"] = s.BankIban
}
if s.BankBranchCode != nil {
structMap["bank_branch_code"] = s.BankBranchCode
}
if s.BankAccountType != nil {
structMap["bank_account_type"] = s.BankAccountType
}
if s.BankAccountHolderType != nil {
structMap["bank_account_holder_type"] = s.BankAccountHolderType
}
if s.PaymentType != nil {
structMap["payment_type"] = s.PaymentType
}
if s.BillingAddress != nil {
structMap["billing_address"] = s.BillingAddress
}
if s.BillingCity != nil {
structMap["billing_city"] = s.BillingCity
}
if s.BillingState != nil {
structMap["billing_state"] = s.BillingState
}
if s.BillingZip != nil {
structMap["billing_zip"] = s.BillingZip
}
if s.BillingCountry != nil {
structMap["billing_country"] = s.BillingCountry
}
if s.ChargifyToken != nil {
structMap["chargify_token"] = s.ChargifyToken
}
if s.CurrentVault != nil {
structMap["current_vault"] = s.CurrentVault
}
if s.GatewayHandle != nil {
structMap["gateway_handle"] = s.GatewayHandle
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for SubscriptionGroupBankAccount.
// It customizes the JSON unmarshaling process for SubscriptionGroupBankAccount objects.
func (s *SubscriptionGroupBankAccount) UnmarshalJSON(input []byte) error {
var temp subscriptionGroupBankAccount
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "bank_name", "bank_account_number", "bank_routing_number", "bank_iban", "bank_branch_code", "bank_account_type", "bank_account_holder_type", "payment_type", "billing_address", "billing_city", "billing_state", "billing_zip", "billing_country", "chargify_token", "current_vault", "gateway_handle")
if err != nil {
return err
}
s.AdditionalProperties = additionalProperties
s.BankName = temp.BankName
s.BankAccountNumber = temp.BankAccountNumber
s.BankRoutingNumber = temp.BankRoutingNumber
s.BankIban = temp.BankIban
s.BankBranchCode = temp.BankBranchCode
s.BankAccountType = temp.BankAccountType
s.BankAccountHolderType = temp.BankAccountHolderType
s.PaymentType = temp.PaymentType
s.BillingAddress = temp.BillingAddress
s.BillingCity = temp.BillingCity
s.BillingState = temp.BillingState
s.BillingZip = temp.BillingZip
s.BillingCountry = temp.BillingCountry
s.ChargifyToken = temp.ChargifyToken
s.CurrentVault = temp.CurrentVault
s.GatewayHandle = temp.GatewayHandle
return nil
}
// subscriptionGroupBankAccount is a temporary struct used for validating the fields of SubscriptionGroupBankAccount.
type subscriptionGroupBankAccount struct {
BankName *string `json:"bank_name,omitempty"`
BankAccountNumber *string `json:"bank_account_number,omitempty"`
BankRoutingNumber *string `json:"bank_routing_number,omitempty"`
BankIban *string `json:"bank_iban,omitempty"`
BankBranchCode *string `json:"bank_branch_code,omitempty"`
BankAccountType *BankAccountType `json:"bank_account_type,omitempty"`
BankAccountHolderType *BankAccountHolderType `json:"bank_account_holder_type,omitempty"`
PaymentType *PaymentType `json:"payment_type,omitempty"`
BillingAddress *string `json:"billing_address,omitempty"`
BillingCity *string `json:"billing_city,omitempty"`
BillingState *string `json:"billing_state,omitempty"`
BillingZip *string `json:"billing_zip,omitempty"`
BillingCountry *string `json:"billing_country,omitempty"`
ChargifyToken *string `json:"chargify_token,omitempty"`
CurrentVault *BankAccountVault `json:"current_vault,omitempty"`
GatewayHandle *string `json:"gateway_handle,omitempty"`
}