RestGO SDK
Login, sessions, accounts, Storage, APIs, videos, and payments through the shared client RestGO.
Configuration
Open RestGo integration → Connection → Application SDK in the sidebar.
- Enable Enable native RestGO integration and enter RestGO instance URL.
- Enter Default database slug for a default database. Application API token is optional and takes the token without Bearer.
- Configure Persist the user session, Session storage, and Session storage key. Options are local storage, the current tab, or memory.
- Click Save changes and save the project.
The RestGO object is available in pages and reusable components. Disabled integration raises RestGoNotConfiguredError. The application token is included in Preview and Build; use a token suitable for the browser.
Login and current user
const result = await RestGO.login('ana@example.com', 'user-password', true);
if (!result.sucess) { Message(result.error.message); return; }
Message(result.data.user.fullName);
Navigate('PageHome');The third argument, remember, is optional. Browser persistence follows integration settings. The public result field is named sucess.
await RestGO.auth.ready;
const user = RestGO.CurrentUser;
if (user) Message(user.nome);
// user.email, user.id, user.emailconfirmed, and user.ativo are also read-only.CurrentUser reads the last confirmed identity without a request. To fetch current data and validate the session, use getUser(); its result contains fullName, email, id, avatarUrl, active, and emailConfirmed. With no user, data is null.
Sign-up, recovery, and avatar
| Action | Method |
|---|---|
| Sign-up | auth.signUp({ email, password, fullName }) |
| Sign in with an object | auth.signInWithPassword({ email, password, remember }) |
| Request password recovery | auth.resetPasswordForEmail(email, { url }) |
| Confirm a new password | auth.confirmPasswordReset({ token, password }) |
| Confirm email | auth.confirmEmail(token) |
| Upload or remove an avatar | auth.uploadAvatar(file), auth.deleteAvatar() |
| Sign out | logout() or auth.signOut() |
Sign-up does not log in automatically. The RestGO instance must allow public sign-up. Recovery and confirmation depend on links sent by the server. Avatar upload uses the session and updates the SDK identity.
Sessions and events
- auth.ready waits for initial restoration. getSession() validates the session; refreshSession() renews credentials; logout() ends the session.
- Automatic renewal uses the refresh token received at login. A network failure does not confirm logout.
- onAuthStateChange() receives INITIAL_SESSION, SIGNED_IN, SIGNED_OUT, SESSION_VALIDATED, TOKEN_REFRESHED, or USER_UPDATED. Keep the subscription and call unsubscribe() when observation ends.
- In Interaction, pages and reusable components offer OnLogin and OnLogout with detail.user. OnUnauthenticated allows redirection after the absence of a session is confirmed.
const subscription = RestGO.onAuthStateChange((event, session) => {
console.log(event, session?.user.fullName);
});
// When observation ends: subscription.unsubscribe();Dynamic APIs
const endpoint = RestGO.from<{ id: number; name: string }[]>('customers', {
database: 'main', version: 1,
});
const result = await endpoint.get({ auth: 'session', page: 1, pagination: 'simple' });
if (result.error) { Message(result.error.message); return; }
console.log(result.data, result.has_more);Use get, post, put, patch, delete, head, options, or request. query, headers, and signal are call options. Pagination accepts exact, simple, and cursor; in cursor mode, set cursorColumn and reuse next_cursor.
| auth | Credential |
|---|---|
| session | User JWT; requires a session |
| apiToken | Application token, without Bearer |
| none | Public access, without Authorization |
| auto | Current session; otherwise, the configured token |
The mode must match the endpoint’s publication settings. Login, sign-up, recovery, and confirmation use their public routes. Storage, videos, avatars, and payments use the user session.
Payments
Use the Payments component for the standard frontend flow. Configure its Gateway slug, sign in as the customer, and call one action from the button's async OnClick handler:
await Payments1.Pay(Edit1.value);For a subscription, use Subscribe(Edit1.value); Checkout(Edit1.value) uses the Inspector's Mode. These component actions recover/persist the attempt, wait for checkout and open the provider automatically. Resume(), Refresh(), WaitForConfirmation(), CancelSubscription(), LoadHistory() and LoadMore() simplify management and return flows. Confirm financial success through RestGo rather than trusting a redirect.
Direct SDK code uses RestGO.payments.gateway(slug), with createCheckout, getOperation, listOperations, and cancelSubscription. The four routes use the customer's Authentication JWT exclusively; there is no application-token fallback. SDK methods return RestGoResult and do not automatically navigate. Direct createCheckout callers must durably save and reuse the original sourceKey, mode and idempotencyKey before POST, then save the returned operation ID before navigation. HTTP 202 is a successful pending operation.
const gateway = RestGO.payments.gateway('customer-payments');
const result = await gateway.listOperations();
if (result.error) Message(result.error.message);
else console.log(result.data.data, result.data.nextCursor);Price, currency, ownership, recurrence, provider credentials and webhooks remain on RestGo. Choose the high-level Payments component unless transport-level control is required.
APIs in the IDE
- In RestGo integration → Connection, the administrative connection manages endpoints. Its credential stays in the IDE, separate from the application token.
- In Endpoints, configure and publish the API. Published APIs lists available routes.
- In API Client, Import from RestGo imports operations; Refresh synchronizes previously imported clients.
- Development login authenticates JWT API tests in the editor. This session is separate from Preview or generated application login.
Storage and videos
Use File Upload and Video Upload to select files and track uploads through the interface. The same operations are available in RestGO.storage and RestGO.videos.
- Storage: list, upload, get, update, remove, download, getPublicUrl, and usage. download returns a Blob. isPublic controls privacy; getPublicUrl only constructs the URL.
- Videos: upload, resumeUpload, list, get, update, and remove. Save resumeToken and select the same file to resume.
- Processing: process, reprocess, cancelProcessing, and waitUntilReady. Waiting observes conversion without starting it.
- Media: getHls, getThumbnail, and getMedia. For playback with controls and quality selection, use Video Player.
- Manual chunks: videos.uploads offers create, get, sendChunk, complete, and cancel. Prefer upload/resumeUpload when individual chunk control is not needed.
Results and failures
SDK operations return { data, error }; login also returns sucess. Check error before using data. Errors include message, code, and status when available. Component methods such as ApiClient1.execute() and FileUpload1.SendToRestGO() reject their Promise on failure: use try/catch.
SDK API
Service signatures. Expand an example to see the call.
RestGO RestGoClient
auth
readonly auth: RestGoAuthClient;storage
readonly storage: RestGoStorageClient;videos
readonly videos: RestGoVideosClient;payments
readonly payments: RestGoPaymentsClient;api
readonly api: RestGoApiClient;baseUrl
readonly baseUrl: string;from
from<T = unknown>(endpoint: string, options?: RestGoEndpointOptions): RestGoEndpoint<T>;Example
const endpoint = RestGO.from<{ id: number; name: string }[]>('customers', { database: 'main', version: 1 });
const result = await endpoint.get({ auth: 'session', query: { page: 1 } });
if (result.error) Message(result.error.message);
else console.log(result.data, result.page, result.has_more);login
login(email: string, password: string, remember?: boolean): Promise<RestGoLoginResult>;Sign in with positional parameters and report whether this login succeeded.
Example
const result = await RestGO.login('ana@example.com', 'user-password', true);
if (!result.sucess) { Message(result.error.message); return; }
Message(result.data.user.fullName);logout
logout(): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.logout();
if (result.error) Message(result.error.message);
else console.log(result.data);getSession
getSession(): Promise<RestGoResult<RestGoSession | null>>;Example
const result = await RestGO.getSession();
if (result.error) Message(result.error.message);
else console.log(result.data);getUser
getUser(): Promise<RestGoResult<RestGoUser | null>>;Example
const result = await RestGO.getUser();
if (result.error) Message(result.error.message);
else console.log(result.data);CurrentUser
get CurrentUser(): RestGoCurrentUser | null;Last server-confirmed identity, or null before authentication/restoration.
refreshSession
refreshSession(): Promise<RestGoResult<RestGoSession>>;Example
const result = await RestGO.refreshSession();
if (result.error) Message(result.error.message);
else console.log(result.data);onAuthStateChange
onAuthStateChange(callback: (event: RestGoAuthEvent, session: RestGoSession | null) => void): {
unsubscribe: () => void;
};Example
const subscription = RestGO.onAuthStateChange((event, session) => {
console.log(event, session?.user.fullName);
});
subscription.unsubscribe();dispose
dispose(): void;Release browser listeners and automatic renewal without logging the user out.
Example
// Do not dispose of the application’s shared client during navigation.
// Use dispose when closing an independent client created by createClient.
RestGO.dispose();RestGO.auth RestGoAuthClient
ready
readonly ready: Promise<RestGoResult<RestGoSession | null>>;Startup checks persisted credentials with GET /auth/session.
dispose
dispose(): void;Stop timers/listeners without revoking or deleting persisted credentials.
Example
// Do not dispose of the application’s shared client during navigation.
// Use dispose when closing an independent client created by createClient.
RestGO.auth.dispose();CurrentUser
get CurrentUser(): RestGoCurrentUser | null;Local snapshot; reading it does not issue a request or validate the session.
refreshSession
refreshSession(): Promise<RestGoResult<RestGoSession>>;POST /auth/refresh, with single-use rotation serialized across callers and tabs.
Example
const result = await RestGO.auth.refreshSession();
if (result.error) Message(result.error.message);
else console.log(result.data);onAuthStateChange
onAuthStateChange(callback: AuthListener): {
unsubscribe: () => void;
};Example
const subscription = RestGO.auth.onAuthStateChange((event, session) => {
console.log(event, session?.user.fullName);
});
subscription.unsubscribe();signInWithPassword
signInWithPassword(input: RestGoSignInInput): Promise<RestGoResult<RestGoSession>>;Example
const result = await RestGO.auth.signInWithPassword({ email: 'ana@example.com', password: 'user-password', remember: true });
if (result.error) Message(result.error.message);signUp
signUp(input: RestGoSignUpInput): Promise<RestGoResult<RestGoManagedUser>>;Public registration. The server must allow anonymous signup. Does not start a session.
Example
const result = await RestGO.auth.signUp({ email: 'ana@example.com', password: 'user-password', fullName: 'Ana Silva' });
if (result.error) Message(result.error.message);
// Sign-up does not log in automatically.signOut
signOut(): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.auth.signOut();
if (result.error) Message(result.error.message);
else console.log(result.data);getSession
getSession(): Promise<RestGoResult<RestGoSession | null>>;Always asks the server; JWT expiry metadata is not proof of an active session.
Example
const result = await RestGO.auth.getSession();
if (result.error) Message(result.error.message);
else console.log(result.data);getUser
getUser(): Promise<RestGoResult<RestGoUser | null>>;Example
const result = await RestGO.auth.getUser();
if (result.error) Message(result.error.message);
else console.log(result.data);setSession
setSession(input: StoredSession): Promise<RestGoResult<RestGoSession>>;Example
// Replace placeholders with values returned by your server.
const result = await RestGO.auth.setSession({
token: 'RECEIVED-JWT',
expiresAt: 'JWT-EXPIRY-IN-ISO-8601',
refreshToken: 'RECEIVED-REFRESH-TOKEN',
refreshExpiresAt: 'REFRESH-EXPIRY-IN-ISO-8601',
});
if (result.error) Message(result.error.message);resetPasswordForEmail
resetPasswordForEmail(email: string, options?: {
url?: string;
}): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.auth.resetPasswordForEmail('ana@example.com', { url: 'https://app.example.com/reset-password' });
if (result.error) Message(result.error.message);confirmPasswordReset
confirmPasswordReset(input: {
token: string;
password: string;
}): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.auth.confirmPasswordReset({ token: 'TOKEN-FROM-LINK', password: 'new-password' });
if (result.error) Message(result.error.message);confirmEmail
confirmEmail(token: string): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.auth.confirmEmail('TOKEN-FROM-LINK');
if (result.error) Message(result.error.message);updateUser
updateUser(input: RestGoUpdateUserInput, options?: RestGoRequestOptions): Promise<RestGoResult<RestGoUpdateUserResult>>;Example
const result = await RestGO.auth.updateUser({ fullName: 'Ana Silva' });
if (result.error) Message(result.error.message);
else console.log(result.data.user.fullName, result.data.sessionRevoked);resendEmailConfirmation
resendEmailConfirmation(options?: RestGoRequestOptions & {
url?: string;
}): Promise<RestGoResult<RestGoSuccess>>;Example
const result = await RestGO.auth.resendEmailConfirmation();
if (result.error) Message(result.error.message);
else console.log(result.data);uploadAvatar
uploadAvatar(file: Blob, options?: {
name?: string;
signal?: AbortSignal;
}): Promise<RestGoResult<{
avatarUrl: string | null;
}>>;Example
const file = FileUpload1.selectedFile;
if (!file) return;
const result = await RestGO.auth.uploadAvatar(file, { name: file.name });
if (result.error) Message(result.error.message);
else console.log(result.data.avatarUrl);deleteAvatar
deleteAvatar(options?: RestGoRequestOptions): Promise<RestGoResult<{
avatarUrl: string | null;
}>>;Example
const result = await RestGO.auth.deleteAvatar();
if (result.error) Message(result.error.message);
else console.log(result.data.avatarUrl);RestGO.storage RestGoStorageClient
list
list(options?: RestGoListOptions): Promise<RestGoResult<RestGoList<RestGoStoredFile>>>;Example
const result = await RestGO.storage.list({ page: 1, pageSize: 20, q: 'report' });
if (result.error) Message(result.error.message);
else console.log(result.data);upload
upload(file: Blob, options?: RestGoFileOptions): Promise<RestGoResult<RestGoStoredFile>>;Example
const file = FileUpload1.selectedFile;
if (!file) return;
const result = await RestGO.storage.upload(file, { name: file.name, isPublic: false, onUploadProgress: p => console.log(p.percentage) });
if (result.error) Message(result.error.message);get
get(id: string, options?: {
signal?: AbortSignal;
}): Promise<RestGoResult<RestGoStoredFile>>;Example
const result = await RestGO.storage.get('FILE-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);update
update(id: string, input: RestGoFileUpdate): Promise<RestGoResult<RestGoStoredFile>>;Example
const result = await RestGO.storage.update('FILE-ID', { name: 'new-name.pdf', isPublic: false });
if (result.error) Message(result.error.message);remove
remove(id: string, options?: {
signal?: AbortSignal;
}): Promise<RestGoResult<null>>;Example
const result = await RestGO.storage.remove('FILE-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);download
download(id: string, options?: {
range?: string;
public?: boolean;
signal?: AbortSignal;
}): Promise<RestGoResult<Blob>>;Example
const result = await RestGO.storage.download('FILE-ID', { public: false });
if (result.error) { Message(result.error.message); return; }
const blob = result.data;
console.log(blob.size, blob.type);getPublicUrl
getPublicUrl(id: string): RestGoResult<{
publicUrl: string;
}>;Constructs a URL; public access still depends on the file's isPublic metadata.
Example
const result = RestGO.storage.getPublicUrl('FILE-ID');
if (!result.error) console.log(result.data.publicUrl);
// The URL does not grant public access to a private file.usage
usage(options?: {
signal?: AbortSignal;
}): Promise<RestGoResult<RestGoStorageUsage>>;Example
const result = await RestGO.storage.usage();
if (result.error) Message(result.error.message);
else console.log(result.data);RestGO.videos RestGoVideosClient
uploads
readonly uploads: RestGoVideoUploadsClient;upload
upload(file: File, options?: RestGoVideoUploadOptions): Promise<RestGoResult<RestGoVideo>>;Example
const file = VideoUpload1.selectedFile;
if (!file) return;
const result = await RestGO.videos.upload(file, { title: 'Presentation', isPublic: false, onProgress: p => console.log(p) });
if (result.error) Message(result.error.message);resumeUpload
resumeUpload(id: string, file: File, options: RestGoVideoResumeOptions): Promise<RestGoResult<RestGoVideo>>;Example
const file = VideoUpload1.selectedFile;
const resumeToken = VideoUpload1.resumeToken;
if (!file || !resumeToken) return;
const result = await RestGO.videos.resumeUpload(resumeToken.uploadId, file, { resumeToken });
if (result.error) Message(result.error.message);list
list(options?: RestGoVideoListOptions): Promise<RestGoResult<RestGoVideoList>>;Example
const result = await RestGO.videos.list({ limit: 20, offset: 0, q: 'presentation' });
if (result.error) Message(result.error.message);
else console.log(result.data);get
get(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<RestGoVideoDetails>>;Example
const result = await RestGO.videos.get('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);update
update(id: string, input: RestGoVideoUpdate, options?: RestGoVideoRequestOptions): Promise<RestGoResult<RestGoVideo>>;Example
const result = await RestGO.videos.update('VIDEO-ID', { title: 'New title', descri: 'Description', isPublic: false });
if (result.error) Message(result.error.message);remove
remove(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<{
id: string;
status: 'deleting';
}>>;Example
const result = await RestGO.videos.remove('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);process
process(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<{
id: string;
jobId: string;
status: 'pending';
}>>;Example
const result = await RestGO.videos.process('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);reprocess
reprocess(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<{
id: string;
jobId: string;
status: 'pending';
}>>;Example
const result = await RestGO.videos.reprocess('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);cancelProcessing
cancelProcessing(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<{
id: string;
state: 'cancelled';
}>>;Example
const result = await RestGO.videos.cancelProcessing('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);getHls
getHls(id: string, options?: RestGoVideoRequestOptions & {
public?: boolean;
}): Promise<RestGoResult<RestGoVideoHlsDescriptor>>;Example
const result = await RestGO.videos.getHls('VIDEO-ID', { public: false });
if (result.error) Message(result.error.message);
else console.log(result.data);getThumbnail
getThumbnail(id: string, options?: RestGoVideoRequestOptions & {
public?: boolean;
}): Promise<RestGoResult<Blob>>;Example
const result = await RestGO.videos.getThumbnail('VIDEO-ID', { public: false });
if (result.error) Message(result.error.message);
else console.log(result.data.size);getMedia
getMedia(id: string, uri: string, options?: RestGoVideoRequestOptions & {
public?: boolean;
range?: string;
method?: 'GET' | 'HEAD';
}): Promise<RestGoResult<Response>>;Browser media bridge: current shared session, one 401 renewal, no cookies or redirects.
Example
const result = await RestGO.videos.getMedia('VIDEO-ID', '/videos/VIDEO-ID/hls/master.m3u8', { public: false, method: 'GET' });
if (result.error) Message(result.error.message);
// Use a valid URI from this same video’s descriptor.waitUntilReady
waitUntilReady(id: string, options?: RestGoVideoWaitOptions): Promise<RestGoResult<RestGoVideo>>;Example
const result = await RestGO.videos.waitUntilReady('VIDEO-ID', { intervalMs: 2000, timeoutMs: 600_000, onProgress: details => console.log(details) });
if (result.error) Message(result.error.message);RestGO.videos.uploads RestGoVideoUploadsClient
create
create(input: RestGoVideoCreateInput, options?: RestGoVideoRequestOptions): Promise<RestGoResult<RestGoVideoUploadSession>>;Example
const file = VideoUpload1.selectedFile;
if (!file) return;
const result = await RestGO.videos.uploads.create({ filename: file.name, sizeBytes: file.size, title: 'Presentation', isPublic: false });
if (result.error) Message(result.error.message);get
get(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<RestGoVideoUploadSession>>;Example
const result = await RestGO.videos.uploads.get('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);sendChunk
sendChunk(id: string, chunk: Blob, options: RestGoVideoChunkOptions): Promise<RestGoResult<RestGoVideoUploadSession>>;Example
const file = VideoUpload1.selectedFile;
const session = VideoUpload1.uploadSession;
if (!file || !session) return;
const offset = session.offset;
const chunk = file.slice(offset, offset + 1024 * 1024);
const digest = await crypto.subtle.digest('SHA-256', await chunk.arrayBuffer());
const checksum = Array.from(new Uint8Array(digest), b => b.toString(16).padStart(2, '0')).join('');
const result = await RestGO.videos.uploads.sendChunk(session.id, chunk, { offset, checksum });
if (result.error) Message(result.error.message);
// Check the confirmed offset before sending the next chunk.complete
complete(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<RestGoVideo>>;Example
const result = await RestGO.videos.uploads.complete('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);cancel
cancel(id: string, options?: RestGoVideoRequestOptions): Promise<RestGoResult<{
status: 'deleting';
}>>;Example
const result = await RestGO.videos.uploads.cancel('VIDEO-OR-UPLOAD-ID');
if (result.error) Message(result.error.message);
else console.log(result.data);RestGO.payments RestGoPaymentsClient
gateway
gateway(slug: string): RestGoPaymentGatewayClient;Example
const gateway = RestGO.payments.gateway('customer-payments');
const result = await gateway.listOperations();
if (result.error) Message(result.error.message);
else console.log(result.data.data);RestGO.payments.gateway('customer-payments') RestGoPaymentGatewayClient
slug
readonly slug: string;createCheckout
createCheckout(input: RestGoCheckoutInput, options?: RestGoPaymentRequestOptions): Promise<RestGoResult<RestGoPaymentOperation>>;Example
// Direct SDK control: persist before the first POST and reuse this saved attempt.
const session = await RestGO.getSession();
if (session.error) throw session.error;
if (!session.data) throw new Error('Sign in before starting checkout.');
const sourceKey = '123';
const storageKey = JSON.stringify(['sdk-checkout', RestGO.baseUrl, session.data.user.id, 'customer-payments', sourceKey, 'payment']);
const saved = localStorage.getItem(storageKey);
const attempt = saved === null ? { sourceKey, mode: 'payment' as const, idempotencyKey: crypto.randomUUID() }
: JSON.parse(saved) as import('@webrad/restgo-sdk').RestGoCheckoutInput;
localStorage.setItem(storageKey, JSON.stringify(attempt));
const result = await RestGO.payments.gateway('customer-payments').createCheckout(attempt);
if (result.error) throw result.error;
localStorage.setItem(storageKey + ':operation', result.data.id);
console.log(result.data.status, result.data.checkoutState);
// Prefer Payments1.Pay(sourceKey) for automatic storage/locking, readiness and opening.getOperation
getOperation(id: string, options?: RestGoPaymentRequestOptions): Promise<RestGoResult<RestGoPaymentOperation>>;Example
const result = await RestGO.payments.gateway('customer-payments').getOperation('00000000-0000-4000-8000-000000000001');
if (result.error) Message(result.error.message);
else console.log(result.data.status, result.data.synchronizationPending);listOperations
listOperations(options?: RestGoPaymentListOptions): Promise<RestGoResult<RestGoPaymentOperationList>>;Example
const gateway = RestGO.payments.gateway('customer-payments');
const first = await gateway.listOperations();
if (first.error) throw first.error;
console.log(first.data.data);
if (first.data.nextCursor) {
const next = await gateway.listOperations({ before: first.data.nextCursor });
if (next.error) throw next.error;
console.log(next.data.data);
}cancelSubscription
cancelSubscription(id: string, options?: RestGoPaymentRequestOptions): Promise<RestGoResult<RestGoPaymentOperation>>;Example
// Call after the customer chooses to cancel their subscription.
const result = await RestGO.payments.gateway('customer-payments').cancelSubscription('00000000-0000-4000-8000-000000000001');
if (result.error) Message(result.error.message);
else console.log(result.data.provider.periodEnd, result.data.provider.cancelAtPeriodEnd);RestGO.api RestGoApiClient
from
from(database?: string): RestGoDatabase;Example
const database = RestGO.api.from('main');
const result = await database.endpoint('customers', { version: 1 }).get({ auth: 'session' });
if (result.error) Message(result.error.message);endpoint
endpoint<T = unknown>(name: string, options?: RestGoEndpointOptions): RestGoEndpoint<T>;Example
const endpoint = RestGO.api.endpoint('customers', { database: 'main', version: 1 });
const result = await endpoint.get({ auth: 'session' });
if (result.error) Message(result.error.message);RestGO.api.from('main') RestGoDatabase
endpoint
endpoint<T = unknown>(name: string, options?: {
version?: number;
}): RestGoEndpoint<T>;Example
const endpoint = RestGO.api.from('main').endpoint('customers', { version: 1 });
const result = await endpoint.get();
if (result.error) Message(result.error.message);RestGO.from('customers') RestGoEndpoint
get
get<U = T>(options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').get({ auth: 'session', query: { page: 1 } });
if (result.error) Message(result.error.message);
else console.log(result.data);post
post<U = T>(body?: unknown, options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').post({ id: 42, name: 'Ana' }, { auth: 'session' });
if (result.error) Message(result.error.message);
else console.log(result.data);put
put<U = T>(body?: unknown, options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').put({ id: 42, name: 'Ana' }, { auth: 'session' });
if (result.error) Message(result.error.message);
else console.log(result.data);patch
patch<U = T>(body?: unknown, options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').patch({ id: 42, name: 'Ana' }, { auth: 'session' });
if (result.error) Message(result.error.message);
else console.log(result.data);delete
delete<U = T>(body?: unknown, options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').delete({ id: 42, name: 'Ana' }, { auth: 'session' });
if (result.error) Message(result.error.message);
else console.log(result.data);head
head(options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<null>>;Example
const result = await RestGO.from('customers').head({ auth: 'session', query: { page: 1 } });
if (result.error) Message(result.error.message);
else console.log(result.data);options
options<U = T>(options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').options({ auth: 'session', query: { page: 1 } });
if (result.error) Message(result.error.message);
else console.log(result.data);request
request<U = T>(method: RestGoHttpMethod, body?: unknown, options?: RestGoDynamicOptions): Promise<RestGoDynamicResult<U>>;Example
const result = await RestGO.from('customers').request('GET', undefined, { auth: 'session', query: { page: 1 } });
if (result.error) Message(result.error.message);
else console.log(result.data);