-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandboxconnectionaccount.go
203 lines (175 loc) · 9.21 KB
/
sandboxconnectionaccount.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
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"
"github.com/Finch-API/finch-api-go/shared"
)
// SandboxConnectionAccountService 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 [NewSandboxConnectionAccountService] method instead.
type SandboxConnectionAccountService struct {
Options []option.RequestOption
}
// NewSandboxConnectionAccountService 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 NewSandboxConnectionAccountService(opts ...option.RequestOption) (r *SandboxConnectionAccountService) {
r = &SandboxConnectionAccountService{}
r.Options = opts
return
}
// Create a new account for an existing connection (company/provider pair)
func (r *SandboxConnectionAccountService) New(ctx context.Context, body SandboxConnectionAccountNewParams, opts ...option.RequestOption) (res *SandboxConnectionAccountNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "sandbox/connections/accounts"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Update an existing sandbox account. Change the connection status to understand
// how the Finch API responds.
func (r *SandboxConnectionAccountService) Update(ctx context.Context, body SandboxConnectionAccountUpdateParams, opts ...option.RequestOption) (res *SandboxConnectionAccountUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
path := "sandbox/connections/accounts"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
return
}
type SandboxConnectionAccountNewResponse 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 SandboxConnectionAccountNewResponseAuthenticationType `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"`
JSON sandboxConnectionAccountNewResponseJSON `json:"-"`
}
// sandboxConnectionAccountNewResponseJSON contains the JSON metadata for the
// struct [SandboxConnectionAccountNewResponse]
type sandboxConnectionAccountNewResponseJSON struct {
AccessToken apijson.Field
AccountID apijson.Field
AuthenticationType apijson.Field
CompanyID apijson.Field
ConnectionID apijson.Field
Products apijson.Field
ProviderID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *SandboxConnectionAccountNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r sandboxConnectionAccountNewResponseJSON) RawJSON() string {
return r.raw
}
type SandboxConnectionAccountNewResponseAuthenticationType string
const (
SandboxConnectionAccountNewResponseAuthenticationTypeCredential SandboxConnectionAccountNewResponseAuthenticationType = "credential"
SandboxConnectionAccountNewResponseAuthenticationTypeAPIToken SandboxConnectionAccountNewResponseAuthenticationType = "api_token"
SandboxConnectionAccountNewResponseAuthenticationTypeOAuth SandboxConnectionAccountNewResponseAuthenticationType = "oauth"
SandboxConnectionAccountNewResponseAuthenticationTypeAssisted SandboxConnectionAccountNewResponseAuthenticationType = "assisted"
)
func (r SandboxConnectionAccountNewResponseAuthenticationType) IsKnown() bool {
switch r {
case SandboxConnectionAccountNewResponseAuthenticationTypeCredential, SandboxConnectionAccountNewResponseAuthenticationTypeAPIToken, SandboxConnectionAccountNewResponseAuthenticationTypeOAuth, SandboxConnectionAccountNewResponseAuthenticationTypeAssisted:
return true
}
return false
}
type SandboxConnectionAccountUpdateResponse struct {
// [DEPRECATED] Use `connection_id` to associate a connection with an access token
//
// Deprecated: deprecated
AccountID string `json:"account_id,required" format:"uuid"`
AuthenticationType SandboxConnectionAccountUpdateResponseAuthenticationType `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"`
Products []string `json:"products,required"`
// The ID of the provider associated with the `access_token`
ProviderID string `json:"provider_id,required"`
// The ID of the new connection
ConnectionID string `json:"connection_id" format:"uuid"`
JSON sandboxConnectionAccountUpdateResponseJSON `json:"-"`
}
// sandboxConnectionAccountUpdateResponseJSON contains the JSON metadata for the
// struct [SandboxConnectionAccountUpdateResponse]
type sandboxConnectionAccountUpdateResponseJSON struct {
AccountID apijson.Field
AuthenticationType apijson.Field
CompanyID apijson.Field
Products apijson.Field
ProviderID apijson.Field
ConnectionID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *SandboxConnectionAccountUpdateResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r sandboxConnectionAccountUpdateResponseJSON) RawJSON() string {
return r.raw
}
type SandboxConnectionAccountUpdateResponseAuthenticationType string
const (
SandboxConnectionAccountUpdateResponseAuthenticationTypeCredential SandboxConnectionAccountUpdateResponseAuthenticationType = "credential"
SandboxConnectionAccountUpdateResponseAuthenticationTypeAPIToken SandboxConnectionAccountUpdateResponseAuthenticationType = "api_token"
SandboxConnectionAccountUpdateResponseAuthenticationTypeOAuth SandboxConnectionAccountUpdateResponseAuthenticationType = "oauth"
SandboxConnectionAccountUpdateResponseAuthenticationTypeAssisted SandboxConnectionAccountUpdateResponseAuthenticationType = "assisted"
)
func (r SandboxConnectionAccountUpdateResponseAuthenticationType) IsKnown() bool {
switch r {
case SandboxConnectionAccountUpdateResponseAuthenticationTypeCredential, SandboxConnectionAccountUpdateResponseAuthenticationTypeAPIToken, SandboxConnectionAccountUpdateResponseAuthenticationTypeOAuth, SandboxConnectionAccountUpdateResponseAuthenticationTypeAssisted:
return true
}
return false
}
type SandboxConnectionAccountNewParams struct {
CompanyID param.Field[string] `json:"company_id,required" format:"uuid"`
// The provider associated with the `access_token`
ProviderID param.Field[string] `json:"provider_id,required"`
AuthenticationType param.Field[SandboxConnectionAccountNewParamsAuthenticationType] `json:"authentication_type"`
// Optional, defaults to Organization products (`company`, `directory`,
// `employment`, `individual`)
Products param.Field[[]string] `json:"products"`
}
func (r SandboxConnectionAccountNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SandboxConnectionAccountNewParamsAuthenticationType string
const (
SandboxConnectionAccountNewParamsAuthenticationTypeCredential SandboxConnectionAccountNewParamsAuthenticationType = "credential"
SandboxConnectionAccountNewParamsAuthenticationTypeAPIToken SandboxConnectionAccountNewParamsAuthenticationType = "api_token"
SandboxConnectionAccountNewParamsAuthenticationTypeOAuth SandboxConnectionAccountNewParamsAuthenticationType = "oauth"
SandboxConnectionAccountNewParamsAuthenticationTypeAssisted SandboxConnectionAccountNewParamsAuthenticationType = "assisted"
)
func (r SandboxConnectionAccountNewParamsAuthenticationType) IsKnown() bool {
switch r {
case SandboxConnectionAccountNewParamsAuthenticationTypeCredential, SandboxConnectionAccountNewParamsAuthenticationTypeAPIToken, SandboxConnectionAccountNewParamsAuthenticationTypeOAuth, SandboxConnectionAccountNewParamsAuthenticationTypeAssisted:
return true
}
return false
}
type SandboxConnectionAccountUpdateParams struct {
ConnectionStatus param.Field[shared.ConnectionStatusType] `json:"connection_status"`
}
func (r SandboxConnectionAccountUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}