@prisma/client#EnumSubscriptionStatus TypeScript Examples

The following examples show how to use @prisma/client#EnumSubscriptionStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: paddle.service.spec.ts    From amplication with Apache License 2.0 6 votes vote down vote up
EXAMPLE_SUBSCRIPTION: Subscription = {
  id: 'ExampleSubscriptionId',
  createdAt: new Date(),
  subscriptionData: {
    paddleEmail: PADDLE_CREATE_EVENT.email,
    paddleUserId: PADDLE_CREATE_EVENT.user_id,
    paddleSubscriptionId: PADDLE_CREATE_EVENT.subscription_id,
    paddleSubscriptionPlanId: PADDLE_CREATE_EVENT.subscription_plan_id,
    paddleSubscriptionStatus: EnumPaddleSubscriptionStatus.Trailing,
    paddleNextBillDate: new Date(PADDLE_CREATE_EVENT.next_bill_date),
    paddleCancellationEffectiveDate: null,
    paddlePausedFrom: null,
    paddleUpdateUrl: PADDLE_CREATE_EVENT.update_url,
    paddleCancelUrl: PADDLE_CREATE_EVENT.cancel_url,
    paddleUnitPrice: +PADDLE_CREATE_EVENT.unit_price
  },
  subscriptionPlan: EnumSubscriptionPlan.Business,
  status: EnumSubscriptionStatus.Active,
  updatedAt: new Date(),
  workspaceId: 'ExampleWorkspaceId'
}
Example #2
Source File: subscription.service.ts    From amplication with Apache License 2.0 6 votes vote down vote up
async updateSubscription(
    data: UpdateSubscriptionInput
  ): Promise<Subscription> {
    const subscriptionToUpdate = await this.getSubscriptionByPaddleSubscriptionId(
      data.workspaceId,
      data.subscriptionData.paddleSubscriptionId
    );

    if (!subscriptionToUpdate) {
      throw new Error(
        `Can't find subscription to update for workspace ID ${data.workspaceId} and paddle subscription ID ${data.subscriptionData.paddleSubscriptionId}`
      );
    }

    const cancellationEffectiveDate =
      data.status === EnumSubscriptionStatus.Deleted
        ? data.subscriptionData.paddleCancellationEffectiveDate
        : null;

    return this.transformPrismaObject(
      await this.prisma.subscription.update({
        where: {
          id: subscriptionToUpdate.id
        },
        data: {
          status: data.status,
          subscriptionPlan: data.plan,
          cancellationEffectiveDate: cancellationEffectiveDate,
          subscriptionData: (data.subscriptionData as unknown) as Prisma.InputJsonValue
        }
      })
    );
  }