Options
All
  • Public
  • Public/Protected
  • All
Menu

Class User

Data container for user data with static methods for interfacing with hackerapi

class
extends

{ HackerAPI.Base }

Hierarchy

Index

Constructors

constructor

  • new User(__namedParameters?: { address: undefined | AddressList; age: undefined | null | number; allergies: undefined | string[]; avatar: undefined | null | string; bio: undefined | null | string; createdAt: undefined | Date; created_at: undefined | Date; dateOfBirth: undefined | null | string; date_of_birth: undefined | string; email: undefined | string; emergencyContact: undefined | null | EmergencyContact; emergency_contact: undefined | EmergencyContact; ethnicity: undefined | null | string; eventRoles: undefined | Attendee[]; event_roles: undefined | Attendee[]; foodRestrictions: undefined | string[]; food_restrictions: undefined | string[]; gender: undefined | null | MALE | FEMALE | PREFER_NOT_TO_SPECIFY | OTHER; id: undefined | number; legalName: undefined | null | string; legal_name: undefined | string; name: undefined | string; nativeLanguage: undefined | null | string; native_language: undefined | string; organizations: undefined | Organization[]; phoneNumber: undefined | null | string; phone_number: undefined | string; roles: undefined | RoleList; shirtSize: undefined | null | number; shirt_size: undefined | number; updatedAt: undefined | Date; updated_at: undefined | Date }): User
  • Creates a new User instance

    constructor

    Parameters

    • Default value __namedParameters: { address: undefined | AddressList; age: undefined | null | number; allergies: undefined | string[]; avatar: undefined | null | string; bio: undefined | null | string; createdAt: undefined | Date; created_at: undefined | Date; dateOfBirth: undefined | null | string; date_of_birth: undefined | string; email: undefined | string; emergencyContact: undefined | null | EmergencyContact; emergency_contact: undefined | EmergencyContact; ethnicity: undefined | null | string; eventRoles: undefined | Attendee[]; event_roles: undefined | Attendee[]; foodRestrictions: undefined | string[]; food_restrictions: undefined | string[]; gender: undefined | null | MALE | FEMALE | PREFER_NOT_TO_SPECIFY | OTHER; id: undefined | number; legalName: undefined | null | string; legal_name: undefined | string; name: undefined | string; nativeLanguage: undefined | null | string; native_language: undefined | string; organizations: undefined | Organization[]; phoneNumber: undefined | null | string; phone_number: undefined | string; roles: undefined | RoleList; shirtSize: undefined | null | number; shirt_size: undefined | number; updatedAt: undefined | Date; updated_at: undefined | Date } = {}
      • address: undefined | AddressList
      • age: undefined | null | number
      • allergies: undefined | string[]
      • avatar: undefined | null | string
      • bio: undefined | null | string
      • createdAt: undefined | Date
      • created_at: undefined | Date
      • dateOfBirth: undefined | null | string
      • date_of_birth: undefined | string
      • email: undefined | string
      • emergencyContact: undefined | null | EmergencyContact
      • emergency_contact: undefined | EmergencyContact
      • ethnicity: undefined | null | string
      • eventRoles: undefined | Attendee[]
      • event_roles: undefined | Attendee[]
      • foodRestrictions: undefined | string[]
      • food_restrictions: undefined | string[]
      • gender: undefined | null | MALE | FEMALE | PREFER_NOT_TO_SPECIFY | OTHER
      • id: undefined | number
      • legalName: undefined | null | string
      • legal_name: undefined | string
      • name: undefined | string
      • nativeLanguage: undefined | null | string
      • native_language: undefined | string
      • organizations: undefined | Organization[]
      • phoneNumber: undefined | null | string
      • phone_number: undefined | string
      • roles: undefined | RoleList
      • shirtSize: undefined | null | number
      • shirt_size: undefined | number
      • updatedAt: undefined | Date
      • updated_at: undefined | Date

    Returns User

Properties

Optional address

address: AddressList

Optional age

age: number | null

Optional allergies

allergies: string[]

Optional avatar

avatar: string | null

Optional bio

bio: string | null

Optional createdAt

createdAt: Date

Optional dateOfBirth

dateOfBirth: string | null

Optional email

email: undefined | string

Optional emergencyContact

emergencyContact: EmergencyContact | null

Optional ethnicity

ethnicity: string | null

Optional eventRoles

eventRoles: Attendee[]

Optional foodRestrictions

foodRestrictions: string[]

Optional gender

gender: Gender | null

Optional id

id: undefined | number

Optional legalName

legalName: string | null

Optional name

name: undefined | string

Optional nativeLanguage

nativeLanguage: string | null

Optional organizations

organizations: Organization[]

Optional phoneNumber

phoneNumber: string | null

Optional roles

roles: RoleList

Optional shirtSize

shirtSize: number | null

specialHandlers

specialHandlers: {}

Type declaration

  • [key: string]: (...args: unknown[]) => [string, undefined | string]
      • (...args: unknown[]): [string, undefined | string]
      • Parameters

        • Rest ...args: unknown[]

        Returns [string, undefined | string]

Optional updatedAt

updatedAt: Date

Accessors

Static AddressList

Static EmergencyContact

Static Gender

Static Hacker

Static MailEvent

Static Mentor

Static RoleList

Static Sponsor

Methods

toHackerAPIFormat

  • toHackerAPIFormat(method?: undefined | string): {}

Static create

  • create(user: User & { password?: undefined | string }, __namedParameters: { password: string }): Promise<{}>
  • Creates a new user on hackerapi

    Parameters

    • user: User & { password?: undefined | string }
    • __namedParameters: { password: string }
      • password: string

    Returns Promise<{}>

Static dateHandler

  • dateHandler(key: string, date: string | Date): string[]
  • Converts a Javascript date (where only day, month and year are relevant) to a format understood by hackerapi

    Parameters

    • key: string
    • date: string | Date

      Doesn't do anything if string

    Returns string[]

    key: [0], value: [1]

Static dateTimeHandler

  • dateTimeHandler(key: string, datetime: string | Date): string[]
  • Converts Javascript date to a format understood by hackerapi

    Parameters

    • key: string
    • datetime: string | Date

    Returns string[]

    key: [0], value: [1]

Static delete

  • delete(__namedParameters: { id: number | "me" }, token?: undefined | string): Promise<null>
  • Deletes a user from hackerapi

    Parameters

    • __namedParameters: { id: number | "me" }
      • id: number | "me"
    • Optional token: undefined | string

    Returns Promise<null>

Static doNotSendHandler

  • doNotSendHandler(key: string, _: any): (undefined | string)[]
  • Does not send the field to hackerapi

    Parameters

    • key: string
    • _: any

    Returns (undefined | string)[]

    key: [0], value: [1]

Static fetch

  • fetch(__namedParameters?: { id: number | "me" }, token?: undefined | string): Promise<{}>
  • Fetches a user from hackerapi

    Parameters

    • Default value __namedParameters: { id: number | "me" } = { id: "me" }
      • id: number | "me"
    • Optional token: undefined | string

    Returns Promise<{}>

Static fetchBadge

  • fetchBadge(__namedParameters?: { id: number | "me" }, role?: string, token?: undefined | string): Promise<string>
  • Fetches a user's badge for the event as a data uri

    Parameters

    • Default value __namedParameters: { id: number | "me" } = { id: "me" }
      • id: number | "me"
    • Default value role: string = "hacker"

      The user's role at the event

    • Optional token: undefined | string

    Returns Promise<string>

Static fetchFiles

  • Fetches all the files belonging to a user, applying the appropriate filters

    see

    HackerAPI.File.fetchAllByUserId - This is just a wrapper function

    Parameters

    Returns Promise<{}>

Static fetchSlackId

  • fetchSlackId(__namedParameters?: { id: number | "me" }, token?: undefined | string): Promise<string>
  • Fetches the slack ID of a user

    throws

    { HackerAPI.Error } - Throws an error if the user hasn't joined slack

    todo

    Better error handling for 404s

    Parameters

    • Default value __namedParameters: { id: number | "me" } = { id: "me" }
      • id: number | "me"
    • Optional token: undefined | string

    Returns Promise<string>

Static renameHandler

  • renameHandler(renamedKey: string): (Anonymous function)
  • HOC for renaming a field before sending it to hackerapi

    Parameters

    • renamedKey: string

      The string to rename the key to

    Returns (Anonymous function)

    key: [0], value: [1]

Static update

  • update(user: User, token?: undefined | string): Promise<{}>
  • Updates a user on hackerapi

    Parameters

    • user: User
    • Optional token: undefined | string

    Returns Promise<{}>

Static updateMe

  • updateMe(user: User, token?: undefined | string): Promise<{}>
  • Updates a user on hackerapi based on the token they authenticate with

    Parameters

    • user: User
    • Optional token: undefined | string

    Returns Promise<{}>

Static uploadAvatar

  • uploadAvatar(__namedParameters?: { id: number | "me" }, formData: { file: string | Blob; type: string } | FormData, token?: undefined | string): Promise<File>
  • Uploads an avatar for the user

    todo

    Test this bad boy

    Parameters

    • Default value __namedParameters: { id: number | "me" } = { id: "me" }
      • id: number | "me"
    • formData: { file: string | Blob; type: string } | FormData
    • Optional token: undefined | string

    Returns Promise<File>

Generated using TypeDoc