Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,535 changes: 126 additions & 1,409 deletions reference.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,85 +38,75 @@ export class AccountingPeriodsClient {
* pageSize: 1
* })
*/
public async list(
public list(
request: Merge.accounting.AccountingPeriodsListRequest = {},
requestOptions?: AccountingPeriodsClient.RequestOptions,
): Promise<core.Page<Merge.accounting.AccountingPeriod, Merge.accounting.PaginatedAccountingPeriodList>> {
const list = core.HttpResponsePromise.interceptFunction(
async (
request: Merge.accounting.AccountingPeriodsListRequest,
): Promise<core.WithRawResponse<Merge.accounting.PaginatedAccountingPeriodList>> => {
const { cursor, includeDeletedData, includeRemoteData, includeShellData, pageSize } = request;
const _queryParams: Record<string, unknown> = {
cursor,
include_deleted_data: includeDeletedData,
include_remote_data: includeRemoteData,
include_shell_data: includeShellData,
page_size: pageSize,
};
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
_authRequest.headers,
this._options?.headers,
mergeOnlyDefinedHeaders({
"X-Account-Token": requestOptions?.accountToken ?? this._options?.accountToken,
}),
requestOptions?.headers,
);
const _response = await (this._options.fetcher ?? core.fetcher)({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.MergeEnvironment.Production,
"accounting/v1/accounting-periods",
),
method: "GET",
headers: _headers,
queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetchFn: this._options?.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: serializers.accounting.PaginatedAccountingPeriodList.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
throw new errors.MergeError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
return handleNonStatusCodeError(
_response.error,
_response.rawResponse,
"GET",
"/accounting/v1/accounting-periods",
);
},
): core.HttpResponsePromise<Merge.accounting.PaginatedAccountingPeriodList> {
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
}

private async __list(
request: Merge.accounting.AccountingPeriodsListRequest = {},
requestOptions?: AccountingPeriodsClient.RequestOptions,
): Promise<core.WithRawResponse<Merge.accounting.PaginatedAccountingPeriodList>> {
const { cursor, includeDeletedData, includeRemoteData, includeShellData, pageSize } = request;
const _queryParams: Record<string, unknown> = {
cursor,
include_deleted_data: includeDeletedData,
include_remote_data: includeRemoteData,
include_shell_data: includeShellData,
page_size: pageSize,
};
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
_authRequest.headers,
this._options?.headers,
mergeOnlyDefinedHeaders({ "X-Account-Token": requestOptions?.accountToken ?? this._options?.accountToken }),
requestOptions?.headers,
);
const dataWithRawResponse = await list(request).withRawResponse();
return new core.Page<Merge.accounting.AccountingPeriod, Merge.accounting.PaginatedAccountingPeriodList>({
response: dataWithRawResponse.data,
rawResponse: dataWithRawResponse.rawResponse,
hasNextPage: (response) =>
response?.next != null && !(typeof response?.next === "string" && response?.next === ""),
getItems: (response) => response?.results ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.next));
},
const _response = await (this._options.fetcher ?? core.fetcher)({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.MergeEnvironment.Production,
"accounting/v1/accounting-periods",
),
method: "GET",
headers: _headers,
queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetchFn: this._options?.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: serializers.accounting.PaginatedAccountingPeriodList.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
rawResponse: _response.rawResponse,
};
}

if (_response.error.reason === "status-code") {
throw new errors.MergeError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}

return handleNonStatusCodeError(
_response.error,
_response.rawResponse,
"GET",
"/accounting/v1/accounting-periods",
);
}

/**
Expand Down
Loading
Loading