Skip to content

Commit

Permalink
simplify the constructor for the Account model
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Mar 14, 2018
1 parent 560bf60 commit 6f6a679
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions app/src/models/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,27 @@ import { getDotComAPIEndpoint, IAPIEmail } from '../lib/api'
* This contains a token that will be used for operations that require authentication.
*/
export class Account {
/** The access token used to perform operations on behalf of this account */
public readonly token: string
/** The login name for this account */
public readonly login: string
/** The server for this account - GitHub or a GitHub Enterprise instance */
public readonly endpoint: string
/** The current list of email addresses associated with the account */
public readonly emails: ReadonlyArray<IAPIEmail>
/** The profile URL to render for this account */
public readonly avatarURL: string
/** The database id for this account */
public readonly id: number
/** The friendly name associated with this account */
public readonly name: string

/** Create an account which can be used to perform unauthenticated API actions */
public static anonymous(): Account {
return new Account('', getDotComAPIEndpoint(), '', [], '', -1, '')
}

public constructor(
login: string,
endpoint: string,
token: string,
emails: ReadonlyArray<IAPIEmail>,
avatarURL: string,
id: number,
name: string
) {
this.login = login
this.endpoint = endpoint
this.token = token
this.emails = emails
this.avatarURL = avatarURL
this.id = id
this.name = name
}
/** The login name for this account */
public readonly login: string,
/** The server for this account - GitHub or a GitHub Enterprise instance */
public readonly endpoint: string,
/** The access token used to perform operations on behalf of this account */
public readonly token: string,
/** The current list of email addresses associated with the account */
public readonly emails: ReadonlyArray<IAPIEmail>,
/** The profile URL to render for this account */
public readonly avatarURL: string,
/** The database id for this account */
public readonly id: number,
/** The friendly name associated with this account */
public readonly name: string
) {}

public withToken(token: string): Account {
return new Account(
Expand Down

0 comments on commit 6f6a679

Please sign in to comment.