idea-toolbox
    Preparing search index...

    Class ProjectSubscription

    Table: idea_projects_subscriptions.

    Indexes:

    • project-validUntil-index (LSI - all).
    • project-planId-index (LSI - all).
    • project-storeReferenceId-index (LSI - all).

    Hierarchy (View Summary)

    Index

    Constructors

    • Object initialization, setting all the default values.

      Parameters

      • OptionalnewData: any

        the data to load, optional

      • Optionaloptions: any

        custom options to apply; they will depend on the child resource

        Usually, there is no need to implement the constructor; implicitly, it will call the load of the child resource and therefore loading all the resources with default values. If needed, this is the suggested implementation:

        super();
        this.load(x);
        // ...

      Returns ProjectSubscription

    Properties

    autoRenewing: boolean

    If false, the subscription won't renew after its set expiration.

    managedByUser: MembershipSummary

    The user who manages the subscription.

    planId: string

    The id of the project plan.

    The platform from which the subscription has been completed. It will be possible to manage the subscription only from the platform in which it was firstly created.

    project: string

    Project / product key.

    storePlanId: string

    The id of the plan in the store.

    storeReceipt: string

    The original receipt of the subscription, to later on check with the store if a subscription is still active.

    storeReferenceId: string

    The store reference id for the subscription. It's an ID coming from the stores, used to double check that a purchase is actually linked to the subscriptionId. Stripe: id. iOS: original_transaction_id. Android: the first part of the orderId.

    subscriptionId: string

    The id of the subscription (the target of the subscription to a plan). Each project has its own meaning of it (e.g. teamId, userId, etc.). Note: it should be a unique id in the entire project; add prefixes accordingly.

    validUntil: number

    The timestamp until this subscription is active.

    Methods

    • Return an attribute in a cleaned standard that force-cast the element.

      Parameters

      • origin: any

        the origin attribute, to cast

      • castFunction: (x: any) => any

        the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.

      • OptionaldefaultVal: any

        if set, the fallback value instead of null

      Returns any

      cleaned attribute

    • Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.

      Parameters

      • origin: any[]

        the origin array, to cast and check

      • castFunction: (x: any) => any

        the cast function, e.g. x => String(x) or x => new CustomClass(x)

      • OptionaldefaultVal: any

        if set, the fallback value instead of null

      Returns any[]

      cleaned array

    • Load the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.

      Parameters

      • newData: any

        the data to load

      • safeData: any

        the attributes to force to specific values

      • Optionaloptions: any

        custom options to apply; they will depend on the child resource

        Typical implementation:

        super.safeLoad(newData, safeData);
        this.keyAttr = safeData.keyAttr;
        this.importantAttr = safeData.importantAttr;
        this.isDraft = safeData.isDraft;
        // ...

        Note well: there is no need to call this.load(), since it's implicitly called from super.safeLoad(), which will anyway use the child version of the method.

      Returns void

    • Valide the object's attributes, performing all the checkings.

      Parameters

      • Optionaloptions: any

        custom options to apply; they will depend on the implementations

      Returns string[]

      errors if empty, the checkings are successfully passed.

      Typical implementation:

      const e = super.validate();
      if(this.iE(this.attr)) e.push(`attr`);
      // ...
      return e;