write and fill up the missing java code 'package com.ipsummusic.challenge.controllers;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.stripe.exception.StripeException;
import com.stripe.model.Charge;
import com.stripe.model.ChargeCollection;
import com.stripe.model.Customer;
import com.stripe.model.CustomerCollection;
import com.stripe.model.PaymentIntent;
import com.stripe.model.PaymentIntentCollection;
import com.stripe.model.PaymentMethod;
import com.stripe.model.PaymentMethodCollection;
import com.stripe.model.Refund;
import com.stripe.model.SetupIntent;
import com.stripe.model.SetupIntentCollection;
import com.stripe.param.ChargeListParams;
import com.stripe.param.CustomerCreateParams;
import com.stripe.param.CustomerUpdateParams;
import com.stripe.param.PaymentIntentCaptureParams;
import com.stripe.param.PaymentIntentCreateParams;
import com.stripe.param.PaymentIntentCreateParams.CaptureMethod;
import com.stripe.param.PaymentIntentListParams;
import com.stripe.param.SetupIntentListParams;

import io.github.cdimascio.dotenv.Dotenv;
import spark.Request;
import spark.Response;
import spark.Route;

public class ChallengeController {

    private static Gson gson = new Gson();

    /**
     * Get Config
     * Fetch the Stripe publishable key
     * Example call:
     * curl -X GET http://localhost:4242/config \
     * Returns: a JSON response of the pubblishable key
     * {
     * key: <STRIPE_PUBLISHABLE_KEY>
     * }
     */
    public static Route getConfig = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    public static Route setupIntentLesson = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        String customerId = null;
        String clientSecret = null;
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    public static Route successfulLesson = (Request request, Response response) -> {

        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    // Milestone 2: '/schedule-lesson'
    // Authorize a payment for a lesson
    //
    // Parameters:
    // customer_id: id of the customer
    // amount: amount of the lesson in cents
    // description: a description of this lesson
    //
    // Example call:
    // curl -X POST http://localhost:4242/schdeule-lesson \
    // -d customer_id=cus_GlY8vzEaWTFmps \
    // -d amount=4500 \
    // -d description='Lesson on Feb 25th'
    //
    // Returns: a JSON response of one of the following forms:
    // For a successful payment, return the Payment Intent:
    // {
    // payment: <payment_intent>
    // }
    //
    // For errors:
    // {
    // error:
    // code: the code returned from the Stripe error if there was one
    // message: the message returned from the Stripe error. if no payment method was
    // found for that customer return an msg 'no payment methods found for
    // <customer_id>'
    // payment_intent_id: if a payment intent was created but not successfully
    // authorized
    // }
    public static Route scheduleLesson = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    // Milestone 2: '/complete-lesson-payment'
    // Capture a payment for a lesson.
    //
    // Parameters:
    // amount: (optional) amount to capture if different than the original amount
    // authorized
    //
    // Example call:
    // curl -X POST http://localhost:4242/complete_lesson_payment \
    // -d payment_intent_id=pi_XXX \
    // -d amount=4500
    //
    // Returns: a JSON response of one of the following forms:
    //
    // For a successful payment, return the payment intent:
    // {
    // payment: <payment_intent>
    // }
    //
    // for errors:
    // {
    // error:
    // code: the code returned from the error
    // message: the message returned from the error from Stripe
    // }
    //

    public static Route completeLessonPayment = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };
    // Milestone 2: '/refund-lesson'
    // Refunds a lesson payment. Refund the payment from the customer (or cancel the
    // auth
    // if a payment hasn't occurred).
    // Sets the refund reason to 'requested_by_customer'
    //
    // Parameters:
    // payment_intent_id: the payment intent to refund
    // amount: (optional) amount to refund if different than the original payment
    //
    // Example call:
    // curl -X POST http://localhost:4242/refund-lesson \
    // -d payment_intent_id=pi_XXX \
    // -d amount=2500
    //
    // Returns
    // If the refund is successfully created returns a JSON response of the format:
    //
    // {
    // refund: refund.id
    // }
    //
    // If there was an error:
    // {
    // error: {
    // code: e.error.code,
    // message: e.error.message
    // }
    // }

    public static Route refundLesson = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    // Milestone 3: Managing account info
    // Displays the account update page for a given customer
    public static Route accountUpdate = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    // Milestone 3: '/delete-account'
    // Deletes a customer object if there are no uncaptured payment intents for
    // them.
    //
    // Parameters:
    // customer_id: the id of the customer to delete
    //
    // Example request
    // curl -X POST http://localhost:4242/delete-account/:customer_id \
    //
    // Returns 1 of 3 responses:
    // If the customer had no uncaptured charges and was successfully deleted
    // returns the response:
    // {
    // deleted: true
    // }
    //
    // If the customer had uncaptured payment intents, return a list of the payment
    // intent ids:
    // {
    // uncaptured_payments: ids of any uncaptured payment intents
    // }
    //
    // If there was an error:
    // {
    // error: {
    // code: e.error.code,
    // message: e.error.message
    // }
    // }
    //
    public static Route deleteAccount = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    public static Route paymentMethod = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    public static Route updatePaymentDetails = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };
    

    // Milestone 4: '/calculate-lesson-total'
    // Returns the total amounts for payments for lessons, ignoring payments
    // for videos and concert tickets, ranging over the last 36 hours.
    // 
    // Example call: curl -X GET http://localhost:4242/calculate-lesson-total
    // 
    // Returns a JSON response of the format:
    // {
    //      payment_total: Total before fees and refunds (including disputes), and excluding payments
    //         that haven't yet been captured.
    //      fee_total: Total amount in fees that the store has paid to Stripe
    //      net_total: Total amount the store has collected from payments, minus their fees.
    // }
    public static Route calculateLessonTotal = (Request request, Response response) -> {
        Map<String, Object> responseWrapper = new HashMap<String, Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseWrapper);
    };

    public static Route findCustomersWithFailedPayments = (Request request, Response response) -> {
        List<Object> responseList = new ArrayList<Object>();
        response.type("application/json");
        // TODO: Integrate Stripe
        return gson.toJson(responseList);
    };
}