<?php

namespace Brandy\Newsletter;

use Brandy\Newsletter\Providers\BrevoNewsletterProvider;
use Brandy\Newsletter\Providers\MailChimpNewsletterProvider;

class NewsletterProviderFactory {
	public static function create( $provider = '', $api_key = '' ) {

		if ( empty( $api_key ) ) {
			$settings = get_option( 'brandy_extensions', array() )['newsletter'] ?? array();
			$api_key  = $settings['api_key'] ?? '';
		}

		switch ( $provider ) {
			case 'brevo':
				return new BrevoNewsletterProvider( $api_key );
			case 'mailchimp':
				return new MailChimpNewsletterProvider( $api_key );
			default:
				return null;
		}
	}
}
