Skip to content

Commit 9fb6bea

Browse files
committed
Revert "chore: init adding version param"
This reverts commit 25fba47.
1 parent 25fba47 commit 9fb6bea

File tree

5 files changed

+35
-302
lines changed

5 files changed

+35
-302
lines changed

packages/sdk/src/client.ts

Lines changed: 14 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export class MoneriumClient {
4949
#env: Environment;
5050

5151
#authorizationHeader?: string;
52-
53-
#version?: string;
5452
/**
5553
* The PKCE code verifier
5654
* @deprecated, use localStorage, will be removed in v3
@@ -93,7 +91,6 @@ export class MoneriumClient {
9391
// No arguments, default to sandbox
9492
if (!envOrOptions) {
9593
this.#env = MONERIUM_CONFIG.environments['sandbox'];
96-
this.#version = 'v2';
9794
return;
9895
}
9996
// String argument
@@ -102,7 +99,6 @@ export class MoneriumClient {
10299
} else {
103100
this.#env =
104101
MONERIUM_CONFIG.environments[envOrOptions.environment || 'sandbox'];
105-
this.#version = envOrOptions?.version || 'v2';
106102

107103
if (!isServer) {
108104
const { clientId, redirectUri } =
@@ -352,42 +348,15 @@ export class MoneriumClient {
352348
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
353349
* @category Accounts
354350
*/
355-
linkAddress(
356-
body: Omit<LinkAddress, 'accounts'> & { profile: string }
357-
): Promise<LinkedAddress>;
358-
/** @deprecated this function should only take one parameter, body with profile id included */
359-
linkAddress(profileId: string, body: LinkAddress): Promise<LinkedAddress>;
360-
361-
linkAddress(
362-
profileIdOrBody:
363-
| string
364-
| (Omit<LinkAddress, 'accounts'> & { profile: string }),
365-
/** @deprecated this function should only take one parameter, body with profile id included */
366-
body?: LinkAddress
367-
): Promise<LinkedAddress> {
368-
if (typeof profileIdOrBody === 'string' && body && this.#version === 'v1') {
369-
body = mapChainIdToChain(body);
370-
if (body?.accounts) {
371-
body.accounts = body?.accounts.map((account) =>
372-
mapChainIdToChain(account)
373-
);
374-
}
351+
linkAddress(profileId: string, body: LinkAddress): Promise<LinkedAddress> {
352+
body = mapChainIdToChain(body);
353+
body.accounts = body.accounts.map((account) => mapChainIdToChain(account));
375354

376-
return this.#api<LinkedAddress>(
377-
'post',
378-
`profiles/${profileIdOrBody}/addresses`,
379-
JSON.stringify(body)
380-
);
381-
} else if (typeof profileIdOrBody === 'object' && this.#version === 'v2') {
382-
profileIdOrBody = mapChainIdToChain(profileIdOrBody);
383-
return this.#api<LinkedAddress>(
384-
'post',
385-
`addresses`,
386-
JSON.stringify(profileIdOrBody)
387-
);
388-
} else {
389-
throw new Error('Invalid arguments');
390-
}
355+
return this.#api(
356+
'post',
357+
`profiles/${profileId}/addresses`,
358+
JSON.stringify(body)
359+
);
391360
}
392361

393362
/**
@@ -428,32 +397,16 @@ export class MoneriumClient {
428397
body?: BodyInit | Record<string, string>,
429398
isFormEncoded?: boolean
430399
): Promise<T> {
431-
const headers: Record<string, string> = {
432-
Authorization: this.#authorizationHeader || '',
433-
'Content-Type': `application/${
434-
isFormEncoded ? 'x-www-form-urlencoded' : 'json'
435-
}`,
436-
};
437-
if (this.#version === 'v2') {
438-
headers['Accept'] = 'application/vnd.monerium.api-v2+json';
439-
}
440-
console.log(
441-
'%c headers',
442-
'color:white; padding: 30px; background-color: darkgreen',
443-
headers
444-
);
445-
446-
console.log(
447-
'%c ${this.#env.api}/${resource}',
448-
'color:white; padding: 30px; background-color: darkgreen',
449-
`${this.#env.api}/${resource}`
450-
);
451-
452400
return rest<T>(
453401
`${this.#env.api}/${resource}`,
454402
method,
455403
isFormEncoded ? urlEncoded(body as Record<string, string>) : body,
456-
headers
404+
{
405+
Authorization: this.#authorizationHeader || '',
406+
'Content-Type': `application/${
407+
isFormEncoded ? 'x-www-form-urlencoded' : 'json'
408+
}`,
409+
}
457410
);
458411
}
459412

packages/sdk/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ export type MoneriumEventListener = (notification: OrderNotification) => void;
473473

474474
export type ClassOptions = {
475475
environment?: ENV;
476-
version?: 'v1' | 'v2';
477476
} & BearerTokenCredentials;
478477

479478
export interface AuthFlowOptions {

packages/sdk/test/client-server-v2.test.ts

Lines changed: 0 additions & 232 deletions
This file was deleted.

packages/sdk/test/client-server.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ process.env.CI !== 'true' &&
4040
client = new MoneriumClient({
4141
clientId: APP_ONE_CREDENTIALS_CLIENT_ID,
4242
clientSecret: APP_ONE_CREDENTIALS_SECRET,
43-
version: 'v1',
4443
});
4544
try {
4645
await client.getAccess();

0 commit comments

Comments
 (0)