package ca.ualberta.cs.linkai.beep;

import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.phenotype.Flag;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import io.searchbox.annotations.JestId;

/**
 * This is activity deal with request
 * @author Linkai, Jinzhu
 */

public class Request {

    @JestId
    private  String id;
    private Account initiator;
    private LatLng startLocation;
    private LatLng endLocation;
    private String start;
    private String end;
    private String reason;
    private Float estimate;
    private Payment payment;
    private ArrayList<Account> acceptances = new ArrayList<Account>();
    private Account confirmedDriver;
    private Date date;
    private Integer status;
    private DateFormat dateFormat;
    private String datestring;
    private float mRating;

    /**
     * Constructor initialize the request
      * @param initiator
     * @param start
     * @param end
     */
    public Request(Account initiator, LatLng start, LatLng end) {
        this.initiator = initiator;
        this.startLocation = start;
        this.endLocation = end;
        this.date = new Date();
        this.status = 0;
    }

    /**
     * Constructor for request, using autocomplete fragment
     *
     * @param initiator
     * @param start
     * @param end
     */
    public Request(Account initiator, String start, String end) {
        this.initiator = initiator;
        this.start = start;
        this.end = end;
        this.date = new Date();
        this.status = 0;
    }

    public String getStartLocation() {
        return start;
    }

    public String getEndLocation() {
        return end;
    }



    public String getDate(){
        dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
        datestring = dateFormat.format(date);
        return datestring;
    }

    public Float setRating (Float rating) {
        this.mRating = rating;
        return mRating;
    }

    public Float getEstimate() {
        return estimate;
    }

    public void setEstimate(Float estimate) {
        this.estimate = estimate;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Payment getPayment() {
        return payment;
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    public ArrayList<Account> getAcceptances() {
        return acceptances;
    }

    public void addAcceptance(Account acceptance) {
        this.acceptances.add(acceptance);
    }

    public Account getConfirmedDriver() {
        return confirmedDriver;
    }

    public void setConfirmedDriver(Account confirmedDriver) {
        this.confirmedDriver = confirmedDriver;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Account getInitiator() {
        return initiator;
    }

    public void setInitiator(Account initiator) {
        this.initiator = initiator;
    }

    public void setStartLocation(LatLng startLocation) {
        this.startLocation = startLocation;
    }


    public void setEndLocation(LatLng endLocation) {
        this.endLocation = endLocation;
    }

    public void acceptPayment(){

    }

    //getter and setter about JestId
    public String getId(){
        return id;
    }

    public void setId(String id){
        this.id = id;
    }
}

@@ -569,34 +569,75 @@
  is 
-activity deal wi
+class deal with request.%0A * It contains all information 
 th
+e
  request
 %0A * 
@@ -632,16 +632,22 @@
  request
+ needs
 %0A * @aut
@@ -1611,44 +1611,52 @@
 uest
-, using autocomplete fragment%0A     *
+. It contains all information about request.
 %0A   

Update Request.java