Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TM-1311 added tracking_destination_country field in Tracking #4

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/com/aftership/sdk/Tracking.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public class Tracking {
/**Tracking key of the shipment for a specific courier. Required by some couriers, such assic-teliway and total-express**/
private String trackingKey;

private String trackingDestinationCountry;

public Tracking(String trackingNumber) {
this.trackingNumber = trackingNumber;
this.title = trackingNumber;
Expand Down Expand Up @@ -141,6 +143,9 @@ public Tracking(JSONObject trackingJSON) throws JSONException,AftershipAPIExcept
this.trackingKey = trackingJSON.isNull("tracking_key")?null:
trackingJSON.getString("tracking_key");

this.trackingDestinationCountry = trackingJSON.isNull("tracking_destination_country")?null:
trackingJSON.getString("tracking_destination_country");

JSONArray smsesArray =trackingJSON.isNull("smses")?null:trackingJSON.getJSONArray("smses");
if(smsesArray !=null && smsesArray.length()!=0){
this.smses = new ArrayList<String>();
Expand Down Expand Up @@ -421,6 +426,14 @@ public void setTrackingShipDate(String trackingShipDate) {
this.trackingShipDate = trackingShipDate;
}

public String getTrackingDestinationCountry() {
return trackingDestinationCountry;
}

public void setTrackingDestinationCountry(String trackingDestinationCountry) {
this.trackingDestinationCountry = trackingDestinationCountry;
}

public JSONObject generateJSON() throws JSONException{
JSONObject globalJSON = new JSONObject();
JSONObject trackingJSON = new JSONObject();
Expand All @@ -447,6 +460,7 @@ public JSONObject generateJSON() throws JSONException{
if (this.trackingPostalCode != null) trackingJSON.put("tracking_postal_code", this.trackingPostalCode);
if (this.trackingShipDate != null) trackingJSON.put("tracking_ship_date", this.trackingShipDate);
if (this.trackingKey != null) trackingJSON.put("tracking_key", this.trackingKey);
if (this.trackingDestinationCountry != null) trackingJSON.put("tracking_destination_country", this.trackingDestinationCountry);
if (this.customFields != null) {
customFieldsJSON = new JSONObject();

Expand Down Expand Up @@ -516,6 +530,7 @@ public String toString() {
sb.append((tag==null)?"":"\n\ttag=" +tag );
sb.append("\n\t" + "trackedCount=" + trackedCount);
sb.append((checkpoints==null)?"": "\n\tcheckpoints=" +checkpoints);
sb.append((trackingDestinationCountry==null)?"": "\n\ttrackingDestinationCountry=" +trackingDestinationCountry);
sb.append("\n}");
return sb.toString();
}
Expand All @@ -539,6 +554,11 @@ public String getQueryRequiredFields(){
qs.add("tracking_key", this.trackingKey);
containsInfo=true;
}
if (this.trackingDestinationCountry!=null){
qs.add("tracking_destination_country", this.trackingDestinationCountry);
containsInfo=true;
}

if(containsInfo){
return qs.toString();
}
Expand Down