Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions official/docs/java/current/billing/add-stripe-bank-account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package billing;

import com.easypost.exception.EasyPostException;
import com.easypost.model.PaymentMethod;
import com.easypost.service.EasyPostClient;

public class CreateStripeCreditCardSecret {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> mandateData = new HashMap<String, Object>();
mandateData.put("ip_address", "127.0.0.1");
mandateData.put("user_agent", "Mozilla/5.0");
mandateData.put("accepted_at", 1722510730);

PaymentMethodObject paymentMethod = client.referralCustomer.addBankAccountFromStripe(
"REFERRAL_USER_API_KEY",
"fca_...",
mandateData,
PaymentMethod.Priority.PRIMARY
);

System.out.println(paymentMethod);
}
}
19 changes: 19 additions & 0 deletions official/docs/java/current/billing/add-stripe-credit-card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package billing;

import com.easypost.exception.EasyPostException;
import com.easypost.model.PaymentMethod;
import com.easypost.service.EasyPostClient;

public class CreateStripeCreditCardSecret {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

PaymentMethodObject paymentMethod = client.referralCustomer.addCreditCardFromStripe(
"REFERRAL_USER_API_KEY",
"seti_123",
PaymentMethod.Priority.PRIMARY
);

System.out.println(paymentMethod);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package billing;

import com.easypost.exception.EasyPostException;
import com.easypost.service.EasyPostClient;

public class CreateStripeBankAccountSecret {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

ClientSecret response = client.betaReferralCustomer.createBankAccountClientSecret();

System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package billing;

import com.easypost.exception.EasyPostException;
import com.easypost.service.EasyPostClient;

public class CreateStripeCreditCardSecret {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

ClientSecret response = client.betaReferralCustomer.createCreditCardClientSecret();

System.out.println(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class RetrieveTimeInTransitStatistics {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

List<SmartRate> smartrates = client.shipment.smartrates("shp_...");
List<SmartRate> smartrates = client.shipment.smartRates("shp_...");

System.out.println(smartrates);
}
Expand Down
7 changes: 6 additions & 1 deletion official/docs/java/current/webhooks/create.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ public static void main(String[] args) throws EasyPostException {

HashMap<String, Object> params = new HashMap<String, Object>();
params.put("url", "example.com");
paramMap.put("webhook_secret", "A1B2C3");
params.put("webhook_secret", "A1B2C3");
params.put("custom_headers", new HashMap<String, String>() {
{
put("X-Header-Name", "header_value");
}
});

Webhook webhook = client.webhook.create(params);

Expand Down
12 changes: 11 additions & 1 deletion official/docs/java/current/webhooks/update.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
import com.easypost.model.Webhook;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class Update {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

Webhook webhook = client.webhook.update("hook_...");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("webhook_secret", "A1B2C3");
params.put("custom_headers", new HashMap<String, String>() {
{
put("X-Header-Name", "header_value");
}
});

Webhook webhook = client.webhook.update("hook_...", params);

System.out.println(webhook);
}
Expand Down
27 changes: 27 additions & 0 deletions official/docs/java/v7/addresses/create-and-verify.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class CreateAndVerify {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> params = new HashMap<String, Object>();

params.put("street1", "000 unknown street");
params.put("city", "Not A City");
params.put("state", "ZZ");
params.put("zip", "00001");
params.put("country", "US");
params.put("email", "test@example.com");
params.put("phone", "5555555555");

Address address = client.address.createAndVerify(params);

System.out.println(address);
}
}
28 changes: 28 additions & 0 deletions official/docs/java/v7/addresses/create.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class Create {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> params = new HashMap<String, Object>();

params.put("street1", "417 MONTGOMERY ST");
params.put("street2", "FLOOR 5");
params.put("city", "SAN FRANCISCO");
params.put("state", "CA");
params.put("zip", "94104");
params.put("country", "US");
params.put("company", "EasyPost");
params.put("phone", "415-123-4567");

Address address = client.address.create(params);

System.out.println(address);
}
}
21 changes: 21 additions & 0 deletions official/docs/java/v7/addresses/list.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.AddressCollection;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class All {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> params = new HashMap<>();

params.put("page_size", 5);

AddressCollection addresses = client.address.all(params);

System.out.println(addresses);
}
}
15 changes: 15 additions & 0 deletions official/docs/java/v7/addresses/retrieve.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

public class Retrieve {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

Address address = client.address.retrieve("adr_...");

System.out.println(address);
}
}
28 changes: 28 additions & 0 deletions official/docs/java/v7/addresses/verify-param.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class VerifyParam {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> params = new HashMap<String, Object>();

params.put("street1", "000 unknown street");
params.put("city", "Not A City");
params.put("state", "ZZ");
params.put("zip", "00001");
params.put("country", "US");
params.put("email", "test@example.com");
params.put("phone", "5555555555");
params.put("verify", true);

Address address = client.address.create(params);

System.out.println(address);
}
}
28 changes: 28 additions & 0 deletions official/docs/java/v7/addresses/verify-strict-param.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

public class VerifyStrictParam {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> params = new HashMap<String, Object>();

params.put("street1", "000 unknown street");
params.put("city", "Not A City");
params.put("state", "ZZ");
params.put("zip", "00001");
params.put("country", "US");
params.put("email", "test@example.com");
params.put("phone", "5555555555");
params.put("verify_strict", true);

Address address = client.address.create(params);

System.out.println(address);
}
}
15 changes: 15 additions & 0 deletions official/docs/java/v7/addresses/verify.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package addresses;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Address;
import com.easypost.service.EasyPostClient;

public class Verify {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

Address address = client.address.verify("adr_...");

System.out.println(address);
}
}
21 changes: 21 additions & 0 deletions official/docs/java/v7/api-keys/retrieve.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package api_keys;

import com.easypost.exception.EasyPostException;
import com.easypost.model.ApiKeys;
import com.easypost.service.EasyPostClient;

public class Retrieve {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

// Retrieve all API keys including children
ApiKeys parentKeys = client.apiKey.all();

System.out.println(parentKeys);

// Retrieve API keys for a specific child user
ApiKeys childKeys = client.apiKey.retrieveApiKeysForUser("user_...");

System.out.println(childKeys);
}
}
32 changes: 32 additions & 0 deletions official/docs/java/v7/batches/add-shipments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package batches;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Batch;
import com.easypost.service.EasyPostClient;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class AddShipments {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

HashMap<String, Object> shipment1 = new HashMap<String, Object>();
shipment1.put("id", "shp_...");

HashMap<String, Object> shipment2 = new HashMap<String, Object>();
shipment2.put("id", "shp_...");

List<HashMap<String, Object>> shipments = new ArrayList<HashMap<String, Object>>();
shipments.add(shipment1);
shipments.add(shipment2);

HashMap<String, Object> params = new HashMap<String, Object>();
params.put("shipments", shipments);

Batch batch = client.batch.addShipments("batch_...", params);

System.out.println(batch);
}
}
48 changes: 48 additions & 0 deletions official/docs/java/v7/batches/buy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package batches;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Batch;
import com.easypost.service.EasyPostClient;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Buy {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

List<HashMap<String, Object>> shipmentsList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> shipmentMap = new HashMap<String, Object>();

HashMap<String, Object> fromAddress = new HashMap<String, Object>();
fromAddress.put("id", "adr_...");
shipmentMap.put("from_address", fromAddress);

HashMap<String, Object> toAddress = new HashMap<String, Object>();
toAddress.put("id", "adr_...");
shipmentMap.put("to_address", toAddress);

HashMap<String, Object> parcel = new HashMap<String, Object>();
parcel.put("id", "prcl_...");
shipmentMap.put("parcel", parcel);

shipmentMap.put("service", "First");
shipmentMap.put("carrier", "USPS");

String[] carrierAccounts = { "ca_..." };
shipmentMap.put("carrier_accounts", carrierAccounts);

shipmentsList.add(shipmentMap);

HashMap<String, Object> params = new HashMap<String, Object>();

params.put("shipment", shipmentsList);

Batch createdBatch = client.batch.create(params);

Batch batch = client.batch.buy(createdBatch.getId());

System.out.println(batch);
}
}
Loading
Loading