Skip to content

Commit

Permalink
feat: add method to get a single tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Apr 23, 2017
1 parent a0dcf60 commit 72552b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/app/twitter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class TwitterService {

getLatestTweets(): Observable<Tweet[]> {
const endpoint = `${this.apiHost}/1.1/statuses/user_timeline.json`;

const params = new URLSearchParams();
params.set('count', '200');
params.set('screen_name', 'realDonaldTrump');
Expand All @@ -34,4 +35,20 @@ export class TwitterService {
});
});
}

getTweet(id: string): Observable<Tweet> {
const endpoint = `${this.apiHost}/1.1/statuses/show.json`;

const params = new URLSearchParams();
params.set('id', id);
params.set('trim_user', 'true');
params.set('include_entities', 'false');

return this.http
.get(endpoint, { params })
.map(res => {
const tweet = <Tweet> res.json();
return { ...tweet, intensity: intensity(tweet.text) };
});
}
}

0 comments on commit 72552b1

Please sign in to comment.