feat: retrieve organization subscriptions list api.

feat: subscriptions reducers.
This commit is contained in:
Ahmed Bouhuolia
2020-10-13 21:46:32 +02:00
parent d71845a4c4
commit 8b97673100
23 changed files with 289 additions and 55 deletions

View File

@@ -100,7 +100,7 @@ export default class OrganizationService {
this.logger.info('[organization] trying to list all organizations.', { user });
const { tenantRepository } = this.sysRepositories;
const tenant = await tenantRepository.getByIdWithSubscriptions(user.tenantId);
const tenant = await tenantRepository.getById(user.tenantId);
return [tenant];
}

View File

@@ -1,5 +1,5 @@
import { Service, Inject } from 'typedi';
import { Plan, Tenant } from 'system/models';
import { Plan, PlanSubscription } from 'system/models';
import Subscription from 'services/Subscription/Subscription';
import LicensePaymentMethod from 'services/Payment/LicensePaymentMethod';
import PaymentContext from 'services/Payment';
@@ -29,7 +29,7 @@ export default class SubscriptionService {
* @param {string} licenseCode
* @return {Promise}
*/
async subscriptionViaLicense(
public async subscriptionViaLicense(
tenantId: number,
planSlug: string,
paymentModel?: ILicensePaymentModel,
@@ -53,4 +53,15 @@ export default class SubscriptionService {
tenantId, paymentModel
});
}
/**
* Retrieve all subscription of the given tenant.
* @param {number} tenantId
*/
public async getSubscriptions(tenantId: number) {
this.logger.info('[subscription] trying to get tenant subscriptions.', { tenantId });
const subscriptions = await PlanSubscription.query().where('tenant_id', tenantId);
return subscriptions;
}
}