// Path: libs/payment/src/main/java/com/africastalking/payment/recipient/Consumer.java
// public final class Consumer {
// 
//     /*
//      * Payment Reasons
//      */
//     public static final String REASON_SALARY = "SalaryPayment";
//     public static final String REASON_SALARY_WITH_CHARGE = "SalaryPaymentWithWithdrawalChargePaid";
//     public static final String REASON_BUSINESS = "BusinessPayment";
//     public static final String REASON_BUSINESS_WITH_CHARGE = "BusinessPaymentWithWithdrawalChargePaid";
//     public static final String REASON_PROMOTION = "PromotionPayment";
// 
//     public String name;
//     public String phoneNumber;
//     public String currencyCode;
//     public float amount;
//     public String providerChannel;
// 
//     public String reason;
//     public HashMap<String, String> metadata = new HashMap<>();
// 
//     /**
//      * Consumer-type payment recipient, used in B2C transactions
//      * @param name Consumer name
//      * @param phoneNumber Consumer phone number
//      * @param amount Amount to transact, along with the currency code. e.g. KES 345
//      * @param reason Purpose for the payment. e.g. {@link com.africastalking.payment.recipient.Consumer Consumer.REASON_SALARY}
//      */
//     public Consumer(String name, String phoneNumber, String amount, String reason) {
//         this.name = name;
//         this.phoneNumber = phoneNumber;
//         this.reason = reason;
// 
//         try {
//             String[] currenciedAmount = amount.trim().split(" ");
//             this.currencyCode = currenciedAmount[0];
//             this.amount = Float.parseFloat(currenciedAmount[1]);
//         } catch (Exception ex) {
//             throw new RuntimeException(ex);
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// 
// }


import com.africastalking.*;
import com.africastalking.payment.recipient.Consumer;
import com.africastalking.voice.action.*;
import com.google.gson.Gson;
import java.io.IOException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;
import static spark.Spark.exception;
import static spark.Spark.get;
import static spark.Spark.port;
import static spark.Spark.post;
import static spark.Spark.staticFiles;
                    response
                            .say(new Say("Hello bot " + data.getOrDefault("callerNumber", "There")))
                            .getDigits(new GetDigits(new Say("Press 1 to listen to some song. Press 2 to tell me your name. Press 3 to talk to a human. Press 4 or hang up to quit"), 1, "#", null));
                    break;
                case "process":
                    switch (dtmf) {
                        case "1":
                            states.put(sessionId, "menu");
                            response
                                    .play(new Play(new URL(songUrl)))
                                    .redirect(new Redirect(new URL(baseUrl + "/voice")));
                            break;
                        case "2":
                            states.put(sessionId, "name");
                            response.record(new Record(new Say("Please say your full name after the beep"), "#", 30, 0, true, true, null));
                            break;
                        case "3":
                            states.remove(sessionId);
                            response
                                    .say(new Say("We are getting our resident human on the line for you, please wait while enjoying this nice tune. You have 30 seconds to enjoy a nice conversation with them"))
                                    .dial(new Dial(Arrays.asList("+254718769882"), false, false, null, new URL(songUrl), 30));
                            break;
                        case "4":
                            states.remove(sessionId);
                            response.say(new Say("Bye Bye, Long Live Our Machine Overlords")).reject(new Reject());
                            break;
                        default:
                            states.put(sessionId, "menu");
                            response
                                    .say(new Say("Invalid choice, try again and you will be exterminated!"))
// Path: libs/payment/src/main/java/com/africastalking/payment/recipient/Consumer.java
// public final class Consumer {
// 
//     /*
//      * Payment Reasons
//      */
//     public static final String REASON_SALARY = "SalaryPayment";
//     public static final String REASON_SALARY_WITH_CHARGE = "SalaryPaymentWithWithdrawalChargePaid";
//     public static final String REASON_BUSINESS = "BusinessPayment";
//     public static final String REASON_BUSINESS_WITH_CHARGE = "BusinessPaymentWithWithdrawalChargePaid";
//     public static final String REASON_PROMOTION = "PromotionPayment";
// 
//     public String name;
//     public String phoneNumber;
//     public String currencyCode;
//     public float amount;
//     public String providerChannel;
// 
//     public String reason;
//     public HashMap<String, String> metadata = new HashMap<>();
// 
//     /**
//      * Consumer-type payment recipient, used in B2C transactions
//      * @param name Consumer name
//      * @param phoneNumber Consumer phone number
//      * @param amount Amount to transact, along with the currency code. e.g. KES 345
//      * @param reason Purpose for the payment. e.g. {@link com.africastalking.payment.recipient.Consumer Consumer.REASON_SALARY}
//      */
//     public Consumer(String name, String phoneNumber, String amount, String reason) {
//         this.name = name;
//         this.phoneNumber = phoneNumber;
//         this.reason = reason;
// 
//         try {
//             String[] currenciedAmount = amount.trim().split(" ");
//             this.currencyCode = currenciedAmount[0];
//             this.amount = Float.parseFloat(currenciedAmount[1]);
//         } catch (Exception ex) {
//             throw new RuntimeException(ex);
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// 
// }


// Path: example/src/main/java/com/africastalking/example/App.java
import com.africastalking.*;
import com.africastalking.payment.recipient.Consumer;
import com.africastalking.voice.action.*;
import com.google.gson.Gson;
import java.io.IOException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;
import static spark.Spark.exception;
import static spark.Spark.get;
import static spark.Spark.port;
import static spark.Spark.post;
import static spark.Spark.staticFiles;

                    response
                            .say(new Say("Hello bot " + data.getOrDefault("callerNumber", "There")))
                            .getDigits(new GetDigits(new Say("Press 1 to listen to some song. Press 2 to tell me your name. Press 3 to talk to a human. Press 4 or hang up to quit"), 1, "#", null));
                    break;
                case "process":
                    switch (dtmf) {
                        case "1":
                            states.put(sessionId, "menu");
                            response
                                    .play(new Play(new URL(songUrl)))
                                    .redirect(new Redirect(new URL(baseUrl + "/voice")));
                            break;
                        case "2":
                            states.put(sessionId, "name");
                            response.record(new Record(new Say("Please say your full name after the beep"), "#", 30, 0, true, true, null));
                            break;
                        case "3":
                            states.remove(sessionId);
                            response
                                    .say(new Say("We are getting our resident human on the line for you, please wait while enjoying this nice tune. You have 30 seconds to enjoy a nice conversation with them"))
                                    .dial(new Dial(Arrays.asList("+254718769882"), false, false, null, new URL(songUrl), 30));
                            break;
                        case "4":
                            states.remove(sessionId);
                            response.say(new Say("Bye Bye, Long Live Our Machine Overlords")).reject(new Reject());
                            break;
                        default:
                            states.put(sessionId, "menu");
                            response
                                    .say(new Say("Invalid choice, try again and you will be exterminated!"))
                                    .redirect(new Redirect(new URL(baseUrl + "/voice")));