-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider.go
More file actions
157 lines (139 loc) · 6.26 KB
/
provider.go
File metadata and controls
157 lines (139 loc) · 6.26 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// 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/requestconfig"
"github.com/Finch-API/finch-api-go/option"
"github.com/Finch-API/finch-api-go/packages/pagination"
)
// ProviderService 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 [NewProviderService] method instead.
type ProviderService struct {
Options []option.RequestOption
}
// NewProviderService 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 NewProviderService(opts ...option.RequestOption) (r *ProviderService) {
r = &ProviderService{}
r.Options = opts
return
}
// Return details on all available payroll and HR systems.
func (r *ProviderService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[ProviderListResponse], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "providers"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Return details on all available payroll and HR systems.
func (r *ProviderService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ProviderListResponse] {
return pagination.NewSinglePageAutoPager(r.List(ctx, opts...))
}
type ProviderListResponse struct {
// The id of the payroll provider used in Connect.
ID string `json:"id,required"`
// The display name of the payroll provider.
DisplayName string `json:"display_name,required"`
// The list of Finch products supported on this payroll provider.
Products []string `json:"products,required"`
// The authentication methods supported by the provider.
AuthenticationMethods []ProviderListResponseAuthenticationMethod `json:"authentication_methods"`
// `true` if the integration is in a beta state, `false` otherwise
Beta bool `json:"beta"`
// The url to the official icon of the payroll provider.
Icon string `json:"icon"`
// The url to the official logo of the payroll provider.
Logo string `json:"logo"`
// [DEPRECATED] Whether the Finch integration with this provider uses the Assisted
// Connect Flow by default. This field is now deprecated. Please check for a `type`
// of `assisted` in the `authentication_methods` field instead.
//
// Deprecated: deprecated
Manual bool `json:"manual"`
// whether MFA is required for the provider.
MfaRequired bool `json:"mfa_required"`
// The hex code for the primary color of the payroll provider.
PrimaryColor string `json:"primary_color"`
JSON providerListResponseJSON `json:"-"`
}
// providerListResponseJSON contains the JSON metadata for the struct
// [ProviderListResponse]
type providerListResponseJSON struct {
ID apijson.Field
DisplayName apijson.Field
Products apijson.Field
AuthenticationMethods apijson.Field
Beta apijson.Field
Icon apijson.Field
Logo apijson.Field
Manual apijson.Field
MfaRequired apijson.Field
PrimaryColor apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProviderListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r providerListResponseJSON) RawJSON() string {
return r.raw
}
type ProviderListResponseAuthenticationMethod struct {
// The type of authentication method
Type ProviderListResponseAuthenticationMethodsType `json:"type,required"`
// The supported benefit types and their configurations
BenefitsSupport map[string]interface{} `json:"benefits_support"`
// The supported fields for each Finch product
SupportedFields map[string]interface{} `json:"supported_fields"`
JSON providerListResponseAuthenticationMethodJSON `json:"-"`
}
// providerListResponseAuthenticationMethodJSON contains the JSON metadata for the
// struct [ProviderListResponseAuthenticationMethod]
type providerListResponseAuthenticationMethodJSON struct {
Type apijson.Field
BenefitsSupport apijson.Field
SupportedFields apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProviderListResponseAuthenticationMethod) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r providerListResponseAuthenticationMethodJSON) RawJSON() string {
return r.raw
}
// The type of authentication method
type ProviderListResponseAuthenticationMethodsType string
const (
ProviderListResponseAuthenticationMethodsTypeAssisted ProviderListResponseAuthenticationMethodsType = "assisted"
ProviderListResponseAuthenticationMethodsTypeCredential ProviderListResponseAuthenticationMethodsType = "credential"
ProviderListResponseAuthenticationMethodsTypeAPIToken ProviderListResponseAuthenticationMethodsType = "api_token"
ProviderListResponseAuthenticationMethodsTypeAPICredential ProviderListResponseAuthenticationMethodsType = "api_credential"
ProviderListResponseAuthenticationMethodsTypeOAuth ProviderListResponseAuthenticationMethodsType = "oauth"
ProviderListResponseAuthenticationMethodsTypeAPI ProviderListResponseAuthenticationMethodsType = "api"
)
func (r ProviderListResponseAuthenticationMethodsType) IsKnown() bool {
switch r {
case ProviderListResponseAuthenticationMethodsTypeAssisted, ProviderListResponseAuthenticationMethodsTypeCredential, ProviderListResponseAuthenticationMethodsTypeAPIToken, ProviderListResponseAuthenticationMethodsTypeAPICredential, ProviderListResponseAuthenticationMethodsTypeOAuth, ProviderListResponseAuthenticationMethodsTypeAPI:
return true
}
return false
}