package com.example.julian.locationservice;

import android.content.Context;

import com.meedamian.info.BasicData;

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

public class DataUploader {

    private Context c;
    private String phone;
    private String vanity;
    private String county;
    private String city;

    public DataUploader(Context context) {
        c = context;
    }


    public void upload() {
        String key = BasicData.getPrivateId(c);

        JSONObject jo = new JSONObject();
        try {
            jo.put("key", key);

            if (phone != null)
                jo.put("phone", phone);

            // TODO: ifs

        } catch (JSONException ignored) {}
        finally {

            // send `jo`
            // as POST body
            // to https://basic-data.parseapp.com/update
        }
    }

    public DataUploader setLocation(String country, String city) {
        this.county = country;
        this.city = city;
        return this;
    }

    public DataUploader setPhone(String phone) {
        this.phone = phone;
        return this;
    }

    public DataUploader setVanity(String vanity) {
        this.vanity = vanity;
        return this;
    }
}

@@ -298,19 +298,20 @@
 ng count
+r
 y;%0A
-
     priv
@@ -653,20 +653,241 @@
     
-// TODO: ifs
+else if(vanity != null)%0A                jo.put(%22vanity%22, vanity);%0A%0A            else if(country != null)%0A                jo.put(%22country%22, country);%0A%0A            else if(city != null)%0A                jo.put(%22city%22, city);%0A            
 %0A%0A  
@@ -1136,24 +1136,24 @@
 ing city) %7B%0A
-
         this
@@ -1158,16 +1158,17 @@
 is.count
+r
 y = coun

Add conditions in upload method