Package com.appspot.finajjarane.framework.service.impl

Source Code of com.appspot.finajjarane.framework.service.impl.TwitterService

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;
  }

}
TOP

Related Classes of com.appspot.finajjarane.framework.service.impl.TwitterService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.