diff --git a/official/docs/java/current/billing/add-stripe-bank-account.java b/official/docs/java/current/billing/add-stripe-bank-account.java new file mode 100644 index 00000000..084813ce --- /dev/null +++ b/official/docs/java/current/billing/add-stripe-bank-account.java @@ -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 mandateData = new HashMap(); + 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); + } +} diff --git a/official/docs/java/current/billing/add-stripe-credit-card.java b/official/docs/java/current/billing/add-stripe-credit-card.java new file mode 100644 index 00000000..b9aa06a1 --- /dev/null +++ b/official/docs/java/current/billing/add-stripe-credit-card.java @@ -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); + } +} diff --git a/official/docs/java/current/billing/create-stripe-bank-account-secret.java b/official/docs/java/current/billing/create-stripe-bank-account-secret.java new file mode 100644 index 00000000..4ec7825c --- /dev/null +++ b/official/docs/java/current/billing/create-stripe-bank-account-secret.java @@ -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); + } +} diff --git a/official/docs/java/current/billing/create-stripe-credit-card-secret.java b/official/docs/java/current/billing/create-stripe-credit-card-secret.java new file mode 100644 index 00000000..5fce59ad --- /dev/null +++ b/official/docs/java/current/billing/create-stripe-credit-card-secret.java @@ -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); + } +} diff --git a/official/docs/java/current/smartrate/retrieve-time-in-transit-statistics.java b/official/docs/java/current/smartrate/retrieve-time-in-transit-statistics.java index 0ae4297f..9ce1d649 100644 --- a/official/docs/java/current/smartrate/retrieve-time-in-transit-statistics.java +++ b/official/docs/java/current/smartrate/retrieve-time-in-transit-statistics.java @@ -10,7 +10,7 @@ public class RetrieveTimeInTransitStatistics { public static void main(String[] args) throws EasyPostException { EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); - List smartrates = client.shipment.smartrates("shp_..."); + List smartrates = client.shipment.smartRates("shp_..."); System.out.println(smartrates); } diff --git a/official/docs/java/current/webhooks/create.java b/official/docs/java/current/webhooks/create.java index 554e9110..946c586c 100644 --- a/official/docs/java/current/webhooks/create.java +++ b/official/docs/java/current/webhooks/create.java @@ -12,7 +12,12 @@ public static void main(String[] args) throws EasyPostException { HashMap params = new HashMap(); params.put("url", "example.com"); - paramMap.put("webhook_secret", "A1B2C3"); + params.put("webhook_secret", "A1B2C3"); + params.put("custom_headers", new HashMap() { + { + put("X-Header-Name", "header_value"); + } + }); Webhook webhook = client.webhook.create(params); diff --git a/official/docs/java/current/webhooks/update.java b/official/docs/java/current/webhooks/update.java index b8819fc7..2f0e3e7f 100644 --- a/official/docs/java/current/webhooks/update.java +++ b/official/docs/java/current/webhooks/update.java @@ -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 params = new HashMap(); + params.put("webhook_secret", "A1B2C3"); + params.put("custom_headers", new HashMap() { + { + put("X-Header-Name", "header_value"); + } + }); + + Webhook webhook = client.webhook.update("hook_...", params); System.out.println(webhook); } diff --git a/official/docs/java/v7/addresses/create-and-verify.java b/official/docs/java/v7/addresses/create-and-verify.java new file mode 100644 index 00000000..1ba94687 --- /dev/null +++ b/official/docs/java/v7/addresses/create-and-verify.java @@ -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 params = new HashMap(); + + 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); + } +} diff --git a/official/docs/java/v7/addresses/create.java b/official/docs/java/v7/addresses/create.java new file mode 100644 index 00000000..8c747ae2 --- /dev/null +++ b/official/docs/java/v7/addresses/create.java @@ -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 params = new HashMap(); + + 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); + } +} diff --git a/official/docs/java/v7/addresses/list.java b/official/docs/java/v7/addresses/list.java new file mode 100644 index 00000000..2ba33e4d --- /dev/null +++ b/official/docs/java/v7/addresses/list.java @@ -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 params = new HashMap<>(); + + params.put("page_size", 5); + + AddressCollection addresses = client.address.all(params); + + System.out.println(addresses); + } +} diff --git a/official/docs/java/v7/addresses/retrieve.java b/official/docs/java/v7/addresses/retrieve.java new file mode 100644 index 00000000..01ca28c9 --- /dev/null +++ b/official/docs/java/v7/addresses/retrieve.java @@ -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); + } +} diff --git a/official/docs/java/v7/addresses/verify-param.java b/official/docs/java/v7/addresses/verify-param.java new file mode 100644 index 00000000..3677ff0b --- /dev/null +++ b/official/docs/java/v7/addresses/verify-param.java @@ -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 params = new HashMap(); + + 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); + } +} diff --git a/official/docs/java/v7/addresses/verify-strict-param.java b/official/docs/java/v7/addresses/verify-strict-param.java new file mode 100644 index 00000000..0025ece0 --- /dev/null +++ b/official/docs/java/v7/addresses/verify-strict-param.java @@ -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 params = new HashMap(); + + 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); + } +} diff --git a/official/docs/java/v7/addresses/verify.java b/official/docs/java/v7/addresses/verify.java new file mode 100644 index 00000000..8532b1f3 --- /dev/null +++ b/official/docs/java/v7/addresses/verify.java @@ -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); + } +} diff --git a/official/docs/java/v7/api-keys/retrieve.java b/official/docs/java/v7/api-keys/retrieve.java new file mode 100644 index 00000000..98a66c33 --- /dev/null +++ b/official/docs/java/v7/api-keys/retrieve.java @@ -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); + } +} diff --git a/official/docs/java/v7/batches/add-shipments.java b/official/docs/java/v7/batches/add-shipments.java new file mode 100644 index 00000000..30a7c6f5 --- /dev/null +++ b/official/docs/java/v7/batches/add-shipments.java @@ -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 shipment1 = new HashMap(); + shipment1.put("id", "shp_..."); + + HashMap shipment2 = new HashMap(); + shipment2.put("id", "shp_..."); + + List> shipments = new ArrayList>(); + shipments.add(shipment1); + shipments.add(shipment2); + + HashMap params = new HashMap(); + params.put("shipments", shipments); + + Batch batch = client.batch.addShipments("batch_...", params); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/buy.java b/official/docs/java/v7/batches/buy.java new file mode 100644 index 00000000..910d6c8e --- /dev/null +++ b/official/docs/java/v7/batches/buy.java @@ -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> shipmentsList = new ArrayList>(); + HashMap shipmentMap = new HashMap(); + + HashMap fromAddress = new HashMap(); + fromAddress.put("id", "adr_..."); + shipmentMap.put("from_address", fromAddress); + + HashMap toAddress = new HashMap(); + toAddress.put("id", "adr_..."); + shipmentMap.put("to_address", toAddress); + + HashMap parcel = new HashMap(); + 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 params = new HashMap(); + + params.put("shipment", shipmentsList); + + Batch createdBatch = client.batch.create(params); + + Batch batch = client.batch.buy(createdBatch.getId()); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/create.java b/official/docs/java/v7/batches/create.java new file mode 100644 index 00000000..7833bdf3 --- /dev/null +++ b/official/docs/java/v7/batches/create.java @@ -0,0 +1,30 @@ +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 Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + List> shipmentsList = new ArrayList>(); + HashMap shipmentMap = new HashMap(); + + shipmentMap.put("id", "shp_..."); + + shipmentsList.add(shipmentMap); + + HashMap params = new HashMap(); + + params.put("shipment", shipmentsList); + + Batch batch = client.batch.create(params); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/label.java b/official/docs/java/v7/batches/label.java new file mode 100644 index 00000000..d328fe20 --- /dev/null +++ b/official/docs/java/v7/batches/label.java @@ -0,0 +1,20 @@ +package batches; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Batch; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Label { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + params.put("file_format", "PDF"); + + Batch batch = client.batch.label("batch_...", params); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/list.java b/official/docs/java/v7/batches/list.java new file mode 100644 index 00000000..9b1354d5 --- /dev/null +++ b/official/docs/java/v7/batches/list.java @@ -0,0 +1,20 @@ +package batches; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.BatchCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + BatchCollection batches = client.batch.all(params); + + System.out.println(batches); + } +} diff --git a/official/docs/java/v7/batches/remove-shipments.java b/official/docs/java/v7/batches/remove-shipments.java new file mode 100644 index 00000000..0e4f2cb4 --- /dev/null +++ b/official/docs/java/v7/batches/remove-shipments.java @@ -0,0 +1,28 @@ +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 RemoveShipments { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap shipment1 = new HashMap(); + shipment1.put("id", "shp_..."); + + List> shipments = new ArrayList>(); + shipments.add(shipment1); + + HashMap params = new HashMap(); + params.put("shipments", shipments); + + Batch batch = client.batch.removeShipments("batch_...", params); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/retrieve.java b/official/docs/java/v7/batches/retrieve.java new file mode 100644 index 00000000..3dc3bf0d --- /dev/null +++ b/official/docs/java/v7/batches/retrieve.java @@ -0,0 +1,15 @@ +package batches; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Batch; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Batch batch = client.batch.retrieve("batch_..."); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/batches/scan-forms.java b/official/docs/java/v7/batches/scan-forms.java new file mode 100644 index 00000000..22663722 --- /dev/null +++ b/official/docs/java/v7/batches/scan-forms.java @@ -0,0 +1,15 @@ +package batches; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Batch; +import com.easypost.service.EasyPostClient; + +public class ScanForms { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Batch batch = client.batch.createScanForm("batch_..."); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v7/billing/create-ep-credit-card.java b/official/docs/java/v7/billing/create-ep-credit-card.java new file mode 100644 index 00000000..01bca41a --- /dev/null +++ b/official/docs/java/v7/billing/create-ep-credit-card.java @@ -0,0 +1,15 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + PaymentMethodObject creditCard = client.referralCustomer.addCreditCardToUser("REFERRAL_USER_API_KEY", + "0123456789101234", 01, 2025, "111", PaymentMethod.Priority.PRIMARY); + + System.out.println(referralUser); + } +} diff --git a/official/docs/java/v7/billing/delete.java b/official/docs/java/v7/billing/delete.java new file mode 100644 index 00000000..eae4639f --- /dev/null +++ b/official/docs/java/v7/billing/delete.java @@ -0,0 +1,13 @@ +package billing; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PaymentMethod; +import com.easypost.service.EasyPostClient; + +public class Delete { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.billing.deletePaymentMethod(PaymentMethod.Priority.PRIMARY); + } +} diff --git a/official/docs/java/v7/billing/fund.java b/official/docs/java/v7/billing/fund.java new file mode 100644 index 00000000..46bbd239 --- /dev/null +++ b/official/docs/java/v7/billing/fund.java @@ -0,0 +1,13 @@ +package billing; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PaymentMethod; +import com.easypost.service.EasyPostClient; + +public class Fund { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.billing.fundWallet("2000", PaymentMethod.Priority.PRIMARY); + } +} diff --git a/official/docs/java/v7/billing/list.java b/official/docs/java/v7/billing/list.java new file mode 100644 index 00000000..bc8d4c97 --- /dev/null +++ b/official/docs/java/v7/billing/list.java @@ -0,0 +1,15 @@ +package billing; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PaymentMethod; +import com.easypost.service.EasyPostClient; + +public class All { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + PaymentMethod paymentMethods = client.billing.retrievePaymentMethods(); + + System.out.println(paymentMethods); + } +} diff --git a/official/docs/java/v7/brand/update.java b/official/docs/java/v7/brand/update.java new file mode 100644 index 00000000..e0d0227e --- /dev/null +++ b/official/docs/java/v7/brand/update.java @@ -0,0 +1,20 @@ +package brand; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Brand; +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"); + + HashMap params = new HashMap<>(); + params.put("color", "303F9F"); + + Brand brand = client.user.updateBrand("user_...", params); + + System.out.println(brand); + } +} diff --git a/official/docs/java/v7/carrier-accounts/create.java b/official/docs/java/v7/carrier-accounts/create.java new file mode 100644 index 00000000..4e5f4fb7 --- /dev/null +++ b/official/docs/java/v7/carrier-accounts/create.java @@ -0,0 +1,35 @@ +package carrier_accounts; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierAccount; +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 credentials = new HashMap(); + credentials.put("client_id", "123456"); + credentials.put("client_secret", "123abc"); + credentials.put("distribution_center", "USLAX1"); + credentials.put("pickup_id", "123456"); + + HashMap testCredentials = new HashMap(); + testCredentials.put("client_id", "123456"); + testCredentials.put("client_secret", "123abc"); + testCredentials.put("distribution_center", "USLAX1"); + testCredentials.put("pickup_id", "123456"); + + HashMap params = new HashMap(); + params.put("type", "DhlEcsAccount"); + params.put("description", "CA Location DHL eCommerce Solutions Account"); + params.put("credentials", credentials); + params.put("test_credentials", testCredentials); + + CarrierAccount carrierAccount = client.carrierAccount.create(params); + + System.out.println(carrierAccount); + } +} diff --git a/official/docs/java/v7/carrier-accounts/delete.java b/official/docs/java/v7/carrier-accounts/delete.java new file mode 100644 index 00000000..13162bfd --- /dev/null +++ b/official/docs/java/v7/carrier-accounts/delete.java @@ -0,0 +1,12 @@ +package carrier_accounts; + +import com.easypost.exception.EasyPostException; +import com.easypost.service.EasyPostClient; + +public class Delete { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.carrierAccount.delete("ca_..."); + } +} diff --git a/official/docs/java/v7/carrier-accounts/list.java b/official/docs/java/v7/carrier-accounts/list.java new file mode 100644 index 00000000..950a8420 --- /dev/null +++ b/official/docs/java/v7/carrier-accounts/list.java @@ -0,0 +1,17 @@ +package carrier_accounts; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierAccount; +import com.easypost.service.EasyPostClient; + +import java.util.List; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + List carrierAccounts = client.carrierAccount.all(); + + System.out.println(carrierAccounts); + } +} diff --git a/official/docs/java/v7/carrier-accounts/retrieve.java b/official/docs/java/v7/carrier-accounts/retrieve.java new file mode 100644 index 00000000..bd45b59f --- /dev/null +++ b/official/docs/java/v7/carrier-accounts/retrieve.java @@ -0,0 +1,15 @@ +package carrier_accounts; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierAccount; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + CarrierAccount carrierAccount = client.carrierAccount.retrieve("ca_..."); + + System.out.println(carrierAccount); + } +} diff --git a/official/docs/java/v7/carrier-accounts/update.java b/official/docs/java/v7/carrier-accounts/update.java new file mode 100644 index 00000000..2aeca2fd --- /dev/null +++ b/official/docs/java/v7/carrier-accounts/update.java @@ -0,0 +1,24 @@ +package carrier_accounts; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierAccount; +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"); + + HashMap credentials = new HashMap(); + credentials.put("pickup_id", "abc123"); + + HashMap params = new HashMap(); + params.put("description", "FL Location DHL eCommerce Solutions Account"); + params.put("credentials", credentials); + + CarrierAccount carrierAccount = client.carrierAccount.update("ca_...", params); + + System.out.println(carrierAccount); + } +} diff --git a/official/docs/java/v7/carrier-metadata/retrieve.java b/official/docs/java/v7/carrier-metadata/retrieve.java new file mode 100644 index 00000000..3b0c3479 --- /dev/null +++ b/official/docs/java/v7/carrier-metadata/retrieve.java @@ -0,0 +1,29 @@ +package carrier_metadata; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierAccount; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.List; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + // Request all metadata for all carriers + CarrierAccount carrierMetadata = client.carrierMetadata.retrieve(); + System.out.println(carrierMetadata); + + // Request specific metadata for specific carriers + List carriers = new ArrayList(); + carriers.add("usps"); + + List types = new ArrayList(); + types.add("service_levels"); + types.add("predefined_packages"); + + CarrierAccount carrierMetadata = client.carrierMetadata.retrieve(carriers, types); + System.out.println(carrierMetadata); + } +} diff --git a/official/docs/java/v7/carrier-types/list.java b/official/docs/java/v7/carrier-types/list.java new file mode 100644 index 00000000..551b8ba6 --- /dev/null +++ b/official/docs/java/v7/carrier-types/list.java @@ -0,0 +1,17 @@ +package carrier_types; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CarrierType; +import com.easypost.service.EasyPostClient; + +import java.util.List; + +public class All { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + List carrierTypes = client.carrierType.all(); + + System.out.println(carrierTypes); + } +} diff --git a/official/docs/java/v7/child-users/create.java b/official/docs/java/v7/child-users/create.java new file mode 100644 index 00000000..898f437c --- /dev/null +++ b/official/docs/java/v7/child-users/create.java @@ -0,0 +1,20 @@ +package users; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.User; +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 params = new HashMap(); + params.put("name", "Child Account Name"); + + User user = client.user.create(params); + + System.out.println(user); + } +} diff --git a/official/docs/java/v7/child-users/delete.java b/official/docs/java/v7/child-users/delete.java new file mode 100644 index 00000000..bb9ba60e --- /dev/null +++ b/official/docs/java/v7/child-users/delete.java @@ -0,0 +1,12 @@ +package users; + +import com.easypost.exception.EasyPostException; +import com.easypost.service.EasyPostClient; + +public class Delete { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.user.delete("user_..."); + } +} diff --git a/official/docs/java/v7/child-users/list.java b/official/docs/java/v7/child-users/list.java new file mode 100644 index 00000000..6777cd2e --- /dev/null +++ b/official/docs/java/v7/child-users/list.java @@ -0,0 +1,21 @@ +package child_users; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ChildUserCollection; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class List { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap<>(); + + params.put("page_size", 5); + + ChildUserCollection childUsers = client.user.allChildren(params); + + System.out.println(childUsers); + } +} diff --git a/official/docs/java/v7/claims/cancel.java b/official/docs/java/v7/claims/cancel.java new file mode 100644 index 00000000..090a1429 --- /dev/null +++ b/official/docs/java/v7/claims/cancel.java @@ -0,0 +1,15 @@ +package claims; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Claim; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Claim claim = client.claim.cancel("clm_..."); + + System.out.println(claim); + } +} diff --git a/official/docs/java/v7/claims/create.java b/official/docs/java/v7/claims/create.java new file mode 100644 index 00000000..66df34e9 --- /dev/null +++ b/official/docs/java/v7/claims/create.java @@ -0,0 +1,30 @@ +package claims; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Claim; +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 params = new HashMap(); + params.put("type", "damage"); + params.put("email_evidence_attachments", + new String[]{"REPLACE_WITH_BASE64_STRING"}); + params.put("invoice_attachments", + new String[]{"REPLACE_WITH_BASE64_STRING"}); + params.put("supporting_documentation_attachments", + new String[]{"REPLACE_WITH_BASE64_STRING"}); + params.put("description", "Test Description"); + params.put("contact_email", "test@example.com"); + params.put("tracking_code", "YOUR_TRACKING_CODE"); + params.put("amount", "100"); + + Claim claim = client.claim.create(params); + + System.out.println(claim); + } +} diff --git a/official/docs/java/v7/claims/list.java b/official/docs/java/v7/claims/list.java new file mode 100644 index 00000000..ab1f2f2b --- /dev/null +++ b/official/docs/java/v7/claims/list.java @@ -0,0 +1,20 @@ +package claims; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ClaimCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + ClaimCollection claims = client.claim.all(params); + + System.out.println(claims); + } +} diff --git a/official/docs/java/v7/claims/retrieve.java b/official/docs/java/v7/claims/retrieve.java new file mode 100644 index 00000000..07afd03e --- /dev/null +++ b/official/docs/java/v7/claims/retrieve.java @@ -0,0 +1,15 @@ +package claims; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Claim; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Claim claim = client.claim.retrieve("clm_..."); + + System.out.println(claim); + } +} diff --git a/official/docs/java/v7/customs-infos/create.java b/official/docs/java/v7/customs-infos/create.java new file mode 100644 index 00000000..f2970ed7 --- /dev/null +++ b/official/docs/java/v7/customs-infos/create.java @@ -0,0 +1,42 @@ +package customs_info; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CustomsInfo; +import com.easypost.model.CustomsItem; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap customsItemMap = new HashMap(); + customsItemMap.put("description", "T-shirt"); + customsItemMap.put("quantity", 1); + customsItemMap.put("value", 10); + customsItemMap.put("weight", 5); + customsItemMap.put("origin_country", "us"); + customsItemMap.put("hs_tariff_number", "123456"); + + CustomsItem customsItem = client.customsItem.create(customsItemMap); + + List customsItemsList = new ArrayList(); + customsItemsList.add(customsItem); + + HashMap params = new HashMap(); + params.put("customs_certify", true); + params.put("customs_signer", "Steve Brule"); + params.put("contents_type", "merchandise"); + params.put("contents_explanation", ""); + params.put("eel_pfc", "NOEEI 30.37(a)"); + params.put("restriction_type", "none"); + params.put("customs_items", customsItemsList); + + CustomsInfo customsInfo = client.customsInfo.create(params); + + System.out.println(customsInfo); + } +} diff --git a/official/docs/java/v7/customs-infos/retrieve.java b/official/docs/java/v7/customs-infos/retrieve.java new file mode 100644 index 00000000..27d8fc68 --- /dev/null +++ b/official/docs/java/v7/customs-infos/retrieve.java @@ -0,0 +1,15 @@ +package customs_info; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CustomsInfo; +import com.easypost.service.EasyPostClient; + +public class Retieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + CustomsInfo customsInfo = client.customsInfo.retrieve("cstinfo_..."); + + System.out.println(customsInfo); + } +} diff --git a/official/docs/java/v7/customs-items/create.java b/official/docs/java/v7/customs-items/create.java new file mode 100644 index 00000000..3c1fbebc --- /dev/null +++ b/official/docs/java/v7/customs-items/create.java @@ -0,0 +1,25 @@ +package customs_items; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CustomsItem; +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 params = new HashMap(); + params.put("description", "T-shirt"); + params.put("quantity", 1); + params.put("value", 10); + params.put("weight", 5); + params.put("origin_country", "US"); + params.put("hs_tariff_number", "123456"); + + CustomsItem customsItem = client.customsItem.create(params); + + System.out.println(customsItem); + } +} diff --git a/official/docs/java/v7/customs-items/retrieve.java b/official/docs/java/v7/customs-items/retrieve.java new file mode 100644 index 00000000..974a1433 --- /dev/null +++ b/official/docs/java/v7/customs-items/retrieve.java @@ -0,0 +1,15 @@ +package customs_items; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.CustomsItem; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + CustomsItem customsItem = client.customsItem.retrieve("cstitem_..."); + + System.out.println(customsItem); + } +} diff --git a/official/docs/java/v7/endshipper/buy.java b/official/docs/java/v7/endshipper/buy.java new file mode 100644 index 00000000..71b9c981 --- /dev/null +++ b/official/docs/java/v7/endshipper/buy.java @@ -0,0 +1,22 @@ +package endshipper; + +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Buy { + public static void main(String[] args) { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.retrieve("shp_..."); + + HashMap params = new HashMap(); + params.put("rate", shipment.lowestRate()); + params.put("end_shipper_id", "es_..."); + + Shipment endShipper = client.shipment.buy(shipment.getId(), params); + + System.out.println(endShipper); + } +} diff --git a/official/docs/java/v7/endshipper/create.java b/official/docs/java/v7/endshipper/create.java new file mode 100644 index 00000000..1c64a36c --- /dev/null +++ b/official/docs/java/v7/endshipper/create.java @@ -0,0 +1,29 @@ +package endshipper; + +import com.easypost.model.EndShipper; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Create { + public static void main(String[] args) { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + + params.put("name", "FOO BAR"); + params.put("company", "BAZ"); + params.put("street1", "164 TOWNSEND STREET UNIT 1"); + params.put("street2", "UNIT 1"); + params.put("city", "SAN FRANCISCO"); + params.put("state", "CA"); + params.put("zip", "94107"); + params.put("country", "US"); + params.put("phone", "555-555-5555"); + params.put("email", "FOO@EXAMPLE.COM"); + + EndShipper endShipper = client.endShipper.create(params); + + System.out.println(endShipper); + } +} diff --git a/official/docs/java/v7/endshipper/list.java b/official/docs/java/v7/endshipper/list.java new file mode 100644 index 00000000..b86f1722 --- /dev/null +++ b/official/docs/java/v7/endshipper/list.java @@ -0,0 +1,19 @@ +package endshipper; + +import com.easypost.model.EndShipperCollection; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class All { + public static void main(String[] args) { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap<>(); + params.put("page_size", 5); + + EndShipperCollection endShippers = client.endShipper.all(params); + + System.out.println(endShippers); + } +} diff --git a/official/docs/java/v7/endshipper/retrieve.java b/official/docs/java/v7/endshipper/retrieve.java new file mode 100644 index 00000000..3b4d1955 --- /dev/null +++ b/official/docs/java/v7/endshipper/retrieve.java @@ -0,0 +1,14 @@ +package endshipper; + +import com.easypost.model.EndShipper; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + EndShipper endShipper = client.endShipper.retrieve("es_..."); + + System.out.println(endShipper); + } +} diff --git a/official/docs/java/v7/endshipper/update.java b/official/docs/java/v7/endshipper/update.java new file mode 100644 index 00000000..fe04f7a6 --- /dev/null +++ b/official/docs/java/v7/endshipper/update.java @@ -0,0 +1,29 @@ +package endshipper; + +import com.easypost.model.EndShipper; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Update { + public static void main(String[] args) { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + + params.put("name", "NEW NAME"); + params.put("company", "BAZ"); + params.put("street1", "164 TOWNSEND STREET UNIT 1"); + params.put("street2", "UNIT 1"); + params.put("city", "SAN FRANCISCO"); + params.put("state", "CA"); + params.put("zip", "94107"); + params.put("country", "US"); + params.put("phone", "555-555-5555"); + params.put("email", "FOO@EXAMPLE.COM"); + + EndShipper endShipper = client.endShipper.update("es_...", params); + + System.out.println(endShipper); + } +} diff --git a/official/docs/java/v7/events/list.java b/official/docs/java/v7/events/list.java new file mode 100644 index 00000000..11eefa5d --- /dev/null +++ b/official/docs/java/v7/events/list.java @@ -0,0 +1,21 @@ +package events; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.EventCollection; +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 params = new HashMap<>(); + + params.put("page_size", 5); + + EventCollection events = client.event.all(params); + + System.out.println(events); + } +} diff --git a/official/docs/java/v7/events/retrieve.java b/official/docs/java/v7/events/retrieve.java new file mode 100644 index 00000000..62aecf95 --- /dev/null +++ b/official/docs/java/v7/events/retrieve.java @@ -0,0 +1,15 @@ +package events; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Event; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Event event = client.event.retrieve("evt_..."); + + System.out.println(event); + } +} diff --git a/official/docs/java/v7/forms/create.java b/official/docs/java/v7/forms/create.java new file mode 100644 index 00000000..b25a7421 --- /dev/null +++ b/official/docs/java/v7/forms/create.java @@ -0,0 +1,34 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.HashMap; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap titleMap = new HashMap(); + titleMap.put("title", "Square Reader"); + + HashMap barcodeMap = new HashMap(); + barcodeMap.put("barcode", "855658003251"); + + ArrayList> lineItemsMap = new ArrayList>(); + lineItemsMap.add(titleMap); + lineItemsMap.add(barcodeMap); + + HashMap params = new HashMap(); + params.put("barcode", "RMA12345678900"); + params.put("units", 8); + params.put("line_items", lineItemsMap); + + Shipment shipment = client.shipment.generateForm("shp_...", "return_packing_slip", + params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/insurance/create.java b/official/docs/java/v7/insurance/create.java new file mode 100644 index 00000000..ebfdce00 --- /dev/null +++ b/official/docs/java/v7/insurance/create.java @@ -0,0 +1,31 @@ +package insurances; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Insurance; +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 toAddressMap = new HashMap(); + toAddressMap.put("id", "adr_..."); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("id", "adr_..."); + + HashMap params = new HashMap(); + params.put("to_address", toAddressMap); + params.put("from_address", fromAddressMap); + params.put("tracking_code", "9400110898825022579493"); + params.put("carrier", "USPS"); + params.put("amount", "100.00"); + params.put("reference", "InsuranceRef1"); + + Insurance insurance = client.insurance.create(params); + + System.out.println(insurance); + } +} diff --git a/official/docs/java/v7/insurance/list.java b/official/docs/java/v7/insurance/list.java new file mode 100644 index 00000000..73bc21bc --- /dev/null +++ b/official/docs/java/v7/insurance/list.java @@ -0,0 +1,20 @@ +package insurances; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.InsuranceCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + InsuranceCollection insurances = client.insurance.all(params); + + System.out.println(insurances); + } +} diff --git a/official/docs/java/v7/insurance/refund.java b/official/docs/java/v7/insurance/refund.java new file mode 100644 index 00000000..1a21d424 --- /dev/null +++ b/official/docs/java/v7/insurance/refund.java @@ -0,0 +1,15 @@ +package insurances; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Insurance; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Insurance insurance = client.insurance.refund("ins_..."); + + System.out.println(insurance); + } +} diff --git a/official/docs/java/v7/insurance/retrieve.java b/official/docs/java/v7/insurance/retrieve.java new file mode 100644 index 00000000..f0380eec --- /dev/null +++ b/official/docs/java/v7/insurance/retrieve.java @@ -0,0 +1,15 @@ +package insurances; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Insurance; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Insurance insurance = client.insurance.retrieve("ins_..."); + + System.out.println(insurance); + } +} diff --git a/official/docs/java/v7/options/create-with-options.java b/official/docs/java/v7/options/create-with-options.java new file mode 100644 index 00000000..e1f8989a --- /dev/null +++ b/official/docs/java/v7/options/create-with-options.java @@ -0,0 +1,35 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class CreateWithOptions { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap toAddress = new HashMap(); + toAddress.put("id", "adr_..."); + + HashMap fromAddress = new HashMap(); + fromAddress.put("id", "adr_..."); + + HashMap parcel = new HashMap(); + parcel.put("id", "prcl_..."); + + HashMap options = new HashMap(); + parcel.put("print_custom_1", "Custom label message"); + + HashMap params = new HashMap(); + params.put("to_address", toAddress); + params.put("from_address", fromAddress); + params.put("parcel", parcel); + params.put("options", options); + + Shipment shipment = client.shipment.create(params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/orders/buy.java b/official/docs/java/v7/orders/buy.java new file mode 100644 index 00000000..ef05b86a --- /dev/null +++ b/official/docs/java/v7/orders/buy.java @@ -0,0 +1,21 @@ +package order; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Order; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Buy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + params.put("carrier", "FedEx"); + params.put("service", "FEDEX_GROUND"); + + Order order = client.order.buy("order_...", params); + + System.out.println(order); + } +} diff --git a/official/docs/java/v7/orders/create.java b/official/docs/java/v7/orders/create.java new file mode 100644 index 00000000..9f6e83fd --- /dev/null +++ b/official/docs/java/v7/orders/create.java @@ -0,0 +1,40 @@ +package order; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Order; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.HashMap; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap toAddress = new HashMap(); + toAddress.put("id", "adr_..."); + + HashMap fromAddress = new HashMap(); + fromAddress.put("id", "adr_..."); + + HashMap parcel1 = new HashMap(); + parcel1.put("weight", 10.2); + + HashMap parcel2 = new HashMap(); + parcel2.put("weight", 17.5); + parcel2.put("predefined_package", "FedExBox"); + + ArrayList> parcels = new ArrayList>(); + parcels.add(parcel1); + parcels.add(parcel2); + + HashMap params = new HashMap(); + params.put("to_address", toAddress); + params.put("from_address", fromAddress); + params.put("shipments", parcels); + + Order order = client.order.create(params); + + System.out.println(order); + } +} diff --git a/official/docs/java/v7/orders/one-call-buy.java b/official/docs/java/v7/orders/one-call-buy.java new file mode 100644 index 00000000..50d4470a --- /dev/null +++ b/official/docs/java/v7/orders/one-call-buy.java @@ -0,0 +1,42 @@ +package order; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Order; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.HashMap; + +public class OneCallBuy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap toAddress = new HashMap(); + toAddress.put("id", "adr_..."); + + HashMap fromAddress = new HashMap(); + fromAddress.put("id", "adr_..."); + + HashMap firstParcel = new HashMap(); + firstParcel.put("weight", 10.2); + + HashMap secondParcel = new HashMap(); + secondParcel.put("weight", 17.5); + secondParcel.put("predefined_package", "FedExBox"); + + ArrayList> shipments = new ArrayList>(); + shipments.add(firstParcel); + shipments.add(secondParcel); + + HashMap params = new HashMap(); + params.put("carrier_accounts", "ca_..."); + params.put("service", "NextDayAir"); + params.put("to_address", toAddress); + params.put("from_address", fromAddress); + params.put("shipments", shipments); + + Order order = client.order.create(params); + + System.out.println(order); + } +} diff --git a/official/docs/java/v7/orders/retrieve.java b/official/docs/java/v7/orders/retrieve.java new file mode 100644 index 00000000..812f8039 --- /dev/null +++ b/official/docs/java/v7/orders/retrieve.java @@ -0,0 +1,15 @@ +package order; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Order; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Order order = client.order.retrieve("order_..."); + + System.out.println(order); + } +} diff --git a/official/docs/java/v7/pagination/get-next-page.java b/official/docs/java/v7/pagination/get-next-page.java new file mode 100644 index 00000000..dd5c43c8 --- /dev/null +++ b/official/docs/java/v7/pagination/get-next-page.java @@ -0,0 +1,24 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ShipmentCollection; +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"); + + // Get the first page of results + HashMap params = new HashMap<>(); + params.put("page_size", 5); + + ShipmentCollection shipments = client.shipment.all(params); + + // Provide the previous results page to move onto the next page + ShipmentCollection nextPage = client.shipment.getNextPage(shipments); + + System.out.println(nextPage); + } +} diff --git a/official/docs/java/v7/parcels/create.java b/official/docs/java/v7/parcels/create.java new file mode 100644 index 00000000..703d2dde --- /dev/null +++ b/official/docs/java/v7/parcels/create.java @@ -0,0 +1,23 @@ +package parcels; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Parcel; +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 params = new HashMap(); + params.put("height", 5); + params.put("width", 10.9); + params.put("length", 20.2); + params.put("weight", 65.9); + + Parcel parcel = client.parcel.create(params); + + System.out.println(parcel); + } +} diff --git a/official/docs/java/v7/parcels/retrieve.java b/official/docs/java/v7/parcels/retrieve.java new file mode 100644 index 00000000..eb568fbf --- /dev/null +++ b/official/docs/java/v7/parcels/retrieve.java @@ -0,0 +1,15 @@ +package parcels; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Parcel; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Parcel parcel = client.parcel.retrieve("prcl_..."); + + System.out.println(parcel); + } +} diff --git a/official/docs/java/v7/payloads/list.java b/official/docs/java/v7/payloads/list.java new file mode 100644 index 00000000..beaa43f0 --- /dev/null +++ b/official/docs/java/v7/payloads/list.java @@ -0,0 +1,15 @@ +package events; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Payload; +import com.easypost.service.EasyPostClient; + +public class RetrieveAllPayloads { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + List payloads = client.event.retrieveAllPayloads("evt_..."); + + System.out.println(payloads); + } +} diff --git a/official/docs/java/v7/payloads/retrieve.java b/official/docs/java/v7/payloads/retrieve.java new file mode 100644 index 00000000..097ef2c5 --- /dev/null +++ b/official/docs/java/v7/payloads/retrieve.java @@ -0,0 +1,15 @@ +package events; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Payload; +import com.easypost.service.EasyPostClient; + +public class RetrievePayload { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Payload payload = client.event.retrievePayload("evt_...", "payload_..."); + + System.out.println(payload); + } +} diff --git a/official/docs/java/v7/pickups/buy.java b/official/docs/java/v7/pickups/buy.java new file mode 100644 index 00000000..1018d387 --- /dev/null +++ b/official/docs/java/v7/pickups/buy.java @@ -0,0 +1,21 @@ +package pickups; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Pickup; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Buy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + params.put("carrier", "UPS"); + params.put("service", "Same-day Pickup"); + + Pickup pickup = client.pickup.buy("pickup_...", params); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v7/pickups/cancel.java b/official/docs/java/v7/pickups/cancel.java new file mode 100644 index 00000000..e7f42ea5 --- /dev/null +++ b/official/docs/java/v7/pickups/cancel.java @@ -0,0 +1,15 @@ +package pickups; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Pickup; +import com.easypost.service.EasyPostClient; + +public class Cancel { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Pickup pickup = client.pickup.cancel("pickup_..."); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v7/pickups/create.java b/official/docs/java/v7/pickups/create.java new file mode 100644 index 00000000..23270b57 --- /dev/null +++ b/official/docs/java/v7/pickups/create.java @@ -0,0 +1,32 @@ +package pickups; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Pickup; +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 address = new HashMap(); + address.put("id", "adr_..."); + + HashMap shipment = new HashMap(); + shipment.put("id", "shp_..."); + + HashMap params = new HashMap(); + params.put("address", address); + params.put("shipment", shipment); + params.put("reference", "my-first-pickup"); + params.put("min_datetime", "2022-10-01 10:30:00"); + params.put("max_datetime", "2022-10-02 10:30:00"); + params.put("is_account_address", false); + params.put("instructions", "Special pickup instructions"); + + Pickup pickup = client.pickup.create(params); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v7/pickups/list.java b/official/docs/java/v7/pickups/list.java new file mode 100644 index 00000000..c20e3aee --- /dev/null +++ b/official/docs/java/v7/pickups/list.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PickupCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + PickupCollection pickupCollection = client.pickup.all(params); + + System.out.println(pickupCollection); + } +} diff --git a/official/docs/java/v7/pickups/retrieve.java b/official/docs/java/v7/pickups/retrieve.java new file mode 100644 index 00000000..c1dc9731 --- /dev/null +++ b/official/docs/java/v7/pickups/retrieve.java @@ -0,0 +1,15 @@ +package pickups; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Pickup; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Pickup pickup = client.pickup.retrieve("pickup_..."); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v7/rates/regenerate.java b/official/docs/java/v7/rates/regenerate.java new file mode 100644 index 00000000..93b396c0 --- /dev/null +++ b/official/docs/java/v7/rates/regenerate.java @@ -0,0 +1,15 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +public class Regenerate { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.newRates("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/rates/retrieve-stateless.java b/official/docs/java/v7/rates/retrieve-stateless.java new file mode 100644 index 00000000..55602fdb --- /dev/null +++ b/official/docs/java/v7/rates/retrieve-stateless.java @@ -0,0 +1,50 @@ +package rates; + +import java.util.HashMap; +import java.util.List; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.StatelessRate; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap toAddressMap = new HashMap(); + toAddressMap.put("name", "Dr. Steve Brule"); + toAddressMap.put("street1", "179 N Harbor Dr"); + toAddressMap.put("city", "Redondo Beach"); + toAddressMap.put("state", "CA"); + toAddressMap.put("country", "US"); + toAddressMap.put("phone", "8573875756"); + toAddressMap.put("email", "dr_steve_brule@gmail.com"); + toAddressMap.put("zip", "90277"); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("name", "EasyPost"); + fromAddressMap.put("street1", "417 Montgomery Street"); + fromAddressMap.put("street2", "5th Floor"); + fromAddressMap.put("city", "San Francisco"); + fromAddressMap.put("state", "CA"); + fromAddressMap.put("zip", "94104"); + fromAddressMap.put("country", "US"); + fromAddressMap.put("phone", "4153334445"); + fromAddressMap.put("email", "support@easypost.com"); + + HashMap parcelMap = new HashMap(); + parcelMap.put("length", 20.2); + parcelMap.put("width", 10.9); + parcelMap.put("height", 5); + parcelMap.put("weight", 65.9); + + HashMap shipmentDetails = new HashMap(); + shipmentDetails.put("to_address", toAddressMap); + shipmentDetails.put("from_address", fromAddressMap); + shipmentDetails.put("parcel", parcelMap); + + List rates = client.betaRate.retrieveStatelessRates(shipmentDetails); + + System.out.println(rates); + } +} diff --git a/official/docs/java/v7/rates/retrieve.java b/official/docs/java/v7/rates/retrieve.java new file mode 100644 index 00000000..4cbced71 --- /dev/null +++ b/official/docs/java/v7/rates/retrieve.java @@ -0,0 +1,15 @@ +package rates; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Rate; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Rate rate = client.rate.retrieve("rate_..."); + + System.out.println(rate); + } +} diff --git a/official/docs/java/v7/referral-customers/add-payment-method-with-bank-account.java b/official/docs/java/v7/referral-customers/add-payment-method-with-bank-account.java new file mode 100644 index 00000000..4c8b11c9 --- /dev/null +++ b/official/docs/java/v7/referral-customers/add-payment-method-with-bank-account.java @@ -0,0 +1,15 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PaymentMethodObject; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + PaymentMethodObject paymentMethod = client.betaReferralCustomer.addPaymentMethod("cus_...", "ba_..."); + + System.out.println(paymentMethod); + } +} diff --git a/official/docs/java/v7/referral-customers/add-payment-method-with-credit-card.java b/official/docs/java/v7/referral-customers/add-payment-method-with-credit-card.java new file mode 100644 index 00000000..b4e65d7d --- /dev/null +++ b/official/docs/java/v7/referral-customers/add-payment-method-with-credit-card.java @@ -0,0 +1,15 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.PaymentMethodObject; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + PaymentMethodObject paymentMethod = client.betaReferralCustomer.addPaymentMethod("cus_...", "card_..."); + + System.out.println(paymentMethod); + } +} diff --git a/official/docs/java/v7/referral-customers/create.java b/official/docs/java/v7/referral-customers/create.java new file mode 100644 index 00000000..f64686cc --- /dev/null +++ b/official/docs/java/v7/referral-customers/create.java @@ -0,0 +1,23 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ReferralCustomer; +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 params = new HashMap<>(); + + params.put("name", "test test"); + params.put("email", "test@test.com"); + params.put("phone", "8888888888"); + + ReferralCustomer referralUser = client.referralCustomer.create(params); + + System.out.println(referralUser); + } +} diff --git a/official/docs/java/v7/referral-customers/list.java b/official/docs/java/v7/referral-customers/list.java new file mode 100644 index 00000000..5cb0557a --- /dev/null +++ b/official/docs/java/v7/referral-customers/list.java @@ -0,0 +1,25 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ReferralCustomer; +import com.easypost.model.ReferralCustomerCollection; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; +import java.util.List; + +public class All { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + + params.put("page_size", 5); + + ReferralCustomerCollection referallCustomorCollection = client.referralCustomer.all(params); + + List referallUsers = referallCustomorCollection.getReferralCustomers(); + + System.out.println(referallUsers); + } +} diff --git a/official/docs/java/v7/referral-customers/refund-by-amount.java b/official/docs/java/v7/referral-customers/refund-by-amount.java new file mode 100644 index 00000000..d666203c --- /dev/null +++ b/official/docs/java/v7/referral-customers/refund-by-amount.java @@ -0,0 +1,15 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.BetaPaymentRefund; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + BetaPaymentRefund refund = client.betaReferralCustomer.refundByAmount(2000); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v7/referral-customers/refund-by-payment-log.java b/official/docs/java/v7/referral-customers/refund-by-payment-log.java new file mode 100644 index 00000000..d666203c --- /dev/null +++ b/official/docs/java/v7/referral-customers/refund-by-payment-log.java @@ -0,0 +1,15 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.BetaPaymentRefund; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + BetaPaymentRefund refund = client.betaReferralCustomer.refundByAmount(2000); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v7/referral-customers/update.java b/official/docs/java/v7/referral-customers/update.java new file mode 100644 index 00000000..b744612d --- /dev/null +++ b/official/docs/java/v7/referral-customers/update.java @@ -0,0 +1,12 @@ +package referral; + +import com.easypost.exception.EasyPostException; +import com.easypost.service.EasyPostClient; + +public class Update { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.referralCustomer.updateEmail("user_...", "new_email@example.com"); + } +} diff --git a/official/docs/java/v7/refunds/create.java b/official/docs/java/v7/refunds/create.java new file mode 100644 index 00000000..166fa171 --- /dev/null +++ b/official/docs/java/v7/refunds/create.java @@ -0,0 +1,21 @@ +package refunds; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Refund; +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 params = new HashMap(); + params.put("carrier", toAddressMap); + params.put("tracking_codes", Arrays.asList(new String[] { "EZ1000000001" })); + + List refunds = client.refund.create(params); + + System.out.println(refunds); + } +} diff --git a/official/docs/java/v7/refunds/list.java b/official/docs/java/v7/refunds/list.java new file mode 100644 index 00000000..d1eef5e0 --- /dev/null +++ b/official/docs/java/v7/refunds/list.java @@ -0,0 +1,20 @@ +package refunds; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.RefundCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + RefundCollection refunds = client.refund.all(params); + + System.out.println(refunds); + } +} diff --git a/official/docs/java/v7/refunds/retrieve.java b/official/docs/java/v7/refunds/retrieve.java new file mode 100644 index 00000000..242b362d --- /dev/null +++ b/official/docs/java/v7/refunds/retrieve.java @@ -0,0 +1,15 @@ +package refunds; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Refund; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Refund refund = client.refund.retrieve("rfnd_..."); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v7/reports/create.java b/official/docs/java/v7/reports/create.java new file mode 100644 index 00000000..aa9f6922 --- /dev/null +++ b/official/docs/java/v7/reports/create.java @@ -0,0 +1,22 @@ +package reports; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Report; +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 params = new HashMap(); + params.put("type", "payment_log"); + params.put("start_date", "2022-10-01"); + params.put("end_date", "2022-10-31"); + + Report report = client.report.create(params); + + System.out.println(report); + } +} diff --git a/official/docs/java/v7/reports/list.java b/official/docs/java/v7/reports/list.java new file mode 100644 index 00000000..a324bb32 --- /dev/null +++ b/official/docs/java/v7/reports/list.java @@ -0,0 +1,21 @@ +package reports; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ReportCollection; +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 params = new HashMap(); + params.put("type", "payment_log"); + params.put("page_size", "5"); + + ReportCollection reports = client.report.all(params); + + System.out.println(reports); + } +} diff --git a/official/docs/java/v7/reports/retrieve.java b/official/docs/java/v7/reports/retrieve.java new file mode 100644 index 00000000..929d7a6b --- /dev/null +++ b/official/docs/java/v7/reports/retrieve.java @@ -0,0 +1,15 @@ +package reports; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Report; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Report report = client.report.retrieve(""); + + System.out.println(report); + } +} diff --git a/official/docs/java/v7/returns/create.java b/official/docs/java/v7/returns/create.java new file mode 100644 index 00000000..c550362a --- /dev/null +++ b/official/docs/java/v7/returns/create.java @@ -0,0 +1,50 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +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 toAddressMap = new HashMap(); + toAddressMap.put("name", "Dr. Steve Brule"); + toAddressMap.put("street1", "179 N Harbor Dr"); + toAddressMap.put("city", "Redondo Beach"); + toAddressMap.put("state", "CA"); + toAddressMap.put("country", "US"); + toAddressMap.put("phone", "8573875756"); + toAddressMap.put("email", "dr_steve_brule@gmail.com"); + toAddressMap.put("zip", "90277"); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("name", "EasyPost"); + fromAddressMap.put("street1", "417 Montgomery Street"); + fromAddressMap.put("street2", "5th Floor"); + fromAddressMap.put("city", "San Francisco"); + fromAddressMap.put("state", "CA"); + fromAddressMap.put("zip", "94104"); + fromAddressMap.put("country", "US"); + fromAddressMap.put("phone", "4153334445"); + fromAddressMap.put("email", "support@easypost.com"); + + HashMap parcelMap = new HashMap(); + parcelMap.put("length", 20.2); + parcelMap.put("width", 10.9); + parcelMap.put("height", 5); + parcelMap.put("weight", 65.9); + + HashMap params = new HashMap(); + params.put("to_address", toAddressMap); + params.put("from_address", fromAddressMap); + params.put("parcel", parcelMap); + params.put("is_return", "true"); + + Shipment shipment = client.shipment.create(params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/scan-form/create.java b/official/docs/java/v7/scan-form/create.java new file mode 100644 index 00000000..6923f8f4 --- /dev/null +++ b/official/docs/java/v7/scan-form/create.java @@ -0,0 +1,28 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ScanForm; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.retrieve("shp_..."); + + List shipments = new ArrayList(); + shipments.add(shipment); + + HashMap params = new HashMap(); + params.put("shipments", shipments); + + ScanForm scanForm = client.scanform.create(params); + + System.out.println(scanForm); + } +} diff --git a/official/docs/java/v7/scan-form/list.java b/official/docs/java/v7/scan-form/list.java new file mode 100644 index 00000000..633ba15f --- /dev/null +++ b/official/docs/java/v7/scan-form/list.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ScanFormCollection; +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 params = new HashMap(); + params.put("page_size", 5); + + ScanFormCollection scanForms = client.scanform.all(params); + + System.out.println(scanForms); + } +} diff --git a/official/docs/java/v7/scan-form/retrieve.java b/official/docs/java/v7/scan-form/retrieve.java new file mode 100644 index 00000000..63799a60 --- /dev/null +++ b/official/docs/java/v7/scan-form/retrieve.java @@ -0,0 +1,15 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ScanForm; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + ScanForm scanForm = client.scanform.retrieve("sf_..."); + + System.out.println(scanForm); + } +} diff --git a/official/docs/java/v7/shipments/buy.java b/official/docs/java/v7/shipments/buy.java new file mode 100644 index 00000000..299b838e --- /dev/null +++ b/official/docs/java/v7/shipments/buy.java @@ -0,0 +1,23 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Buy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment retrievedShipment = client.shipment.retrieve("shp_..."); + + HashMap params = new HashMap(); + params.put("rate", retrievedShipment.lowestRate()); + params.put("insurance", "249.99"); + + Shipment shipment = client.shipment.buy(retrievedShipment.getId(), params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipments/create.java b/official/docs/java/v7/shipments/create.java new file mode 100644 index 00000000..19651a45 --- /dev/null +++ b/official/docs/java/v7/shipments/create.java @@ -0,0 +1,53 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +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 toAddressMap = new HashMap(); + toAddressMap.put("name", "Dr. Steve Brule"); + toAddressMap.put("street1", "179 N Harbor Dr"); + toAddressMap.put("city", "Redondo Beach"); + toAddressMap.put("state", "CA"); + toAddressMap.put("country", "US"); + toAddressMap.put("phone", "8573875756"); + toAddressMap.put("email", "dr_steve_brule@gmail.com"); + toAddressMap.put("zip", "90277"); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("name", "EasyPost"); + fromAddressMap.put("street1", "417 Montgomery Street"); + fromAddressMap.put("street2", "5th Floor"); + fromAddressMap.put("city", "San Francisco"); + fromAddressMap.put("state", "CA"); + fromAddressMap.put("zip", "94104"); + fromAddressMap.put("country", "US"); + fromAddressMap.put("phone", "4153334445"); + fromAddressMap.put("email", "support@easypost.com"); + + HashMap parcelMap = new HashMap(); + parcelMap.put("length", 20.2); + parcelMap.put("width", 10.9); + parcelMap.put("height", 5); + parcelMap.put("weight", 65.9); + + HashMap customsInfoMap = new HashMap(); + customsInfoMap.put("id", "cstinfo_..."); + + HashMap params = new HashMap(); + params.put("to_address", toAddressMap); + params.put("from_address", fromAddressMap); + params.put("parcel", parcelMap); + params.put("customs_info", customsInfoMap); + + Shipment shipment = client.shipment.create(params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipments/label.java b/official/docs/java/v7/shipments/label.java new file mode 100644 index 00000000..52a60c91 --- /dev/null +++ b/official/docs/java/v7/shipments/label.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Label { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + params.put("file_format", "ZPL"); + + Shipment shipment = client.shipment.label("shp_...", params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipments/list.java b/official/docs/java/v7/shipments/list.java new file mode 100644 index 00000000..37f6d758 --- /dev/null +++ b/official/docs/java/v7/shipments/list.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.ShipmentCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + ShipmentCollection shipments = client.shipment.all(params); + + System.out.println(shipments); + } +} diff --git a/official/docs/java/v7/shipments/one-call-buy.java b/official/docs/java/v7/shipments/one-call-buy.java new file mode 100644 index 00000000..bb557cda --- /dev/null +++ b/official/docs/java/v7/shipments/one-call-buy.java @@ -0,0 +1,55 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class OneCallBuy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap toAddressMap = new HashMap(); + toAddressMap.put("name", "Dr. Steve Brule"); + toAddressMap.put("street1", "179 N Harbor Dr"); + toAddressMap.put("city", "Redondo Beach"); + toAddressMap.put("state", "CA"); + toAddressMap.put("country", "US"); + toAddressMap.put("phone", "8573875756"); + toAddressMap.put("email", "dr_steve_brule@gmail.com"); + toAddressMap.put("zip", "90277"); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("name", "EasyPost"); + fromAddressMap.put("street1", "417 Montgomery Street"); + fromAddressMap.put("street2", "5th Floor"); + fromAddressMap.put("city", "San Francisco"); + fromAddressMap.put("state", "CA"); + fromAddressMap.put("zip", "94104"); + fromAddressMap.put("country", "US"); + fromAddressMap.put("phone", "4153334445"); + fromAddressMap.put("email", "support@easypost.com"); + + HashMap parcelMap = new HashMap(); + parcelMap.put("length", 20.2); + parcelMap.put("width", 10.9); + parcelMap.put("height", 5); + parcelMap.put("weight", 65.9); + + HashMap customsInfoMap = new HashMap(); + customsInfoMap.put("id", "cstinfo_..."); + + HashMap params = new HashMap(); + params.put("to_address", toAddressMap); + params.put("from_address", fromAddressMap); + params.put("parcel", parcelMap); + params.put("customs_info", customsInfoMap); + params.put("carrier_accounts", "ca_..."); + params.put("service", "NextDayAir"); + + Shipment shipment = client.shipment.create(params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipments/retrieve.java b/official/docs/java/v7/shipments/retrieve.java new file mode 100644 index 00000000..b942018c --- /dev/null +++ b/official/docs/java/v7/shipments/retrieve.java @@ -0,0 +1,15 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.retrieve("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipping-insurance/insure.java b/official/docs/java/v7/shipping-insurance/insure.java new file mode 100644 index 00000000..0ac3d12b --- /dev/null +++ b/official/docs/java/v7/shipping-insurance/insure.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Insure { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + HashMap params = new HashMap(); + params.put("amount", 100); + + Shipment shipment = client.shipment.insure("shp_...", params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/shipping-refund/refund.java b/official/docs/java/v7/shipping-refund/refund.java new file mode 100644 index 00000000..c7ed93b4 --- /dev/null +++ b/official/docs/java/v7/shipping-refund/refund.java @@ -0,0 +1,15 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.service.EasyPostClient; + +public class Create { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.refund("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/smartrate/retrieve-estimated-delivery-date.java b/official/docs/java/v7/smartrate/retrieve-estimated-delivery-date.java new file mode 100644 index 00000000..a6cee688 --- /dev/null +++ b/official/docs/java/v7/smartrate/retrieve-estimated-delivery-date.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.model.EstimatedDeliveryDate; +import com.easypost.service.EasyPostClient; + +import java.util.List; + +public class RetrieveEstimatedDeliveryDate { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.retrieve("shp_..."); + List estimatedDeliveryDates = client + .shipmentretrieveEstimatedDeliveryDate(shipment.getId(), "YYYY-MM-DD"); + + System.out.println(estimatedDeliveryDates); + } +} diff --git a/official/docs/java/v7/smartrate/retrieve-recommend-ship-date.java b/official/docs/java/v7/smartrate/retrieve-recommend-ship-date.java new file mode 100644 index 00000000..0ff2ccb2 --- /dev/null +++ b/official/docs/java/v7/smartrate/retrieve-recommend-ship-date.java @@ -0,0 +1,20 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +import com.easypost.model.RecommendShipDateForShipmentResult; +import com.easypost.service.EasyPostClient; + +import java.util.List; + +public class RetrieveRecommendShipDate { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Shipment shipment = client.shipment.retrieve("shp_..."); + List rates = client.shipment + .recommendShipDate(shipment.getId(), "YYYY-MM-DD"); + + System.out.println(rates); + } +} diff --git a/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-by.java b/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-by.java new file mode 100644 index 00000000..75b704d2 --- /dev/null +++ b/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-by.java @@ -0,0 +1,25 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.EstimateDeliveryDateForZipPairResult; +import com.easypost.service.EasyPostClient; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class RetrieveRecommendShipDate { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + Map params = new HashMap(); + params.put("from_zip", "10001"); + params.put("to_zip", "10002"); + params.put("planned_ship_date", "2024-07-18"); + params.put("carriers", Collections.singletonList("UPS")); + + EstimateDeliveryDateForZipPairResult results = client.smartRate + .estimateDeliveryDate(params); + + System.out.println(results); + } +} diff --git a/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-on.java b/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-on.java new file mode 100644 index 00000000..3b9a6367 --- /dev/null +++ b/official/docs/java/v7/smartrate/retrieve-standalone-smartrate-deliver-on.java @@ -0,0 +1,25 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.RecommendShipDateForZipPairResult; +import com.easypost.service.EasyPostClient; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class RetrieveRecommendShipDate { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + Map params = new HashMap(); + params.put("from_zip", "10001"); + params.put("to_zip", "10002"); + params.put("desired_delivery_date", "2024-07-18"); + params.put("carriers", Collections.singletonList("UPS")); + + RecommendShipDateForZipPairResult results = client.smartRate + .recommendShipDate(params); + + System.out.println(results); + } +} diff --git a/official/docs/java/v7/smartrate/retrieve-time-in-transit-statistics.java b/official/docs/java/v7/smartrate/retrieve-time-in-transit-statistics.java new file mode 100644 index 00000000..0ae4297f --- /dev/null +++ b/official/docs/java/v7/smartrate/retrieve-time-in-transit-statistics.java @@ -0,0 +1,17 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.SmartRate; +import com.easypost.service.EasyPostClient; + +import java.util.List; + +public class RetrieveTimeInTransitStatistics { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + List smartrates = client.shipment.smartrates("shp_..."); + + System.out.println(smartrates); + } +} diff --git a/official/docs/java/v7/tax-identifiers/create.java b/official/docs/java/v7/tax-identifiers/create.java new file mode 100644 index 00000000..4a7bf313 --- /dev/null +++ b/official/docs/java/v7/tax-identifiers/create.java @@ -0,0 +1,60 @@ +package shipments; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Shipment; +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 toAddressMap = new HashMap(); + toAddressMap.put("name", "Dr. Steve Brule"); + toAddressMap.put("street1", "179 N Harbor Dr"); + toAddressMap.put("city", "Redondo Beach"); + toAddressMap.put("state", "CA"); + toAddressMap.put("country", "US"); + toAddressMap.put("phone", "8573875756"); + toAddressMap.put("email", "dr_steve_brule@gmail.com"); + toAddressMap.put("zip", "90277"); + + HashMap fromAddressMap = new HashMap(); + fromAddressMap.put("name", "EasyPost"); + fromAddressMap.put("street1", "417 Montgomery Street"); + fromAddressMap.put("street2", "5th Floor"); + fromAddressMap.put("city", "San Francisco"); + fromAddressMap.put("state", "CA"); + fromAddressMap.put("zip", "94104"); + fromAddressMap.put("country", "US"); + fromAddressMap.put("phone", "4153334445"); + fromAddressMap.put("email", "support@easypost.com"); + + HashMap parcelMap = new HashMap(); + parcelMap.put("length", 20.2); + parcelMap.put("width", 10.9); + parcelMap.put("height", 5); + parcelMap.put("weight", 65.9); + + HashMap customsInfoMap = new HashMap(); + customsInfoMap.put("id", "cstinfo_..."); + + HashMap taxIdentifiersMap = new HashMap(); + taxIdentifiersMap.put("entity", "SENDER"); + taxIdentifiersMap.put("tax_id", "GB123456789"); + taxIdentifiersMap.put("tax_id_type", "EORI"); + taxIdentifiersMap.put("issuing_country", "GB"); + + HashMap params = new HashMap(); + params.put("to_address", toAddressMap); + params.put("from_address", fromAddressMap); + params.put("parcel", parcelMap); + params.put("customs_info", customsInfoMap); + params.put("tax_identifiers", taxIdentifiersMap); + + Shipment shipment = client.shipment.create(params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v7/trackers/create.java b/official/docs/java/v7/trackers/create.java new file mode 100644 index 00000000..7fc070ef --- /dev/null +++ b/official/docs/java/v7/trackers/create.java @@ -0,0 +1,21 @@ +package trackers; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Tracker; +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 params = new HashMap(); + params.put("tracking_code", "EZ1000000001"); + params.put("carrier", "USPS"); + + Tracker tracker = client.tracker.create(params); + + System.out.println(tracker); + } +} diff --git a/official/docs/java/v7/trackers/list.java b/official/docs/java/v7/trackers/list.java new file mode 100644 index 00000000..21d5fb37 --- /dev/null +++ b/official/docs/java/v7/trackers/list.java @@ -0,0 +1,20 @@ +package trackers; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.TrackerCollection; +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 params = new HashMap<>(); + params.put("page_size", 5); + + TrackerCollection trackers = client.tracker.all(params); + + System.out.println(trackers); + } +} diff --git a/official/docs/java/v7/trackers/retrieve.java b/official/docs/java/v7/trackers/retrieve.java new file mode 100644 index 00000000..aa0cd155 --- /dev/null +++ b/official/docs/java/v7/trackers/retrieve.java @@ -0,0 +1,15 @@ +package trackers; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Tracker; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Tracker tracker = client.tracker.retrieve("trk_..."); + + System.out.println(tracker); + } +} diff --git a/official/docs/java/v7/users/retrieve.java b/official/docs/java/v7/users/retrieve.java new file mode 100644 index 00000000..7fb1398a --- /dev/null +++ b/official/docs/java/v7/users/retrieve.java @@ -0,0 +1,21 @@ +package users; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.User; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + // Retrieve the authenticated user + User parentUser = client.user.retrieveMe(); + + System.out.println(parentUser); + + // Retrieve a child user + User childUser = client.user.retrieve("user_..."); + + System.out.println(childUser); + } +} diff --git a/official/docs/java/v7/users/update.java b/official/docs/java/v7/users/update.java new file mode 100644 index 00000000..c3e59093 --- /dev/null +++ b/official/docs/java/v7/users/update.java @@ -0,0 +1,20 @@ +package users; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.User; +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"); + + HashMap params = new HashMap(); + params.put("recharge_threshold", "50.00"); + + User user = client.user.update("user_...", params); + + System.out.println(user); + } +} diff --git a/official/docs/java/v7/webhooks/create.java b/official/docs/java/v7/webhooks/create.java new file mode 100644 index 00000000..554e9110 --- /dev/null +++ b/official/docs/java/v7/webhooks/create.java @@ -0,0 +1,21 @@ +package webhooks; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Webhook; +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 params = new HashMap(); + params.put("url", "example.com"); + paramMap.put("webhook_secret", "A1B2C3"); + + Webhook webhook = client.webhook.create(params); + + System.out.println(webhook); + } +} diff --git a/official/docs/java/v7/webhooks/delete.java b/official/docs/java/v7/webhooks/delete.java new file mode 100644 index 00000000..bbf6adcb --- /dev/null +++ b/official/docs/java/v7/webhooks/delete.java @@ -0,0 +1,12 @@ +package webhooks; + +import com.easypost.exception.EasyPostException; +import com.easypost.service.EasyPostClient; + +public class Delete { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + client.webhook.delete("hook_..."); + } +} diff --git a/official/docs/java/v7/webhooks/list.java b/official/docs/java/v7/webhooks/list.java new file mode 100644 index 00000000..d676aaa5 --- /dev/null +++ b/official/docs/java/v7/webhooks/list.java @@ -0,0 +1,15 @@ +package webhooks; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.WebhookCollection; +import com.easypost.service.EasyPostClient; + +public class All { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + WebhookCollection webhooks = client.webhook.all(); + + System.out.println(webhooks); + } +} diff --git a/official/docs/java/v7/webhooks/retrieve.java b/official/docs/java/v7/webhooks/retrieve.java new file mode 100644 index 00000000..d8c264a5 --- /dev/null +++ b/official/docs/java/v7/webhooks/retrieve.java @@ -0,0 +1,15 @@ +package webhooks; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Webhook; +import com.easypost.service.EasyPostClient; + +public class Retrieve { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Webhook webhook = client.webhook.retrieve("hook_..."); + + System.out.println(webhook); + } +} diff --git a/official/docs/java/v7/webhooks/update.java b/official/docs/java/v7/webhooks/update.java new file mode 100644 index 00000000..b8819fc7 --- /dev/null +++ b/official/docs/java/v7/webhooks/update.java @@ -0,0 +1,15 @@ +package webhooks; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Webhook; +import com.easypost.service.EasyPostClient; + +public class Update { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + + Webhook webhook = client.webhook.update("hook_..."); + + System.out.println(webhook); + } +} diff --git a/official/guides/errors-guide/csharp/catch-error.cs b/official/guides/errors-guide/csharp/catch-error.cs index c19e386a..a2a66c37 100644 --- a/official/guides/errors-guide/csharp/catch-error.cs +++ b/official/guides/errors-guide/csharp/catch-error.cs @@ -15,12 +15,12 @@ public static async Task Main() // When the `errors` key is returned as an array of FieldError objects try { - // Simulate a request with missing parameters: PARAMETER.REQUIRED + // Simulate a request with missing parameters await client.Shipment.Create(new Dictionary()); } - catch (InvalidRequestError exception) + catch (ApiError error) { - FieldError fieldError = (FieldError)exception.Errors.First(); + FieldError fieldError = (FieldError)error.Errors.First(); Console.Write(fieldError.Message); } @@ -29,13 +29,13 @@ public static async Task Main() { var claimParameters = new EasyPost.Parameters.Claims.Create { - TrackingCode = "123" // Simulate a request with an invalid tracking code: NOT_FOUND + TrackingCode = "123" // Simulate a request with an invalid tracking code } await Client.Claim.Create(claimParameters); } - catch (NotFoundError exception) + catch (ApiError error) { - Console.Write(exception.Errors.First()); + Console.Write(error.Errors.First()); } } } diff --git a/official/guides/errors-guide/golang/catch-error.go b/official/guides/errors-guide/golang/catch-error.go index 8837f921..56459bed 100644 --- a/official/guides/errors-guide/golang/catch-error.go +++ b/official/guides/errors-guide/golang/catch-error.go @@ -10,13 +10,14 @@ import ( func main() { client := easypost.New("EASYPOST_API_KEY") + var apiError *easypost.APIError + // When the `errors` key is returned as an array of FieldError objects _, err := client.CreateShipment( - &easypost.Shipment{}, // Simulate a request with missing parameters: PARAMETER.REQUIRED + &easypost.Shipment{}, // Simulate a request with missing parameters ) - var invalidRequestError *easypost.InvalidRequestError - if errors.As(err, &invalidRequestError) { - if errorsList, ok := invalidRequestError.Errors.([]interface{}); ok { + if errors.As(err, &apiError) { + if errorsList, ok := apiError.Errors.([]interface{}); ok { if fieldError, ok := errorsList[0].(*easypost.FieldError); ok { fmt.Println(fieldError.Message) } @@ -25,11 +26,10 @@ func main() { // When the `errors` key is returned as an array of strings _, err = client.CreateClaim(&easypost.CreateClaimParameters{ - TrackingCode: "123", // Simulate a request with an invalid tracking code: NOT_FOUND + TrackingCode: "123", // Simulate a request with an invalid tracking code }) - var notFoundError *easypost.NotFoundError - if errors.As(err, ¬FoundError) { - if errorsList, ok := notFoundError.Errors.([]interface{}); ok { + if errors.As(err, &apiError) { + if errorsList, ok := apiError.Errors.([]interface{}); ok { fmt.Println(errorsList[0]) } } diff --git a/official/guides/errors-guide/java/catch-error.java b/official/guides/errors-guide/java/catch-error.java index 64633904..258b3690 100644 --- a/official/guides/errors-guide/java/catch-error.java +++ b/official/guides/errors-guide/java/catch-error.java @@ -1,22 +1,33 @@ package errors; import java.util.HashMap; +import java.util.Map; -import com.easypost.service.EasyPostClient; import com.easypost.exception.APIException; +import com.easypost.exception.General.EasyPostException; +import com.easypost.service.EasyPostClient; public class CatchError { public static void main(String[] args) throws EasyPostException { EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY"); + // When the `errors` key is returned as an array of FieldError objects try { - Map addressData = new HashMap(); - - addressData.put("verify_strict", true); + Map shipmentData = new HashMap<>(); + // Simulate a request with missing parameters + client.shipment.create(shipmentData); + } catch (APIException exception) { + FieldError fieldError = (FieldError) exception.getErrors().get(0); + System.err.println(fieldError.getMessage()); + } - Address address = client.address.create(address); - } catch (APIException error) { - System.err.println(error.getCode()); + // When the `errors` key is returned as an array of strings + try { + Map claimData = new HashMap<>(); + claimData.put("tracking_code", "123"); // Simulate a request with an invalid tracking code + client.claim.create(claimData); + } catch (APIException exception) { + System.err.println(exception.getErrors().get(0)); } } }