Skip to content

Commit

Permalink
feat(dao): retrieve twarrt reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Feb 13, 2019
1 parent 049bd80 commit 17c27ec
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/dao/StreamDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export interface IStreamOptions {
}

export class StreamDAO extends AbstractDAO {
/**
* Retrieve a collection of twarrts.
*/
public async posts(streamOptions?: IStreamOptions) {
const options = new TwitarrHTTPOptions()
.withParameter('app', 'plain');
Expand All @@ -54,6 +57,9 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Retrieve a particular twarrt (including its children).
*/
public async thread(id: string, limit?: number, page?: number) {
const options = new TwitarrHTTPOptions()
.withParameter('app', 'plain');
Expand All @@ -68,6 +74,9 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Retrieve a list of twarrts that mention a particular user.
*/
public async mentions(username: string, limit?: number, page?: number, after?: Moment) {
const options = new TwitarrHTTPOptions()
.withParameter('app', 'plain');
Expand All @@ -85,6 +94,9 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Retrieve a list of twarrts that contain a particular hashtag.
*/
public async hashtag(hashtag: string, limit?: number, page?: number, after?: Moment) {
const options = new TwitarrHTTPOptions()
.withParameter('app', 'plain');
Expand All @@ -102,6 +114,9 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Send a new twarrt.
*/
public async send(message: string, parent?: string, photo?: string) {
const options = new TwitarrHTTPOptions()
.withData({
Expand All @@ -118,6 +133,9 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Edit an existing twarrt.
*/
public async updatePost(id: string, message: string, photo?: string) {
const options = new TwitarrHTTPOptions()
.withData({
Expand All @@ -131,30 +149,54 @@ export class StreamDAO extends AbstractDAO {
});
}

/**
* Delete a twarrt.
*/
public async deletePost(id: string) {
return this.http.httpDelete('/api/v2/tweet/' + id).then(() => {
return true;
});
}

/**
* Lock a twarrt.
*/
public async lockPost(id: string) {
return this.http.post('/api/v2/tweet/' + id + '/locked/true').then((result) => {
return result.data.locked as boolean;
});
}

/**
* Unlock a twarrt.
*/
public async unlockPost(id: string) {
return this.http.post('/api/v2/tweet/' + id + '/locked/false').then((result) => {
return result.data.locked as boolean;
});
}

/**
* Retrieve the reactions to a twarrt.
*/
public async reactions(id: string) {
return this.http.get('/api/v2/tweet/' + id + '/react').then((result) => {
return ReactionsSummary.fromRest(result.data.reactions);
});
}

/**
* Add a reaction to a twarrt.
*/
public async react(id: string, reaction: string) {
return this.http.post('/api/v2/tweet/' + id + '/react/' + reaction).then((result) => {
return ReactionsSummary.fromRest(result.data.reactions);
});
}

/**
* Remove a reaction from a twarrt.
*/
public async deleteReact(id: string, reaction: string) {
return this.http.httpDelete('/api/v2/tweet/' + id + '/react/' + reaction).then((result) => {
return ReactionsSummary.fromRest(result.data.reactions);
Expand Down

0 comments on commit 17c27ec

Please sign in to comment.