mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* doc(conn-92): fix doc link * doc(CONN-92): clarify the new connector creation instructions * feat(CONN-92): qonto plugin, account retrieval * feat(CONN-92): implement pagination and fix timezone * feat(CONN-92): add metadata * feat(CONN-92): fetchBalance implemented * feat(CONN-92): remove unsupported capabilities * feat(CONN-92): bank account type differ from different endpoint * feat(CONN-92): added external account + beneficiaries endpoint * feat(CONN-92): invalid beneficiary's accounts actually happen all the time * feat(CONN-92): allow multiple currencies for external accounts * feat(CONN-92): temp commit to debug payment save * feat(CONN-92): remove loggers * feat(CONN-92): better job at omitempty * feat(CONN-92): fix payment destination account to match external account * feat(CONN-92): added test for no from payload * feat(CONN-92): test on raw where relevant * feat(CONN-92): added payment_test * feat(CONN-92): use jsonNumber for incoming floats * feat(CONN_92): remove page number from request, instead use last_updated + pagesize * feat(CONN-92): fetch all transactions by statuses, in order (not only completed ones) * feat(CONN-92): always add the parentReference * feat(CONN-92): extract couple of method to improve readability * feat(CONN-92): use constants for transaction status * feat(CONN-92): added comment on transaction status * feat(CONN-92): add transfer endpoint * feat(CONN-92): unify account metadata syntax between internal & external accounts * feat(CONN-92): make plugin inherit from basePlugin * feat(CONN-92): add transfer capability * feat(CONN-92): fix internal transfert -- doc is lying on the response format * feat(CONN-92): avoid sending update_at_from == zero time (as Qonto refuses the request) * feat(CONN-92): coderabbit suggestions: * fix error formatting * more leniency in transfer response status check (allwing completed) * more validaiton when creating a transfer * feat(CONN-92): more coderabbit suggestions, improve error reporting * feat(CONN-92): more coderabbit suggestions, more errors on invalid state * feat(CONN-92): more coderabbit reviews, more coverage and bits of refacto * feat(CONN-92): bit more coverage * feat(CONN-92): bit more coverage * feat(CONN-92): added more coverage for config & errors; also improved Qonto's error reporting * feat(CONN-92): precommit run * feat(CONN-92): remove needMore functionality as its mostly irrelevant here * feat(CONN-92): codeRabbit is right, Qonto has a max page size -- my bad * feat(CONN-92): correct Account pagination * feat(CONN-92): account pagination with equal lastUpdatedAt * feat(CONN-92): review pagination for beneficiaries and payments * feat(CONN-92): update speakeasy lock * feat(CONN-92): added a bit of comments on the surprising bits * feat(CONN-92): codeRabbit comment * feat(CONN-92): transfer don't always return currency -- we can default to EUR as its the only one supported * feat(CONN-92): return error when account does not have currency set * feat(CONN-92): remove initialization of lastUpdatedAt * feat(CONN-92): remove all pagination from accounts, as we fetch all anyway * feat(CONN-92): cleaned somewhat the http connection logic * feat(CONN-92): add uuid in transfer as reference to pick it up for transaction matching later on * feat(CONN-92): detect transactions created via transfer and set parentId appropriately * feat(CONN-92): truncate too long reference * feat(CONN-92): remove create internal transfer endpoint
393 lines
13 KiB
Go
393 lines
13 KiB
Go
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
|
|
package components
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"github.com/formancehq/payments/pkg/client/internal/utils"
|
|
)
|
|
|
|
type V3InstallConnectorRequestType string
|
|
|
|
const (
|
|
V3InstallConnectorRequestTypeAdyen V3InstallConnectorRequestType = "Adyen"
|
|
V3InstallConnectorRequestTypeAtlar V3InstallConnectorRequestType = "Atlar"
|
|
V3InstallConnectorRequestTypeBankingcircle V3InstallConnectorRequestType = "Bankingcircle"
|
|
V3InstallConnectorRequestTypeColumn V3InstallConnectorRequestType = "Column"
|
|
V3InstallConnectorRequestTypeCurrencycloud V3InstallConnectorRequestType = "Currencycloud"
|
|
V3InstallConnectorRequestTypeDummypay V3InstallConnectorRequestType = "Dummypay"
|
|
V3InstallConnectorRequestTypeGeneric V3InstallConnectorRequestType = "Generic"
|
|
V3InstallConnectorRequestTypeMangopay V3InstallConnectorRequestType = "Mangopay"
|
|
V3InstallConnectorRequestTypeModulr V3InstallConnectorRequestType = "Modulr"
|
|
V3InstallConnectorRequestTypeMoneycorp V3InstallConnectorRequestType = "Moneycorp"
|
|
V3InstallConnectorRequestTypeQonto V3InstallConnectorRequestType = "Qonto"
|
|
V3InstallConnectorRequestTypeStripe V3InstallConnectorRequestType = "Stripe"
|
|
V3InstallConnectorRequestTypeWise V3InstallConnectorRequestType = "Wise"
|
|
)
|
|
|
|
type V3InstallConnectorRequest struct {
|
|
V3AdyenConfig *V3AdyenConfig `queryParam:"inline"`
|
|
V3AtlarConfig *V3AtlarConfig `queryParam:"inline"`
|
|
V3BankingcircleConfig *V3BankingcircleConfig `queryParam:"inline"`
|
|
V3ColumnConfig *V3ColumnConfig `queryParam:"inline"`
|
|
V3CurrencycloudConfig *V3CurrencycloudConfig `queryParam:"inline"`
|
|
V3DummypayConfig *V3DummypayConfig `queryParam:"inline"`
|
|
V3GenericConfig *V3GenericConfig `queryParam:"inline"`
|
|
V3MangopayConfig *V3MangopayConfig `queryParam:"inline"`
|
|
V3ModulrConfig *V3ModulrConfig `queryParam:"inline"`
|
|
V3MoneycorpConfig *V3MoneycorpConfig `queryParam:"inline"`
|
|
V3QontoConfig *V3QontoConfig `queryParam:"inline"`
|
|
V3StripeConfig *V3StripeConfig `queryParam:"inline"`
|
|
V3WiseConfig *V3WiseConfig `queryParam:"inline"`
|
|
|
|
Type V3InstallConnectorRequestType
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestAdyen(adyen V3AdyenConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeAdyen
|
|
|
|
typStr := string(typ)
|
|
adyen.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3AdyenConfig: &adyen,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestAtlar(atlar V3AtlarConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeAtlar
|
|
|
|
typStr := string(typ)
|
|
atlar.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3AtlarConfig: &atlar,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestBankingcircle(bankingcircle V3BankingcircleConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeBankingcircle
|
|
|
|
typStr := string(typ)
|
|
bankingcircle.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3BankingcircleConfig: &bankingcircle,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestColumn(column V3ColumnConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeColumn
|
|
|
|
typStr := string(typ)
|
|
column.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3ColumnConfig: &column,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestCurrencycloud(currencycloud V3CurrencycloudConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeCurrencycloud
|
|
|
|
typStr := string(typ)
|
|
currencycloud.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3CurrencycloudConfig: ¤cycloud,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestDummypay(dummypay V3DummypayConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeDummypay
|
|
|
|
typStr := string(typ)
|
|
dummypay.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3DummypayConfig: &dummypay,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestGeneric(generic V3GenericConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeGeneric
|
|
|
|
typStr := string(typ)
|
|
generic.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3GenericConfig: &generic,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestMangopay(mangopay V3MangopayConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeMangopay
|
|
|
|
typStr := string(typ)
|
|
mangopay.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3MangopayConfig: &mangopay,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestModulr(modulr V3ModulrConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeModulr
|
|
|
|
typStr := string(typ)
|
|
modulr.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3ModulrConfig: &modulr,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestMoneycorp(moneycorp V3MoneycorpConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeMoneycorp
|
|
|
|
typStr := string(typ)
|
|
moneycorp.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3MoneycorpConfig: &moneycorp,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestQonto(qonto V3QontoConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeQonto
|
|
|
|
typStr := string(typ)
|
|
qonto.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3QontoConfig: &qonto,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestStripe(stripe V3StripeConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeStripe
|
|
|
|
typStr := string(typ)
|
|
stripe.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3StripeConfig: &stripe,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV3InstallConnectorRequestWise(wise V3WiseConfig) V3InstallConnectorRequest {
|
|
typ := V3InstallConnectorRequestTypeWise
|
|
|
|
typStr := string(typ)
|
|
wise.Provider = &typStr
|
|
|
|
return V3InstallConnectorRequest{
|
|
V3WiseConfig: &wise,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func (u *V3InstallConnectorRequest) UnmarshalJSON(data []byte) error {
|
|
|
|
type discriminator struct {
|
|
Provider string `json:"provider"`
|
|
}
|
|
|
|
dis := new(discriminator)
|
|
if err := json.Unmarshal(data, &dis); err != nil {
|
|
return fmt.Errorf("could not unmarshal discriminator: %w", err)
|
|
}
|
|
|
|
switch dis.Provider {
|
|
case "Adyen":
|
|
v3AdyenConfig := new(V3AdyenConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3AdyenConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Adyen) type V3AdyenConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3AdyenConfig = v3AdyenConfig
|
|
u.Type = V3InstallConnectorRequestTypeAdyen
|
|
return nil
|
|
case "Atlar":
|
|
v3AtlarConfig := new(V3AtlarConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3AtlarConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Atlar) type V3AtlarConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3AtlarConfig = v3AtlarConfig
|
|
u.Type = V3InstallConnectorRequestTypeAtlar
|
|
return nil
|
|
case "Bankingcircle":
|
|
v3BankingcircleConfig := new(V3BankingcircleConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3BankingcircleConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Bankingcircle) type V3BankingcircleConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3BankingcircleConfig = v3BankingcircleConfig
|
|
u.Type = V3InstallConnectorRequestTypeBankingcircle
|
|
return nil
|
|
case "Column":
|
|
v3ColumnConfig := new(V3ColumnConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3ColumnConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Column) type V3ColumnConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3ColumnConfig = v3ColumnConfig
|
|
u.Type = V3InstallConnectorRequestTypeColumn
|
|
return nil
|
|
case "Currencycloud":
|
|
v3CurrencycloudConfig := new(V3CurrencycloudConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3CurrencycloudConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Currencycloud) type V3CurrencycloudConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3CurrencycloudConfig = v3CurrencycloudConfig
|
|
u.Type = V3InstallConnectorRequestTypeCurrencycloud
|
|
return nil
|
|
case "Dummypay":
|
|
v3DummypayConfig := new(V3DummypayConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3DummypayConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Dummypay) type V3DummypayConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3DummypayConfig = v3DummypayConfig
|
|
u.Type = V3InstallConnectorRequestTypeDummypay
|
|
return nil
|
|
case "Generic":
|
|
v3GenericConfig := new(V3GenericConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3GenericConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Generic) type V3GenericConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3GenericConfig = v3GenericConfig
|
|
u.Type = V3InstallConnectorRequestTypeGeneric
|
|
return nil
|
|
case "Mangopay":
|
|
v3MangopayConfig := new(V3MangopayConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3MangopayConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Mangopay) type V3MangopayConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3MangopayConfig = v3MangopayConfig
|
|
u.Type = V3InstallConnectorRequestTypeMangopay
|
|
return nil
|
|
case "Modulr":
|
|
v3ModulrConfig := new(V3ModulrConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3ModulrConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Modulr) type V3ModulrConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3ModulrConfig = v3ModulrConfig
|
|
u.Type = V3InstallConnectorRequestTypeModulr
|
|
return nil
|
|
case "Moneycorp":
|
|
v3MoneycorpConfig := new(V3MoneycorpConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3MoneycorpConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Moneycorp) type V3MoneycorpConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3MoneycorpConfig = v3MoneycorpConfig
|
|
u.Type = V3InstallConnectorRequestTypeMoneycorp
|
|
return nil
|
|
case "Qonto":
|
|
v3QontoConfig := new(V3QontoConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3QontoConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Qonto) type V3QontoConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3QontoConfig = v3QontoConfig
|
|
u.Type = V3InstallConnectorRequestTypeQonto
|
|
return nil
|
|
case "Stripe":
|
|
v3StripeConfig := new(V3StripeConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3StripeConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Stripe) type V3StripeConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3StripeConfig = v3StripeConfig
|
|
u.Type = V3InstallConnectorRequestTypeStripe
|
|
return nil
|
|
case "Wise":
|
|
v3WiseConfig := new(V3WiseConfig)
|
|
if err := utils.UnmarshalJSON(data, &v3WiseConfig, "", true, false); err != nil {
|
|
return fmt.Errorf("could not unmarshal `%s` into expected (Provider == Wise) type V3WiseConfig within V3InstallConnectorRequest: %w", string(data), err)
|
|
}
|
|
|
|
u.V3WiseConfig = v3WiseConfig
|
|
u.Type = V3InstallConnectorRequestTypeWise
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("could not unmarshal `%s` into any supported union types for V3InstallConnectorRequest", string(data))
|
|
}
|
|
|
|
func (u V3InstallConnectorRequest) MarshalJSON() ([]byte, error) {
|
|
if u.V3AdyenConfig != nil {
|
|
return utils.MarshalJSON(u.V3AdyenConfig, "", true)
|
|
}
|
|
|
|
if u.V3AtlarConfig != nil {
|
|
return utils.MarshalJSON(u.V3AtlarConfig, "", true)
|
|
}
|
|
|
|
if u.V3BankingcircleConfig != nil {
|
|
return utils.MarshalJSON(u.V3BankingcircleConfig, "", true)
|
|
}
|
|
|
|
if u.V3ColumnConfig != nil {
|
|
return utils.MarshalJSON(u.V3ColumnConfig, "", true)
|
|
}
|
|
|
|
if u.V3CurrencycloudConfig != nil {
|
|
return utils.MarshalJSON(u.V3CurrencycloudConfig, "", true)
|
|
}
|
|
|
|
if u.V3DummypayConfig != nil {
|
|
return utils.MarshalJSON(u.V3DummypayConfig, "", true)
|
|
}
|
|
|
|
if u.V3GenericConfig != nil {
|
|
return utils.MarshalJSON(u.V3GenericConfig, "", true)
|
|
}
|
|
|
|
if u.V3MangopayConfig != nil {
|
|
return utils.MarshalJSON(u.V3MangopayConfig, "", true)
|
|
}
|
|
|
|
if u.V3ModulrConfig != nil {
|
|
return utils.MarshalJSON(u.V3ModulrConfig, "", true)
|
|
}
|
|
|
|
if u.V3MoneycorpConfig != nil {
|
|
return utils.MarshalJSON(u.V3MoneycorpConfig, "", true)
|
|
}
|
|
|
|
if u.V3QontoConfig != nil {
|
|
return utils.MarshalJSON(u.V3QontoConfig, "", true)
|
|
}
|
|
|
|
if u.V3StripeConfig != nil {
|
|
return utils.MarshalJSON(u.V3StripeConfig, "", true)
|
|
}
|
|
|
|
if u.V3WiseConfig != nil {
|
|
return utils.MarshalJSON(u.V3WiseConfig, "", true)
|
|
}
|
|
|
|
return nil, errors.New("could not marshal union type V3InstallConnectorRequest: all fields are null")
|
|
}
|