Skip to content

Commit

Permalink
feat(api): add sandbox APIs (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 9, 2024
1 parent 58e49c4 commit 3b861cf
Show file tree
Hide file tree
Showing 28 changed files with 2,955 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 23
configured_endpoints: 33
65 changes: 53 additions & 12 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/Finch-API/finch-api-go/internal/apijson"
"github.com/Finch-API/finch-api-go/internal/requestconfig"
"github.com/Finch-API/finch-api-go/internal/shared"
"github.com/Finch-API/finch-api-go/option"
)

Expand Down Expand Up @@ -66,7 +67,8 @@ func (r *DisconnectResponse) UnmarshalJSON(data []byte) (err error) {

type Introspection struct {
// The Finch uuid of the account used to connect this company.
AccountID string `json:"account_id,required"`
AccountID string `json:"account_id,required"`
AuthenticationMethods IntrospectionAuthenticationMethods `json:"authentication_methods,required"`
// The client id of the application associated with the `access_token`.
ClientID string `json:"client_id,required"`
// The type of application associated with a token.
Expand Down Expand Up @@ -94,23 +96,62 @@ type Introspection struct {

// introspectionJSON contains the JSON metadata for the struct [Introspection]
type introspectionJSON struct {
AccountID apijson.Field
ClientID apijson.Field
ClientType apijson.Field
CompanyID apijson.Field
ConnectionType apijson.Field
Manual apijson.Field
PayrollProviderID apijson.Field
Products apijson.Field
Username apijson.Field
raw string
ExtraFields map[string]apijson.Field
AccountID apijson.Field
AuthenticationMethods apijson.Field
ClientID apijson.Field
ClientType apijson.Field
CompanyID apijson.Field
ConnectionType apijson.Field
Manual apijson.Field
PayrollProviderID apijson.Field
Products apijson.Field
Username apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *Introspection) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type IntrospectionAuthenticationMethods struct {
ConnectionStatus IntrospectionAuthenticationMethodsConnectionStatus `json:"connection_status"`
Type string `json:"type"`
JSON introspectionAuthenticationMethodsJSON `json:"-"`
}

// introspectionAuthenticationMethodsJSON contains the JSON metadata for the struct
// [IntrospectionAuthenticationMethods]
type introspectionAuthenticationMethodsJSON struct {
ConnectionStatus apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *IntrospectionAuthenticationMethods) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type IntrospectionAuthenticationMethodsConnectionStatus struct {
Message string `json:"message"`
Status shared.IntrospectResponseConnectionStatus `json:"status"`
JSON introspectionAuthenticationMethodsConnectionStatusJSON `json:"-"`
}

// introspectionAuthenticationMethodsConnectionStatusJSON contains the JSON
// metadata for the struct [IntrospectionAuthenticationMethodsConnectionStatus]
type introspectionAuthenticationMethodsConnectionStatusJSON struct {
Message apijson.Field
Status apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *IntrospectionAuthenticationMethodsConnectionStatus) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

// The type of application associated with a token.
type IntrospectionClientType string

Expand Down
21 changes: 21 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ import (

type Error = apierror.Error

// This is an alias to an internal type.
type IntrospectResponseConnectionStatus = shared.IntrospectResponseConnectionStatus

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusPending = shared.IntrospectResponseConnectionStatusPending

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusProcessing = shared.IntrospectResponseConnectionStatusProcessing

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusConnected = shared.IntrospectResponseConnectionStatusConnected

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusErrorNoAccountSetup = shared.IntrospectResponseConnectionStatusErrorNoAccountSetup

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusErrorPermissions = shared.IntrospectResponseConnectionStatusErrorPermissions

// This is an alias to an internal value.
const IntrospectResponseConnectionStatusReauth = shared.IntrospectResponseConnectionStatusReauth

// - `supported`: This operation is supported by both the provider and Finch
//
// - `not_supported_by_finch`: This operation is not supported by Finch but
Expand Down
104 changes: 104 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Shared Params Types

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared#IntrospectResponseConnectionStatus">IntrospectResponseConnectionStatus</a>

# Shared Response Types

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared#IntrospectResponseConnectionStatus">IntrospectResponseConnectionStatus</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared#OperationSupport">OperationSupport</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared#OperationSupportMatrix">OperationSupportMatrix</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/shared#Paging">Paging</a>
Expand All @@ -24,6 +29,12 @@ Methods:

# HRIS

Params Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#IncomeParam">IncomeParam</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#LocationParam">LocationParam</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#MoneyParam">MoneyParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#Income">Income</a>
Expand Down Expand Up @@ -198,3 +209,96 @@ Response Types:
Methods:

- <code title="get /jobs/manual/{job_id}">client.Jobs.Manual.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#JobManualService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, jobID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#ManualAsyncJob">ManualAsyncJob</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Auth

Methods:

- <code title="post /auth/token">client.Auth.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#AuthService.NewToken">NewToken</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#AuthNewTokenParams">AuthNewTokenParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#CreateAccessTokenResponse">CreateAccessTokenResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Sandbox

## Connections

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionNewResponse">SandboxConnectionNewResponse</a>

Methods:

- <code title="post /sandbox/connections">client.Sandbox.Connections.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionNewParams">SandboxConnectionNewParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionNewResponse">SandboxConnectionNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### Accounts

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountNewResponse">SandboxConnectionAccountNewResponse</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountUpdateResponse">SandboxConnectionAccountUpdateResponse</a>

Methods:

- <code title="post /sandbox/connections/accounts">client.Sandbox.Connections.Accounts.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountNewParams">SandboxConnectionAccountNewParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountNewResponse">SandboxConnectionAccountNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /sandbox/connections/accounts">client.Sandbox.Connections.Accounts.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountUpdateParams">SandboxConnectionAccountUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxConnectionAccountUpdateResponse">SandboxConnectionAccountUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Company

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxCompanyUpdateResponse">SandboxCompanyUpdateResponse</a>

Methods:

- <code title="put /sandbox/company">client.Sandbox.Company.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxCompanyService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxCompanyUpdateParams">SandboxCompanyUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxCompanyUpdateResponse">SandboxCompanyUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Directory

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxDirectoryNewResponse">SandboxDirectoryNewResponse</a>

Methods:

- <code title="post /sandbox/directory">client.Sandbox.Directory.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxDirectoryService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxDirectoryNewParams">SandboxDirectoryNewParams</a>) ([]<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxDirectoryNewResponse">SandboxDirectoryNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Individual

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxIndividualUpdateResponse">SandboxIndividualUpdateResponse</a>

Methods:

- <code title="put /sandbox/individual/{individual_id}">client.Sandbox.Individual.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxIndividualService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, individualID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxIndividualUpdateParams">SandboxIndividualUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxIndividualUpdateResponse">SandboxIndividualUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Employment

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxEmploymentUpdateResponse">SandboxEmploymentUpdateResponse</a>

Methods:

- <code title="put /sandbox/employment/{individual_id}">client.Sandbox.Employment.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxEmploymentService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, individualID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxEmploymentUpdateParams">SandboxEmploymentUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxEmploymentUpdateResponse">SandboxEmploymentUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Payment

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxPaymentNewResponse">SandboxPaymentNewResponse</a>

Methods:

- <code title="post /sandbox/payment">client.Sandbox.Payment.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxPaymentService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxPaymentNewParams">SandboxPaymentNewParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxPaymentNewResponse">SandboxPaymentNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Jobs

### Configuration

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfiguration">SandboxJobConfiguration</a>

Methods:

- <code title="get /sandbox/jobs/configuration">client.Sandbox.Jobs.Configuration.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) ([]<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfiguration">SandboxJobConfiguration</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /sandbox/jobs/configuration">client.Sandbox.Jobs.Configuration.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationUpdateParams">SandboxJobConfigurationUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfiguration">SandboxJobConfiguration</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
49 changes: 49 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// File generated from our OpenAPI spec by Stainless.

package finchgo

import (
"context"
"net/http"

"github.com/Finch-API/finch-api-go/internal/apijson"
"github.com/Finch-API/finch-api-go/internal/param"
"github.com/Finch-API/finch-api-go/internal/requestconfig"
"github.com/Finch-API/finch-api-go/option"
)

// AuthService contains methods and other services that help with interacting with
// the Finch API. Note, unlike clients, this service does not read variables from
// the environment automatically. You should not instantiate this service directly,
// and instead use the [NewAuthService] method instead.
type AuthService struct {
Options []option.RequestOption
}

// NewAuthService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewAuthService(opts ...option.RequestOption) (r *AuthService) {
r = &AuthService{}
r.Options = opts
return
}

// Exchange the authorization code for an access token
func (r *AuthService) NewToken(ctx context.Context, body AuthNewTokenParams, opts ...option.RequestOption) (res *CreateAccessTokenResponse, err error) {
opts = append(r.Options[:], opts...)
path := "auth/token"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}

type AuthNewTokenParams struct {
ClientID param.Field[string] `json:"client_id,required"`
ClientSecret param.Field[string] `json:"client_secret,required"`
Code param.Field[string] `json:"code,required"`
RedirectUri param.Field[string] `json:"redirect_uri,required"`
}

func (r AuthNewTokenParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
Loading

0 comments on commit 3b861cf

Please sign in to comment.