Newer
Older
sendgrid-api / src / main / java / io / ljunggren / sendgrid / api / SendgridApi.java
package io.ljunggren.sendgrid.api;

import java.util.List;
import java.util.Map;

import io.ljunggren.sendgrid.api.exception.SendgridException;
import io.ljunggren.sendgrid.api.model.Statistics;
import io.ljunggren.sendgrid.api.service.EmailService;
import io.ljunggren.sendgrid.api.service.UsageService;

public class SendgridApi {
	
	private EmailService emailService;
	private UsageService usageService;
	
	public SendgridApi(String apiKey) {
		this.emailService = new EmailService(apiKey);
		this.usageService = new UsageService(apiKey);
	}
	
	public void sendEmail(String from, String to, String subject, String body) throws SendgridException {
		emailService.sendEmail(from, to, subject, body);
	}
	
	public void sendTemplateEmail(String templateId, String from, String to, Map<String, Object> templateData) throws SendgridException {
		emailService.sendTemplateEmail(templateId, from, to, templateData);
	}
	
	public List<Statistics> getDailyUsage() throws SendgridException {
		return usageService.getDailyUsage();
	}
	
	public List<Statistics> getMonthlyStatistics() throws SendgridException {
		return usageService.getMonthlyStatistics();
	}
	
	public List<Statistics> getStatistics(int days) throws SendgridException {
		return usageService.getStatistics(days);
	}

}