Skip to content

Commit 2a582a8

Browse files
Sync SDK with updates to Merge API, fix PermissionRequest object typing (#18)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent e9bcfa4 commit 2a582a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5818
-111
lines changed

accounting/audit_trail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type AuditTrailListRequest struct {
77
Cursor *string `json:"-"`
88
// If included, will only include audit trail events that occurred before this time
99
EndDate *string `json:"-"`
10-
// If included, will only include events with the given event type. Possible values include: `CREATED_REMOTE_PRODUCTION_API_KEY`, `DELETED_REMOTE_PRODUCTION_API_KEY`, `CREATED_TEST_API_KEY`, `DELETED_TEST_API_KEY`, `REGENERATED_PRODUCTION_API_KEY`, `INVITED_USER`, `TWO_FACTOR_AUTH_ENABLED`, `TWO_FACTOR_AUTH_DISABLED`, `DELETED_LINKED_ACCOUNT`, `CREATED_DESTINATION`, `DELETED_DESTINATION`, `CHANGED_SCOPES`, `CHANGED_PERSONAL_INFORMATION`, `CHANGED_ORGANIZATION_SETTINGS`, `ENABLED_INTEGRATION`, `DISABLED_INTEGRATION`, `ENABLED_CATEGORY`, `DISABLED_CATEGORY`, `CHANGED_PASSWORD`, `RESET_PASSWORD`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `CREATED_INTEGRATION_WIDE_FIELD_MAPPING`, `CREATED_LINKED_ACCOUNT_FIELD_MAPPING`, `CHANGED_INTEGRATION_WIDE_FIELD_MAPPING`, `CHANGED_LINKED_ACCOUNT_FIELD_MAPPING`, `DELETED_INTEGRATION_WIDE_FIELD_MAPPING`, `DELETED_LINKED_ACCOUNT_FIELD_MAPPING`
10+
// If included, will only include events with the given event type. Possible values include: `CREATED_REMOTE_PRODUCTION_API_KEY`, `DELETED_REMOTE_PRODUCTION_API_KEY`, `CREATED_TEST_API_KEY`, `DELETED_TEST_API_KEY`, `REGENERATED_PRODUCTION_API_KEY`, `INVITED_USER`, `TWO_FACTOR_AUTH_ENABLED`, `TWO_FACTOR_AUTH_DISABLED`, `DELETED_LINKED_ACCOUNT`, `CREATED_DESTINATION`, `DELETED_DESTINATION`, `CHANGED_DESTINATION`, `CHANGED_SCOPES`, `CHANGED_PERSONAL_INFORMATION`, `CHANGED_ORGANIZATION_SETTINGS`, `ENABLED_INTEGRATION`, `DISABLED_INTEGRATION`, `ENABLED_CATEGORY`, `DISABLED_CATEGORY`, `CHANGED_PASSWORD`, `RESET_PASSWORD`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `CREATED_INTEGRATION_WIDE_FIELD_MAPPING`, `CREATED_LINKED_ACCOUNT_FIELD_MAPPING`, `CHANGED_INTEGRATION_WIDE_FIELD_MAPPING`, `CHANGED_LINKED_ACCOUNT_FIELD_MAPPING`, `DELETED_INTEGRATION_WIDE_FIELD_MAPPING`, `DELETED_LINKED_ACCOUNT_FIELD_MAPPING`
1111
EventType *string `json:"-"`
1212
// Number of results to return per page.
1313
PageSize *int `json:"-"`

accounting/client/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
creditnotes "github.com/merge-api/merge-go-client/accounting/creditnotes"
2020
deleteaccount "github.com/merge-api/merge-go-client/accounting/deleteaccount"
2121
expenses "github.com/merge-api/merge-go-client/accounting/expenses"
22+
fieldmapping "github.com/merge-api/merge-go-client/accounting/fieldmapping"
2223
forceresync "github.com/merge-api/merge-go-client/accounting/forceresync"
2324
generatekey "github.com/merge-api/merge-go-client/accounting/generatekey"
2425
incomestatements "github.com/merge-api/merge-go-client/accounting/incomestatements"
@@ -33,6 +34,7 @@ import (
3334
phonenumbers "github.com/merge-api/merge-go-client/accounting/phonenumbers"
3435
purchaseorders "github.com/merge-api/merge-go-client/accounting/purchaseorders"
3536
regeneratekey "github.com/merge-api/merge-go-client/accounting/regeneratekey"
37+
scopes "github.com/merge-api/merge-go-client/accounting/scopes"
3638
selectivesync "github.com/merge-api/merge-go-client/accounting/selectivesync"
3739
syncstatus "github.com/merge-api/merge-go-client/accounting/syncstatus"
3840
taxrates "github.com/merge-api/merge-go-client/accounting/taxrates"
@@ -63,8 +65,10 @@ type Client struct {
6365
CompanyInfo *companyinfo.Client
6466
Contacts *contacts.Client
6567
CreditNotes *creditnotes.Client
68+
Scopes *scopes.Client
6669
DeleteAccount *deleteaccount.Client
6770
Expenses *expenses.Client
71+
FieldMapping *fieldmapping.Client
6872
GenerateKey *generatekey.Client
6973
IncomeStatements *incomestatements.Client
7074
Invoices *invoices.Client
@@ -111,8 +115,10 @@ func NewClient(opts ...core.ClientOption) *Client {
111115
CompanyInfo: companyinfo.NewClient(opts...),
112116
Contacts: contacts.NewClient(opts...),
113117
CreditNotes: creditnotes.NewClient(opts...),
118+
Scopes: scopes.NewClient(opts...),
114119
DeleteAccount: deleteaccount.NewClient(opts...),
115120
Expenses: expenses.NewClient(opts...),
121+
FieldMapping: fieldmapping.NewClient(opts...),
116122
GenerateKey: generatekey.NewClient(opts...),
117123
IncomeStatements: incomestatements.NewClient(opts...),
118124
Invoices: invoices.NewClient(opts...),

accounting/field_mapping.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package accounting
4+
5+
type CreateFieldMappingRequest struct {
6+
// The name of the target field you want this remote field to map to.
7+
TargetFieldName string `json:"target_field_name"`
8+
// The description of the target field you want this remote field to map to.
9+
TargetFieldDescription string `json:"target_field_description"`
10+
// The field traversal path of the remote field listed when you hit the GET /remote-fields endpoint.
11+
RemoteFieldTraversalPath []interface{} `json:"remote_field_traversal_path,omitempty"`
12+
// The method of the remote endpoint where the remote field is coming from.
13+
RemoteMethod string `json:"remote_method"`
14+
// The path of the remote endpoint where the remote field is coming from.
15+
RemoteUrlPath string `json:"remote_url_path"`
16+
// The name of the Common Model that the remote field corresponds to in a given category.
17+
CommonModelName string `json:"common_model_name"`
18+
}
19+
20+
type PatchedEditFieldMappingRequest struct {
21+
// The field traversal path of the remote field listed when you hit the GET /remote-fields endpoint.
22+
RemoteFieldTraversalPath []interface{} `json:"remote_field_traversal_path,omitempty"`
23+
// The method of the remote endpoint where the remote field is coming from.
24+
RemoteMethod *string `json:"remote_method,omitempty"`
25+
// The path of the remote endpoint where the remote field is coming from.
26+
RemoteUrlPath *string `json:"remote_url_path,omitempty"`
27+
}
28+
29+
type RemoteFieldsRetrieveRequest struct {
30+
// A comma seperated list of Common Model names. If included, will only return Remote Fields for those Common Models.
31+
CommonModels *string `json:"-"`
32+
// If true, will include example values, where available, for remote fields in the 3rd party platform. These examples come from active data from your customers.
33+
IncludeExampleValues *string `json:"-"`
34+
}

accounting/fieldmapping/client.go

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package fieldmapping
4+
5+
import (
6+
context "context"
7+
fmt "fmt"
8+
accounting "github.com/merge-api/merge-go-client/accounting"
9+
core "github.com/merge-api/merge-go-client/core"
10+
http "net/http"
11+
url "net/url"
12+
)
13+
14+
type Client struct {
15+
baseURL string
16+
caller *core.Caller
17+
header http.Header
18+
}
19+
20+
func NewClient(opts ...core.ClientOption) *Client {
21+
options := core.NewClientOptions()
22+
for _, opt := range opts {
23+
opt(options)
24+
}
25+
return &Client{
26+
baseURL: options.BaseURL,
27+
caller: core.NewCaller(options.HTTPClient),
28+
header: options.ToHeader(),
29+
}
30+
}
31+
32+
// Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/overview/).
33+
func (c *Client) FieldMappingsRetrieve(ctx context.Context) (*accounting.FieldMappingApiInstanceResponse, error) {
34+
baseURL := "https://api.merge.dev"
35+
if c.baseURL != "" {
36+
baseURL = c.baseURL
37+
}
38+
endpointURL := baseURL + "/" + "api/accounting/v1/field-mappings"
39+
40+
var response *accounting.FieldMappingApiInstanceResponse
41+
if err := c.caller.Call(
42+
ctx,
43+
&core.CallParams{
44+
URL: endpointURL,
45+
Method: http.MethodGet,
46+
Headers: c.header,
47+
Response: &response,
48+
},
49+
); err != nil {
50+
return nil, err
51+
}
52+
return response, nil
53+
}
54+
55+
// Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
56+
func (c *Client) FieldMappingsCreate(ctx context.Context, request *accounting.CreateFieldMappingRequest) (*accounting.FieldMappingInstanceResponse, error) {
57+
baseURL := "https://api.merge.dev"
58+
if c.baseURL != "" {
59+
baseURL = c.baseURL
60+
}
61+
endpointURL := baseURL + "/" + "api/accounting/v1/field-mappings"
62+
63+
var response *accounting.FieldMappingInstanceResponse
64+
if err := c.caller.Call(
65+
ctx,
66+
&core.CallParams{
67+
URL: endpointURL,
68+
Method: http.MethodPost,
69+
Headers: c.header,
70+
Request: request,
71+
Response: &response,
72+
},
73+
); err != nil {
74+
return nil, err
75+
}
76+
return response, nil
77+
}
78+
79+
// Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
80+
func (c *Client) FieldMappingsDestroy(ctx context.Context, fieldMappingId string) (*accounting.FieldMappingInstanceResponse, error) {
81+
baseURL := "https://api.merge.dev"
82+
if c.baseURL != "" {
83+
baseURL = c.baseURL
84+
}
85+
endpointURL := fmt.Sprintf(baseURL+"/"+"api/accounting/v1/field-mappings/%v", fieldMappingId)
86+
87+
var response *accounting.FieldMappingInstanceResponse
88+
if err := c.caller.Call(
89+
ctx,
90+
&core.CallParams{
91+
URL: endpointURL,
92+
Method: http.MethodDelete,
93+
Headers: c.header,
94+
Response: &response,
95+
},
96+
); err != nil {
97+
return nil, err
98+
}
99+
return response, nil
100+
}
101+
102+
// Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
103+
func (c *Client) FieldMappingsPartialUpdate(ctx context.Context, fieldMappingId string, request *accounting.PatchedEditFieldMappingRequest) (*accounting.FieldMappingInstanceResponse, error) {
104+
baseURL := "https://api.merge.dev"
105+
if c.baseURL != "" {
106+
baseURL = c.baseURL
107+
}
108+
endpointURL := fmt.Sprintf(baseURL+"/"+"api/accounting/v1/field-mappings/%v", fieldMappingId)
109+
110+
var response *accounting.FieldMappingInstanceResponse
111+
if err := c.caller.Call(
112+
ctx,
113+
&core.CallParams{
114+
URL: endpointURL,
115+
Method: http.MethodPatch,
116+
Headers: c.header,
117+
Request: request,
118+
Response: &response,
119+
},
120+
); err != nil {
121+
return nil, err
122+
}
123+
return response, nil
124+
}
125+
126+
// Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/overview/).
127+
func (c *Client) RemoteFieldsRetrieve(ctx context.Context, request *accounting.RemoteFieldsRetrieveRequest) (*accounting.RemoteFieldApiResponse, error) {
128+
baseURL := "https://api.merge.dev"
129+
if c.baseURL != "" {
130+
baseURL = c.baseURL
131+
}
132+
endpointURL := baseURL + "/" + "api/accounting/v1/remote-fields"
133+
134+
queryParams := make(url.Values)
135+
if request.CommonModels != nil {
136+
queryParams.Add("common_models", fmt.Sprintf("%v", *request.CommonModels))
137+
}
138+
if request.IncludeExampleValues != nil {
139+
queryParams.Add("include_example_values", fmt.Sprintf("%v", *request.IncludeExampleValues))
140+
}
141+
if len(queryParams) > 0 {
142+
endpointURL += "?" + queryParams.Encode()
143+
}
144+
145+
var response *accounting.RemoteFieldApiResponse
146+
if err := c.caller.Call(
147+
ctx,
148+
&core.CallParams{
149+
URL: endpointURL,
150+
Method: http.MethodGet,
151+
Headers: c.header,
152+
Response: &response,
153+
},
154+
); err != nil {
155+
return nil, err
156+
}
157+
return response, nil
158+
}
159+
160+
// Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/target-fields/).
161+
func (c *Client) TargetFieldsRetrieve(ctx context.Context) (*accounting.ExternalTargetFieldApiResponse, error) {
162+
baseURL := "https://api.merge.dev"
163+
if c.baseURL != "" {
164+
baseURL = c.baseURL
165+
}
166+
endpointURL := baseURL + "/" + "api/accounting/v1/target-fields"
167+
168+
var response *accounting.ExternalTargetFieldApiResponse
169+
if err := c.caller.Call(
170+
ctx,
171+
&core.CallParams{
172+
URL: endpointURL,
173+
Method: http.MethodGet,
174+
Headers: c.header,
175+
Response: &response,
176+
},
177+
); err != nil {
178+
return nil, err
179+
}
180+
return response, nil
181+
}

accounting/forceresync/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewClient(opts ...core.ClientOption) *Client {
2727
}
2828
}
2929

30-
// Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Core, Professional, or Enterprise plans. Doing so will consume a sync credit for the relevant linked account.
30+
// Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Launch, Professional, or Enterprise plans. Doing so will consume a sync credit for the relevant linked account.
3131
func (c *Client) SyncStatusResyncCreate(ctx context.Context) ([]*accounting.SyncStatus, error) {
3232
baseURL := "https://api.merge.dev"
3333
if c.baseURL != "" {

accounting/issues.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type IssuesListRequest struct {
1818
FirstIncidentTimeAfter *time.Time `json:"-"`
1919
// If provided, will only return issues whose first incident time was before this datetime.
2020
FirstIncidentTimeBefore *time.Time `json:"-"`
21-
// If True, will include muted issues
21+
// If true, will include muted issues
2222
IncludeMuted *string `json:"-"`
2323
IntegrationName *string `json:"-"`
2424
// If provided, will only return issues whose last incident time was after this datetime.

accounting/link_token.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ type EndUserDetailsRequest struct {
1919
ShouldCreateMagicLinkUrl *bool `json:"should_create_magic_link_url,omitempty"`
2020
// An array of objects to specify the models and fields that will be disabled for a given Linked Account. Each object uses model_id, enabled_actions, and disabled_fields to specify the model, method, and fields that are scoped for a given Linked Account.
2121
CommonModels []*CommonModelScopesBodyRequest `json:"common_models,omitempty"`
22+
// When creating a Link Token, you can set permissions for Common Models that will apply to the account that is going to be linked. Any model or field not specified in link token payload will default to existing settings.
23+
CategoryCommonModelScopes map[string][]*IndividualCommonModelScopeDeserializerRequest `json:"category_common_model_scopes,omitempty"`
2224
}

accounting/scopes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package accounting
4+
5+
type LinkedAccountCommonModelScopeDeserializerRequest struct {
6+
// The common models you want to update the scopes for
7+
CommonModels []*IndividualCommonModelScopeDeserializerRequest `json:"common_models,omitempty"`
8+
}

accounting/scopes/client.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package scopes
4+
5+
import (
6+
context "context"
7+
accounting "github.com/merge-api/merge-go-client/accounting"
8+
core "github.com/merge-api/merge-go-client/core"
9+
http "net/http"
10+
)
11+
12+
type Client struct {
13+
baseURL string
14+
caller *core.Caller
15+
header http.Header
16+
}
17+
18+
func NewClient(opts ...core.ClientOption) *Client {
19+
options := core.NewClientOptions()
20+
for _, opt := range opts {
21+
opt(options)
22+
}
23+
return &Client{
24+
baseURL: options.BaseURL,
25+
caller: core.NewCaller(options.HTTPClient),
26+
header: options.ToHeader(),
27+
}
28+
}
29+
30+
// Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. [Learn More](https://help.merge.dev/en/articles/8828211-common-model-and-field-scopes).
31+
func (c *Client) DefaultScopesRetrieve(ctx context.Context) (*accounting.CommonModelScopeApi, error) {
32+
baseURL := "https://api.merge.dev"
33+
if c.baseURL != "" {
34+
baseURL = c.baseURL
35+
}
36+
endpointURL := baseURL + "/" + "api/accounting/v1/default-scopes"
37+
38+
var response *accounting.CommonModelScopeApi
39+
if err := c.caller.Call(
40+
ctx,
41+
&core.CallParams{
42+
URL: endpointURL,
43+
Method: http.MethodGet,
44+
Headers: c.header,
45+
Response: &response,
46+
},
47+
); err != nil {
48+
return nil, err
49+
}
50+
return response, nil
51+
}
52+
53+
// Get all available permissions for Merge Common Models and fields for a single Linked Account. [Learn More](https://help.merge.dev/en/articles/8828211-common-model-and-field-scopes).
54+
func (c *Client) LinkedAccountScopesRetrieve(ctx context.Context) (*accounting.CommonModelScopeApi, error) {
55+
baseURL := "https://api.merge.dev"
56+
if c.baseURL != "" {
57+
baseURL = c.baseURL
58+
}
59+
endpointURL := baseURL + "/" + "api/accounting/v1/linked-account-scopes"
60+
61+
var response *accounting.CommonModelScopeApi
62+
if err := c.caller.Call(
63+
ctx,
64+
&core.CallParams{
65+
URL: endpointURL,
66+
Method: http.MethodGet,
67+
Headers: c.header,
68+
Response: &response,
69+
},
70+
); err != nil {
71+
return nil, err
72+
}
73+
return response, nil
74+
}
75+
76+
// Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. [Learn More](https://help.merge.dev/en/articles/8828211-common-model-and-field-scopes)
77+
func (c *Client) LinkedAccountScopesCreate(ctx context.Context, request *accounting.LinkedAccountCommonModelScopeDeserializerRequest) (*accounting.CommonModelScopeApi, error) {
78+
baseURL := "https://api.merge.dev"
79+
if c.baseURL != "" {
80+
baseURL = c.baseURL
81+
}
82+
endpointURL := baseURL + "/" + "api/accounting/v1/linked-account-scopes"
83+
84+
var response *accounting.CommonModelScopeApi
85+
if err := c.caller.Call(
86+
ctx,
87+
&core.CallParams{
88+
URL: endpointURL,
89+
Method: http.MethodPost,
90+
Headers: c.header,
91+
Request: request,
92+
Response: &response,
93+
},
94+
); err != nil {
95+
return nil, err
96+
}
97+
return response, nil
98+
}

0 commit comments

Comments
 (0)