diff --git a/client/.openapi-generator-ignore b/client/.openapi-generator-ignore index 7484ee59..c09dc47b 100644 --- a/client/.openapi-generator-ignore +++ b/client/.openapi-generator-ignore @@ -21,3 +21,4 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md +test/ \ No newline at end of file diff --git a/client/.openapi-generator/FILES b/client/.openapi-generator/FILES index 949fc56b..54d42d42 100644 --- a/client/.openapi-generator/FILES +++ b/client/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore .travis.yml README.md api/openapi.yaml @@ -8,9 +7,14 @@ client.go configuration.go docs/BankingCircleConfig.md docs/ConnectorBaseInfo.md +docs/ConnectorTaskBase.md +docs/Connectors.md docs/CurrencyCloudConfig.md docs/DummyPayConfig.md docs/GetPaymentResponse.md +docs/ListConnectorsConfigsResponse.md +docs/ListConnectorsConfigsResponseConnector.md +docs/ListConnectorsConfigsResponseConnectorKey.md docs/ListConnectorsResponse.md docs/ListPaymentsResponse.md docs/ModulrConfig.md @@ -18,22 +22,28 @@ docs/Payment.md docs/PaymentsApi.md docs/StripeConfig.md docs/StripeTask.md +docs/StripeTransferRequest.md docs/WiseConfig.md git_push.sh go.mod go.sum model_banking_circle_config.go model_connector_base_info.go +model_connector_task_base.go +model_connectors.go model_currency_cloud_config.go model_dummy_pay_config.go model_get_payment_response.go +model_list_connectors_configs_response.go +model_list_connectors_configs_response_connector.go +model_list_connectors_configs_response_connector_key.go model_list_connectors_response.go model_list_payments_response.go model_modulr_config.go model_payment.go model_stripe_config.go model_stripe_task.go +model_stripe_transfer_request.go model_wise_config.go response.go -test/api_payments_test.go utils.go diff --git a/client/.openapi-generator/VERSION b/client/.openapi-generator/VERSION index d6b4ec4a..0df17dd0 100644 --- a/client/.openapi-generator/VERSION +++ b/client/.openapi-generator/VERSION @@ -1 +1 @@ -6.3.0-SNAPSHOT \ No newline at end of file +6.2.1 \ No newline at end of file diff --git a/client/README.md b/client/README.md index 7ca0a070..5d05b226 100644 --- a/client/README.md +++ b/client/README.md @@ -15,6 +15,7 @@ Install the following dependencies: ```shell go get github.com/stretchr/testify/assert +go get golang.org/x/oauth2 go get golang.org/x/net/context ``` @@ -77,6 +78,7 @@ All URIs are relative to *http://localhost* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*PaymentsApi* | [**ConnectorsStripeTransfer**](docs/PaymentsApi.md#connectorsstripetransfer) | **Post** /connectors/stripe/transfer | Transfer funds between Stripe accounts *PaymentsApi* | [**GetAllConnectors**](docs/PaymentsApi.md#getallconnectors) | **Get** /connectors | Get all installed connectors *PaymentsApi* | [**GetAllConnectorsConfigs**](docs/PaymentsApi.md#getallconnectorsconfigs) | **Get** /connectors/configs | Get all available connectors configs *PaymentsApi* | [**GetConnectorTask**](docs/PaymentsApi.md#getconnectortask) | **Get** /connectors/{connector}/tasks/{taskId} | Read a specific task of the connector @@ -93,15 +95,21 @@ Class | Method | HTTP request | Description - [BankingCircleConfig](docs/BankingCircleConfig.md) - [ConnectorBaseInfo](docs/ConnectorBaseInfo.md) + - [ConnectorTaskBase](docs/ConnectorTaskBase.md) + - [Connectors](docs/Connectors.md) - [CurrencyCloudConfig](docs/CurrencyCloudConfig.md) - [DummyPayConfig](docs/DummyPayConfig.md) - [GetPaymentResponse](docs/GetPaymentResponse.md) + - [ListConnectorsConfigsResponse](docs/ListConnectorsConfigsResponse.md) + - [ListConnectorsConfigsResponseConnector](docs/ListConnectorsConfigsResponseConnector.md) + - [ListConnectorsConfigsResponseConnectorKey](docs/ListConnectorsConfigsResponseConnectorKey.md) - [ListConnectorsResponse](docs/ListConnectorsResponse.md) - [ListPaymentsResponse](docs/ListPaymentsResponse.md) - [ModulrConfig](docs/ModulrConfig.md) - [Payment](docs/Payment.md) - [StripeConfig](docs/StripeConfig.md) - [StripeTask](docs/StripeTask.md) + - [StripeTransferRequest](docs/StripeTransferRequest.md) - [WiseConfig](docs/WiseConfig.md) diff --git a/client/api/openapi.yaml b/client/api/openapi.yaml index 1d19ec2e..f8f9f45a 100644 --- a/client/api/openapi.yaml +++ b/client/api/openapi.yaml @@ -91,7 +91,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ConnectorConfig' + $ref: '#/components/schemas/ListConnectorsConfigsResponse' description: List of available connectors configs summary: Get all available connectors configs tags: @@ -107,8 +107,7 @@ paths: name: connector required: true schema: - enum: - - stripe + $ref: '#/components/schemas/Connectors' style: simple responses: "204": @@ -126,12 +125,7 @@ paths: name: connector required: true schema: - enum: - - stripe - - dummypay - - wise - - modulr - - currencycloud + $ref: '#/components/schemas/Connectors' style: simple requestBody: content: @@ -156,8 +150,7 @@ paths: name: connector required: true schema: - enum: - - stripe + $ref: '#/components/schemas/Connectors' style: simple responses: "200": @@ -181,8 +174,7 @@ paths: name: connector required: true schema: - enum: - - stripe + $ref: '#/components/schemas/Connectors' style: simple responses: "204": @@ -201,8 +193,7 @@ paths: name: connector required: true schema: - enum: - - stripe + $ref: '#/components/schemas/Connectors' style: simple responses: "200": @@ -210,7 +201,13 @@ paths: application/json: schema: items: - $ref: '#/components/schemas/ConnectorTask' + oneOf: + - $ref: '#/components/schemas/TaskDescriptorStripe' + - $ref: '#/components/schemas/TaskDescriptorWise' + - $ref: '#/components/schemas/TaskDescriptorCurrencyCloud' + - $ref: '#/components/schemas/TaskDescriptorDummyPay' + - $ref: '#/components/schemas/TaskDescriptorModulr' + - $ref: '#/components/schemas/TaskDescriptorBankingCircle' description: Task list summary: List connector tasks tags: @@ -226,8 +223,7 @@ paths: name: connector required: true schema: - enum: - - stripe + $ref: '#/components/schemas/Connectors' style: simple - description: The task id example: task1 @@ -242,13 +238,43 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ConnectorTask' + oneOf: + - $ref: '#/components/schemas/TaskDescriptorStripe' + - $ref: '#/components/schemas/TaskDescriptorWise' + - $ref: '#/components/schemas/TaskDescriptorCurrencyCloud' + - $ref: '#/components/schemas/TaskDescriptorDummyPay' + - $ref: '#/components/schemas/TaskDescriptorModulr' + - $ref: '#/components/schemas/TaskDescriptorBankingCircle' description: The specified task summary: Read a specific task of the connector tags: - Payments + /connectors/stripe/transfer: + post: + description: Execute a transfer between two Stripe accounts + operationId: connectorsStripeTransfer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StripeTransferRequest' + required: true + responses: + "200": + description: Transfer has been executed + summary: Transfer funds between Stripe accounts + tags: + - Payments components: schemas: + Connectors: + enum: + - STRIPE + - DUMMY-PAY + - SIE + - MODULR + - CURRENCY-CLOUD + - BANKING-CIRCLE ConnectorConfig: oneOf: - $ref: '#/components/schemas/StripeConfig' @@ -257,9 +283,6 @@ components: - $ref: '#/components/schemas/ModulrConfig' - $ref: '#/components/schemas/CurrencyCloudConfig' - $ref: '#/components/schemas/BankingCircleConfig' - ConnectorTask: - oneOf: - - $ref: '#/components/schemas/StripeTask' StripeConfig: properties: pollingPeriod: @@ -435,9 +458,128 @@ components: $ref: '#/components/schemas/ConnectorBaseInfo' required: - data + ListConnectorsConfigsResponse: + example: + connector: + key: + datatype: "" + required: "" + properties: + connector: + $ref: '#/components/schemas/ListConnectorsConfigsResponse_connector' ConnectorBaseInfo: properties: provider: example: stripe disabled: example: false + StripeTransferRequest: + example: + amount: 100 + metadata: + order_id: "6735" + destination: acct_1Gqj58KZcSIg2N2q + asset: USD + properties: + amount: + example: 100 + asset: + example: USD + destination: + example: acct_1Gqj58KZcSIg2N2q + metadata: + description: | + A set of key/value pairs that you can attach to a transfer object. + It can be useful for storing additional information about the transfer in a structured format. + example: + order_id: "6735" + ConnectorTaskBase: + properties: + provider: + description: The connector code + example: stripe + createdAt: + description: The date when the task was created + example: 2020-01-01T00:00:00.000Z + format: date-time + status: + description: The task status + enum: + - stopped + - pending + - terminated + - active + - failed + example: stopped + error: + description: The error message if the task failed + example: "Error: Something went wrong" + state: + description: The task state + example: {} + TaskDescriptorStripe: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + main: {} + account: {} + TaskDescriptorWise: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + key: {} + profileID: {} + TaskDescriptorModulr: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + key: {} + accountID: {} + TaskDescriptorDummyPay: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + key: {} + fileName: {} + TaskDescriptorCurrencyCloud: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + TaskDescriptorBankingCircle: + allOf: + - $ref: '#/components/schemas/ConnectorTaskBase' + - properties: + descriptor: + properties: + name: {} + key: {} + ListConnectorsConfigsResponse_connector_key: + example: + datatype: "" + required: "" + properties: + datatype: {} + required: {} + ListConnectorsConfigsResponse_connector: + example: + key: + datatype: "" + required: "" + properties: + key: + $ref: '#/components/schemas/ListConnectorsConfigsResponse_connector_key' diff --git a/client/api_payments.go b/client/api_payments.go index 5b6b418e..4cabc8a2 100644 --- a/client/api_payments.go +++ b/client/api_payments.go @@ -22,6 +22,105 @@ import ( // PaymentsApiService PaymentsApi service type PaymentsApiService service +type ApiConnectorsStripeTransferRequest struct { + ctx context.Context + ApiService *PaymentsApiService + stripeTransferRequest *StripeTransferRequest +} + +func (r ApiConnectorsStripeTransferRequest) StripeTransferRequest(stripeTransferRequest StripeTransferRequest) ApiConnectorsStripeTransferRequest { + r.stripeTransferRequest = &stripeTransferRequest + return r +} + +func (r ApiConnectorsStripeTransferRequest) Execute() (*http.Response, error) { + return r.ApiService.ConnectorsStripeTransferExecute(r) +} + +/* +ConnectorsStripeTransfer Transfer funds between Stripe accounts + +Execute a transfer between two Stripe accounts + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiConnectorsStripeTransferRequest +*/ +func (a *PaymentsApiService) ConnectorsStripeTransfer(ctx context.Context) ApiConnectorsStripeTransferRequest { + return ApiConnectorsStripeTransferRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +func (a *PaymentsApiService) ConnectorsStripeTransferExecute(r ApiConnectorsStripeTransferRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PaymentsApiService.ConnectorsStripeTransfer") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/connectors/stripe/transfer" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.stripeTransferRequest == nil { + return nil, reportError("stripeTransferRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.stripeTransferRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + type ApiGetAllConnectorsRequest struct { ctx context.Context ApiService *PaymentsApiService @@ -126,7 +225,7 @@ type ApiGetAllConnectorsConfigsRequest struct { ApiService *PaymentsApiService } -func (r ApiGetAllConnectorsConfigsRequest) Execute() (interface{}, *http.Response, error) { +func (r ApiGetAllConnectorsConfigsRequest) Execute() (*ListConnectorsConfigsResponse, *http.Response, error) { return r.ApiService.GetAllConnectorsConfigsExecute(r) } @@ -146,13 +245,13 @@ func (a *PaymentsApiService) GetAllConnectorsConfigs(ctx context.Context) ApiGet } // Execute executes the request -// @return interface{} -func (a *PaymentsApiService) GetAllConnectorsConfigsExecute(r ApiGetAllConnectorsConfigsRequest) (interface{}, *http.Response, error) { +// @return ListConnectorsConfigsResponse +func (a *PaymentsApiService) GetAllConnectorsConfigsExecute(r ApiGetAllConnectorsConfigsRequest) (*ListConnectorsConfigsResponse, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue interface{} + localVarReturnValue *ListConnectorsConfigsResponse ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PaymentsApiService.GetAllConnectorsConfigs") @@ -223,7 +322,7 @@ func (a *PaymentsApiService) GetAllConnectorsConfigsExecute(r ApiGetAllConnector type ApiGetConnectorTaskRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors taskId interface{} } @@ -241,7 +340,7 @@ Get a specific task associated to the connector @param taskId The task id @return ApiGetConnectorTaskRequest */ -func (a *PaymentsApiService) GetConnectorTask(ctx context.Context, connector interface{}, taskId interface{}) ApiGetConnectorTaskRequest { +func (a *PaymentsApiService) GetConnectorTask(ctx context.Context, connector Connectors, taskId interface{}) ApiGetConnectorTaskRequest { return ApiGetConnectorTaskRequest{ ApiService: a, ctx: ctx, @@ -266,8 +365,8 @@ func (a *PaymentsApiService) GetConnectorTaskExecute(r ApiGetConnectorTaskReques } localVarPath := localBasePath + "/connectors/{connector}/tasks/{taskId}" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"taskId"+"}", url.PathEscape(parameterValueToString(r.taskId, "taskId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"taskId"+"}", url.PathEscape(parameterToString(r.taskId, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -368,7 +467,7 @@ func (a *PaymentsApiService) GetPaymentExecute(r ApiGetPaymentRequest) (*Payment } localVarPath := localBasePath + "/payments/{paymentId}" - localVarPath = strings.Replace(localVarPath, "{"+"paymentId"+"}", url.PathEscape(parameterValueToString(r.paymentId, "paymentId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"paymentId"+"}", url.PathEscape(parameterToString(r.paymentId, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -431,7 +530,7 @@ func (a *PaymentsApiService) GetPaymentExecute(r ApiGetPaymentRequest) (*Payment type ApiInstallConnectorRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors body *interface{} } @@ -453,7 +552,7 @@ Install connector @param connector The connector code @return ApiInstallConnectorRequest */ -func (a *PaymentsApiService) InstallConnector(ctx context.Context, connector interface{}) ApiInstallConnectorRequest { +func (a *PaymentsApiService) InstallConnector(ctx context.Context, connector Connectors) ApiInstallConnectorRequest { return ApiInstallConnectorRequest{ ApiService: a, ctx: ctx, @@ -475,7 +574,7 @@ func (a *PaymentsApiService) InstallConnectorExecute(r ApiInstallConnectorReques } localVarPath := localBasePath + "/connectors/{connector}" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -534,7 +633,7 @@ func (a *PaymentsApiService) InstallConnectorExecute(r ApiInstallConnectorReques type ApiListConnectorTasksRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors } func (r ApiListConnectorTasksRequest) Execute() (interface{}, *http.Response, error) { @@ -550,7 +649,7 @@ List all tasks associated with this connector. @param connector The connector code @return ApiListConnectorTasksRequest */ -func (a *PaymentsApiService) ListConnectorTasks(ctx context.Context, connector interface{}) ApiListConnectorTasksRequest { +func (a *PaymentsApiService) ListConnectorTasks(ctx context.Context, connector Connectors) ApiListConnectorTasksRequest { return ApiListConnectorTasksRequest{ ApiService: a, ctx: ctx, @@ -574,7 +673,7 @@ func (a *PaymentsApiService) ListConnectorTasksExecute(r ApiListConnectorTasksRe } localVarPath := localBasePath + "/connectors/{connector}/tasks" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -699,13 +798,13 @@ func (a *PaymentsApiService) ListPaymentsExecute(r ApiListPaymentsRequest) (*Lis localVarFormParams := url.Values{} if r.limit != nil { - parameterAddToQuery(localVarQueryParams, "limit", r.limit, "") + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) } if r.skip != nil { - parameterAddToQuery(localVarQueryParams, "skip", r.skip, "") + localVarQueryParams.Add("skip", parameterToString(*r.skip, "")) } if r.sort != nil { - parameterAddToQuery(localVarQueryParams, "sort", r.sort, "") + localVarQueryParams.Add("sort", parameterToString(*r.sort, "")) } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -764,7 +863,7 @@ func (a *PaymentsApiService) ListPaymentsExecute(r ApiListPaymentsRequest) (*Lis type ApiReadConnectorConfigRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors } func (r ApiReadConnectorConfigRequest) Execute() (interface{}, *http.Response, error) { @@ -780,7 +879,7 @@ Read connector config @param connector The connector code @return ApiReadConnectorConfigRequest */ -func (a *PaymentsApiService) ReadConnectorConfig(ctx context.Context, connector interface{}) ApiReadConnectorConfigRequest { +func (a *PaymentsApiService) ReadConnectorConfig(ctx context.Context, connector Connectors) ApiReadConnectorConfigRequest { return ApiReadConnectorConfigRequest{ ApiService: a, ctx: ctx, @@ -804,7 +903,7 @@ func (a *PaymentsApiService) ReadConnectorConfigExecute(r ApiReadConnectorConfig } localVarPath := localBasePath + "/connectors/{connector}/config" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -867,7 +966,7 @@ func (a *PaymentsApiService) ReadConnectorConfigExecute(r ApiReadConnectorConfig type ApiResetConnectorRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors } func (r ApiResetConnectorRequest) Execute() (*http.Response, error) { @@ -883,7 +982,7 @@ Reset connector. Will remove the connector and ALL PAYMENTS generated with it. @param connector The connector code @return ApiResetConnectorRequest */ -func (a *PaymentsApiService) ResetConnector(ctx context.Context, connector interface{}) ApiResetConnectorRequest { +func (a *PaymentsApiService) ResetConnector(ctx context.Context, connector Connectors) ApiResetConnectorRequest { return ApiResetConnectorRequest{ ApiService: a, ctx: ctx, @@ -905,7 +1004,7 @@ func (a *PaymentsApiService) ResetConnectorExecute(r ApiResetConnectorRequest) ( } localVarPath := localBasePath + "/connectors/{connector}/reset" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -959,7 +1058,7 @@ func (a *PaymentsApiService) ResetConnectorExecute(r ApiResetConnectorRequest) ( type ApiUninstallConnectorRequest struct { ctx context.Context ApiService *PaymentsApiService - connector interface{} + connector Connectors } func (r ApiUninstallConnectorRequest) Execute() (*http.Response, error) { @@ -975,7 +1074,7 @@ Uninstall connector @param connector The connector code @return ApiUninstallConnectorRequest */ -func (a *PaymentsApiService) UninstallConnector(ctx context.Context, connector interface{}) ApiUninstallConnectorRequest { +func (a *PaymentsApiService) UninstallConnector(ctx context.Context, connector Connectors) ApiUninstallConnectorRequest { return ApiUninstallConnectorRequest{ ApiService: a, ctx: ctx, @@ -997,7 +1096,7 @@ func (a *PaymentsApiService) UninstallConnectorExecute(r ApiUninstallConnectorRe } localVarPath := localBasePath + "/connectors/{connector}" - localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterValueToString(r.connector, "connector")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"connector"+"}", url.PathEscape(parameterToString(r.connector, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} diff --git a/client/client.go b/client/client.go index 4b8537eb..86a30b52 100644 --- a/client/client.go +++ b/client/client.go @@ -32,13 +32,13 @@ import ( "strings" "time" "unicode/utf8" + + "golang.org/x/oauth2" ) var ( - jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) - xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) - queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) - queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) ) // APIClient manages communication with the Payments API API v1.0.0 @@ -125,101 +125,28 @@ func typeCheckParameter(obj interface{}, expected string, name string) error { return nil } -func parameterValueToString(obj interface{}, key string) string { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return fmt.Sprintf("%v", obj) - } - var param, ok = obj.(MappedNullable) - if !ok { - return "" - } - dataMap, err := param.ToMap() - if err != nil { - return "" - } - return fmt.Sprintf("%v", dataMap[key]) -} - -// parameterAddToQuery adds the provided object to the url query supporting deep object syntax -func parameterAddToQuery(queryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { - var v = reflect.ValueOf(obj) - var value = "" - if v == reflect.ValueOf(nil) { - value = "null" - } else { - switch v.Kind() { - case reflect.Invalid: - value = "invalid" - - case reflect.Struct: - if t, ok := obj.(MappedNullable); ok { - dataMap, err := t.ToMap() - if err != nil { - return - } - parameterAddToQuery(queryParams, keyPrefix, dataMap, collectionType) - return - } - if t, ok := obj.(time.Time); ok { - parameterAddToQuery(queryParams, keyPrefix, t.Format(time.RFC3339), collectionType) - return - } - value = v.Type().String() + " value" - case reflect.Slice: - var indValue = reflect.ValueOf(obj) - if indValue == reflect.ValueOf(nil) { - return - } - var lenIndValue = indValue.Len() - for i := 0; i < lenIndValue; i++ { - var arrayValue = indValue.Index(i) - parameterAddToQuery(queryParams, keyPrefix, arrayValue.Interface(), collectionType) - } - return - - case reflect.Map: - var indValue = reflect.ValueOf(obj) - if indValue == reflect.ValueOf(nil) { - return - } - iter := indValue.MapRange() - for iter.Next() { - k, v := iter.Key(), iter.Value() - parameterAddToQuery(queryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType) - } - return +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string - case reflect.Interface: - fallthrough - case reflect.Ptr: - parameterAddToQuery(queryParams, keyPrefix, v.Elem().Interface(), collectionType) - return - - case reflect.Int, reflect.Int8, reflect.Int16, - reflect.Int32, reflect.Int64: - value = strconv.FormatInt(v.Int(), 10) - case reflect.Uint, reflect.Uint8, reflect.Uint16, - reflect.Uint32, reflect.Uint64, reflect.Uintptr: - value = strconv.FormatUint(v.Uint(), 10) - case reflect.Float32, reflect.Float64: - value = strconv.FormatFloat(v.Float(), 'g', -1, 32) - case reflect.Bool: - value = strconv.FormatBool(v.Bool()) - case reflect.String: - value = v.String() - default: - value = v.Type().String() + " value" - } + switch collectionFormat { + case "pipes": + delimiter = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," } - switch valuesMap := queryParams.(type) { - case url.Values: - valuesMap.Add(keyPrefix, value) - break - case map[string]string: - valuesMap[keyPrefix] = value - break + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } else if t, ok := obj.(time.Time); ok { + return t.Format(time.RFC3339) } + + return fmt.Sprintf("%v", obj) } // helper for converting interface{} parameters to json strings @@ -371,11 +298,7 @@ func (c *APIClient) prepareRequest( } // Encode the parameters. - url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { - pieces := strings.Split(s, "=") - pieces[0] = queryDescape.Replace(pieces[0]) - return strings.Join(pieces, "=") - }) + url.RawQuery = query.Encode() // Generate a new request if body != nil { @@ -405,6 +328,27 @@ func (c *APIClient) prepareRequest( // Walk through any authentication. + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + } for header, value := range c.cfg.DefaultHeader { @@ -421,18 +365,6 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err *s = string(b) return nil } - if f, ok := v.(*os.File); ok { - f, err = ioutil.TempFile("", "HttpClientFile") - if err != nil { - return - } - _, err = f.Write(b) - if err != nil { - return - } - _, err = f.Seek(0, io.SeekStart) - return - } if f, ok := v.(**os.File); ok { *f, err = ioutil.TempFile("", "HttpClientFile") if err != nil { @@ -508,8 +440,8 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) - } else if fp, ok := body.(*os.File); ok { - _, err = bodyBuf.ReadFrom(fp) + } else if fp, ok := body.(**os.File); ok { + _, err = bodyBuf.ReadFrom(*fp) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { @@ -632,6 +564,7 @@ func (e GenericOpenAPIError) Model() interface{} { // format error message using title and detail when model implements rfc7807 func formatErrorMessage(status string, v interface{}) string { + str := "" metaValue := reflect.ValueOf(v).Elem() @@ -646,5 +579,5 @@ func formatErrorMessage(status string, v interface{}) string { } // status title (detail) - return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) + return fmt.Sprintf("%s %s", status, str) } diff --git a/client/configuration.go b/client/configuration.go index a7715b78..ba2061bb 100644 --- a/client/configuration.go +++ b/client/configuration.go @@ -28,6 +28,21 @@ func (c contextKey) String() string { } var ( + // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKeys takes a string apikey as authentication for the request + ContextAPIKeys = contextKey("apiKeys") + + // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request. + ContextHttpSignatureAuth = contextKey("httpsignature") + // ContextServerIndex uses a server configuration from the index. ContextServerIndex = contextKey("serverIndex") diff --git a/client/docs/Connectors.md b/client/docs/Connectors.md new file mode 100644 index 00000000..24123a55 --- /dev/null +++ b/client/docs/Connectors.md @@ -0,0 +1,30 @@ +# Connectors + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Methods + +### NewConnectors + +`func NewConnectors() *Connectors` + +NewConnectors instantiates a new Connectors object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewConnectorsWithDefaults + +`func NewConnectorsWithDefaults() *Connectors` + +NewConnectorsWithDefaults instantiates a new Connectors object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client/docs/PaymentsApi.md b/client/docs/PaymentsApi.md index 02b4ed0d..6c42f9f8 100644 --- a/client/docs/PaymentsApi.md +++ b/client/docs/PaymentsApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- +[**ConnectorsStripeTransfer**](PaymentsApi.md#ConnectorsStripeTransfer) | **Post** /connectors/stripe/transfer | Transfer funds between Stripe accounts [**GetAllConnectors**](PaymentsApi.md#GetAllConnectors) | **Get** /connectors | Get all installed connectors [**GetAllConnectorsConfigs**](PaymentsApi.md#GetAllConnectorsConfigs) | **Get** /connectors/configs | Get all available connectors configs [**GetConnectorTask**](PaymentsApi.md#GetConnectorTask) | **Get** /connectors/{connector}/tasks/{taskId} | Read a specific task of the connector @@ -17,6 +18,70 @@ Method | HTTP request | Description +## ConnectorsStripeTransfer + +> ConnectorsStripeTransfer(ctx).StripeTransferRequest(stripeTransferRequest).Execute() + +Transfer funds between Stripe accounts + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + stripeTransferRequest := *openapiclient.NewStripeTransferRequest() // StripeTransferRequest | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.PaymentsApi.ConnectorsStripeTransfer(context.Background()).StripeTransferRequest(stripeTransferRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `PaymentsApi.ConnectorsStripeTransfer``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiConnectorsStripeTransferRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **stripeTransferRequest** | [**StripeTransferRequest**](StripeTransferRequest.md) | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## GetAllConnectors > ListConnectorsResponse GetAllConnectors(ctx).Execute() @@ -80,7 +145,7 @@ No authorization required ## GetAllConnectorsConfigs -> interface{} GetAllConnectorsConfigs(ctx).Execute() +> ListConnectorsConfigsResponse GetAllConnectorsConfigs(ctx).Execute() Get all available connectors configs @@ -107,7 +172,7 @@ func main() { fmt.Fprintf(os.Stderr, "Error when calling `PaymentsApi.GetAllConnectorsConfigs``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } - // response from `GetAllConnectorsConfigs`: interface{} + // response from `GetAllConnectorsConfigs`: ListConnectorsConfigsResponse fmt.Fprintf(os.Stdout, "Response from `PaymentsApi.GetAllConnectorsConfigs`: %v\n", resp) } ``` @@ -123,7 +188,7 @@ Other parameters are passed through a pointer to a apiGetAllConnectorsConfigsReq ### Return type -**interface{}** +[**ListConnectorsConfigsResponse**](ListConnectorsConfigsResponse.md) ### Authorization @@ -160,7 +225,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code taskId := TODO // interface{} | The task id configuration := openapiclient.NewConfiguration() @@ -181,7 +246,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | **taskId** | [**interface{}**](.md) | The task id | ### Other Parameters @@ -301,7 +366,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code body := interface{}(987) // interface{} | configuration := openapiclient.NewConfiguration() @@ -320,7 +385,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | ### Other Parameters @@ -371,7 +436,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -391,7 +456,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | ### Other Parameters @@ -509,7 +574,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -529,7 +594,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | ### Other Parameters @@ -579,7 +644,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -597,7 +662,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | ### Other Parameters @@ -647,7 +712,7 @@ import ( ) func main() { - connector := TODO // interface{} | The connector code + connector := *openapiclient.NewConnectors() // Connectors | The connector code configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -665,7 +730,7 @@ func main() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**connector** | [**interface{}**](.md) | The connector code | +**connector** | [**Connectors**](.md) | The connector code | ### Other Parameters diff --git a/client/go.mod b/client/go.mod index 1cda6c9b..60048988 100644 --- a/client/go.mod +++ b/client/go.mod @@ -1,6 +1,7 @@ -module github.com/numary/payments/client +module github.com/formancehq/payments/client go 1.13 require ( + golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 ) diff --git a/client/go.sum b/client/go.sum index c966c8dd..734252e6 100644 --- a/client/go.sum +++ b/client/go.sum @@ -4,6 +4,8 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/client/model_banking_circle_config.go b/client/model_banking_circle_config.go index 0681f44e..3374bd28 100644 --- a/client/model_banking_circle_config.go +++ b/client/model_banking_circle_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the BankingCircleConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &BankingCircleConfig{} - // BankingCircleConfig struct for BankingCircleConfig type BankingCircleConfig struct { Username interface{} `json:"username"` @@ -151,14 +148,6 @@ func (o *BankingCircleConfig) SetAuthorizationEndpoint(v interface{}) { } func (o BankingCircleConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o BankingCircleConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.Username != nil { toSerialize["username"] = o.Username @@ -172,7 +161,7 @@ func (o BankingCircleConfig) ToMap() (map[string]interface{}, error) { if o.AuthorizationEndpoint != nil { toSerialize["authorizationEndpoint"] = o.AuthorizationEndpoint } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableBankingCircleConfig struct { diff --git a/client/model_connector_base_info.go b/client/model_connector_base_info.go index a8b25302..8ab27f25 100644 --- a/client/model_connector_base_info.go +++ b/client/model_connector_base_info.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the ConnectorBaseInfo type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ConnectorBaseInfo{} - // ConnectorBaseInfo struct for ConnectorBaseInfo type ConnectorBaseInfo struct { Provider interface{} `json:"provider,omitempty"` @@ -107,14 +104,6 @@ func (o *ConnectorBaseInfo) SetDisabled(v interface{}) { } func (o ConnectorBaseInfo) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ConnectorBaseInfo) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.Provider != nil { toSerialize["provider"] = o.Provider @@ -122,7 +111,7 @@ func (o ConnectorBaseInfo) ToMap() (map[string]interface{}, error) { if o.Disabled != nil { toSerialize["disabled"] = o.Disabled } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableConnectorBaseInfo struct { diff --git a/client/model_connectors.go b/client/model_connectors.go new file mode 100644 index 00000000..6d076674 --- /dev/null +++ b/client/model_connectors.go @@ -0,0 +1,77 @@ +/* +Payments API + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" +) + +// Connectors struct for Connectors +type Connectors struct { +} + +// NewConnectors instantiates a new Connectors object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewConnectors() *Connectors { + this := Connectors{} + return &this +} + +// NewConnectorsWithDefaults instantiates a new Connectors object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewConnectorsWithDefaults() *Connectors { + this := Connectors{} + return &this +} + +func (o Connectors) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + return json.Marshal(toSerialize) +} + +type NullableConnectors struct { + value *Connectors + isSet bool +} + +func (v NullableConnectors) Get() *Connectors { + return v.value +} + +func (v *NullableConnectors) Set(val *Connectors) { + v.value = val + v.isSet = true +} + +func (v NullableConnectors) IsSet() bool { + return v.isSet +} + +func (v *NullableConnectors) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConnectors(val *Connectors) *NullableConnectors { + return &NullableConnectors{value: val, isSet: true} +} + +func (v NullableConnectors) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConnectors) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/client/model_currency_cloud_config.go b/client/model_currency_cloud_config.go index 428ef15d..9b38db17 100644 --- a/client/model_currency_cloud_config.go +++ b/client/model_currency_cloud_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the CurrencyCloudConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CurrencyCloudConfig{} - // CurrencyCloudConfig struct for CurrencyCloudConfig type CurrencyCloudConfig struct { ApiKey interface{} `json:"apiKey"` @@ -166,14 +163,6 @@ func (o *CurrencyCloudConfig) SetEndpoint(v interface{}) { } func (o CurrencyCloudConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CurrencyCloudConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.ApiKey != nil { toSerialize["apiKey"] = o.ApiKey @@ -187,7 +176,7 @@ func (o CurrencyCloudConfig) ToMap() (map[string]interface{}, error) { if o.Endpoint != nil { toSerialize["endpoint"] = o.Endpoint } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableCurrencyCloudConfig struct { diff --git a/client/model_dummy_pay_config.go b/client/model_dummy_pay_config.go index 5c35970f..83e4302a 100644 --- a/client/model_dummy_pay_config.go +++ b/client/model_dummy_pay_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the DummyPayConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &DummyPayConfig{} - // DummyPayConfig struct for DummyPayConfig type DummyPayConfig struct { // The frequency at which the connector will try to fetch new payment objects from the directory @@ -137,14 +134,6 @@ func (o *DummyPayConfig) SetDirectory(v interface{}) { } func (o DummyPayConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o DummyPayConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.FilePollingPeriod != nil { toSerialize["filePollingPeriod"] = o.FilePollingPeriod @@ -155,7 +144,7 @@ func (o DummyPayConfig) ToMap() (map[string]interface{}, error) { if o.Directory != nil { toSerialize["directory"] = o.Directory } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableDummyPayConfig struct { diff --git a/client/model_get_payment_response.go b/client/model_get_payment_response.go index 419f015e..4f3d71f4 100644 --- a/client/model_get_payment_response.go +++ b/client/model_get_payment_response.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the GetPaymentResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GetPaymentResponse{} - // GetPaymentResponse struct for GetPaymentResponse type GetPaymentResponse struct { Data Payment `json:"data"` @@ -65,19 +62,13 @@ func (o *GetPaymentResponse) SetData(v Payment) { } func (o GetPaymentResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err + toSerialize := map[string]interface{}{} + if true { + toSerialize["data"] = o.Data } return json.Marshal(toSerialize) } -func (o GetPaymentResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - return toSerialize, nil -} - type NullableGetPaymentResponse struct { value *GetPaymentResponse isSet bool diff --git a/client/model_list_connectors_response.go b/client/model_list_connectors_response.go index 5a49bb64..e4ddde63 100644 --- a/client/model_list_connectors_response.go +++ b/client/model_list_connectors_response.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the ListConnectorsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListConnectorsResponse{} - // ListConnectorsResponse struct for ListConnectorsResponse type ListConnectorsResponse struct { Data interface{} `json:"data"` @@ -67,19 +64,11 @@ func (o *ListConnectorsResponse) SetData(v interface{}) { } func (o ListConnectorsResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListConnectorsResponse) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.Data != nil { toSerialize["data"] = o.Data } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableListConnectorsResponse struct { diff --git a/client/model_list_payments_response.go b/client/model_list_payments_response.go index 3ae3f49f..805d2368 100644 --- a/client/model_list_payments_response.go +++ b/client/model_list_payments_response.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the ListPaymentsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListPaymentsResponse{} - // ListPaymentsResponse struct for ListPaymentsResponse type ListPaymentsResponse struct { Data interface{} `json:"data"` @@ -67,19 +64,11 @@ func (o *ListPaymentsResponse) SetData(v interface{}) { } func (o ListPaymentsResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListPaymentsResponse) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.Data != nil { toSerialize["data"] = o.Data } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableListPaymentsResponse struct { diff --git a/client/model_modulr_config.go b/client/model_modulr_config.go index a70bc046..de3ceabf 100644 --- a/client/model_modulr_config.go +++ b/client/model_modulr_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the ModulrConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ModulrConfig{} - // ModulrConfig struct for ModulrConfig type ModulrConfig struct { ApiKey interface{} `json:"apiKey"` @@ -129,14 +126,6 @@ func (o *ModulrConfig) SetEndpoint(v interface{}) { } func (o ModulrConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ModulrConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.ApiKey != nil { toSerialize["apiKey"] = o.ApiKey @@ -147,7 +136,7 @@ func (o ModulrConfig) ToMap() (map[string]interface{}, error) { if o.Endpoint != nil { toSerialize["endpoint"] = o.Endpoint } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableModulrConfig struct { diff --git a/client/model_payment.go b/client/model_payment.go index 2013d2f4..6112000e 100644 --- a/client/model_payment.go +++ b/client/model_payment.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the Payment type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Payment{} - // Payment struct for Payment type Payment struct { Provider interface{} `json:"provider"` @@ -331,14 +328,6 @@ func (o *Payment) SetRaw(v interface{}) { } func (o Payment) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Payment) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.Provider != nil { toSerialize["provider"] = o.Provider @@ -370,7 +359,7 @@ func (o Payment) ToMap() (map[string]interface{}, error) { if o.Raw != nil { toSerialize["raw"] = o.Raw } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullablePayment struct { diff --git a/client/model_stripe_config.go b/client/model_stripe_config.go index 24a3dfa6..c0c1c851 100644 --- a/client/model_stripe_config.go +++ b/client/model_stripe_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the StripeConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StripeConfig{} - // StripeConfig struct for StripeConfig type StripeConfig struct { // The frequency at which the connector will try to fetch new BalanceTransaction objects from Stripe api @@ -137,14 +134,6 @@ func (o *StripeConfig) SetPageSize(v interface{}) { } func (o StripeConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StripeConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.PollingPeriod != nil { toSerialize["pollingPeriod"] = o.PollingPeriod @@ -155,7 +144,7 @@ func (o StripeConfig) ToMap() (map[string]interface{}, error) { if o.PageSize != nil { toSerialize["pageSize"] = o.PageSize } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableStripeConfig struct { diff --git a/client/model_stripe_task.go b/client/model_stripe_task.go index e415aea5..8bc3d4bd 100644 --- a/client/model_stripe_task.go +++ b/client/model_stripe_task.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the StripeTask type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StripeTask{} - // StripeTask struct for StripeTask type StripeTask struct { // The id of the oldest BalanceTransaction fetched from stripe for this account @@ -213,14 +210,6 @@ func (o *StripeTask) SetNoMoreHistory(v interface{}) { } func (o StripeTask) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StripeTask) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.OldestId != nil { toSerialize["oldestId"] = o.OldestId @@ -237,7 +226,7 @@ func (o StripeTask) ToMap() (map[string]interface{}, error) { if o.NoMoreHistory != nil { toSerialize["noMoreHistory"] = o.NoMoreHistory } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableStripeTask struct { diff --git a/client/model_wise_config.go b/client/model_wise_config.go index 2cf3aa87..d529e57e 100644 --- a/client/model_wise_config.go +++ b/client/model_wise_config.go @@ -14,9 +14,6 @@ import ( "encoding/json" ) -// checks if the WiseConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &WiseConfig{} - // WiseConfig struct for WiseConfig type WiseConfig struct { ApiKey interface{} `json:"apiKey"` @@ -67,19 +64,11 @@ func (o *WiseConfig) SetApiKey(v interface{}) { } func (o WiseConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o WiseConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if o.ApiKey != nil { toSerialize["apiKey"] = o.ApiKey } - return toSerialize, nil + return json.Marshal(toSerialize) } type NullableWiseConfig struct { diff --git a/client/test/api_payments_test.go b/client/test/api_payments_test.go deleted file mode 100644 index 3d87012d..00000000 --- a/client/test/api_payments_test.go +++ /dev/null @@ -1,158 +0,0 @@ -/* -Payments API - -Testing PaymentsApiService - -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package client - -import ( - "context" - "testing" - - openapiclient "github.com/formancehq/payments/client" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func Test_client_PaymentsApiService(t *testing.T) { - - configuration := openapiclient.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test PaymentsApiService GetAllConnectors", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.PaymentsApi.GetAllConnectors(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService GetAllConnectorsConfigs", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.PaymentsApi.GetAllConnectorsConfigs(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService GetConnectorTask", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - var taskId interface{} - - resp, httpRes, err := apiClient.PaymentsApi.GetConnectorTask(context.Background(), connector, taskId).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService GetPayment", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var paymentId interface{} - - resp, httpRes, err := apiClient.PaymentsApi.GetPayment(context.Background(), paymentId).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService InstallConnector", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - - httpRes, err := apiClient.PaymentsApi.InstallConnector(context.Background(), connector).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService ListConnectorTasks", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - - resp, httpRes, err := apiClient.PaymentsApi.ListConnectorTasks(context.Background(), connector).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService ListPayments", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.PaymentsApi.ListPayments(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService ReadConnectorConfig", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - - resp, httpRes, err := apiClient.PaymentsApi.ReadConnectorConfig(context.Background(), connector).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService ResetConnector", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - - httpRes, err := apiClient.PaymentsApi.ResetConnector(context.Background(), connector).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test PaymentsApiService UninstallConnector", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var connector interface{} - - httpRes, err := apiClient.PaymentsApi.UninstallConnector(context.Background(), connector).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - -} diff --git a/client/utils.go b/client/utils.go index 7b178ca4..d83916f7 100644 --- a/client/utils.go +++ b/client/utils.go @@ -341,7 +341,3 @@ func isNil(i interface{}) bool { } return false } - -type MappedNullable interface { - ToMap() (map[string]interface{}, error) -} diff --git a/main.go b/main.go index c52a3c1f..9e9fdf11 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -//go:generate docker run --rm -w /local -v ${PWD}:/local openapitools/openapi-generator-cli:v6.2.1 generate -i ./swagger.yml -g go -o ./client --git-user-id=formancehq --git-repo-id=payments/client -p packageVersion=latest -p isGoSubmodule=true -p packageName=client -//go:generate docker run --rm -w /local -v ${PWD}:/local cytopia/goimports: -w -e ./client +//go:generate docker run --rm -w /local -v ${PWD}:/local openapitools/openapi-generator-cli:v6.2.1 generate -i ./swagger.yml -g go -o ./client --git-user-id=formancehq --git-repo-id=payments -p packageVersion=latest -p isGoSubmodule=true -p packageName=client +//go:generate docker run --rm -w /local -v ${PWD}:/local cytopia/goimports -w -e ./client package main import "github.com/formancehq/payments/cmd"