Refactor billing service and enhance account APIs
This commit includes renaming and refactoring of some billing services for clarification and coherence. It also improves account APIs in team-accounts and accounts packages by having added `getAccount` and `getTeamAccount` methods, allowing retrieval of account details via slug and id. Changes also include type modifications in `getSupabaseServerActionClient` function for better flexibility and precision.
This commit is contained in:
@@ -10,6 +10,25 @@ import { Database } from '@kit/supabase/database';
|
||||
export class TeamAccountsApi {
|
||||
constructor(private readonly client: SupabaseClient<Database>) {}
|
||||
|
||||
/**
|
||||
* @name getTeamAccount
|
||||
* @description Get the account data for the given slug.
|
||||
* @param slug
|
||||
*/
|
||||
async getTeamAccount(slug: string) {
|
||||
const { data, error } = await this.client
|
||||
.from('accounts')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name getTeamAccountById
|
||||
* @description Check if the user is already in the account.
|
||||
@@ -20,7 +39,7 @@ export class TeamAccountsApi {
|
||||
.from('accounts')
|
||||
.select('*')
|
||||
.eq('id', accountId)
|
||||
.maybeSingle();
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user