From b510a8f4be95d54eaa89027b130ef2a964eb8099 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Feb 2026 05:19:22 +0000 Subject: [PATCH 1/5] fix createMembership --- docs/examples/teams/create-membership.md | 4 +-- docs/examples/teams/update-membership.md | 4 +-- src/client.ts | 35 +++++++++++++++++++--- src/enums/roles.ts | 5 ---- src/index.ts | 1 - src/services/account.ts | 22 +++++++------- src/services/avatars.ts | 6 ++-- src/services/graphql.ts | 4 +-- src/services/teams.ts | 37 ++++++++++++------------ 9 files changed, 69 insertions(+), 49 deletions(-) delete mode 100644 src/enums/roles.ts diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 41c726c7..824c129c 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams, Roles } from "react-native-appwrite"; +import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.createMembership({ teamId: '', - roles: [Roles.Admin], + roles: [], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index a5109fcb..0f00f5ee 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams, Roles } from "react-native-appwrite"; +import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.updateMembership({ teamId: '', membershipId: '', - roles: [Roles.Admin] + roles: [] }); console.log(result); diff --git a/src/client.ts b/src/client.ts index a1c6632f..343f3856 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { Models } from './models'; import { Service } from './service'; import { Platform } from 'react-native'; +import { Query } from './query'; import JSONbigModule from 'json-bigint'; import BigNumber from 'bignumber.js'; const JSONbigParser = JSONbigModule({ storeAsString: false }); @@ -90,8 +91,10 @@ type Realtime = { url?: string; lastMessage?: RealtimeResponse; channels: Set; + queries: Set; subscriptions: Map) => void }>; subscriptionsCounter: number; @@ -101,7 +104,7 @@ type Realtime = { connect: () => void; createSocket: () => void; createHeartbeat: () => void; - cleanUp: (channels: string[]) => void; + cleanUp: (channels: string[], queries: string[]) => void; onMessage: (event: MessageEvent) => void; } @@ -284,6 +287,7 @@ class Client { heartbeat: undefined, url: '', channels: new Set(), + queries: new Set(), subscriptions: new Map(), subscriptionsCounter: 0, reconnect: true, @@ -330,6 +334,9 @@ class Client { this.realtime.channels.forEach(channel => { channels.append('channels[]', channel); }); + this.realtime.queries.forEach(query => { + channels.append('queries[]', query); + }); const url = this.config.endpointRealtime + '/realtime?' + channels.toString(); @@ -408,7 +415,7 @@ class Client { console.error(e); } }, - cleanUp: channels => { + cleanUp: (channels, queries) => { this.realtime.channels.forEach(channel => { if (channels.includes(channel)) { let found = Array.from(this.realtime.subscriptions).some(([_key, subscription] )=> { @@ -420,6 +427,18 @@ class Client { } } }) + + this.realtime.queries.forEach(query => { + if (queries.includes(query)) { + let found = Array.from(this.realtime.subscriptions).some(([_key, subscription]) => { + return subscription.queries?.includes(query); + }) + + if (!found) { + this.realtime.queries.delete(query); + } + } + }) } } @@ -448,13 +467,21 @@ class Client { * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update. * @returns {() => void} Unsubscribes from events. */ - subscribe(channels: string | string[], callback: (payload: RealtimeResponseEvent) => void): () => void { + subscribe( + channels: string | string[], + callback: (payload: RealtimeResponseEvent) => void, + queries: (string | Query)[] = [] + ): () => void { let channelArray = typeof channels === 'string' ? [channels] : channels; channelArray.forEach(channel => this.realtime.channels.add(channel)); + const queryStrings = (queries ?? []).map(q => typeof q === 'string' ? q : q.toString()); + queryStrings.forEach(query => this.realtime.queries.add(query)); + const counter = this.realtime.subscriptionsCounter++; this.realtime.subscriptions.set(counter, { channels: channelArray, + queries: queryStrings, callback }); @@ -462,7 +489,7 @@ class Client { return () => { this.realtime.subscriptions.delete(counter); - this.realtime.cleanUp(channelArray); + this.realtime.cleanUp(channelArray, queryStrings); this.realtime.connect(); } } diff --git a/src/enums/roles.ts b/src/enums/roles.ts deleted file mode 100644 index f548f935..00000000 --- a/src/enums/roles.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Roles { - Admin = 'admin', - Developer = 'developer', - Owner = 'owner', -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 50baa582..f6d51fd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,6 +29,5 @@ export { BrowserPermission } from './enums/browser-permission'; export { ImageFormat } from './enums/image-format'; export { ExecutionMethod } from './enums/execution-method'; export { ImageGravity } from './enums/image-gravity'; -export { Roles } from './enums/roles'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; diff --git a/src/services/account.ts b/src/services/account.ts index cee6e8b5..6025e72c 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -447,7 +447,7 @@ export class Account extends Service { ): Promise { let params: { type: AuthenticatorType }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { @@ -492,7 +492,7 @@ export class Account extends Service { ): Promise { let params: { type: AuthenticatorType }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { @@ -541,7 +541,7 @@ export class Account extends Service { ): Promise> { let params: { type: AuthenticatorType, otp: string }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; } else { params = { @@ -599,7 +599,7 @@ export class Account extends Service { ): Promise> { let params: { type: AuthenticatorType, otp: string }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; } else { params = { @@ -655,7 +655,7 @@ export class Account extends Service { ): Promise<{}> { let params: { type: AuthenticatorType }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { @@ -700,7 +700,7 @@ export class Account extends Service { ): Promise<{}> { let params: { type: AuthenticatorType }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { @@ -746,7 +746,7 @@ export class Account extends Service { ): Promise { let params: { factor: AuthenticationFactor }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { @@ -795,7 +795,7 @@ export class Account extends Service { ): Promise { let params: { factor: AuthenticationFactor }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { @@ -1281,7 +1281,7 @@ export class Account extends Service { ): Promise> { let params: { prefs: Partial }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { prefs: Partial }; } else { params = { @@ -1663,7 +1663,7 @@ export class Account extends Service { ): void | URL { let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; } else { params = { @@ -2353,7 +2353,7 @@ export class Account extends Service { ): void | URL { let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; } else { params = { diff --git a/src/services/avatars.ts b/src/services/avatars.ts index e7f475ce..e216f092 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -53,7 +53,7 @@ export class Avatars extends Service { ): Promise { let params: { code: Browser, width?: number, height?: number, quality?: number }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number }; } else { params = { @@ -134,7 +134,7 @@ export class Avatars extends Service { ): Promise { let params: { code: CreditCard, width?: number, height?: number, quality?: number }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number }; } else { params = { @@ -273,7 +273,7 @@ export class Avatars extends Service { ): Promise { let params: { code: Flag, width?: number, height?: number, quality?: number }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number }; } else { params = { diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 4d67b695..1c3bdba7 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -35,7 +35,7 @@ export class Graphql extends Service { ): Promise<{}> { let params: { query: object }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { @@ -85,7 +85,7 @@ export class Graphql extends Service { ): Promise<{}> { let params: { query: object }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) { + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { diff --git a/src/services/teams.ts b/src/services/teams.ts index 19a462b6..ae8c4ea4 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -5,7 +5,6 @@ import type { UploadProgress, Payload } from '../client'; import * as FileSystem from 'expo-file-system'; import { Platform } from 'react-native'; -import { Roles } from '../enums/roles'; export class Teams extends Service { @@ -372,7 +371,7 @@ export class Teams extends Service { * * * @param {string} params.teamId - Team ID. - * @param {Roles[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param {string} params.email - Email of the new team member. * @param {string} params.userId - ID of the user to be added to a team. * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -381,7 +380,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - createMembership(params: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; + createMembership(params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. * @@ -393,7 +392,7 @@ export class Teams extends Service { * * * @param {string} teamId - Team ID. - * @param {Roles[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param {string} email - Email of the new team member. * @param {string} userId - ID of the user to be added to a team. * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -403,19 +402,19 @@ export class Teams extends Service { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; + createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; createMembership( - paramsOrFirst: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string, - ...rest: [(Roles[])?, (string)?, (string)?, (string)?, (string)?, (string)?] + paramsOrFirst: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string, + ...rest: [(string[])?, (string)?, (string)?, (string)?, (string)?, (string)?] ): Promise { - let params: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + let params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + params = (paramsOrFirst || {}) as { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; } else { params = { teamId: paramsOrFirst as string, - roles: rest[0] as Roles[], + roles: rest[0] as string[], email: rest[1] as string, userId: rest[2] as string, phone: rest[3] as string, @@ -532,36 +531,36 @@ export class Teams extends Service { * * @param {string} params.teamId - Team ID. * @param {string} params.membershipId - Membership ID. - * @param {Roles[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @throws {AppwriteException} * @returns {Promise} */ - updateMembership(params: { teamId: string, membershipId: string, roles: Roles[] }): Promise; + updateMembership(params: { teamId: string, membershipId: string, roles: string[] }): Promise; /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). * * * @param {string} teamId - Team ID. * @param {string} membershipId - Membership ID. - * @param {Roles[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(teamId: string, membershipId: string, roles: Roles[]): Promise; + updateMembership(teamId: string, membershipId: string, roles: string[]): Promise; updateMembership( - paramsOrFirst: { teamId: string, membershipId: string, roles: Roles[] } | string, - ...rest: [(string)?, (Roles[])?] + paramsOrFirst: { teamId: string, membershipId: string, roles: string[] } | string, + ...rest: [(string)?, (string[])?] ): Promise { - let params: { teamId: string, membershipId: string, roles: Roles[] }; + let params: { teamId: string, membershipId: string, roles: string[] }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: Roles[] }; + params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: string[] }; } else { params = { teamId: paramsOrFirst as string, membershipId: rest[0] as string, - roles: rest[1] as Roles[] + roles: rest[1] as string[] }; } From bd8f71e1c80ec545ba262e29f4dfef914cdb95cf Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Feb 2026 05:45:00 +0000 Subject: [PATCH 2/5] changeog --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/client.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 737ef947..d111ee5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log +## 0.21.0 + +* Add `queries` parameter to `client.subscribe()` for filtering Realtime events +* Fix `Roles` enum removed from Teams service; `roles` parameter now accepts `string[]` +* Fix parameter detection in overloaded methods to check for optional params (Account, Avatars, Graphql) + ## 0.20.0 * Add array-based enum parameters (e.g., `permissions: BrowserPermission[]`). diff --git a/package.json b/package.json index f82bf3b5..ab9b6cc1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "0.20.0", + "version": "0.21.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 343f3856..387d35e3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -145,7 +145,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.20.0', + 'x-sdk-version': '0.21.0', 'X-Appwrite-Response-Format': '1.8.0', }; From e402a3eb5ebd00c454ce8f8320d5b63961e5f55b Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 08:05:18 +0000 Subject: [PATCH 3/5] updated spec --- README.md | 2 +- .../account/create-billing-address.md | 20 + docs/examples/account/create-key.md | 17 + .../examples/account/create-payment-method.md | 13 + .../account/delete-billing-address.md | 15 + docs/examples/account/delete-key.md | 15 + .../examples/account/delete-payment-method.md | 15 + docs/examples/account/get-billing-address.md | 15 + docs/examples/account/get-key.md | 15 + docs/examples/account/get-payment-method.md | 15 + .../account/list-billing-addresses.md | 15 + docs/examples/account/list-keys.md | 15 + docs/examples/account/list-payment-methods.md | 15 + .../account/update-billing-address.md | 21 + docs/examples/account/update-key.md | 18 + .../update-payment-method-mandate-options.md | 15 + .../account/update-payment-method-provider.md | 18 + .../examples/account/update-payment-method.md | 18 + .../create-downgrade-feedback.md | 19 + docs/examples/organizations/delete.md | 15 + .../estimation-delete-organization.md | 15 + .../organizations/get-billing-address.md | 16 + .../organizations/get-payment-method.md | 16 + src/channel.ts | 16 +- src/enums/o-auth-provider.ts | 2 + src/enums/scopes.ts | 5 + src/index.ts | 2 + src/models.ts | 388 +++++++ src/services/account.ts | 1029 ++++++++++++++++- src/services/organizations.ts | 307 +++++ 30 files changed, 2067 insertions(+), 40 deletions(-) create mode 100644 docs/examples/account/create-billing-address.md create mode 100644 docs/examples/account/create-key.md create mode 100644 docs/examples/account/create-payment-method.md create mode 100644 docs/examples/account/delete-billing-address.md create mode 100644 docs/examples/account/delete-key.md create mode 100644 docs/examples/account/delete-payment-method.md create mode 100644 docs/examples/account/get-billing-address.md create mode 100644 docs/examples/account/get-key.md create mode 100644 docs/examples/account/get-payment-method.md create mode 100644 docs/examples/account/list-billing-addresses.md create mode 100644 docs/examples/account/list-keys.md create mode 100644 docs/examples/account/list-payment-methods.md create mode 100644 docs/examples/account/update-billing-address.md create mode 100644 docs/examples/account/update-key.md create mode 100644 docs/examples/account/update-payment-method-mandate-options.md create mode 100644 docs/examples/account/update-payment-method-provider.md create mode 100644 docs/examples/account/update-payment-method.md create mode 100644 docs/examples/organizations/create-downgrade-feedback.md create mode 100644 docs/examples/organizations/delete.md create mode 100644 docs/examples/organizations/estimation-delete-organization.md create mode 100644 docs/examples/organizations/get-billing-address.md create mode 100644 docs/examples/organizations/get-payment-method.md create mode 100644 src/enums/scopes.ts create mode 100644 src/services/organizations.ts diff --git a/README.md b/README.md index ee5c4eb5..5452c01f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/examples/account/create-billing-address.md b/docs/examples/account/create-billing-address.md new file mode 100644 index 00000000..450ddb64 --- /dev/null +++ b/docs/examples/account/create-billing-address.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createBillingAddress({ + country: '', + city: '', + streetAddress: '', + addressLine2: '', // optional + state: '', // optional + postalCode: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md new file mode 100644 index 00000000..abc1e4b6 --- /dev/null +++ b/docs/examples/account/create-key.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Account, Scopes } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createKey({ + name: '', + scopes: [Scopes.Account], + expire: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md new file mode 100644 index 00000000..023ea356 --- /dev/null +++ b/docs/examples/account/create-payment-method.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createPaymentMethod(); + +console.log(result); +``` diff --git a/docs/examples/account/delete-billing-address.md b/docs/examples/account/delete-billing-address.md new file mode 100644 index 00000000..650929e5 --- /dev/null +++ b/docs/examples/account/delete-billing-address.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.deleteBillingAddress({ + billingAddressId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md new file mode 100644 index 00000000..d8207ef4 --- /dev/null +++ b/docs/examples/account/delete-key.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.deleteKey({ + keyId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md new file mode 100644 index 00000000..1aff0a48 --- /dev/null +++ b/docs/examples/account/delete-payment-method.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.deletePaymentMethod({ + paymentMethodId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/get-billing-address.md b/docs/examples/account/get-billing-address.md new file mode 100644 index 00000000..70d1c292 --- /dev/null +++ b/docs/examples/account/get-billing-address.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.getBillingAddress({ + billingAddressId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md new file mode 100644 index 00000000..3faa25da --- /dev/null +++ b/docs/examples/account/get-key.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.getKey({ + keyId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md new file mode 100644 index 00000000..d77c67c9 --- /dev/null +++ b/docs/examples/account/get-payment-method.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.getPaymentMethod({ + paymentMethodId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/list-billing-addresses.md b/docs/examples/account/list-billing-addresses.md new file mode 100644 index 00000000..a3be8640 --- /dev/null +++ b/docs/examples/account/list-billing-addresses.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.listBillingAddresses({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md new file mode 100644 index 00000000..93760ea7 --- /dev/null +++ b/docs/examples/account/list-keys.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.listKeys({ + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md new file mode 100644 index 00000000..e68025b7 --- /dev/null +++ b/docs/examples/account/list-payment-methods.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.listPaymentMethods({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-billing-address.md b/docs/examples/account/update-billing-address.md new file mode 100644 index 00000000..69725196 --- /dev/null +++ b/docs/examples/account/update-billing-address.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updateBillingAddress({ + billingAddressId: '', + country: '', + city: '', + streetAddress: '', + addressLine2: '', // optional + state: '', // optional + postalCode: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md new file mode 100644 index 00000000..e3ee6fb4 --- /dev/null +++ b/docs/examples/account/update-key.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Account, Scopes } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updateKey({ + keyId: '', + name: '', + scopes: [Scopes.Account], + expire: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md new file mode 100644 index 00000000..586db083 --- /dev/null +++ b/docs/examples/account/update-payment-method-mandate-options.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePaymentMethodMandateOptions({ + paymentMethodId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md new file mode 100644 index 00000000..008e6e2e --- /dev/null +++ b/docs/examples/account/update-payment-method-provider.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePaymentMethodProvider({ + paymentMethodId: '', + providerMethodId: '', + name: '', + state: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md new file mode 100644 index 00000000..8530c84d --- /dev/null +++ b/docs/examples/account/update-payment-method.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePaymentMethod({ + paymentMethodId: '', + expiryMonth: 1, + expiryYear: 2026, + state: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/create-downgrade-feedback.md b/docs/examples/organizations/create-downgrade-feedback.md new file mode 100644 index 00000000..19772320 --- /dev/null +++ b/docs/examples/organizations/create-downgrade-feedback.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Organizations } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organizations = new Organizations(client); + +const result = await organizations.createDowngradeFeedback({ + organizationId: '', + reason: '', + message: '', + fromPlanId: '', + toPlanId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 00000000..8fa38518 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Organizations } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organizations = new Organizations(client); + +const result = await organizations.delete({ + organizationId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 00000000..b43e70dd --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Organizations } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organizations = new Organizations(client); + +const result = await organizations.estimationDeleteOrganization({ + organizationId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/get-billing-address.md b/docs/examples/organizations/get-billing-address.md new file mode 100644 index 00000000..d36dfce3 --- /dev/null +++ b/docs/examples/organizations/get-billing-address.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Organizations } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organizations = new Organizations(client); + +const result = await organizations.getBillingAddress({ + organizationId: '', + billingAddressId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/get-payment-method.md b/docs/examples/organizations/get-payment-method.md new file mode 100644 index 00000000..81bf26ba --- /dev/null +++ b/docs/examples/organizations/get-payment-method.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Organizations } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organizations = new Organizations(client); + +const result = await organizations.getPaymentMethod({ + organizationId: '', + paymentMethodId: '' +}); + +console.log(result); +``` diff --git a/src/channel.ts b/src/channel.ts index 1d68ded7..9e5dc479 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -13,7 +13,7 @@ interface Team { _team: any } interface Membership { _mem: any } interface Resolved { _res: any } -type Actionable = Document | Row | File | Execution | Team | Membership; +type Actionable = Document | Row | File | Team | Membership; function normalize(id: string): string { const trimmed = id.trim(); @@ -62,11 +62,6 @@ export class Channel { return this.next("files", id); } - // --- FUNCTION ROUTE --- - execution(this: Channel, id: string = "*"): Channel { - return this.next("executions", id); - } - // --- TERMINAL ACTIONS --- // Restricted to the Actionable union create(this: Channel): Channel { @@ -98,6 +93,10 @@ export class Channel { return new Channel(["functions", normalize(id)]); } + static execution(id: string = "*") { + return new Channel(["executions", normalize(id)]); + } + static team(id: string = "*") { return new Channel(["teams", normalize(id)]); } @@ -106,9 +105,8 @@ export class Channel { return new Channel(["memberships", normalize(id)]); } - static account(userId: string = ""): string { - const id = normalize(userId); - return id === "*" ? "account" : `account.${id}`; + static account(): string { + return "account"; } // Global events diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 3382e3bf..66833dfe 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -38,4 +38,6 @@ export enum OAuthProvider { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', + GithubImagine = 'githubImagine', + GoogleImagine = 'googleImagine', } \ No newline at end of file diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts new file mode 100644 index 00000000..a30e13ea --- /dev/null +++ b/src/enums/scopes.ts @@ -0,0 +1,5 @@ +export enum Scopes { + Account = 'account', + TeamsRead = 'teams.read', + TeamsWrite = 'teams.write', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index f6d51fd5..b88230c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Organizations } from './services/organizations'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; @@ -17,6 +18,7 @@ export { Role } from './role'; export { ID } from './id'; export { Channel } from './channel'; export { Operator, Condition } from './operator'; +export { Scopes } from './enums/scopes'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; export { OAuthProvider } from './enums/o-auth-provider'; diff --git a/src/models.ts b/src/models.ts index cbe1e894..0dc45f8f 100644 --- a/src/models.ts +++ b/src/models.ts @@ -131,6 +131,20 @@ export namespace Models { executions: Execution[]; } + /** + * API Keys List + */ + export type KeyList = { + /** + * Total number of keys that matched your query. + */ + total: number; + /** + * List of keys. + */ + keys: Key[]; + } + /** * Countries List */ @@ -1080,6 +1094,48 @@ export namespace Models { scheduledAt?: string; } + /** + * Key + */ + export type Key = { + /** + * Key ID. + */ + $id: string; + /** + * Key creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Key update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Key name. + */ + name: string; + /** + * Key expiration date in ISO 8601 format. + */ + expire: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; + /** + * Secret key. + */ + secret: string; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * List of SDK user agents that used this key. + */ + sdks: string[]; + } + /** * Country */ @@ -1373,4 +1429,336 @@ export namespace Models { */ expired: boolean; } + + /** + * BillingAddress + */ + export type BillingAddress = { + /** + * Region ID + */ + $id: string; + /** + * User ID + */ + userId: string; + /** + * Street address + */ + streetAddress: string; + /** + * Address line 2 + */ + addressLine2: string; + /** + * Address country + */ + country: string; + /** + * city + */ + city: string; + /** + * state + */ + state: string; + /** + * postal code + */ + postalCode: string; + } + + /** + * Downgrade Feedback + */ + export type DowngradeFeedback = { + /** + * Feedback ID. + */ + $id: string; + /** + * Feedback creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Feedback update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Feedback reason + */ + title: string; + /** + * Feedback message + */ + message: string; + /** + * Plan ID downgrading from + */ + fromPlanId: string; + /** + * Plan ID downgrading to + */ + toPlanId: string; + /** + * Organization ID + */ + teamId: string; + /** + * User ID who submitted feedback + */ + userId: string; + /** + * Console version + */ + version: string; + } + + /** + * Invoice + */ + export type Invoice = { + /** + * Invoice ID. + */ + $id: string; + /** + * Invoice creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Invoice update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Invoice permissions. [Learn more about permissions](/docs/permissions). + */ + $permissions: string[]; + /** + * Project ID + */ + teamId: string; + /** + * Aggregation ID + */ + aggregationId: string; + /** + * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. + */ + plan: string; + /** + * Usage breakdown per resource + */ + usage: UsageResources[]; + /** + * Invoice Amount + */ + amount: number; + /** + * Tax percentage + */ + tax: number; + /** + * Tax amount + */ + taxAmount: number; + /** + * VAT percentage + */ + vat: number; + /** + * VAT amount + */ + vatAmount: number; + /** + * Gross amount after vat, tax, and discounts applied. + */ + grossAmount: number; + /** + * Credits used. + */ + creditsUsed: number; + /** + * Currency the invoice is in + */ + currency: string; + /** + * Client secret for processing failed payments in front-end + */ + clientSecret: string; + /** + * Invoice status + */ + status: string; + /** + * Last payment error associated with the invoice + */ + lastError: string; + /** + * Invoice due date. + */ + dueAt: string; + /** + * Beginning date of the invoice + */ + from: string; + /** + * End date of the invoice + */ + to: string; + } + + /** + * paymentMethod + */ + export type PaymentMethod = { + /** + * Payment Method ID. + */ + $id: string; + /** + * Payment method creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Payment method update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Payment method permissions. [Learn more about permissions](/docs/permissions). + */ + $permissions: string[]; + /** + * Payment method ID from the payment provider + */ + providerMethodId: string; + /** + * Client secret hash for payment setup + */ + clientSecret: string; + /** + * User ID from the payment provider. + */ + providerUserId: string; + /** + * ID of the Team. + */ + userId: string; + /** + * Expiry month of the payment method. + */ + expiryMonth: number; + /** + * Expiry year of the payment method. + */ + expiryYear: number; + /** + * Last 4 digit of the payment method + */ + last4: string; + /** + * Payment method brand + */ + brand: string; + /** + * Name of the owner + */ + name: string; + /** + * Mandate ID of the payment method + */ + mandateId: string; + /** + * Country of the payment method + */ + country: string; + /** + * State of the payment method + */ + state: string; + /** + * Last payment error associated with the payment method. + */ + lastError: string; + /** + * True when it's the default payment method. + */ + default: boolean; + /** + * True when payment method has expired. + */ + expired: boolean; + /** + * True when payment method has failed to process multiple times. + */ + failed: boolean; + } + + /** + * UsageResource + */ + export type UsageResources = { + /** + * Invoice name + */ + name: string; + /** + * Invoice value + */ + value: number; + /** + * Invoice amount + */ + amount: number; + /** + * Invoice rate + */ + rate: number; + /** + * Invoice description + */ + desc: string; + /** + * Resource ID + */ + resourceId: string; + } + + /** + * EstimationDeleteOrganization + */ + export type EstimationDeleteOrganization = { + /** + * List of unpaid invoices + */ + unpaidInvoices: Invoice[]; + } + + /** + * Billing address list + */ + export type BillingAddressList = { + /** + * Total number of billingAddresses that matched your query. + */ + total: number; + /** + * List of billingAddresses. + */ + billingAddresses: BillingAddress[]; + } + + /** + * Payment methods list + */ + export type PaymentMethodList = { + /** + * Total number of paymentMethods that matched your query. + */ + total: number; + /** + * List of paymentMethods. + */ + paymentMethods: PaymentMethod[]; + } } diff --git a/src/services/account.ts b/src/services/account.ts index 6025e72c..48ef520f 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -5,6 +5,7 @@ import type { UploadProgress, Payload } from '../client'; import * as FileSystem from 'expo-file-system'; import { Platform } from 'react-native'; +import { Scopes } from '../enums/scopes'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; @@ -113,6 +114,343 @@ export class Account extends Service { }, payload); } + /** + * List all billing addresses for a user. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed + * @throws {AppwriteException} + * @returns {Promise} + */ + listBillingAddresses(params?: { queries?: string[] }): Promise; + /** + * List all billing addresses for a user. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBillingAddresses(queries?: string[]): Promise; + listBillingAddresses( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + const apiPath = '/account/billing-addresses'; + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Add a new billing address to a user's account. + * + * @param {string} params.country - Country + * @param {string} params.city - City + * @param {string} params.streetAddress - Street address + * @param {string} params.addressLine2 - Address line 2 + * @param {string} params.state - State or province + * @param {string} params.postalCode - Postal code + * @throws {AppwriteException} + * @returns {Promise} + */ + createBillingAddress(params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; + /** + * Add a new billing address to a user's account. + * + * @param {string} country - Country + * @param {string} city - City + * @param {string} streetAddress - Street address + * @param {string} addressLine2 - Address line 2 + * @param {string} state - State or province + * @param {string} postalCode - Postal code + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBillingAddress(country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; + createBillingAddress( + paramsOrFirst: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + } else { + params = { + country: paramsOrFirst as string, + city: rest[0] as string, + streetAddress: rest[1] as string, + addressLine2: rest[2] as string, + state: rest[3] as string, + postalCode: rest[4] as string + }; + } + + const country = params.country; + const city = params.city; + const streetAddress = params.streetAddress; + const addressLine2 = params.addressLine2; + const state = params.state; + const postalCode = params.postalCode; + + if (typeof country === 'undefined') { + throw new AppwriteException('Missing required parameter: "country"'); + } + + if (typeof city === 'undefined') { + throw new AppwriteException('Missing required parameter: "city"'); + } + + if (typeof streetAddress === 'undefined') { + throw new AppwriteException('Missing required parameter: "streetAddress"'); + } + + const apiPath = '/account/billing-addresses'; + const payload: Payload = {}; + + if (typeof country !== 'undefined') { + payload['country'] = country; + } + + if (typeof city !== 'undefined') { + payload['city'] = city; + } + + if (typeof streetAddress !== 'undefined') { + payload['streetAddress'] = streetAddress; + } + + if (typeof addressLine2 !== 'undefined') { + payload['addressLine2'] = addressLine2; + } + + if (typeof state !== 'undefined') { + payload['state'] = state; + } + + if (typeof postalCode !== 'undefined') { + payload['postalCode'] = postalCode; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a specific billing address for a user using it's ID. + * + * @param {string} params.billingAddressId - Unique ID of billing address + * @throws {AppwriteException} + * @returns {Promise} + */ + getBillingAddress(params: { billingAddressId: string }): Promise; + /** + * Get a specific billing address for a user using it's ID. + * + * @param {string} billingAddressId - Unique ID of billing address + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBillingAddress(billingAddressId: string): Promise; + getBillingAddress( + paramsOrFirst: { billingAddressId: string } | string + ): Promise { + let params: { billingAddressId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { billingAddressId: string }; + } else { + params = { + billingAddressId: paramsOrFirst as string + }; + } + + const billingAddressId = params.billingAddressId; + + if (typeof billingAddressId === 'undefined') { + throw new AppwriteException('Missing required parameter: "billingAddressId"'); + } + + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Update a specific billing address using it's ID. + * + * @param {string} params.billingAddressId - Unique ID of billing address + * @param {string} params.country - Country + * @param {string} params.city - City + * @param {string} params.streetAddress - Street address + * @param {string} params.addressLine2 - Address line 2 + * @param {string} params.state - State or province + * @param {string} params.postalCode - Postal code + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBillingAddress(params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; + /** + * Update a specific billing address using it's ID. + * + * @param {string} billingAddressId - Unique ID of billing address + * @param {string} country - Country + * @param {string} city - City + * @param {string} streetAddress - Street address + * @param {string} addressLine2 - Address line 2 + * @param {string} state - State or province + * @param {string} postalCode - Postal code + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBillingAddress(billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; + updateBillingAddress( + paramsOrFirst: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + } else { + params = { + billingAddressId: paramsOrFirst as string, + country: rest[0] as string, + city: rest[1] as string, + streetAddress: rest[2] as string, + addressLine2: rest[3] as string, + state: rest[4] as string, + postalCode: rest[5] as string + }; + } + + const billingAddressId = params.billingAddressId; + const country = params.country; + const city = params.city; + const streetAddress = params.streetAddress; + const addressLine2 = params.addressLine2; + const state = params.state; + const postalCode = params.postalCode; + + if (typeof billingAddressId === 'undefined') { + throw new AppwriteException('Missing required parameter: "billingAddressId"'); + } + + if (typeof country === 'undefined') { + throw new AppwriteException('Missing required parameter: "country"'); + } + + if (typeof city === 'undefined') { + throw new AppwriteException('Missing required parameter: "city"'); + } + + if (typeof streetAddress === 'undefined') { + throw new AppwriteException('Missing required parameter: "streetAddress"'); + } + + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); + const payload: Payload = {}; + + if (typeof country !== 'undefined') { + payload['country'] = country; + } + + if (typeof city !== 'undefined') { + payload['city'] = city; + } + + if (typeof streetAddress !== 'undefined') { + payload['streetAddress'] = streetAddress; + } + + if (typeof addressLine2 !== 'undefined') { + payload['addressLine2'] = addressLine2; + } + + if (typeof state !== 'undefined') { + payload['state'] = state; + } + + if (typeof postalCode !== 'undefined') { + payload['postalCode'] = postalCode; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Delete a specific billing address using it's ID. + * + * @param {string} params.billingAddressId - Billing address unique ID + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteBillingAddress(params: { billingAddressId: string }): Promise<{}>; + /** + * Delete a specific billing address using it's ID. + * + * @param {string} billingAddressId - Billing address unique ID + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBillingAddress(billingAddressId: string): Promise<{}>; + deleteBillingAddress( + paramsOrFirst: { billingAddressId: string } | string + ): Promise<{}> { + let params: { billingAddressId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { billingAddressId: string }; + } else { + params = { + billingAddressId: paramsOrFirst as string + }; + } + + const billingAddressId = params.billingAddressId; + + if (typeof billingAddressId === 'undefined') { + throw new AppwriteException('Missing required parameter: "billingAddressId"'); + } + + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. @@ -262,62 +600,343 @@ export class Account extends Service { }; } - const identityId = params.identityId; + const identityId = params.identityId; + + if (typeof identityId === 'undefined') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + + const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * + * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createJWT(params?: { duration?: number }): Promise; + /** + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * + * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createJWT(duration?: number): Promise; + createJWT( + paramsOrFirst?: { duration?: number } | number + ): Promise { + let params: { duration?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { duration?: number }; + } else { + params = { + duration: paramsOrFirst as number + }; + } + + const duration = params.duration; + + const apiPath = '/account/jwts'; + const payload: Payload = {}; + + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a list of all API keys from the current account. + * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listKeys(params?: { total?: boolean }): Promise; + /** + * Get a list of all API keys from the current account. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listKeys(total?: boolean): Promise; + listKeys( + paramsOrFirst?: { total?: boolean } | boolean + ): Promise { + let params: { total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean + }; + } + + const total = params.total; + + const apiPath = '/account/keys'; + const payload: Payload = {}; + + if (typeof total !== 'undefined') { + payload['total'] = total; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Create a new account API key. + * + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + createKey(params: { name: string, scopes: Scopes[], expire?: string }): Promise; + /** + * Create a new account API key. + * + * @param {string} name - Key name. Max length: 128 chars. + * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createKey(name: string, scopes: Scopes[], expire?: string): Promise; + createKey( + paramsOrFirst: { name: string, scopes: Scopes[], expire?: string } | string, + ...rest: [(Scopes[])?, (string)?] + ): Promise { + let params: { name: string, scopes: Scopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name: string, scopes: Scopes[], expire?: string }; + } else { + params = { + name: paramsOrFirst as string, + scopes: rest[0] as Scopes[], + expire: rest[1] as string + }; + } + + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + + const apiPath = '/account/keys'; + const payload: Payload = {}; + + if (typeof name !== 'undefined') { + payload['name'] = name; + } + + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a key by its unique ID. This endpoint returns details about a specific API key in your account including it's scopes. + * + * @param {string} params.keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getKey(params: { keyId: string }): Promise; + /** + * Get a key by its unique ID. This endpoint returns details about a specific API key in your account including it's scopes. + * + * @param {string} keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getKey(keyId: string): Promise; + getKey( + paramsOrFirst: { keyId: string } | string + ): Promise { + let params: { keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; + } else { + params = { + keyId: paramsOrFirst as string + }; + } + + const keyId = params.keyId; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} params.keyId - Key unique ID. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} keyId - Key unique ID. + * @param {string} name - Key name. Max length: 128 chars. + * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateKey(keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; + updateKey( + paramsOrFirst: { keyId: string, name: string, scopes: Scopes[], expire?: string } | string, + ...rest: [(string)?, (Scopes[])?, (string)?] + ): Promise { + let params: { keyId: string, name: string, scopes: Scopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: Scopes[], expire?: string }; + } else { + params = { + keyId: paramsOrFirst as string, + name: rest[0] as string, + scopes: rest[1] as Scopes[], + expire: rest[2] as string + }; + } + + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } - if (typeof identityId === 'undefined') { - throw new AppwriteException('Missing required parameter: "identityId"'); + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); } - const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId); + const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. * - * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @param {string} params.keyId - Key unique ID. * @throws {AppwriteException} * @returns {Promise} */ - createJWT(params?: { duration?: number }): Promise; + deleteKey(params: { keyId: string }): Promise<{}>; /** - * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. * - * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @param {string} keyId - Key unique ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - createJWT(duration?: number): Promise; - createJWT( - paramsOrFirst?: { duration?: number } | number - ): Promise { - let params: { duration?: number }; + deleteKey(keyId: string): Promise<{}>; + deleteKey( + paramsOrFirst: { keyId: string } | string + ): Promise<{}> { + let params: { keyId: string }; - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { duration?: number }; + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - duration: paramsOrFirst as number + keyId: paramsOrFirst as string }; } - const duration = params.duration; - - const apiPath = '/account/jwts'; - const payload: Payload = {}; + const keyId = params.keyId; - if (typeof duration !== 'undefined') { - payload['duration'] = duration; + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); } + const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } @@ -1182,6 +1801,356 @@ export class Account extends Service { }, payload); } + /** + * List payment methods for this account. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed + * @throws {AppwriteException} + * @returns {Promise} + */ + listPaymentMethods(params?: { queries?: string[] }): Promise; + /** + * List payment methods for this account. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPaymentMethods(queries?: string[]): Promise; + listPaymentMethods( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + const apiPath = '/account/payment-methods'; + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Create a new payment method for the current user account. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createPaymentMethod(): Promise { + const apiPath = '/account/payment-methods'; + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a specific payment method for the user. + * + * @param {string} params.paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + */ + getPaymentMethod(params: { paymentMethodId: string }): Promise; + /** + * Get a specific payment method for the user. + * + * @param {string} paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPaymentMethod(paymentMethodId: string): Promise; + getPaymentMethod( + paramsOrFirst: { paymentMethodId: string } | string + ): Promise { + let params: { paymentMethodId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { paymentMethodId: string }; + } else { + params = { + paymentMethodId: paramsOrFirst as string + }; + } + + const paymentMethodId = params.paymentMethodId; + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Update a new payment method for the current user account. + * + * @param {string} params.paymentMethodId - Unique ID of payment method + * @param {number} params.expiryMonth - Payment expiry month + * @param {number} params.expiryYear - Expiry year + * @param {string} params.state - State of the payment method country + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePaymentMethod(params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }): Promise; + /** + * Update a new payment method for the current user account. + * + * @param {string} paymentMethodId - Unique ID of payment method + * @param {number} expiryMonth - Payment expiry month + * @param {number} expiryYear - Expiry year + * @param {string} state - State of the payment method country + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePaymentMethod(paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string): Promise; + updatePaymentMethod( + paramsOrFirst: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string } | string, + ...rest: [(number)?, (number)?, (string)?] + ): Promise { + let params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; + } else { + params = { + paymentMethodId: paramsOrFirst as string, + expiryMonth: rest[0] as number, + expiryYear: rest[1] as number, + state: rest[2] as string + }; + } + + const paymentMethodId = params.paymentMethodId; + const expiryMonth = params.expiryMonth; + const expiryYear = params.expiryYear; + const state = params.state; + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + if (typeof expiryMonth === 'undefined') { + throw new AppwriteException('Missing required parameter: "expiryMonth"'); + } + + if (typeof expiryYear === 'undefined') { + throw new AppwriteException('Missing required parameter: "expiryYear"'); + } + + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + if (typeof expiryMonth !== 'undefined') { + payload['expiryMonth'] = expiryMonth; + } + + if (typeof expiryYear !== 'undefined') { + payload['expiryYear'] = expiryYear; + } + + if (typeof state !== 'undefined') { + payload['state'] = state; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Delete a specific payment method from a user's account. + * + * @param {string} params.paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + */ + deletePaymentMethod(params: { paymentMethodId: string }): Promise<{}>; + /** + * Delete a specific payment method from a user's account. + * + * @param {string} paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePaymentMethod(paymentMethodId: string): Promise<{}>; + deletePaymentMethod( + paramsOrFirst: { paymentMethodId: string } | string + ): Promise<{}> { + let params: { paymentMethodId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { paymentMethodId: string }; + } else { + params = { + paymentMethodId: paramsOrFirst as string + }; + } + + const paymentMethodId = params.paymentMethodId; + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Update payment method provider. + * + * @param {string} params.paymentMethodId - Unique ID of payment method + * @param {string} params.providerMethodId - Payment method ID from the payment provider + * @param {string} params.name - Name in the payment method + * @param {string} params.state - State of the payment method country + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePaymentMethodProvider(params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }): Promise; + /** + * Update payment method provider. + * + * @param {string} paymentMethodId - Unique ID of payment method + * @param {string} providerMethodId - Payment method ID from the payment provider + * @param {string} name - Name in the payment method + * @param {string} state - State of the payment method country + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePaymentMethodProvider(paymentMethodId: string, providerMethodId: string, name: string, state?: string): Promise; + updatePaymentMethodProvider( + paramsOrFirst: { paymentMethodId: string, providerMethodId: string, name: string, state?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise { + let params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; + } else { + params = { + paymentMethodId: paramsOrFirst as string, + providerMethodId: rest[0] as string, + name: rest[1] as string, + state: rest[2] as string + }; + } + + const paymentMethodId = params.paymentMethodId; + const providerMethodId = params.providerMethodId; + const name = params.name; + const state = params.state; + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + if (typeof providerMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerMethodId"'); + } + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/account/payment-methods/{paymentMethodId}/provider'.replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + if (typeof providerMethodId !== 'undefined') { + payload['providerMethodId'] = providerMethodId; + } + + if (typeof name !== 'undefined') { + payload['name'] = name; + } + + if (typeof state !== 'undefined') { + payload['state'] = state; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Update payment method mandate options. + * + * @param {string} params.paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePaymentMethodMandateOptions(params: { paymentMethodId: string }): Promise; + /** + * Update payment method mandate options. + * + * @param {string} paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePaymentMethodMandateOptions(paymentMethodId: string): Promise; + updatePaymentMethodMandateOptions( + paramsOrFirst: { paymentMethodId: string } | string + ): Promise { + let params: { paymentMethodId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { paymentMethodId: string }; + } else { + params = { + paymentMethodId: paramsOrFirst as string + }; + } + + const paymentMethodId = params.paymentMethodId; + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + const apiPath = '/account/payment-methods/{paymentMethodId}/setup'.replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * @@ -1632,7 +2601,7 @@ export class Account extends Service { * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1648,7 +2617,7 @@ export class Account extends Service { * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -2323,7 +3292,7 @@ export class Account extends Service { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -2338,7 +3307,7 @@ export class Account extends Service { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. diff --git a/src/services/organizations.ts b/src/services/organizations.ts new file mode 100644 index 00000000..82a7af54 --- /dev/null +++ b/src/services/organizations.ts @@ -0,0 +1,307 @@ +import { Service } from '../service'; +import { AppwriteException, Client } from '../client'; +import type { Models } from '../models'; +import type { UploadProgress, Payload } from '../client'; +import * as FileSystem from 'expo-file-system'; +import { Platform } from 'react-native'; + + +export class Organizations extends Service { + + constructor(client: Client) + { + super(client); + } + + /** + * Delete an organization. + * + * @param {string} params.organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + delete(params: { organizationId: string }): Promise<{}>; + /** + * Delete an organization. + * + * @param {string} organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(organizationId: string): Promise<{}>; + delete( + paramsOrFirst: { organizationId: string } | string + ): Promise<{}> { + let params: { organizationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string }; + } else { + params = { + organizationId: paramsOrFirst as string + }; + } + + const organizationId = params.organizationId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + const apiPath = '/organizations/{organizationId}'.replace('{organizationId}', organizationId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a billing address using it's ID. + * + * @param {string} params.organizationId - Organization ID + * @param {string} params.billingAddressId - Unique ID of billing address + * @throws {AppwriteException} + * @returns {Promise} + */ + getBillingAddress(params: { organizationId: string, billingAddressId: string }): Promise; + /** + * Get a billing address using it's ID. + * + * @param {string} organizationId - Organization ID + * @param {string} billingAddressId - Unique ID of billing address + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBillingAddress(organizationId: string, billingAddressId: string): Promise; + getBillingAddress( + paramsOrFirst: { organizationId: string, billingAddressId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { organizationId: string, billingAddressId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string, billingAddressId: string }; + } else { + params = { + organizationId: paramsOrFirst as string, + billingAddressId: rest[0] as string + }; + } + + const organizationId = params.organizationId; + const billingAddressId = params.billingAddressId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + if (typeof billingAddressId === 'undefined') { + throw new AppwriteException('Missing required parameter: "billingAddressId"'); + } + + const apiPath = '/organizations/{organizationId}/billing-addresses/{billingAddressId}'.replace('{organizationId}', organizationId).replace('{billingAddressId}', billingAddressId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Get estimation for deleting an organization. + * + * @param {string} params.organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + estimationDeleteOrganization(params: { organizationId: string }): Promise; + /** + * Get estimation for deleting an organization. + * + * @param {string} organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + estimationDeleteOrganization(organizationId: string): Promise; + estimationDeleteOrganization( + paramsOrFirst: { organizationId: string } | string + ): Promise { + let params: { organizationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string }; + } else { + params = { + organizationId: paramsOrFirst as string + }; + } + + const organizationId = params.organizationId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + const apiPath = '/organizations/{organizationId}/estimations/delete-organization'.replace('{organizationId}', organizationId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. + * + * + * @param {string} params.organizationId - Organization Unique ID + * @param {string} params.reason - Feedback reason + * @param {string} params.message - Feedback message + * @param {string} params.fromPlanId - Plan downgrading from + * @param {string} params.toPlanId - Plan downgrading to + * @throws {AppwriteException} + * @returns {Promise} + */ + createDowngradeFeedback(params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }): Promise; + /** + * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. + * + * + * @param {string} organizationId - Organization Unique ID + * @param {string} reason - Feedback reason + * @param {string} message - Feedback message + * @param {string} fromPlanId - Plan downgrading from + * @param {string} toPlanId - Plan downgrading to + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDowngradeFeedback(organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string): Promise; + createDowngradeFeedback( + paramsOrFirst: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; + } else { + params = { + organizationId: paramsOrFirst as string, + reason: rest[0] as string, + message: rest[1] as string, + fromPlanId: rest[2] as string, + toPlanId: rest[3] as string + }; + } + + const organizationId = params.organizationId; + const reason = params.reason; + const message = params.message; + const fromPlanId = params.fromPlanId; + const toPlanId = params.toPlanId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + if (typeof reason === 'undefined') { + throw new AppwriteException('Missing required parameter: "reason"'); + } + + if (typeof message === 'undefined') { + throw new AppwriteException('Missing required parameter: "message"'); + } + + if (typeof fromPlanId === 'undefined') { + throw new AppwriteException('Missing required parameter: "fromPlanId"'); + } + + if (typeof toPlanId === 'undefined') { + throw new AppwriteException('Missing required parameter: "toPlanId"'); + } + + const apiPath = '/organizations/{organizationId}/feedbacks/downgrade'.replace('{organizationId}', organizationId); + const payload: Payload = {}; + + if (typeof reason !== 'undefined') { + payload['reason'] = reason; + } + + if (typeof message !== 'undefined') { + payload['message'] = message; + } + + if (typeof fromPlanId !== 'undefined') { + payload['fromPlanId'] = fromPlanId; + } + + if (typeof toPlanId !== 'undefined') { + payload['toPlanId'] = toPlanId; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get an organization's payment method using it's payment method ID. + * + * @param {string} params.organizationId - Organization ID + * @param {string} params.paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + */ + getPaymentMethod(params: { organizationId: string, paymentMethodId: string }): Promise; + /** + * Get an organization's payment method using it's payment method ID. + * + * @param {string} organizationId - Organization ID + * @param {string} paymentMethodId - Unique ID of payment method + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPaymentMethod(organizationId: string, paymentMethodId: string): Promise; + getPaymentMethod( + paramsOrFirst: { organizationId: string, paymentMethodId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { organizationId: string, paymentMethodId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string, paymentMethodId: string }; + } else { + params = { + organizationId: paramsOrFirst as string, + paymentMethodId: rest[0] as string + }; + } + + const organizationId = params.organizationId; + const paymentMethodId = params.paymentMethodId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + if (typeof paymentMethodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + } + + const apiPath = '/organizations/{organizationId}/payment-methods/{paymentMethodId}'.replace('{organizationId}', organizationId).replace('{paymentMethodId}', paymentMethodId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } +}; From acd4cf113c897e265a72103542f409f2c526a40b Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 08:40:02 +0000 Subject: [PATCH 4/5] updated --- .../account/create-billing-address.md | 20 -- .../account/delete-billing-address.md | 15 - docs/examples/account/get-billing-address.md | 15 - .../account/list-billing-addresses.md | 15 - .../account/update-billing-address.md | 21 -- .../create-downgrade-feedback.md | 19 - docs/examples/organizations/delete.md | 15 - .../estimation-delete-organization.md | 15 - .../organizations/get-billing-address.md | 16 - .../organizations/get-payment-method.md | 16 - src/index.ts | 1 - src/models.ts | 232 ------------ src/services/account.ts | 337 ------------------ src/services/organizations.ts | 307 ---------------- 14 files changed, 1044 deletions(-) delete mode 100644 docs/examples/account/create-billing-address.md delete mode 100644 docs/examples/account/delete-billing-address.md delete mode 100644 docs/examples/account/get-billing-address.md delete mode 100644 docs/examples/account/list-billing-addresses.md delete mode 100644 docs/examples/account/update-billing-address.md delete mode 100644 docs/examples/organizations/create-downgrade-feedback.md delete mode 100644 docs/examples/organizations/delete.md delete mode 100644 docs/examples/organizations/estimation-delete-organization.md delete mode 100644 docs/examples/organizations/get-billing-address.md delete mode 100644 docs/examples/organizations/get-payment-method.md delete mode 100644 src/services/organizations.ts diff --git a/docs/examples/account/create-billing-address.md b/docs/examples/account/create-billing-address.md deleted file mode 100644 index 450ddb64..00000000 --- a/docs/examples/account/create-billing-address.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.createBillingAddress({ - country: '', - city: '', - streetAddress: '', - addressLine2: '', // optional - state: '', // optional - postalCode: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/delete-billing-address.md b/docs/examples/account/delete-billing-address.md deleted file mode 100644 index 650929e5..00000000 --- a/docs/examples/account/delete-billing-address.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.deleteBillingAddress({ - billingAddressId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/get-billing-address.md b/docs/examples/account/get-billing-address.md deleted file mode 100644 index 70d1c292..00000000 --- a/docs/examples/account/get-billing-address.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.getBillingAddress({ - billingAddressId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/list-billing-addresses.md b/docs/examples/account/list-billing-addresses.md deleted file mode 100644 index a3be8640..00000000 --- a/docs/examples/account/list-billing-addresses.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.listBillingAddresses({ - queries: [] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/update-billing-address.md b/docs/examples/account/update-billing-address.md deleted file mode 100644 index 69725196..00000000 --- a/docs/examples/account/update-billing-address.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.updateBillingAddress({ - billingAddressId: '', - country: '', - city: '', - streetAddress: '', - addressLine2: '', // optional - state: '', // optional - postalCode: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/create-downgrade-feedback.md b/docs/examples/organizations/create-downgrade-feedback.md deleted file mode 100644 index 19772320..00000000 --- a/docs/examples/organizations/create-downgrade-feedback.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -import { Client, Organizations } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.createDowngradeFeedback({ - organizationId: '', - reason: '', - message: '', - fromPlanId: '', - toPlanId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md deleted file mode 100644 index 8fa38518..00000000 --- a/docs/examples/organizations/delete.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Organizations } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.delete({ - organizationId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md deleted file mode 100644 index b43e70dd..00000000 --- a/docs/examples/organizations/estimation-delete-organization.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Organizations } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.estimationDeleteOrganization({ - organizationId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/get-billing-address.md b/docs/examples/organizations/get-billing-address.md deleted file mode 100644 index d36dfce3..00000000 --- a/docs/examples/organizations/get-billing-address.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -import { Client, Organizations } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.getBillingAddress({ - organizationId: '', - billingAddressId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/get-payment-method.md b/docs/examples/organizations/get-payment-method.md deleted file mode 100644 index 81bf26ba..00000000 --- a/docs/examples/organizations/get-payment-method.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -import { Client, Organizations } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.getPaymentMethod({ - organizationId: '', - paymentMethodId: '' -}); - -console.log(result); -``` diff --git a/src/index.ts b/src/index.ts index b88230c1..0c7fc288 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,6 @@ export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; -export { Organizations } from './services/organizations'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; diff --git a/src/models.ts b/src/models.ts index 0dc45f8f..98d2086e 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1430,184 +1430,6 @@ export namespace Models { expired: boolean; } - /** - * BillingAddress - */ - export type BillingAddress = { - /** - * Region ID - */ - $id: string; - /** - * User ID - */ - userId: string; - /** - * Street address - */ - streetAddress: string; - /** - * Address line 2 - */ - addressLine2: string; - /** - * Address country - */ - country: string; - /** - * city - */ - city: string; - /** - * state - */ - state: string; - /** - * postal code - */ - postalCode: string; - } - - /** - * Downgrade Feedback - */ - export type DowngradeFeedback = { - /** - * Feedback ID. - */ - $id: string; - /** - * Feedback creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Feedback update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Feedback reason - */ - title: string; - /** - * Feedback message - */ - message: string; - /** - * Plan ID downgrading from - */ - fromPlanId: string; - /** - * Plan ID downgrading to - */ - toPlanId: string; - /** - * Organization ID - */ - teamId: string; - /** - * User ID who submitted feedback - */ - userId: string; - /** - * Console version - */ - version: string; - } - - /** - * Invoice - */ - export type Invoice = { - /** - * Invoice ID. - */ - $id: string; - /** - * Invoice creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * Invoice update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Invoice permissions. [Learn more about permissions](/docs/permissions). - */ - $permissions: string[]; - /** - * Project ID - */ - teamId: string; - /** - * Aggregation ID - */ - aggregationId: string; - /** - * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. - */ - plan: string; - /** - * Usage breakdown per resource - */ - usage: UsageResources[]; - /** - * Invoice Amount - */ - amount: number; - /** - * Tax percentage - */ - tax: number; - /** - * Tax amount - */ - taxAmount: number; - /** - * VAT percentage - */ - vat: number; - /** - * VAT amount - */ - vatAmount: number; - /** - * Gross amount after vat, tax, and discounts applied. - */ - grossAmount: number; - /** - * Credits used. - */ - creditsUsed: number; - /** - * Currency the invoice is in - */ - currency: string; - /** - * Client secret for processing failed payments in front-end - */ - clientSecret: string; - /** - * Invoice status - */ - status: string; - /** - * Last payment error associated with the invoice - */ - lastError: string; - /** - * Invoice due date. - */ - dueAt: string; - /** - * Beginning date of the invoice - */ - from: string; - /** - * End date of the invoice - */ - to: string; - } - /** * paymentMethod */ @@ -1694,60 +1516,6 @@ export namespace Models { failed: boolean; } - /** - * UsageResource - */ - export type UsageResources = { - /** - * Invoice name - */ - name: string; - /** - * Invoice value - */ - value: number; - /** - * Invoice amount - */ - amount: number; - /** - * Invoice rate - */ - rate: number; - /** - * Invoice description - */ - desc: string; - /** - * Resource ID - */ - resourceId: string; - } - - /** - * EstimationDeleteOrganization - */ - export type EstimationDeleteOrganization = { - /** - * List of unpaid invoices - */ - unpaidInvoices: Invoice[]; - } - - /** - * Billing address list - */ - export type BillingAddressList = { - /** - * Total number of billingAddresses that matched your query. - */ - total: number; - /** - * List of billingAddresses. - */ - billingAddresses: BillingAddress[]; - } - /** * Payment methods list */ diff --git a/src/services/account.ts b/src/services/account.ts index 48ef520f..722c1fec 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -114,343 +114,6 @@ export class Account extends Service { }, payload); } - /** - * List all billing addresses for a user. - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed - * @throws {AppwriteException} - * @returns {Promise} - */ - listBillingAddresses(params?: { queries?: string[] }): Promise; - /** - * List all billing addresses for a user. - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listBillingAddresses(queries?: string[]): Promise; - listBillingAddresses( - paramsOrFirst?: { queries?: string[] } | string[] - ): Promise { - let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[] }; - } else { - params = { - queries: paramsOrFirst as string[] - }; - } - - const queries = params.queries; - - const apiPath = '/account/billing-addresses'; - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Add a new billing address to a user's account. - * - * @param {string} params.country - Country - * @param {string} params.city - City - * @param {string} params.streetAddress - Street address - * @param {string} params.addressLine2 - Address line 2 - * @param {string} params.state - State or province - * @param {string} params.postalCode - Postal code - * @throws {AppwriteException} - * @returns {Promise} - */ - createBillingAddress(params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; - /** - * Add a new billing address to a user's account. - * - * @param {string} country - Country - * @param {string} city - City - * @param {string} streetAddress - Street address - * @param {string} addressLine2 - Address line 2 - * @param {string} state - State or province - * @param {string} postalCode - Postal code - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createBillingAddress(country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; - createBillingAddress( - paramsOrFirst: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] - ): Promise { - let params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - } else { - params = { - country: paramsOrFirst as string, - city: rest[0] as string, - streetAddress: rest[1] as string, - addressLine2: rest[2] as string, - state: rest[3] as string, - postalCode: rest[4] as string - }; - } - - const country = params.country; - const city = params.city; - const streetAddress = params.streetAddress; - const addressLine2 = params.addressLine2; - const state = params.state; - const postalCode = params.postalCode; - - if (typeof country === 'undefined') { - throw new AppwriteException('Missing required parameter: "country"'); - } - - if (typeof city === 'undefined') { - throw new AppwriteException('Missing required parameter: "city"'); - } - - if (typeof streetAddress === 'undefined') { - throw new AppwriteException('Missing required parameter: "streetAddress"'); - } - - const apiPath = '/account/billing-addresses'; - const payload: Payload = {}; - - if (typeof country !== 'undefined') { - payload['country'] = country; - } - - if (typeof city !== 'undefined') { - payload['city'] = city; - } - - if (typeof streetAddress !== 'undefined') { - payload['streetAddress'] = streetAddress; - } - - if (typeof addressLine2 !== 'undefined') { - payload['addressLine2'] = addressLine2; - } - - if (typeof state !== 'undefined') { - payload['state'] = state; - } - - if (typeof postalCode !== 'undefined') { - payload['postalCode'] = postalCode; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get a specific billing address for a user using it's ID. - * - * @param {string} params.billingAddressId - Unique ID of billing address - * @throws {AppwriteException} - * @returns {Promise} - */ - getBillingAddress(params: { billingAddressId: string }): Promise; - /** - * Get a specific billing address for a user using it's ID. - * - * @param {string} billingAddressId - Unique ID of billing address - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getBillingAddress(billingAddressId: string): Promise; - getBillingAddress( - paramsOrFirst: { billingAddressId: string } | string - ): Promise { - let params: { billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { billingAddressId: string }; - } else { - params = { - billingAddressId: paramsOrFirst as string - }; - } - - const billingAddressId = params.billingAddressId; - - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Update a specific billing address using it's ID. - * - * @param {string} params.billingAddressId - Unique ID of billing address - * @param {string} params.country - Country - * @param {string} params.city - City - * @param {string} params.streetAddress - Street address - * @param {string} params.addressLine2 - Address line 2 - * @param {string} params.state - State or province - * @param {string} params.postalCode - Postal code - * @throws {AppwriteException} - * @returns {Promise} - */ - updateBillingAddress(params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; - /** - * Update a specific billing address using it's ID. - * - * @param {string} billingAddressId - Unique ID of billing address - * @param {string} country - Country - * @param {string} city - City - * @param {string} streetAddress - Street address - * @param {string} addressLine2 - Address line 2 - * @param {string} state - State or province - * @param {string} postalCode - Postal code - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateBillingAddress(billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; - updateBillingAddress( - paramsOrFirst: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] - ): Promise { - let params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - } else { - params = { - billingAddressId: paramsOrFirst as string, - country: rest[0] as string, - city: rest[1] as string, - streetAddress: rest[2] as string, - addressLine2: rest[3] as string, - state: rest[4] as string, - postalCode: rest[5] as string - }; - } - - const billingAddressId = params.billingAddressId; - const country = params.country; - const city = params.city; - const streetAddress = params.streetAddress; - const addressLine2 = params.addressLine2; - const state = params.state; - const postalCode = params.postalCode; - - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - if (typeof country === 'undefined') { - throw new AppwriteException('Missing required parameter: "country"'); - } - - if (typeof city === 'undefined') { - throw new AppwriteException('Missing required parameter: "city"'); - } - - if (typeof streetAddress === 'undefined') { - throw new AppwriteException('Missing required parameter: "streetAddress"'); - } - - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); - const payload: Payload = {}; - - if (typeof country !== 'undefined') { - payload['country'] = country; - } - - if (typeof city !== 'undefined') { - payload['city'] = city; - } - - if (typeof streetAddress !== 'undefined') { - payload['streetAddress'] = streetAddress; - } - - if (typeof addressLine2 !== 'undefined') { - payload['addressLine2'] = addressLine2; - } - - if (typeof state !== 'undefined') { - payload['state'] = state; - } - - if (typeof postalCode !== 'undefined') { - payload['postalCode'] = postalCode; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('put', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Delete a specific billing address using it's ID. - * - * @param {string} params.billingAddressId - Billing address unique ID - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteBillingAddress(params: { billingAddressId: string }): Promise<{}>; - /** - * Delete a specific billing address using it's ID. - * - * @param {string} billingAddressId - Billing address unique ID - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteBillingAddress(billingAddressId: string): Promise<{}>; - deleteBillingAddress( - paramsOrFirst: { billingAddressId: string } | string - ): Promise<{}> { - let params: { billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { billingAddressId: string }; - } else { - params = { - billingAddressId: paramsOrFirst as string - }; - } - - const billingAddressId = params.billingAddressId; - - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', billingAddressId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } - /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. diff --git a/src/services/organizations.ts b/src/services/organizations.ts deleted file mode 100644 index 82a7af54..00000000 --- a/src/services/organizations.ts +++ /dev/null @@ -1,307 +0,0 @@ -import { Service } from '../service'; -import { AppwriteException, Client } from '../client'; -import type { Models } from '../models'; -import type { UploadProgress, Payload } from '../client'; -import * as FileSystem from 'expo-file-system'; -import { Platform } from 'react-native'; - - -export class Organizations extends Service { - - constructor(client: Client) - { - super(client); - } - - /** - * Delete an organization. - * - * @param {string} params.organizationId - Team ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - delete(params: { organizationId: string }): Promise<{}>; - /** - * Delete an organization. - * - * @param {string} organizationId - Team ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - delete(organizationId: string): Promise<{}>; - delete( - paramsOrFirst: { organizationId: string } | string - ): Promise<{}> { - let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string }; - } else { - params = { - organizationId: paramsOrFirst as string - }; - } - - const organizationId = params.organizationId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - const apiPath = '/organizations/{organizationId}'.replace('{organizationId}', organizationId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get a billing address using it's ID. - * - * @param {string} params.organizationId - Organization ID - * @param {string} params.billingAddressId - Unique ID of billing address - * @throws {AppwriteException} - * @returns {Promise} - */ - getBillingAddress(params: { organizationId: string, billingAddressId: string }): Promise; - /** - * Get a billing address using it's ID. - * - * @param {string} organizationId - Organization ID - * @param {string} billingAddressId - Unique ID of billing address - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getBillingAddress(organizationId: string, billingAddressId: string): Promise; - getBillingAddress( - paramsOrFirst: { organizationId: string, billingAddressId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { organizationId: string, billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingAddressId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - billingAddressId: rest[0] as string - }; - } - - const organizationId = params.organizationId; - const billingAddressId = params.billingAddressId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - const apiPath = '/organizations/{organizationId}/billing-addresses/{billingAddressId}'.replace('{organizationId}', organizationId).replace('{billingAddressId}', billingAddressId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Get estimation for deleting an organization. - * - * @param {string} params.organizationId - Team ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - estimationDeleteOrganization(params: { organizationId: string }): Promise; - /** - * Get estimation for deleting an organization. - * - * @param {string} organizationId - Team ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - estimationDeleteOrganization(organizationId: string): Promise; - estimationDeleteOrganization( - paramsOrFirst: { organizationId: string } | string - ): Promise { - let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string }; - } else { - params = { - organizationId: paramsOrFirst as string - }; - } - - const organizationId = params.organizationId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - const apiPath = '/organizations/{organizationId}/estimations/delete-organization'.replace('{organizationId}', organizationId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. - * - * - * @param {string} params.organizationId - Organization Unique ID - * @param {string} params.reason - Feedback reason - * @param {string} params.message - Feedback message - * @param {string} params.fromPlanId - Plan downgrading from - * @param {string} params.toPlanId - Plan downgrading to - * @throws {AppwriteException} - * @returns {Promise} - */ - createDowngradeFeedback(params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }): Promise; - /** - * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. - * - * - * @param {string} organizationId - Organization Unique ID - * @param {string} reason - Feedback reason - * @param {string} message - Feedback message - * @param {string} fromPlanId - Plan downgrading from - * @param {string} toPlanId - Plan downgrading to - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDowngradeFeedback(organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string): Promise; - createDowngradeFeedback( - paramsOrFirst: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] - ): Promise { - let params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - reason: rest[0] as string, - message: rest[1] as string, - fromPlanId: rest[2] as string, - toPlanId: rest[3] as string - }; - } - - const organizationId = params.organizationId; - const reason = params.reason; - const message = params.message; - const fromPlanId = params.fromPlanId; - const toPlanId = params.toPlanId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - if (typeof reason === 'undefined') { - throw new AppwriteException('Missing required parameter: "reason"'); - } - - if (typeof message === 'undefined') { - throw new AppwriteException('Missing required parameter: "message"'); - } - - if (typeof fromPlanId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fromPlanId"'); - } - - if (typeof toPlanId === 'undefined') { - throw new AppwriteException('Missing required parameter: "toPlanId"'); - } - - const apiPath = '/organizations/{organizationId}/feedbacks/downgrade'.replace('{organizationId}', organizationId); - const payload: Payload = {}; - - if (typeof reason !== 'undefined') { - payload['reason'] = reason; - } - - if (typeof message !== 'undefined') { - payload['message'] = message; - } - - if (typeof fromPlanId !== 'undefined') { - payload['fromPlanId'] = fromPlanId; - } - - if (typeof toPlanId !== 'undefined') { - payload['toPlanId'] = toPlanId; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get an organization's payment method using it's payment method ID. - * - * @param {string} params.organizationId - Organization ID - * @param {string} params.paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - */ - getPaymentMethod(params: { organizationId: string, paymentMethodId: string }): Promise; - /** - * Get an organization's payment method using it's payment method ID. - * - * @param {string} organizationId - Organization ID - * @param {string} paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getPaymentMethod(organizationId: string, paymentMethodId: string): Promise; - getPaymentMethod( - paramsOrFirst: { organizationId: string, paymentMethodId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { organizationId: string, paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, paymentMethodId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - paymentMethodId: rest[0] as string - }; - } - - const organizationId = params.organizationId; - const paymentMethodId = params.paymentMethodId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/organizations/{organizationId}/payment-methods/{paymentMethodId}'.replace('{organizationId}', organizationId).replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } -}; From e59d5875d302c27ac9de103688f686573bc2598e Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 10:21:47 +0000 Subject: [PATCH 5/5] updated spec --- docs/examples/account/create-key.md | 17 - .../examples/account/create-payment-method.md | 13 - docs/examples/account/delete-key.md | 15 - .../examples/account/delete-payment-method.md | 15 - docs/examples/account/get-key.md | 15 - docs/examples/account/get-payment-method.md | 15 - docs/examples/account/list-keys.md | 15 - docs/examples/account/list-payment-methods.md | 15 - docs/examples/account/update-key.md | 18 - .../update-payment-method-mandate-options.md | 15 - .../account/update-payment-method-provider.md | 18 - .../examples/account/update-payment-method.md | 18 - src/enums/scopes.ts | 5 - src/index.ts | 1 - src/models.ts | 156 ----- src/services/account.ts | 632 ------------------ 16 files changed, 983 deletions(-) delete mode 100644 docs/examples/account/create-key.md delete mode 100644 docs/examples/account/create-payment-method.md delete mode 100644 docs/examples/account/delete-key.md delete mode 100644 docs/examples/account/delete-payment-method.md delete mode 100644 docs/examples/account/get-key.md delete mode 100644 docs/examples/account/get-payment-method.md delete mode 100644 docs/examples/account/list-keys.md delete mode 100644 docs/examples/account/list-payment-methods.md delete mode 100644 docs/examples/account/update-key.md delete mode 100644 docs/examples/account/update-payment-method-mandate-options.md delete mode 100644 docs/examples/account/update-payment-method-provider.md delete mode 100644 docs/examples/account/update-payment-method.md delete mode 100644 src/enums/scopes.ts diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md deleted file mode 100644 index abc1e4b6..00000000 --- a/docs/examples/account/create-key.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, Account, Scopes } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.createKey({ - name: '', - scopes: [Scopes.Account], - expire: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md deleted file mode 100644 index 023ea356..00000000 --- a/docs/examples/account/create-payment-method.md +++ /dev/null @@ -1,13 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.createPaymentMethod(); - -console.log(result); -``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md deleted file mode 100644 index d8207ef4..00000000 --- a/docs/examples/account/delete-key.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.deleteKey({ - keyId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md deleted file mode 100644 index 1aff0a48..00000000 --- a/docs/examples/account/delete-payment-method.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.deletePaymentMethod({ - paymentMethodId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md deleted file mode 100644 index 3faa25da..00000000 --- a/docs/examples/account/get-key.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.getKey({ - keyId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md deleted file mode 100644 index d77c67c9..00000000 --- a/docs/examples/account/get-payment-method.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.getPaymentMethod({ - paymentMethodId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md deleted file mode 100644 index 93760ea7..00000000 --- a/docs/examples/account/list-keys.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.listKeys({ - total: false // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md deleted file mode 100644 index e68025b7..00000000 --- a/docs/examples/account/list-payment-methods.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.listPaymentMethods({ - queries: [] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md deleted file mode 100644 index e3ee6fb4..00000000 --- a/docs/examples/account/update-key.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -import { Client, Account, Scopes } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.updateKey({ - keyId: '', - name: '', - scopes: [Scopes.Account], - expire: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md deleted file mode 100644 index 586db083..00000000 --- a/docs/examples/account/update-payment-method-mandate-options.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.updatePaymentMethodMandateOptions({ - paymentMethodId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md deleted file mode 100644 index 008e6e2e..00000000 --- a/docs/examples/account/update-payment-method-provider.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.updatePaymentMethodProvider({ - paymentMethodId: '', - providerMethodId: '', - name: '', - state: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md deleted file mode 100644 index 8530c84d..00000000 --- a/docs/examples/account/update-payment-method.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -import { Client, Account } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const account = new Account(client); - -const result = await account.updatePaymentMethod({ - paymentMethodId: '', - expiryMonth: 1, - expiryYear: 2026, - state: '' // optional -}); - -console.log(result); -``` diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts deleted file mode 100644 index a30e13ea..00000000 --- a/src/enums/scopes.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Scopes { - Account = 'account', - TeamsRead = 'teams.read', - TeamsWrite = 'teams.write', -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 0c7fc288..f6d51fd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,6 @@ export { Role } from './role'; export { ID } from './id'; export { Channel } from './channel'; export { Operator, Condition } from './operator'; -export { Scopes } from './enums/scopes'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; export { OAuthProvider } from './enums/o-auth-provider'; diff --git a/src/models.ts b/src/models.ts index 98d2086e..cbe1e894 100644 --- a/src/models.ts +++ b/src/models.ts @@ -131,20 +131,6 @@ export namespace Models { executions: Execution[]; } - /** - * API Keys List - */ - export type KeyList = { - /** - * Total number of keys that matched your query. - */ - total: number; - /** - * List of keys. - */ - keys: Key[]; - } - /** * Countries List */ @@ -1094,48 +1080,6 @@ export namespace Models { scheduledAt?: string; } - /** - * Key - */ - export type Key = { - /** - * Key ID. - */ - $id: string; - /** - * Key creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Key update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Key name. - */ - name: string; - /** - * Key expiration date in ISO 8601 format. - */ - expire: string; - /** - * Allowed permission scopes. - */ - scopes: string[]; - /** - * Secret key. - */ - secret: string; - /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - */ - accessedAt: string; - /** - * List of SDK user agents that used this key. - */ - sdks: string[]; - } - /** * Country */ @@ -1429,104 +1373,4 @@ export namespace Models { */ expired: boolean; } - - /** - * paymentMethod - */ - export type PaymentMethod = { - /** - * Payment Method ID. - */ - $id: string; - /** - * Payment method creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * Payment method update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Payment method permissions. [Learn more about permissions](/docs/permissions). - */ - $permissions: string[]; - /** - * Payment method ID from the payment provider - */ - providerMethodId: string; - /** - * Client secret hash for payment setup - */ - clientSecret: string; - /** - * User ID from the payment provider. - */ - providerUserId: string; - /** - * ID of the Team. - */ - userId: string; - /** - * Expiry month of the payment method. - */ - expiryMonth: number; - /** - * Expiry year of the payment method. - */ - expiryYear: number; - /** - * Last 4 digit of the payment method - */ - last4: string; - /** - * Payment method brand - */ - brand: string; - /** - * Name of the owner - */ - name: string; - /** - * Mandate ID of the payment method - */ - mandateId: string; - /** - * Country of the payment method - */ - country: string; - /** - * State of the payment method - */ - state: string; - /** - * Last payment error associated with the payment method. - */ - lastError: string; - /** - * True when it's the default payment method. - */ - default: boolean; - /** - * True when payment method has expired. - */ - expired: boolean; - /** - * True when payment method has failed to process multiple times. - */ - failed: boolean; - } - - /** - * Payment methods list - */ - export type PaymentMethodList = { - /** - * Total number of paymentMethods that matched your query. - */ - total: number; - /** - * List of paymentMethods. - */ - paymentMethods: PaymentMethod[]; - } } diff --git a/src/services/account.ts b/src/services/account.ts index 722c1fec..4c523326 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -5,7 +5,6 @@ import type { UploadProgress, Payload } from '../client'; import * as FileSystem from 'expo-file-system'; import { Platform } from 'react-native'; -import { Scopes } from '../enums/scopes'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; @@ -323,287 +322,6 @@ export class Account extends Service { }, payload); } - /** - * Get a list of all API keys from the current account. - * - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listKeys(params?: { total?: boolean }): Promise; - /** - * Get a list of all API keys from the current account. - * - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listKeys(total?: boolean): Promise; - listKeys( - paramsOrFirst?: { total?: boolean } | boolean - ): Promise { - let params: { total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { total?: boolean }; - } else { - params = { - total: paramsOrFirst as boolean - }; - } - - const total = params.total; - - const apiPath = '/account/keys'; - const payload: Payload = {}; - - if (typeof total !== 'undefined') { - payload['total'] = total; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Create a new account API key. - * - * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - */ - createKey(params: { name: string, scopes: Scopes[], expire?: string }): Promise; - /** - * Create a new account API key. - * - * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createKey(name: string, scopes: Scopes[], expire?: string): Promise; - createKey( - paramsOrFirst: { name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(Scopes[])?, (string)?] - ): Promise { - let params: { name: string, scopes: Scopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name: string, scopes: Scopes[], expire?: string }; - } else { - params = { - name: paramsOrFirst as string, - scopes: rest[0] as Scopes[], - expire: rest[1] as string - }; - } - - const name = params.name; - const scopes = params.scopes; - const expire = params.expire; - - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - if (typeof scopes === 'undefined') { - throw new AppwriteException('Missing required parameter: "scopes"'); - } - - const apiPath = '/account/keys'; - const payload: Payload = {}; - - if (typeof name !== 'undefined') { - payload['name'] = name; - } - - if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get a key by its unique ID. This endpoint returns details about a specific API key in your account including it's scopes. - * - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getKey(params: { keyId: string }): Promise; - /** - * Get a key by its unique ID. This endpoint returns details about a specific API key in your account including it's scopes. - * - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { - let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string }; - } else { - params = { - keyId: paramsOrFirst as string - }; - } - - const keyId = params.keyId; - - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. - * - * @param {string} params.keyId - Key unique ID. - * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; - /** - * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. - * - * @param {string} keyId - Key unique ID. - * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateKey(keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; - updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (Scopes[])?, (string)?] - ): Promise { - let params: { keyId: string, name: string, scopes: Scopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: Scopes[], expire?: string }; - } else { - params = { - keyId: paramsOrFirst as string, - name: rest[0] as string, - scopes: rest[1] as Scopes[], - expire: rest[2] as string - }; - } - - const keyId = params.keyId; - const name = params.name; - const scopes = params.scopes; - const expire = params.expire; - - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - if (typeof scopes === 'undefined') { - throw new AppwriteException('Missing required parameter: "scopes"'); - } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); - const payload: Payload = {}; - - if (typeof name !== 'undefined') { - payload['name'] = name; - } - - if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('put', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - * - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteKey(params: { keyId: string }): Promise<{}>; - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - * - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { - let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string }; - } else { - params = { - keyId: paramsOrFirst as string - }; - } - - const keyId = params.keyId; - - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', keyId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } - /** * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * @@ -1464,356 +1182,6 @@ export class Account extends Service { }, payload); } - /** - * List payment methods for this account. - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed - * @throws {AppwriteException} - * @returns {Promise} - */ - listPaymentMethods(params?: { queries?: string[] }): Promise; - /** - * List payment methods for this account. - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, expired, failed - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listPaymentMethods(queries?: string[]): Promise; - listPaymentMethods( - paramsOrFirst?: { queries?: string[] } | string[] - ): Promise { - let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[] }; - } else { - params = { - queries: paramsOrFirst as string[] - }; - } - - const queries = params.queries; - - const apiPath = '/account/payment-methods'; - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Create a new payment method for the current user account. - * - * @throws {AppwriteException} - * @returns {Promise} - */ - createPaymentMethod(): Promise { - const apiPath = '/account/payment-methods'; - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get a specific payment method for the user. - * - * @param {string} params.paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - */ - getPaymentMethod(params: { paymentMethodId: string }): Promise; - /** - * Get a specific payment method for the user. - * - * @param {string} paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getPaymentMethod(paymentMethodId: string): Promise; - getPaymentMethod( - paramsOrFirst: { paymentMethodId: string } | string - ): Promise { - let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string }; - } else { - params = { - paymentMethodId: paramsOrFirst as string - }; - } - - const paymentMethodId = params.paymentMethodId; - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Update a new payment method for the current user account. - * - * @param {string} params.paymentMethodId - Unique ID of payment method - * @param {number} params.expiryMonth - Payment expiry month - * @param {number} params.expiryYear - Expiry year - * @param {string} params.state - State of the payment method country - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePaymentMethod(params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }): Promise; - /** - * Update a new payment method for the current user account. - * - * @param {string} paymentMethodId - Unique ID of payment method - * @param {number} expiryMonth - Payment expiry month - * @param {number} expiryYear - Expiry year - * @param {string} state - State of the payment method country - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePaymentMethod(paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string): Promise; - updatePaymentMethod( - paramsOrFirst: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string } | string, - ...rest: [(number)?, (number)?, (string)?] - ): Promise { - let params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; - } else { - params = { - paymentMethodId: paramsOrFirst as string, - expiryMonth: rest[0] as number, - expiryYear: rest[1] as number, - state: rest[2] as string - }; - } - - const paymentMethodId = params.paymentMethodId; - const expiryMonth = params.expiryMonth; - const expiryYear = params.expiryYear; - const state = params.state; - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - if (typeof expiryMonth === 'undefined') { - throw new AppwriteException('Missing required parameter: "expiryMonth"'); - } - - if (typeof expiryYear === 'undefined') { - throw new AppwriteException('Missing required parameter: "expiryYear"'); - } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - if (typeof expiryMonth !== 'undefined') { - payload['expiryMonth'] = expiryMonth; - } - - if (typeof expiryYear !== 'undefined') { - payload['expiryYear'] = expiryYear; - } - - if (typeof state !== 'undefined') { - payload['state'] = state; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Delete a specific payment method from a user's account. - * - * @param {string} params.paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - */ - deletePaymentMethod(params: { paymentMethodId: string }): Promise<{}>; - /** - * Delete a specific payment method from a user's account. - * - * @param {string} paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deletePaymentMethod(paymentMethodId: string): Promise<{}>; - deletePaymentMethod( - paramsOrFirst: { paymentMethodId: string } | string - ): Promise<{}> { - let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string }; - } else { - params = { - paymentMethodId: paramsOrFirst as string - }; - } - - const paymentMethodId = params.paymentMethodId; - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Update payment method provider. - * - * @param {string} params.paymentMethodId - Unique ID of payment method - * @param {string} params.providerMethodId - Payment method ID from the payment provider - * @param {string} params.name - Name in the payment method - * @param {string} params.state - State of the payment method country - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePaymentMethodProvider(params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }): Promise; - /** - * Update payment method provider. - * - * @param {string} paymentMethodId - Unique ID of payment method - * @param {string} providerMethodId - Payment method ID from the payment provider - * @param {string} name - Name in the payment method - * @param {string} state - State of the payment method country - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePaymentMethodProvider(paymentMethodId: string, providerMethodId: string, name: string, state?: string): Promise; - updatePaymentMethodProvider( - paramsOrFirst: { paymentMethodId: string, providerMethodId: string, name: string, state?: string } | string, - ...rest: [(string)?, (string)?, (string)?] - ): Promise { - let params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; - } else { - params = { - paymentMethodId: paramsOrFirst as string, - providerMethodId: rest[0] as string, - name: rest[1] as string, - state: rest[2] as string - }; - } - - const paymentMethodId = params.paymentMethodId; - const providerMethodId = params.providerMethodId; - const name = params.name; - const state = params.state; - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - if (typeof providerMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerMethodId"'); - } - - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/account/payment-methods/{paymentMethodId}/provider'.replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - if (typeof providerMethodId !== 'undefined') { - payload['providerMethodId'] = providerMethodId; - } - - if (typeof name !== 'undefined') { - payload['name'] = name; - } - - if (typeof state !== 'undefined') { - payload['state'] = state; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Update payment method mandate options. - * - * @param {string} params.paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePaymentMethodMandateOptions(params: { paymentMethodId: string }): Promise; - /** - * Update payment method mandate options. - * - * @param {string} paymentMethodId - Unique ID of payment method - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePaymentMethodMandateOptions(paymentMethodId: string): Promise; - updatePaymentMethodMandateOptions( - paramsOrFirst: { paymentMethodId: string } | string - ): Promise { - let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string }; - } else { - params = { - paymentMethodId: paramsOrFirst as string - }; - } - - const paymentMethodId = params.paymentMethodId; - - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/account/payment-methods/{paymentMethodId}/setup'.replace('{paymentMethodId}', paymentMethodId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - /** * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. *