Refactor subscription and order retrieval methods
The changes refactor how subscription and order data is retrieved throughout the codebase. This includes renaming methods from 'getSubscriptionData' and 'getOrdersData' to 'getSubscription' and 'getOrder' respectively. The code for obtaining these subscriptions and orders has been rewritten for improved clarity and error handling.
This commit is contained in:
@@ -29,6 +29,43 @@ export class TeamAccountsApi {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name getSubscription
|
||||
* @description Get the subscription data for the account.
|
||||
* @param accountId
|
||||
*/
|
||||
async getSubscription(accountId: string) {
|
||||
const { data, error } = await this.client
|
||||
.from('subscriptions')
|
||||
.select('*')
|
||||
.eq('account_id', accountId)
|
||||
.maybeSingle();
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the orders data for the given account.
|
||||
* @param accountId
|
||||
*/
|
||||
async getOrder(accountId: string) {
|
||||
const response = await this.client
|
||||
.from('orders')
|
||||
.select('*, items: order_items !inner (*)')
|
||||
.eq('account_id', accountId)
|
||||
.maybeSingle();
|
||||
|
||||
if (response.error) {
|
||||
throw response.error;
|
||||
}
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name getAccountWorkspace
|
||||
* @description Get the account workspace data.
|
||||
|
||||
Reference in New Issue
Block a user