diff --git a/__tests__/any.test.ts b/__tests__/any.test.ts new file mode 100644 index 0000000..4222175 --- /dev/null +++ b/__tests__/any.test.ts @@ -0,0 +1,29 @@ +import { describe, test, expect } from "@jest/globals"; +import { + API, + APIClientConfig, + DirectLoginAuthentication, + Version, + get, + Any, + GetAny, +} from "../src/api"; + +describe("Any", () => { + test("get should be able to get any OBP data.", async () => { + const directLogin: DirectLoginAuthentication = { + username: global.obpUsername, + password: global.obpPassword, + consumerKey: global.obpConsumerKey, + }; + const clientConfig: APIClientConfig = { + baseUri: global.obpBaseUri, + version: global.obpVersion as Version, + authentication: directLogin, + }; + const resourceDocs = await get(clientConfig, Any)(GetAny)( + "/resource-docs/v5.1.0/obp?tags=Account" + ); + expect(resourceDocs).toBeDefined(); + }); +}); diff --git a/examples/any.ts b/examples/any.ts new file mode 100644 index 0000000..7838b8c --- /dev/null +++ b/examples/any.ts @@ -0,0 +1,29 @@ +import { + API, + APIClientConfig, + DirectLoginAuthentication, + Version, + get, + Any, + GetAny, +} from "../src/api"; + +const directLogin: DirectLoginAuthentication = { + username: process.env.OBP_USERNAME, + password: process.env.OBP_PASSWORD, + consumerKey: process.env.OBP_CONSUMER_KEY, +}; +const clientConfig: APIClientConfig = { + baseUri: "https://obp-apisandbox.joinfincubator.com", + version: Version.v510, + authentication: directLogin, +}; + +(async () => { + // Get Resource Docs + console.log( + await get(clientConfig, Any)(GetAny)( + "/resource-docs/v5.1.0/obp?tags=Account" + ) + ); +})(); diff --git a/examples/bank.ts b/examples/bank.ts index fe6454e..7622fc7 100644 --- a/examples/bank.ts +++ b/examples/bank.ts @@ -7,7 +7,7 @@ import { Bank, GetBanks, GetBanksById, -} from "../src/api"; +} from "obp-typescript/src"; const directLogin: DirectLoginAuthentication = { username: process.env.OBP_USERNAME, diff --git a/src/api/account.ts b/src/api/account.ts index 41e104a..f765040 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/any.ts b/src/api/any.ts new file mode 100644 index 0000000..1879d18 --- /dev/null +++ b/src/api/any.ts @@ -0,0 +1,73 @@ +/** + * Open Bank Project - OBP-TypeScript + * Copyright (C) 2011-2023, TESOBE GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Email: contact@tesobe.com + * TESOBE GmbH + * Osloerstrasse 16/17 + * Berlin 13359, Germany + * + * This product includes software developed at + * TESOBE (http://www.tesobe.com/) + */ + +import { + API, + APIRequest, + APIClientConfig, + apiCallWithCustomURIPath, +} from "./client"; + +/** + * Get any data. + * Returns the response of the requested endpoint. + * + * @param config - The APIClientConfig object + * @param methodCall - A higher order function + * @returns A curried function + * + * @see {@link APIClientConfig} + * + * @public + */ +export const GetAny = + ( + config: APIClientConfig, + methodCall: (config: APIClientConfig, path: string) => Promise + ) => + async (path: string) => { + return await methodCall(config, path); + }; + +/** + * Returns an anonymous function for creating or getting Any data. + * + * @param config - The APIClientConfig object + * @param methodCall - A higher order function + * @returns A higher order function + * + * @see {@link APIClientConfig} + * @see {@link APIRequest} + * + * @public + */ +export const Any: APIRequest = { + get: ( + config: APIClientConfig, + methodCall: (config: APIClientConfig, path: string) => Promise + ) => { + return apiCallWithCustomURIPath(config, methodCall); + }, +}; diff --git a/src/api/bank.ts b/src/api/bank.ts index ac02050..fd6e266 100644 --- a/src/api/bank.ts +++ b/src/api/bank.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/client.ts b/src/api/client.ts index 7b6cac1..c2a8d25 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,6 +49,7 @@ export enum API { Customer, KYC, Metadata, + Any, } /** diff --git a/src/api/customer.ts b/src/api/customer.ts index 04fbdde..677549e 100644 --- a/src/api/customer.ts +++ b/src/api/customer.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/index.ts b/src/api/index.ts index 8cd5b7d..ab65a11 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,6 +40,7 @@ export { CreateTransactionRequestAccount, } from "./transaction"; export { User, Current } from "./user"; +export { Any, GetAny } from "./any"; export { API, Version, diff --git a/src/api/kyc.ts b/src/api/kyc.ts index 0acfeb1..03ba32d 100644 --- a/src/api/kyc.ts +++ b/src/api/kyc.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/metadata.ts b/src/api/metadata.ts index b248a13..5988b80 100644 --- a/src/api/metadata.ts +++ b/src/api/metadata.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/transaction.ts b/src/api/transaction.ts index ebed314..b2a2929 100644 --- a/src/api/transaction.ts +++ b/src/api/transaction.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/api/user.ts b/src/api/user.ts index 813bb5e..bbad078 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/index.ts b/src/index.ts index e9f9589..a9a6cbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,6 +40,7 @@ export { CreateTransactionRequestAccount, } from "./api/transaction"; export { User, Current } from "./api/user"; +export { Any, GetAny } from "./api/any"; export { API, Version,