0.1.6Updated a month ago
declare namespace Supply {
  interface Allotment {
    id?: number

    item_key: string
    user_key: string

    timestamp: Date

    reference?: string
    source?: string

    expired?: boolean
    expiry_timestamp?: Date

    reserved?: boolean
  }

  namespace Allotment {
    namespace Function {
      interface AllotmentResponse {
        new_allotment_id: number,
        new_allotment_timestamp: Date,
        user_total_earned_value: number,
      }

      interface ClaimResponseSuccess {
        claimed: true
        allotment: Allotment
      }

      interface ClaimResponseFailure {
        claimed: false
        reason: string
      }

      type ClaimResponse = ClaimResponseSuccess | ClaimResponseFailure

      interface DeleteResponseSuccess {
        deleted: true
        allotment: Allotment
      }

      interface DeleteResponseFailure {
        deleted: false
        reason: string
      }

      type DeleteResponse = DeleteResponseSuccess | DeleteResponseFailure
    }

    type Unentered = Omit<Allotment, 'id' | 'timestamp' | 'expired' | 'expiry_timestamp'>

    interface AllotResponseFailure {
      allotted: false
      reason: string
    }

    interface AllotResponseSuccess {
      allotted: true
    }

    type Response = AllotResponseFailure | AllotResponseSuccess

    interface ArchiveResponseFailure {
      archived: false
      reason: string
    }

    interface ArchiveResponseSuccess {
      archived: true
    }

    type ArchiveResponse = ArchiveResponseFailure | ArchiveResponseSuccess
  }
}