package com.appspot.finajjarane.framework.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.twitter.api.Tweet;
import org.springframework.stereotype.Service;
import com.appspot.finajjarane.framework.generic.Utils;
import com.appspot.finajjarane.framework.models.TweetModel;
import com.appspot.finajjarane.framework.service.ITwitterService;
import com.appspot.finajjarane.framework.social.ITwitter;
@Service
public class TwitterService implements ITwitterService {
@Autowired
ITwitter iTwitter;
@Override
public List<TweetModel> getTweetsInHomeTimeline() {
List<Tweet> tweets = iTwitter.getLatestTweets();
List<TweetModel> tweetModelList = new ArrayList<TweetModel>();
for (Tweet tweet : tweets) {
TweetModel tweetModel = new TweetModel();
tweetModel.setTweet(tweet.getText());
tweetModel.setLogoUrl(tweet.getProfileImageUrl());
tweetModel.setUserName(tweet.getFromUser());
tweetModel.setDate(Utils.dateToDateDetailsModel(tweet.getCreatedAt()));
tweetModelList.add(tweetModel);
}
return tweetModelList;
}
}