Skip to content

Commit

Permalink
completed docs with working examples
Browse files Browse the repository at this point in the history
  • Loading branch information
KaseyCantu committed Sep 14, 2021
1 parent aba42af commit 55ee6b3
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 67 deletions.
2 changes: 1 addition & 1 deletion docs/get-rates-with-shipment-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Output
The `getRatesWithShipmentDetails` method returns the rates that were calculated for the given shipment params.

Example
=======
-------

```java
import com.shipengine.ShipEngine;
Expand Down
4 changes: 3 additions & 1 deletion docs/list-carriers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
List Carrier Accounts
=====================
[ShipEngine](www.shipengine.com) allows you to connect
your own carrier accounts through the ShipEngine [dashboard](https://www.shipengine.com/docs/carriers/setup/). You can list all the carrier accounts you have connected with the `listCarriers` method. To learn more about carrier accounts please see [our docs](https://www.shipengine.com/docs/reference/list-carriers/).
your own carrier accounts through the ShipEngine [dashboard](https://www.shipengine.com/docs/carriers/setup/). You can
list all the carrier accounts you have connected with the `listCarriers` method. To learn more about carrier accounts
please see [our docs](https://www.shipengine.com/docs/reference/list-carriers/).

Output
------
Expand Down
54 changes: 46 additions & 8 deletions docs/track-using-carrier-code-and-tracking-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,71 @@ see [our docs](https://www.shipengine.com/docs/tracking/) to learn more about tr
Input Parameters
----------------

The `trackUsingCarrierCodeAndTrackingNumber` method requires the carrier code and tracking number of the shipment
being tracked.
The `trackUsingCarrierCodeAndTrackingNumber` method requires the carrier code and tracking number of the shipment being tracked.

Output
------
The `trackUsingCarrierCodeAndTrackingNumber` method returns tracking information associated with the shipment for the
carrier code and tracking number.

The `trackUsingCarrierCodeAndTrackingNumber` method returns tracking information associated with the shipment for the carrier code and tracking number.

Example
=======
-------

```java
import com.shipengine.ShipEngine;

public class ShipEngineDemo {
public static void main() {
ShipEngine shipengine = new ShipEngine("<YOUR_API_KEY_HERE>");

Map<String, Object> trackingData = new HashMap<>() {{
put("carrierCode", "se-1234");
put("trackingNumber", "abc123");
}};

Map<String, String> result = shipengine.trackUsingCarrierCodeAndTrackingNumber(trackingData);
System.out.println("result = " + result);
}
}
```

Example Output
--------------

### Tracking Result
```java

{carrier_status_code=1.0, status_description=Delivered, status_code=DE, exception_description=string, tracking_number=1Z932R800392060079, actual_delivery_date=2018-09-23T15:00:00.000Z, carrier_status_description=Your item was delivered in or at the mailbox at 9:10 am on March, estimated_delivery_date=2018-09-23T15:00:00.000Z, events=[{occurred_at=2018-09-23T15:00:00.000Z, carrier_occurred_at=2018-09-23T15:00:00.000Z, description=Delivered, In/At Mailbox, city_locality=AUSTIN, state_province=TX, postal_code=78756.0, country_code=CA, company_name=Stamps.com, signer=string, event_code=string, latitude=-90.0, longitude=-180.0}], ship_date=2018-09-23T15:00:00.000Z}
```

### *JSON Output for reference:*

```json5

{
"tracking_number": "1Z932R800392060079",
"status_code": "DE",
"status_description": "Delivered",
"carrier_status_code": 1,
"carrier_status_description": "Your item was delivered in or at the mailbox at 9:10 am on March",
"ship_date": "2018-09-23T15:00:00.000Z",
"estimated_delivery_date": "2018-09-23T15:00:00.000Z",
"actual_delivery_date": "2018-09-23T15:00:00.000Z",
"exception_description": "string",
"events": [
{
"occurred_at": "2018-09-23T15:00:00.000Z",
"carrier_occurred_at": "2018-09-23T15:00:00.000Z",
"description": "Delivered, In/At Mailbox",
"city_locality": "AUSTIN",
"state_province": "TX",
"postal_code": 78756,
"country_code": "CA",
"company_name": "Stamps.com",
"signer": "string",
"event_code": "string",
"latitude": -90,
"longitude": -180
}
]
}
```

Exceptions
Expand Down
72 changes: 57 additions & 15 deletions docs/track-using-label-id.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,77 @@
Track package by Label ID Documentation
=======================================
[ShipEngine](www.shipengine.com) allows you to track a package by its ShipEngine `label_id`. This is the recommended
way to track shipments whose labels have been crated using ShipEngine API.
Track By Label ID
=================
[ShipEngine](www.shipengine.com) allows you to track a package by its ShipEngine label ID. Please
see [our docs](https://www.shipengine.com/docs/tracking/track-by-label-id/) to learn more about tracking shipments.

Please see [our docs](https://www.shipengine.com/docs/tracking/track-by-label-id/) to learn
more about tracking shipments.
Input Parameters
----------------

Input
------
The `track_by_label_id` method requires the ID of the label associated with the shipment you are trying to track.
```java
```
The `trackUsingLabelId` method requires the ID of the label associated with the shipment you are trying to track.

Output
------
The `track_by_label_id` method returns tracking information associated with the shipment for the given label ID.
The `trackUsingLabelId` method returns tracking information associated with the shipment for the given label ID.

Example
=======
-------

```java
import com.shipengine.ShipEngine;

public class ShipEngineDemo {
public static void main() {
ShipEngine shipengine = new ShipEngine("<YOUR_API_KEY_HERE>");

Map<String, String> result = shipengine.trackUsingLabelId("se-1234");
System.out.println("result = " + result);
}
}
```

Example Output
==============
---------------

Example Output
--------------

```java
{carrier_status_code=1.0, status_description=Delivered, status_code=DE, exception_description=string, tracking_number=1Z932R800392060079, actual_delivery_date=2018-09-23T15:00:00.000Z, carrier_status_description=Your item was delivered in or at the mailbox at 9:10 am on March, estimated_delivery_date=2018-09-23T15:00:00.000Z, events=[{occurred_at=2018-09-23T15:00:00.000Z, carrier_occurred_at=2018-09-23T15:00:00.000Z, description=Delivered, In/At Mailbox, city_locality=AUSTIN, state_province=TX, postal_code=78756.0, country_code=CA, company_name=Stamps.com, signer=string, event_code=string, latitude=-90.0, longitude=-180.0}], ship_date=2018-09-23T15:00:00.000Z}
```

### *JSON Output for reference:*

```json5
{
"tracking_number": "1Z932R800392060079",
"status_code": "DE",
"status_description": "Delivered",
"carrier_status_code": 1,
"carrier_status_description": "Your item was delivered in or at the mailbox at 9:10 am on March",
"ship_date": "2018-09-23T15:00:00.000Z",
"estimated_delivery_date": "2018-09-23T15:00:00.000Z",
"actual_delivery_date": "2018-09-23T15:00:00.000Z",
"exception_description": "string",
"events": [
{
"occurred_at": "2018-09-23T15:00:00.000Z",
"carrier_occurred_at": "2018-09-23T15:00:00.000Z",
"description": "Delivered, In/At Mailbox",
"city_locality": "AUSTIN",
"state_province": "TX",
"postal_code": 78756,
"country_code": "CA",
"company_name": "Stamps.com",
"signer": "string",
"event_code": "string",
"latitude": -90,
"longitude": -180
}
]
}
```

Exceptions
==========
----------

- This method will only throw an exception that is an instance/extension of
([ShipEngineError]()) if there is a problem if a problem occurs, such as a network
Expand Down
102 changes: 77 additions & 25 deletions docs/validate-addresses.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,95 @@
Addresses Validate Documentation
================================
[ShipEngine](www.shipengine.com) allows you to validate an address before using it to create a shipment to ensure
accurate delivery of your packages.

Address validation can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine
cross-references multiple databases to validate addresses and identify potential delivery issues and supports address
validation for virtually every country_code on Earth, including the United state_provinces, Canada, Great Britain,
Australia, Germany, France, Norway, Spain, Sweden, Israel, Italy, and over 160 others.

Please see [our docs](https://www.shipengine.com/docs/addresses/validation/) to learn more about validating addresses.
Validate Addresses
==================
[ShipEngine](www.shipengine.com) allows you to validate an array of addresses before using it to create a shipment to
ensure accurate delivery of your packages. Please see [our docs](https://www.shipengine.com/docs/addresses/validation/)
to learn more about validating addresses.

Input Parameters
----------------
The `validate_addresses` method accepts a list of addresses as seen below.
```java

```
The `validateAddresses` method accepts an array of addresses.

Output
------
The `validate_addresses` method returns a list of address validation result objects.
The `validateAddresses` method returns an array of address validation result objects.

Example
-------

Example:
========
- Pass in a list of addresses you wish to validate into the `validate_addresses` method.
```java
import com.shipengine.ShipEngine;

public class ShipEngineDemo {
public static void main() {
ShipEngine shipengine = new ShipEngine("<YOUR_API_KEY_HERE>");

HashMap<String, String> stubAddress = new HashMap<>() {{
put("name", "ShipEngine");
put("company", "Auctane");
put("phone", "1-123-456-7891");
put("address_line1", "3800 N Lamar Blvd");
put("address_line2", "ste 220");
put("city_locality", "Austin");
put("state_province", "TX");
put("postal_code", "78756");
put("country_code", "US");
put("address_residential_indicator", "unknown");
}};

Map<String, String> result = shipengine.validateAddresses(stubAddress);
System.out.println("result = " + result);
}
}
```

Example Output:
===============
- A list of carrier account that are connected to a given ShipEngine account.
Example Output
--------------

### Successful Address Validation

```java
[{matched_address={name=SHIPENGINE, phone=1-123-456-7891, address_line1=3800 N LAMAR BLVD STE 220, address_line2=, city_locality=AUSTIN, state_province=TX, postal_code=78756-0003, country_code=US, address_residential_indicator=no}, original_address={name=ShipEngine, phone=1-123-456-7891, address_line1=3800 N Lamar Blvd, address_line2=ste 220, city_locality=Austin, state_province=TX, postal_code=78756, country_code=US, address_residential_indicator=unknown}, messages=[], status=verified}]
```

### *JSON Output for reference:*

```json5
[
{
"status": "verified",
"original_address": {
"name": "ShipEngine",
"phone": "1-123-456-7891",
"company_name": null,
"address_line1": "3800 N Lamar Blvd",
"address_line2": "ste 220",
"address_line3": null,
"city_locality": "Austin",
"state_province": "TX",
"postal_code": "78756",
"country_code": "US",
"address_residential_indicator": "unknown"
},
"matched_address": {
"name": "SHIPENGINE",
"phone": "1-123-456-7891",
"company_name": null,
"address_line1": "3800 N LAMAR BLVD STE 220",
"address_line2": "",
"address_line3": null,
"city_locality": "AUSTIN",
"state_province": "TX",
"postal_code": "78756-0003",
"country_code": "US",
"address_residential_indicator": "no"
},
"messages": []
}
]
```

Exceptions
==========
----------

- This method will only throw an exception that is an instance/extension of
([ShipEngineError](../shipengine/errors/__init__.py)) if there is a problem if a problem occurs, such as a network
error or an error response from the API.
- This method will only throw an exception that is an instance/extension of **ShipEngineException** if there is a
problem if a problem occurs, such as a network error or an error response from the API.
47 changes: 31 additions & 16 deletions docs/void-label-with-label-id.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
Void Label by Label ID Documentation
====================================
[ShipEngine](www.shipengine.com) allows you to attempt to void a previously purchased label.

Please see [our docs](https://www.shipengine.com/docs/labels/voiding/) to learn more about voiding a label.

Void Label With Label Id
================================
[ShipEngine](www.shipengine.com) allows you to attempt to void a previously purchased label. Please see
[our docs](https://www.shipengine.com/docs/labels/voiding/) to learn more about voiding a label.

Input Parameters
----------------
The `void_label_by_label_id` method accepts a string that contains the label ID that is being voided.

The `voidLabelWithLabelId` method accepts a string that contains the `labelId` that is being voided.

Output
------
The `void_label_by_label_id` method returns an object that indicates the status of the void label request.

The `voidLabelWithLabelId` method returns an object that indicates the status of the void label request.

Example
=======
-------
```java

import com.shipengine.ShipEngine;

public class ShipEngineDemo {
public static void main() {
ShipEngine shipengine = new ShipEngine("<YOUR_API_KEY_HERE>");
Map<String, String> result = shipengine.voidLabelWithLabelId("se-1234");
System.out.println("result = " + result);
}
}
```

Example Output
==============
--------------

### Successful Address Validation
```java
{approved=true, message=This label has been voided.}
```

### *JSON Output for reference:*

```json5
{
"approved": true,
"message": "This label has been voided."
}
```

Exceptions
==========
----------

- This method will only throw an exception that is an instance/extension of
([ShipEngineError]()) if there is a problem if a problem occurs, such as a network
error or an error response from the API.
- This method will only throw an exception that is an instance/extension of **ShipEngineException** if there is a
problem if a problem occurs, such as a network error or an error response from the API.
6 changes: 5 additions & 1 deletion src/main/java/com/shipengine/InternalClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
import java.net.http.HttpResponse;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down
Loading

0 comments on commit 55ee6b3

Please sign in to comment.