// Path: src/main/java/com/twocheckout/model/Sale.java
// public class Sale {
//     private long sale_id;
//     private String ip_address;
//     private String ip_country;
//     private RecurringDecline recurring_decline;
//     private Invoice[] invoices;
//     private Comments[] comments;
// 
//     public long getSaleId() {
//         return sale_id;
//     }
//     
//     public String getIpAddress() {
//         return ip_address;
//     }
//     
//     public String getIpCountry() {
//         return ip_country;
//     }
//     
//     public RecurringDecline getRecurringDecline() {
//         return recurring_decline;
//     }
//     
//     public Invoice[] getInvoices() {
//         return invoices;
//     }
//     
//     public Comments[] getComments() {
//         return comments;
//     }
//     
//     public TwocheckoutResponse refund(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/refund_invoice";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse comment(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));;
//         String urlSuffix = "/api/sales/create_comment";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse ship(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/mark_shipped";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse stop() throws TwocheckoutException {
//         String urlSuffix = "/api/sales/stop_lineitem_recurring";
//         Invoice invoice = invoices[invoices.length-1];
//         Lineitem[] lineitems = invoice.getLineitems();
//         String stopped_lineitems = null;
//         StringBuffer stopped_lineitems_buffer = new StringBuffer();
//         HashMap<String, String> params = new HashMap<String, String>();
//         for(int i = 0;i< lineitems.length; i++){
//             if (lineitems[i].getBilling().getRecurringStatus() != null) {
//                 if (lineitems[i].getBilling().getRecurringStatus().equals("active")) {
//                     params.put("lineitem_id", String.valueOf(lineitems[i].getBilling().getLineitemId()));
//                     String response = TwocheckoutApi.post(urlSuffix, params);
//                     TwocheckoutResponse resultObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//                     if(resultObj.getResponseCode().equals("OK")) {
//                         stopped_lineitems_buffer.append(",").append(String.valueOf(lineitems[i].getLineitemID()));
//                     }
//                 }
//             }
//         }
//         stopped_lineitems = stopped_lineitems_buffer.toString();
//         TwocheckoutResponse responseObj = new TwocheckoutResponse();
//         if (stopped_lineitems.length() == 0) {
//             responseObj.setResponseCode("OK");
//             responseObj.setResponseMessage("No active recurring lineitems.");
//         } else {
//             stopped_lineitems = stopped_lineitems.substring(1);
//             responseObj.setResponseCode("OK");
//             responseObj.setResponseMessage(stopped_lineitems);
//         }
//         return responseObj;
//     }
//     
//     public Sale refresh() throws TwocheckoutException {
//         HashMap<String, String> args = new HashMap<String, String>();
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/detail_sale";
//         String response = TwocheckoutApi.get(urlSuffix, args);
//         TwocheckoutSale responseObj = new Gson().fromJson(response, TwocheckoutSale.class);
//         response = new Gson().toJson(responseObj.sale);
//         Sale resultObj = new Gson().fromJson(response, Sale.class);
//         return resultObj;
//     }
//     
// }
// 
// Path: src/main/java/com/twocheckout/model/SaleList.java
// public class SaleList {
//     private PageInfo page_info;
//     private Sales[] sale_summary;
// 
//     public PageInfo getPageInfo() {
//         return page_info;
//     }
// 
//     public Sales[] getSales() {
//         return sale_summary;
//     }
// }


import com.google.gson.Gson;
import com.twocheckout.model.Sale;
import com.twocheckout.model.SaleList;
import java.util.HashMap;

package com.twocheckout;


public class TwocheckoutSale extends TwocheckoutApi {

    public Sale sale;

    public static Sale retrieve(String sale_id) throws TwocheckoutException {
        String urlSuffix = "/api/sales/detail_sale";
        HashMap<String, String> args = new HashMap<String, String>();
        args.put("sale_id", sale_id);
        String response = TwocheckoutApi.get(urlSuffix, args);
        TwocheckoutSale resultObj = new Gson().fromJson(response, TwocheckoutSale.class);
        response = new Gson().toJson(resultObj.sale);
        Sale responseObj = new Gson().fromJson(response, Sale.class);
        return responseObj;
    }


// Path: src/main/java/com/twocheckout/model/Sale.java
// public class Sale {
//     private long sale_id;
//     private String ip_address;
//     private String ip_country;
//     private RecurringDecline recurring_decline;
//     private Invoice[] invoices;
//     private Comments[] comments;
// 
//     public long getSaleId() {
//         return sale_id;
//     }
//     
//     public String getIpAddress() {
//         return ip_address;
//     }
//     
//     public String getIpCountry() {
//         return ip_country;
//     }
//     
//     public RecurringDecline getRecurringDecline() {
//         return recurring_decline;
//     }
//     
//     public Invoice[] getInvoices() {
//         return invoices;
//     }
//     
//     public Comments[] getComments() {
//         return comments;
//     }
//     
//     public TwocheckoutResponse refund(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/refund_invoice";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse comment(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));;
//         String urlSuffix = "/api/sales/create_comment";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse ship(HashMap<String, String> args) throws TwocheckoutException {
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/mark_shipped";
//         String response = TwocheckoutApi.post(urlSuffix, args);
//         TwocheckoutResponse responseObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//         return responseObj;
//     }
//     
//     public TwocheckoutResponse stop() throws TwocheckoutException {
//         String urlSuffix = "/api/sales/stop_lineitem_recurring";
//         Invoice invoice = invoices[invoices.length-1];
//         Lineitem[] lineitems = invoice.getLineitems();
//         String stopped_lineitems = null;
//         StringBuffer stopped_lineitems_buffer = new StringBuffer();
//         HashMap<String, String> params = new HashMap<String, String>();
//         for(int i = 0;i< lineitems.length; i++){
//             if (lineitems[i].getBilling().getRecurringStatus() != null) {
//                 if (lineitems[i].getBilling().getRecurringStatus().equals("active")) {
//                     params.put("lineitem_id", String.valueOf(lineitems[i].getBilling().getLineitemId()));
//                     String response = TwocheckoutApi.post(urlSuffix, params);
//                     TwocheckoutResponse resultObj = new Gson().fromJson(response, TwocheckoutResponse.class);
//                     if(resultObj.getResponseCode().equals("OK")) {
//                         stopped_lineitems_buffer.append(",").append(String.valueOf(lineitems[i].getLineitemID()));
//                     }
//                 }
//             }
//         }
//         stopped_lineitems = stopped_lineitems_buffer.toString();
//         TwocheckoutResponse responseObj = new TwocheckoutResponse();
//         if (stopped_lineitems.length() == 0) {
//             responseObj.setResponseCode("OK");
//             responseObj.setResponseMessage("No active recurring lineitems.");
//         } else {
//             stopped_lineitems = stopped_lineitems.substring(1);
//             responseObj.setResponseCode("OK");
//             responseObj.setResponseMessage(stopped_lineitems);
//         }
//         return responseObj;
//     }
//     
//     public Sale refresh() throws TwocheckoutException {
//         HashMap<String, String> args = new HashMap<String, String>();
//         args.put("sale_id", String.valueOf(sale_id));
//         String urlSuffix = "/api/sales/detail_sale";
//         String response = TwocheckoutApi.get(urlSuffix, args);
//         TwocheckoutSale responseObj = new Gson().fromJson(response, TwocheckoutSale.class);
//         response = new Gson().toJson(responseObj.sale);
//         Sale resultObj = new Gson().fromJson(response, Sale.class);
//         return resultObj;
//     }
//     
// }
// 
// Path: src/main/java/com/twocheckout/model/SaleList.java
// public class SaleList {
//     private PageInfo page_info;
//     private Sales[] sale_summary;
// 
//     public PageInfo getPageInfo() {
//         return page_info;
//     }
// 
//     public Sales[] getSales() {
//         return sale_summary;
//     }
// }


// Path: src/main/java/com/twocheckout/TwocheckoutSale.java
import com.google.gson.Gson;
import com.twocheckout.model.Sale;
import com.twocheckout.model.SaleList;
import java.util.HashMap;

package com.twocheckout;


public class TwocheckoutSale extends TwocheckoutApi {

    public Sale sale;

    public static Sale retrieve(String sale_id) throws TwocheckoutException {
        String urlSuffix = "/api/sales/detail_sale";
        HashMap<String, String> args = new HashMap<String, String>();
        args.put("sale_id", sale_id);
        String response = TwocheckoutApi.get(urlSuffix, args);
        TwocheckoutSale resultObj = new Gson().fromJson(response, TwocheckoutSale.class);
        response = new Gson().toJson(resultObj.sale);
        Sale responseObj = new Gson().fromJson(response, Sale.class);
        return responseObj;
    }


    public static SaleList list(HashMap<String, String> args) throws TwocheckoutException {
