package cashfree;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class CreateSubscriptionRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    // Subscription

    private String subscription_id;

    // Customer Details

    private String customer_name;
    private String customer_email;
    private String customer_phone;

    private String customer_bank_account_holder_name;
    private String customer_bank_account_number;
    private String customer_bank_ifsc;
    private String customer_bank_code;
    private String customer_bank_account_type;

    // Plan Details

    // ===== ON_DEMAND =====
    private String plan_id;           // NOT NEEDED (skip)
    private String plan_name;         // Recommended - unique, easy reference
    private String plan_type = "ON_DEMAND"; // REQUIRED

    private double plan_amount;       // NOT NEEDED (only for PERIODIC)
    private double plan_max_amount;   // REQUIRED - max loan amount (e.g. 100000)
    private int plan_max_cycles;      // OPTIONAL - limit total debits (e.g. 12 EMIs)
    private int plan_intervals;       // NOT NEEDED (only for PERIODIC)

    private String plan_currency = "INR"; // Recommended
    private String plan_interval_type;    // NOT NEEDED (only for PERIODIC)
    private String plan_note;             // Optional

    // Authorization Details

    private double authorization_amount=0;
    private boolean authorization_amount_refund=true;
    private List<String> payment_methods = Arrays.asList("enach", "pnach", "upi", "card");


    // Subscription Meta

    private String return_url;
    private List<String> notification_channel = Arrays.asList("EMAIL", "SMS");
    private String session_id_expiry = getExpiryTime(2); // 2 hours from now


    // Subscription Dates

    private String subscription_expiry_time;
    private String subscription_first_charge_time;

    // Subscription

    private String subscription_note;

    private Map<String, String> subscription_tags;

    // Helper method
    private String getExpiryTime(int hours) {
        ZonedDateTime expiry = ZonedDateTime.now(ZoneId.of("Asia/Kolkata"))
                                            .plusHours(hours);
        return expiry.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
    }
    
    // Getters & Setters

    public String getSubscription_id() {
        return subscription_id;
    }

    public void setSubscription_id(String subscription_id) {
        this.subscription_id = subscription_id;
    }

    public String getCustomer_name() {
        return customer_name;
    }

    public void setCustomer_name(String customer_name) {
        this.customer_name = customer_name;
    }

    public String getCustomer_email() {
        return customer_email;
    }

    public void setCustomer_email(String customer_email) {
        this.customer_email = customer_email;
    }

    public String getCustomer_phone() {
        return customer_phone;
    }

    public void setCustomer_phone(String customer_phone) {
        this.customer_phone = customer_phone;
    }

    public String getCustomer_bank_account_holder_name() {
        return customer_bank_account_holder_name;
    }

    public void setCustomer_bank_account_holder_name(
            String customer_bank_account_holder_name) {
        this.customer_bank_account_holder_name =
                customer_bank_account_holder_name;
    }

    public String getCustomer_bank_account_number() {
        return customer_bank_account_number;
    }

    public void setCustomer_bank_account_number(
            String customer_bank_account_number) {
        this.customer_bank_account_number =
                customer_bank_account_number;
    }

    public String getCustomer_bank_ifsc() {
        return customer_bank_ifsc;
    }

    public void setCustomer_bank_ifsc(String customer_bank_ifsc) {
        this.customer_bank_ifsc = customer_bank_ifsc;
    }

    public String getCustomer_bank_code() {
        return customer_bank_code;
    }

    public void setCustomer_bank_code(String customer_bank_code) {
        this.customer_bank_code = customer_bank_code;
    }

    public String getCustomer_bank_account_type() {
        return customer_bank_account_type;
    }

    public void setCustomer_bank_account_type(
            String customer_bank_account_type) {
        this.customer_bank_account_type =
                customer_bank_account_type;
    }


    // =========================================================
    // Plan Getters & Setters
    // =========================================================

    public String getPlan_id() {
        return plan_id;
    }

    public void setPlan_id(String plan_id) {
        this.plan_id = plan_id;
    }

    public String getPlan_name() {
        return plan_name;
    }

    public void setPlan_name(String plan_name) {
        this.plan_name = plan_name;
    }

    public String getPlan_type() {
        return plan_type;
    }

    public void setPlan_type(String plan_type) {
        this.plan_type = plan_type;
    }

    public double getPlan_amount() {
        return plan_amount;
    }

    public void setPlan_amount(double plan_amount) {
        this.plan_amount = plan_amount;
    }

    public double getPlan_max_amount() {
        return plan_max_amount;
    }

    public void setPlan_max_amount(double plan_max_amount) {
        this.plan_max_amount = plan_max_amount;
    }

    public int getPlan_max_cycles() {
        return plan_max_cycles;
    }

    public void setPlan_max_cycles(int plan_max_cycles) {
        this.plan_max_cycles = plan_max_cycles;
    }

    public int getPlan_intervals() {
        return plan_intervals;
    }

    public void setPlan_intervals(int plan_intervals) {
        this.plan_intervals = plan_intervals;
    }

    public String getPlan_currency() {
        return plan_currency;
    }

    public void setPlan_currency(String plan_currency) {
        this.plan_currency = plan_currency;
    }

    public String getPlan_interval_type() {
        return plan_interval_type;
    }

    public void setPlan_interval_type(String plan_interval_type) {
        this.plan_interval_type = plan_interval_type;
    }

    public String getPlan_note() {
        return plan_note;
    }

    public void setPlan_note(String plan_note) {
        this.plan_note = plan_note;
    }


    // =========================================================
    // Authorization Getters & Setters
    // =========================================================

    public double getAuthorization_amount() {
        return authorization_amount;
    }

    public void setAuthorization_amount(double authorization_amount) {
        this.authorization_amount = authorization_amount;
    }

    public boolean isAuthorization_amount_refund() {
        return authorization_amount_refund;
    }

    public void setAuthorization_amount_refund(
            boolean authorization_amount_refund) {
        this.authorization_amount_refund =
                authorization_amount_refund;
    }

    public List<String> getPayment_methods() {
        return payment_methods;
    }

    public void setPayment_methods(List<String> payment_methods) {
        this.payment_methods = payment_methods;
    }


    // =========================================================
    // Subscription Meta Getters & Setters
    // =========================================================

    public String getReturn_url() {
        return return_url;
    }

    public void setReturn_url(String return_url) {
        this.return_url = return_url;
    }

    public List<String> getNotification_channel() {
        return notification_channel;
    }

    public void setNotification_channel(
            List<String> notification_channel) {
        this.notification_channel = notification_channel;
    }

    public String getSession_id_expiry() {
        return session_id_expiry;
    }

    public void setSession_id_expiry(String session_id_expiry) {
        this.session_id_expiry = session_id_expiry;
    }


    // =========================================================
    // Subscription Date Getters & Setters
    // =========================================================

    public String getSubscription_expiry_time() {
        return subscription_expiry_time;
    }

    public void setSubscription_expiry_time(
            String subscription_expiry_time) {
        this.subscription_expiry_time =
                subscription_expiry_time;
    }

    public String getSubscription_first_charge_time() {
        return subscription_first_charge_time;
    }

    public void setSubscription_first_charge_time(
            String subscription_first_charge_time) {
        this.subscription_first_charge_time =
                subscription_first_charge_time;
    }

    public String getSubscription_note() {
        return subscription_note;
    }

    public void setSubscription_note(String subscription_note) {
        this.subscription_note = subscription_note;
    }

    public Map<String, String> getSubscription_tags() {
        return subscription_tags;
    }

    public void setSubscription_tags(
            Map<String, String> subscription_tags) {
        this.subscription_tags = subscription_tags;
    }
}