-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsandboxconnection.go
More file actions
135 lines (117 loc) · 5.8 KB
/
sandboxconnection.go
File metadata and controls
135 lines (117 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"slices"
"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"
)
// SandboxConnectionService 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 [NewSandboxConnectionService] method instead.
type SandboxConnectionService struct {
Options []option.RequestOption
Accounts *SandboxConnectionAccountService
}
// NewSandboxConnectionService 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 NewSandboxConnectionService(opts ...option.RequestOption) (r *SandboxConnectionService) {
r = &SandboxConnectionService{}
r.Options = opts
r.Accounts = NewSandboxConnectionAccountService(opts...)
return
}
// Create a new connection (new company/provider pair) with a new account
func (r *SandboxConnectionService) New(ctx context.Context, body SandboxConnectionNewParams, opts ...option.RequestOption) (res *SandboxConnectionNewResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "sandbox/connections"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type SandboxConnectionNewResponse struct {
AccessToken string `json:"access_token,required" format:"uuid"`
// [DEPRECATED] Use `connection_id` to associate a connection with an access token
//
// Deprecated: deprecated
AccountID string `json:"account_id,required" format:"uuid"`
AuthenticationType SandboxConnectionNewResponseAuthenticationType `json:"authentication_type,required"`
// [DEPRECATED] Use `connection_id` to associate a connection with an access token
//
// Deprecated: deprecated
CompanyID string `json:"company_id,required" format:"uuid"`
// The ID of the new connection
ConnectionID string `json:"connection_id,required" format:"uuid"`
Products []string `json:"products,required"`
// The ID of the provider associated with the `access_token`.
ProviderID string `json:"provider_id,required" format:"uuid"`
TokenType string `json:"token_type"`
JSON sandboxConnectionNewResponseJSON `json:"-"`
}
// sandboxConnectionNewResponseJSON contains the JSON metadata for the struct
// [SandboxConnectionNewResponse]
type sandboxConnectionNewResponseJSON struct {
AccessToken apijson.Field
AccountID apijson.Field
AuthenticationType apijson.Field
CompanyID apijson.Field
ConnectionID apijson.Field
Products apijson.Field
ProviderID apijson.Field
TokenType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *SandboxConnectionNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r sandboxConnectionNewResponseJSON) RawJSON() string {
return r.raw
}
type SandboxConnectionNewResponseAuthenticationType string
const (
SandboxConnectionNewResponseAuthenticationTypeCredential SandboxConnectionNewResponseAuthenticationType = "credential"
SandboxConnectionNewResponseAuthenticationTypeAPIToken SandboxConnectionNewResponseAuthenticationType = "api_token"
SandboxConnectionNewResponseAuthenticationTypeOAuth SandboxConnectionNewResponseAuthenticationType = "oauth"
SandboxConnectionNewResponseAuthenticationTypeAssisted SandboxConnectionNewResponseAuthenticationType = "assisted"
)
func (r SandboxConnectionNewResponseAuthenticationType) IsKnown() bool {
switch r {
case SandboxConnectionNewResponseAuthenticationTypeCredential, SandboxConnectionNewResponseAuthenticationTypeAPIToken, SandboxConnectionNewResponseAuthenticationTypeOAuth, SandboxConnectionNewResponseAuthenticationTypeAssisted:
return true
}
return false
}
type SandboxConnectionNewParams struct {
// The provider associated with the connection
ProviderID param.Field[string] `json:"provider_id,required"`
AuthenticationType param.Field[SandboxConnectionNewParamsAuthenticationType] `json:"authentication_type"`
// Optional: the size of the employer to be created with this connection. Defaults
// to 20. Note that if this is higher than 100, historical payroll data will not be
// generated, and instead only one pay period will be created.
EmployeeSize param.Field[int64] `json:"employee_size"`
Products param.Field[[]string] `json:"products"`
}
func (r SandboxConnectionNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SandboxConnectionNewParamsAuthenticationType string
const (
SandboxConnectionNewParamsAuthenticationTypeCredential SandboxConnectionNewParamsAuthenticationType = "credential"
SandboxConnectionNewParamsAuthenticationTypeAPIToken SandboxConnectionNewParamsAuthenticationType = "api_token"
SandboxConnectionNewParamsAuthenticationTypeOAuth SandboxConnectionNewParamsAuthenticationType = "oauth"
SandboxConnectionNewParamsAuthenticationTypeAssisted SandboxConnectionNewParamsAuthenticationType = "assisted"
)
func (r SandboxConnectionNewParamsAuthenticationType) IsKnown() bool {
switch r {
case SandboxConnectionNewParamsAuthenticationTypeCredential, SandboxConnectionNewParamsAuthenticationTypeAPIToken, SandboxConnectionNewParamsAuthenticationTypeOAuth, SandboxConnectionNewParamsAuthenticationTypeAssisted:
return true
}
return false
}