package reddit.pojo.processing;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import chatbot.client.MessageDispatcher;
import chatbot.client.ResponseProcessor;
import reddit.pojo.SubredditJson;
public class RedditJSonProcessor implements ResponseProcessor {
private static final Logger logger = LoggerFactory.getLogger(RedditJSonProcessor.class);
private MessageDispatcher dispatcher;
public RedditJSonProcessor(MessageDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
@Override
public void processMessage(String jsonResponse) {
SubredditJson subreddit = SubredditJsonUnmarshaller.unmarshalJson(jsonResponse);
logger.info("Json response successfully unmarshalled: {}", jsonResponse);
dispatcher.dispatchMessage(subreddit.toString());
}
}