diff --git a/official/docs/csharp/v5/addresses/create-and-verify.cs b/official/docs/csharp/v5/addresses/create-and-verify.cs new file mode 100644 index 00000000..815d1812 --- /dev/null +++ b/official/docs/csharp/v5/addresses/create-and-verify.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "417 Montgomery Street", + Street2 = "FL 5", + City = "San Francisco", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + }; + + Address address = await client.Address.CreateAndVerify(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/create.cs b/official/docs/csharp/v5/addresses/create.cs new file mode 100644 index 00000000..ac3f2415 --- /dev/null +++ b/official/docs/csharp/v5/addresses/create.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "417 MONTGOMERY ST", + Street2 = "FLOOR 5", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + }; + + Address address = await client.Address.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/list.cs b/official/docs/csharp/v5/addresses/list.cs new file mode 100644 index 00000000..953833ac --- /dev/null +++ b/official/docs/csharp/v5/addresses/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.All parameters = new() + { + PageSize = 5 + }; + + AddressCollection addressCollection = await client.Address.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(addressCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/retrieve.cs b/official/docs/csharp/v5/addresses/retrieve.cs new file mode 100644 index 00000000..c980fac6 --- /dev/null +++ b/official/docs/csharp/v5/addresses/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Address address = await client.Address.Retrieve("adr_..."); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/verify-failure.cs b/official/docs/csharp/v5/addresses/verify-failure.cs new file mode 100644 index 00000000..a67db3b4 --- /dev/null +++ b/official/docs/csharp/v5/addresses/verify-failure.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "UNDELIVERABLE ST", + Street2 = "FLOOR 5", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + }; + + Address address = await client.Address.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/verify-param.cs b/official/docs/csharp/v5/addresses/verify-param.cs new file mode 100644 index 00000000..09d63218 --- /dev/null +++ b/official/docs/csharp/v5/addresses/verify-param.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "417 MONTGOMERY ST", + Street2 = "FLOOR 5", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + Verify = true + }; + + Address address = await client.Address.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/verify-strict-param.cs b/official/docs/csharp/v5/addresses/verify-strict-param.cs new file mode 100644 index 00000000..c5719b9d --- /dev/null +++ b/official/docs/csharp/v5/addresses/verify-strict-param.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "417 MONTGOMERY ST", + Street2 = "FLOOR 5", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + VerifyStrict = true + }; + + Address address = await client.Address.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/addresses/verify.cs b/official/docs/csharp/v5/addresses/verify.cs new file mode 100644 index 00000000..a358fd96 --- /dev/null +++ b/official/docs/csharp/v5/addresses/verify.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Address.Create parameters = new() + { + Street1 = "417 MONTGOMERY ST", + Street2 = "FLOOR 5", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94104", + Country = "US", + Company = "EasyPost", + Phone = "415-123-4567", + }; + + Address address = await client.Address.Create(parameters); + + address = await client.Address.Verify(address.Id) + + Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/api-keys/retrieve.cs b/official/docs/csharp/v5/api-keys/retrieve.cs new file mode 100644 index 00000000..1565117b --- /dev/null +++ b/official/docs/csharp/v5/api-keys/retrieve.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Retrieve all API keys including children + List apiKeys = await client.ApiKey.All(); + + Console.WriteLine(JsonConvert.SerializeObject(apiKeys, Formatting.Indented)); + + // Retrieve API keys for a specific child user + List childApiKeys = await client.ApiKey.RetrieveApiKeysForUser("user_..."); + + Console.WriteLine(JsonConvert.SerializeObject(childApiKeys, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/add-shipments.cs b/official/docs/csharp/v5/batches/add-shipments.cs new file mode 100644 index 00000000..0de57e6e --- /dev/null +++ b/official/docs/csharp/v5/batches/add-shipments.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + Parameters.Batch.AddShipments parameters = new() + { + Shipments = new List { shipment }, + }; + + batch = await client.Batch.AddShipments(batch.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/buy.cs b/official/docs/csharp/v5/batches/buy.cs new file mode 100644 index 00000000..d70655f2 --- /dev/null +++ b/official/docs/csharp/v5/batches/buy.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + batch = await client.Batch.Buy(batch.Id); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/create.cs b/official/docs/csharp/v5/batches/create.cs new file mode 100644 index 00000000..069c9822 --- /dev/null +++ b/official/docs/csharp/v5/batches/create.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Batch.Create parameters = new() + { + Shipments = new List() + { + shipment + } + }; + + Batch batch = await client.Batch.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/label.cs b/official/docs/csharp/v5/batches/label.cs new file mode 100644 index 00000000..c993b401 --- /dev/null +++ b/official/docs/csharp/v5/batches/label.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + Parameters.Batch.GenerateLabel parameters = new() + { + FileFormat = "PDF", + } + + batch = await client.Batch.GenerateLabel(batch.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/list.cs b/official/docs/csharp/v5/batches/list.cs new file mode 100644 index 00000000..9f953f56 --- /dev/null +++ b/official/docs/csharp/v5/batches/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Batch.All parameters = new() + { + PageSize = 5 + }; + + BatchCollection batchCollection = await client.Batch.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batchCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/remove-shipments.cs b/official/docs/csharp/v5/batches/remove-shipments.cs new file mode 100644 index 00000000..b1672d0c --- /dev/null +++ b/official/docs/csharp/v5/batches/remove-shipments.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + Parameters.Batch.RemoveShipments parameters = new() + { + Shipments = new List { shipment }, + }; + + batch = await client.Batch.RemoveShipments(batch.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/retrieve.cs b/official/docs/csharp/v5/batches/retrieve.cs new file mode 100644 index 00000000..ffbb4048 --- /dev/null +++ b/official/docs/csharp/v5/batches/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/batches/scan-forms.cs b/official/docs/csharp/v5/batches/scan-forms.cs new file mode 100644 index 00000000..4745ba8f --- /dev/null +++ b/official/docs/csharp/v5/batches/scan-forms.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Batch batch = await client.Batch.Retrieve("batch_..."); + + Parameters.Batch.GenerateScanForm parameters = new() + { + FileFormat = "ZPL", + } + + batch = await client.Batch.GenerateScanForm(batch.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/billing/create-ep-credit-card.cs b/official/docs/csharp/v5/billing/create-ep-credit-card.cs new file mode 100644 index 00000000..c6a6a680 --- /dev/null +++ b/official/docs/csharp/v5/billing/create-ep-credit-card.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + string referralUserApiKey = Environment.GetEnvironmentVariable("REFERRAL_USER_API_KEY")!; + + PaymentMethod paymentMethod = await client.ReferralCustomer.AddCreditCardToUser(referralUserApiKey, "0123456789101234", "01", "2025", "111", PaymentMethod.Priority.Primary); + + Console.WriteLine(JsonConvert.SerializeObject(referralUser, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/billing/delete.cs b/official/docs/csharp/v5/billing/delete.cs new file mode 100644 index 00000000..45d09b5a --- /dev/null +++ b/official/docs/csharp/v5/billing/delete.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + await client.Billing.DeletePaymentMethod(PaymentMethod.Priority.Primary); + } + } diff --git a/official/docs/csharp/v5/billing/fund.cs b/official/docs/csharp/v5/billing/fund.cs new file mode 100644 index 00000000..74240f85 --- /dev/null +++ b/official/docs/csharp/v5/billing/fund.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + await client.Billing.FundWallet("2000", PaymentMethod.Priority.Primary); + } + } diff --git a/official/docs/csharp/v5/billing/list.cs b/official/docs/csharp/v5/billing/list.cs new file mode 100644 index 00000000..1ec2ba75 --- /dev/null +++ b/official/docs/csharp/v5/billing/list.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + PaymentMethodsSummary paymentMethodsSummary = await client.Billing.RetrievePaymentMethodsSummary(); + + Console.WriteLine(JsonConvert.SerializeObject(paymentMethodsSummary, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/brand/update.cs b/official/docs/csharp/v5/brand/update.cs new file mode 100644 index 00000000..dfb14157 --- /dev/null +++ b/official/docs/csharp/v5/brand/update.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + User user = await client.User.RetrieveMe(); + + Parameters.User.UpdateBrand parameters = new() + { + BackgroundColorHexCode = "#FFFFFF", + ColorHexCode = "#303F9F", + LogoBase64 = "data:image/png;base64,iVBORw0K...", + LogoUrl = "https://easypost.com", + AdBase64 = null, + AdUrl = null, + Theme = "theme1" + }; + + Brand brand = await client.User.UpdateBrand(user.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/current/carbon-offset/buy.cs b/official/docs/csharp/v5/carbon-offset/buy.cs similarity index 100% rename from official/docs/csharp/current/carbon-offset/buy.cs rename to official/docs/csharp/v5/carbon-offset/buy.cs diff --git a/official/docs/csharp/current/carbon-offset/create.cs b/official/docs/csharp/v5/carbon-offset/create.cs similarity index 100% rename from official/docs/csharp/current/carbon-offset/create.cs rename to official/docs/csharp/v5/carbon-offset/create.cs diff --git a/official/docs/csharp/current/carbon-offset/one-call-buy.cs b/official/docs/csharp/v5/carbon-offset/one-call-buy.cs similarity index 100% rename from official/docs/csharp/current/carbon-offset/one-call-buy.cs rename to official/docs/csharp/v5/carbon-offset/one-call-buy.cs diff --git a/official/docs/csharp/v5/carrier-accounts/create.cs b/official/docs/csharp/v5/carrier-accounts/create.cs new file mode 100644 index 00000000..7a31d52f --- /dev/null +++ b/official/docs/csharp/v5/carrier-accounts/create.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.CarrierAccount.Create parameters = new() + { + Type = "DhlEcsAccount", + Description = "CA Location DHL eCommerce Solutions Account", + Credentials = new() + { + { "client_id", "123456" }, + { "client_secret", "123abc" }, + { "distribution_center", "USLAX1" }, + { "pickup_id", "123456" } + }, + TestCredentials = new() + { + { "client_id", "123456" }, + { "client_secret", "123abc" }, + { "distribution_center", "USLAX1" }, + { "pickup_id", "123456" } + } + }; + + CarrierAccount carrierAccount = await client.CarrierAccount.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(carrierAccount, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/carrier-accounts/delete.cs b/official/docs/csharp/v5/carrier-accounts/delete.cs new file mode 100644 index 00000000..637e3668 --- /dev/null +++ b/official/docs/csharp/v5/carrier-accounts/delete.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_..."); + + await client.CarrierAccount.Delete(carrierAccount.Id); + } + } diff --git a/official/docs/csharp/v5/carrier-accounts/list.cs b/official/docs/csharp/v5/carrier-accounts/list.cs new file mode 100644 index 00000000..9c421c83 --- /dev/null +++ b/official/docs/csharp/v5/carrier-accounts/list.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + List carrierAccounts = await client.CarrierAccount.All(); + + Console.WriteLine(JsonConvert.SerializeObject(carrierAccounts, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/carrier-accounts/retrieve.cs b/official/docs/csharp/v5/carrier-accounts/retrieve.cs new file mode 100644 index 00000000..ed0375d6 --- /dev/null +++ b/official/docs/csharp/v5/carrier-accounts/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_..."); + + Console.WriteLine(JsonConvert.SerializeObject(carrierAccount, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/carrier-accounts/update.cs b/official/docs/csharp/v5/carrier-accounts/update.cs new file mode 100644 index 00000000..5b8655ad --- /dev/null +++ b/official/docs/csharp/v5/carrier-accounts/update.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_..."); + + Parameters.CarrierAccount.Update parameters = new() + { + Description = "FL Location DHL eCommerce Solutions Account", + Credentials = new() + { + { "pickup_id", "abc123" } + }, + }; + + carrierAccount = await client.CarrierAccount.Update(carrierAccount.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(carrierAccount, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/carrier-metadata/retrieve.cs b/official/docs/csharp/v5/carrier-metadata/retrieve.cs new file mode 100644 index 00000000..eccfd461 --- /dev/null +++ b/official/docs/csharp/v5/carrier-metadata/retrieve.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; +using Newtonsoft.Json; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Request all metadata for all carriers + List carrierMetadata = await client.CarrierMetadata.Retrieve(); + + Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented)); + + // Request specific metadata for specific carriers + Parameters.CarrierMetadata.Retrieve parameters = new() + { + Carriers = new List { "UPS", "USPS" }, + Types = new List { CarrierMetadataType.ServiceLevels, CarrierMetadataType.PredefinedPackages }, + }; + + List carrierMetadata = await client.CarrierMetadata.Retrieve(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/carrier-types/list.cs b/official/docs/csharp/v5/carrier-types/list.cs new file mode 100644 index 00000000..f88f1093 --- /dev/null +++ b/official/docs/csharp/v5/carrier-types/list.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + List carrierTypes = await client.CarrierType.All(); + + Console.WriteLine(JsonConvert.SerializeObject(carrierTypes, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/child-users/create.cs b/official/docs/csharp/v5/child-users/create.cs new file mode 100644 index 00000000..5de2d013 --- /dev/null +++ b/official/docs/csharp/v5/child-users/create.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.User.CreateChild parameters = new() + { + Name = "Child Account Name", + }; + + User user = await client.User.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/child-users/delete.cs b/official/docs/csharp/v5/child-users/delete.cs new file mode 100644 index 00000000..d400b36b --- /dev/null +++ b/official/docs/csharp/v5/child-users/delete.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + User user = await client.User.Retrieve("user_..."); + + await client.User.Delete(user.Id); + } + } diff --git a/official/docs/csharp/v5/customs-infos/create.cs b/official/docs/csharp/v5/customs-infos/create.cs new file mode 100644 index 00000000..97fe396b --- /dev/null +++ b/official/docs/csharp/v5/customs-infos/create.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.CustomsInfo.Create parameters = new() + { + CustomsCertify = true, + CustomsSigner = "Steve Brule", + ContentsType = "merchandise", + ContentsExplanation = "", + RestrictionType = "none", + EelPfc = "NOEEI 30.37(a)", + CustomsItems = new List() + { + new() + { + Description = "T-shirt", + Quantity = 1, + Weight = 5, + Value = 10, + HsTariffNumber = "123456", + OriginCountry = "US" + } + } + }; + + CustomsInfo customsInfo = await client.CustomsInfo.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(customsInfo, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/customs-infos/retrieve.cs b/official/docs/csharp/v5/customs-infos/retrieve.cs new file mode 100644 index 00000000..320f5bfc --- /dev/null +++ b/official/docs/csharp/v5/customs-infos/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + CustomsInfo customsInfo = await client.CustomsInfo.Retrieve("cstinfo_..."); + + Console.WriteLine(JsonConvert.SerializeObject(customsInfo, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/customs-items/create.cs b/official/docs/csharp/v5/customs-items/create.cs new file mode 100644 index 00000000..4aebb9e1 --- /dev/null +++ b/official/docs/csharp/v5/customs-items/create.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.CustomsItems.Create parameters = new() + { + Description = "T-shirt", + Quantity = 1, + Weight = 5, + Value = 10, + HsTariffNumber = "123456", + OriginCountry = "US" + }; + + CustomsItem customsItem = await client.CustomsItem.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(customsItem, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/customs-items/retrieve.cs b/official/docs/csharp/v5/customs-items/retrieve.cs new file mode 100644 index 00000000..64e8dc6c --- /dev/null +++ b/official/docs/csharp/v5/customs-items/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + CustomsItem customsItem = await client.CustomsItem.Retrieve("cstitem_..."); + + Console.WriteLine(JsonConvert.SerializeObject(customsItem, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/endshipper/buy.cs b/official/docs/csharp/v5/endshipper/buy.cs new file mode 100644 index 00000000..be7b3c08 --- /dev/null +++ b/official/docs/csharp/v5/endshipper/buy.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Rate rate = shipment.LowestRate(); + + Parameters.Shipment.Buy parameters = new(rate) + { + EndShipperId = "es_...", + }; + + shipment = await client.Shipment.Buy(shipment.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/endshipper/create.cs b/official/docs/csharp/v5/endshipper/create.cs new file mode 100644 index 00000000..3197f23a --- /dev/null +++ b/official/docs/csharp/v5/endshipper/create.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.EndShipper.Create parameters = new() + { + Name = "FOO BAR", + Company = "BAZ", + Street1 = "164 TOWNSEND STREET UNIT 1", + Street2 = "UNIT 1", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94107", + Country = "US", + Phone = "555-555-5555", + Email = "FOO@EXAMPLE.COM", + }; + + EndShipper endShipper = await client.EndShipper.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(endShipper, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/endshipper/list.cs b/official/docs/csharp/v5/endshipper/list.cs new file mode 100644 index 00000000..ae8e650a --- /dev/null +++ b/official/docs/csharp/v5/endshipper/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.EndShipper.All parameters = new() + { + PageSize = 5 + }; + + EndShipperCollection endShipperCollection = await client.EndShipper.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(endShipperCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/endshipper/retrieve.cs b/official/docs/csharp/v5/endshipper/retrieve.cs new file mode 100644 index 00000000..263aa190 --- /dev/null +++ b/official/docs/csharp/v5/endshipper/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + EndShipper endShipper = await client.EndShipper.Retrieve("es_..."); + + Console.WriteLine(JsonConvert.SerializeObject(endShipper, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/endshipper/update.cs b/official/docs/csharp/v5/endshipper/update.cs new file mode 100644 index 00000000..f3e60b6d --- /dev/null +++ b/official/docs/csharp/v5/endshipper/update.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + EndShipper endShipper = await client.EndShipper.Retrieve("es_..."); + + // Updating an EndShipper requires all the original data to be sent back + the updated data + Parameters.EndShipper.Update parameters = new() + { + Name = "NEW NAME", + Company = "BAZ", + Street1 = "164 TOWNSEND STREET UNIT 1", + Street2 = "UNIT 1", + City = "SAN FRANCISCO", + State = "CA", + Zip = "94107", + Country = "US", + Phone = "555-555-5555", + Email = "FOO@EXAMPLE.COM", + }; + + endShipper = await client.EndShipper.Update(endShipper.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(endShipper, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/events/list.cs b/official/docs/csharp/v5/events/list.cs new file mode 100644 index 00000000..f15a49c6 --- /dev/null +++ b/official/docs/csharp/v5/events/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Event.All parameters = new() + { + PageSize = 5, + }; + + EventCollection events = await client.Event.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(events, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/events/retrieve.cs b/official/docs/csharp/v5/events/retrieve.cs new file mode 100644 index 00000000..4e98aaa1 --- /dev/null +++ b/official/docs/csharp/v5/events/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Event @event = await client.Event.Retrieve("evt_..."); + + Console.WriteLine(JsonConvert.SerializeObject(@event, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/forms/create.cs b/official/docs/csharp/v5/forms/create.cs new file mode 100644 index 00000000..75227359 --- /dev/null +++ b/official/docs/csharp/v5/forms/create.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Shipment has to be purchased before forms can be generated + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Shipment.GenerateForm parameters = new() + { + Type = "return_packing_slip", + Data = new() + { + { "barcode", "RMA12345678900" }, + { + "line_items", new List>() + { + { + new Dictionary + { + { "title", "Square Reader" }, + { "barcode", "855658003251" } + } + } + } + }, + { "units", 8 } + } + }; + + shipment = await client.Shipment.GenerateForm(shipment.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/insurance/create.cs b/official/docs/csharp/v5/insurance/create.cs new file mode 100644 index 00000000..50b951bf --- /dev/null +++ b/official/docs/csharp/v5/insurance/create.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Insurance.Create parameters = new() + { + Amount = 100.00, + Carrier = "USPS", + TrackingCode = "9400110898825022579493", + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + } + }; + + Insurance insurance = await client.Insurance.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(insurance, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/insurance/list.cs b/official/docs/csharp/v5/insurance/list.cs new file mode 100644 index 00000000..fff1d77d --- /dev/null +++ b/official/docs/csharp/v5/insurance/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Insurance.All parameters = new() + { + PageSize = 5 + }; + + InsuranceCollection insuranceCollection = await client.Insurance.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(insuranceCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/insurance/retrieve.cs b/official/docs/csharp/v5/insurance/retrieve.cs new file mode 100644 index 00000000..89a6c0e0 --- /dev/null +++ b/official/docs/csharp/v5/insurance/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Insurance insurance = await client.Insurance.Retrieve("ins_..."); + + Console.WriteLine(JsonConvert.SerializeObject(insurance, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/options/create-with-options.cs b/official/docs/csharp/v5/options/create-with-options.cs new file mode 100644 index 00000000..5d51eaec --- /dev/null +++ b/official/docs/csharp/v5/options/create-with-options.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Shipment.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Parcel = new Parameters.Parcel.Create + { + Length = 20.2, + Width = 10.9, + Height = 5, + Weight = 65.9 + }, + Options = new Options + { + PrintCustom1 = "Custom label message" + } + }; + + Shipment shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/orders/buy.cs b/official/docs/csharp/v5/orders/buy.cs new file mode 100644 index 00000000..2f9d8cbd --- /dev/null +++ b/official/docs/csharp/v5/orders/buy.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Order order = await client.Order.Retrieve("order_..."); + + Parameters.Order.Buy parameters = new("FedEx", "FEDEX_GROUND"); + + order = await client.Order.Buy(order.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/orders/create.cs b/official/docs/csharp/v5/orders/create.cs new file mode 100644 index 00000000..3bc8c9fe --- /dev/null +++ b/official/docs/csharp/v5/orders/create.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Order.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Shipments = new List() { shipment } + }; + + Order order = await client.Order.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/orders/one-call-buy.cs b/official/docs/csharp/v5/orders/one-call-buy.cs new file mode 100644 index 00000000..7a103c3c --- /dev/null +++ b/official/docs/csharp/v5/orders/one-call-buy.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Order.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Shipments = new List + { + new() + { + Parcel = new Parameters.Parcel.Create + { + Weight = 10.2 + } + }, + new() + { + Parcel = new Parameters.Parcel.Create + { + PredefinedPackage = "FedExBox", + Weight = 17.5 + } + } + }, + Service = "NextDayAir", + CarrierAccountIds = new List + { + "ca_..." + } + }; + + Order order = await client.Order.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/orders/retrieve.cs b/official/docs/csharp/v5/orders/retrieve.cs new file mode 100644 index 00000000..c82b6dd4 --- /dev/null +++ b/official/docs/csharp/v5/orders/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Order order = await client.Order.Retrieve("order_..."); + + Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/pagination/get-next-page.cs b/official/docs/csharp/v5/pagination/get-next-page.cs new file mode 100644 index 00000000..31d460a0 --- /dev/null +++ b/official/docs/csharp/v5/pagination/get-next-page.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Get first page of results + Parameters.Shipment.All parameters = new() + { + PageSize = 5 + }; + + ShipmentCollection shipmentCollection = await client.Shipment.All(parameters); + + // Provide the previous results page to move onto the next page + ShipmentCollection nextPage = await client.Shipment.GetNextPage(shipmentCollection) + + Console.WriteLine(JsonConvert.SerializeObject(nextPage, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/parcels/create.cs b/official/docs/csharp/v5/parcels/create.cs new file mode 100644 index 00000000..7ca9b9ad --- /dev/null +++ b/official/docs/csharp/v5/parcels/create.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Parcel.Create parameters = new() + { + Length = 20.2, + Width = 10.9, + Height = 5, + Weight = 65.9 + }; + + Parcel parcel = await client.Parcel.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(parcel, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/parcels/retrieve.cs b/official/docs/csharp/v5/parcels/retrieve.cs new file mode 100644 index 00000000..74911925 --- /dev/null +++ b/official/docs/csharp/v5/parcels/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parcel parcel = await client.Parcel.Retrieve("prcl_..."); + + Console.WriteLine(JsonConvert.SerializeObject(parcel, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/payloads/list.cs b/official/docs/csharp/v5/payloads/list.cs new file mode 100644 index 00000000..380d60ee --- /dev/null +++ b/official/docs/csharp/v5/payloads/list.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + List payloads = await client.Event.RetrieveAllPayloads("evt_..."); + + Console.WriteLine(JsonConvert.SerializeObject(payloads, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/payloads/retrieve.cs b/official/docs/csharp/v5/payloads/retrieve.cs new file mode 100644 index 00000000..4e3d24b1 --- /dev/null +++ b/official/docs/csharp/v5/payloads/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Payload payload = await client.Event.RetrievePayload("evt_...", "payload_..."); + + Console.WriteLine(JsonConvert.SerializeObject(payload, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/pickups/buy.cs b/official/docs/csharp/v5/pickups/buy.cs new file mode 100644 index 00000000..9847618e --- /dev/null +++ b/official/docs/csharp/v5/pickups/buy.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Pickup pickup = await client.Pickup.Retrieve("pickup_..."); + + Parameters.Pickup.Buy parameters = new("UPS", "Same-Day Pickup"); + + pickup = await client.Pickup.Buy(pickup.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/pickups/cancel.cs b/official/docs/csharp/v5/pickups/cancel.cs new file mode 100644 index 00000000..0219e854 --- /dev/null +++ b/official/docs/csharp/v5/pickups/cancel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Pickup pickup = await client.Pickup.Retrieve("pickup_..."); + + pickup = await client.Pickup.Cancel(pickup.Id); + + Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/pickups/create.cs b/official/docs/csharp/v5/pickups/create.cs new file mode 100644 index 00000000..804c777f --- /dev/null +++ b/official/docs/csharp/v5/pickups/create.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Pickup.Create parameters = new() + { + Address = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Shipment = shipment, + Reference = "my-first-pickup", + MinDatetime = "2022-10-01 10:30:00", + MaxDatetime = "2022-10-01 17:30:00", + Instructions = "Special pickup instructions", + IsAccountAddress = false + }; + + Pickup pickup = await client.Pickup.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/pickups/list.cs b/official/docs/csharp/v5/pickups/list.cs new file mode 100644 index 00000000..2a26273f --- /dev/null +++ b/official/docs/csharp/v5/pickups/list.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY"); + + var client = new EasyPost.Client(apiKey); + + Dictionary listParams = new Dictionary() + { + { "page_size", 5 } + }; + + PickupCollection pickups = await client.Pickup.All(listParams); + + Console.WriteLine(JsonConvert.SerializeObject(pickups, Formatting.Indented)); + } + } +} + diff --git a/official/docs/csharp/v5/pickups/retrieve.cs b/official/docs/csharp/v5/pickups/retrieve.cs new file mode 100644 index 00000000..43ac9ede --- /dev/null +++ b/official/docs/csharp/v5/pickups/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Pickup pickup = await client.Pickup.Retrieve("pickup_..."); + + Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/rates/regenerate.cs b/official/docs/csharp/v5/rates/regenerate.cs new file mode 100644 index 00000000..49affa9a --- /dev/null +++ b/official/docs/csharp/v5/rates/regenerate.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + shipment = await client.Shipment.RegenerateRates(shipment.Id); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/rates/retrieve-stateless.cs b/official/docs/csharp/v5/rates/retrieve-stateless.cs new file mode 100644 index 00000000..3c578bd9 --- /dev/null +++ b/official/docs/csharp/v5/rates/retrieve-stateless.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Beta.Rate.Retrieve shipmentDetails = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "179 N Harbor Dr", + City = "Redondo Beach", + State = "CA", + Zip = "90277", + Country = "US", + Phone = "8573875756", + Email = "dr_steve_brule@gmail.com" + }, + FromAddress = new Parameters.Address.Create + { + Name = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Zip = "94104", + Country = "US", + Phone = "4153334445", + Email = "support@easypost.com", + }, + Parcel = new Parameters.Parcel.Create + { + Length = 20.2, + Width = 10.9, + Height = 5, + Weight = 65.9 + } + }; + + List rates = await client.Beta.Rate.RetrieveStatelessRates(shipmentDetails); + + Console.WriteLine(JsonConvert.SerializeObject(rates, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/rates/retrieve.cs b/official/docs/csharp/v5/rates/retrieve.cs new file mode 100644 index 00000000..3c18a4e9 --- /dev/null +++ b/official/docs/csharp/v5/rates/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Rate rate = await client.Rate.Retrieve("rate..."); + + Console.WriteLine(JsonConvert.SerializeObject(rate, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/add-payment-method-with-bank-account.cs b/official/docs/csharp/v5/referral-customers/add-payment-method-with-bank-account.cs new file mode 100644 index 00000000..7a81a76a --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/add-payment-method-with-bank-account.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + PaymentMethod paymentMethod = await client.Beta.ReferralCustomer.AddPaymentMethod("cus_...", "ba_...", PaymentMethod.Priority.Primary); + + Console.WriteLine(JsonConvert.SerializeObject(paymentMethod, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/add-payment-method-with-credit-card.cs b/official/docs/csharp/v5/referral-customers/add-payment-method-with-credit-card.cs new file mode 100644 index 00000000..4de6aa45 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/add-payment-method-with-credit-card.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + PaymentMethod paymentMethod = await client.Beta.ReferralCustomer.AddPaymentMethod("cus_...", "card_...", PaymentMethod.Priority.Primary); + + Console.WriteLine(JsonConvert.SerializeObject(paymentMethod, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/create.cs b/official/docs/csharp/v5/referral-customers/create.cs new file mode 100644 index 00000000..587459a8 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/create.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.ReferralCustomer.Create parameters = new() + { + Name = "test user", + Email = "email@example.com", + Phone = "8888888888" + }; + + ReferralCustomer referralUser = await client.ReferralCustomer.CreateReferral(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(referralUser, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/list.cs b/official/docs/csharp/v5/referral-customers/list.cs new file mode 100644 index 00000000..b7fa8e99 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/list.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.ReferralCustomer.All parameters = new() + { + PageSize = 5 + }; + + ReferralCustomerCollection referralCustomerCollection = await client.ReferralCustomer.All(parameters); + + List referralCustomers = referralCustomerCollection.ReferralCustomers; + + Console.WriteLine(JsonConvert.SerializeObject(referralCustomers, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/refund-by-amount.cs b/official/docs/csharp/v5/referral-customers/refund-by-amount.cs new file mode 100644 index 00000000..54f542f3 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/refund-by-amount.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.ReferralCustomer.RefundByAmount parameters = new() + { + Amount = 2000, + }; + + PaymentRefund refund = await client.Beta.ReferralCustomer.RefundByAmount(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(refund, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/refund-by-payment-log.cs b/official/docs/csharp/v5/referral-customers/refund-by-payment-log.cs new file mode 100644 index 00000000..96328140 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/refund-by-payment-log.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.ReferralCustomer.RefundByPaymentLog parameters = new() + { + PaymentLogId = "paylog_...", + }; + + PaymentRefund refund = await client.Beta.ReferralCustomer.RefundByPaymentLog(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(refund, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/referral-customers/update.cs b/official/docs/csharp/v5/referral-customers/update.cs new file mode 100644 index 00000000..d1bc5a08 --- /dev/null +++ b/official/docs/csharp/v5/referral-customers/update.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + await client.ReferralCustomer.UpdateReferralEmail("user_...", "new_email@example.com"); + } + } +} diff --git a/official/docs/csharp/v5/refunds/create.cs b/official/docs/csharp/v5/refunds/create.cs new file mode 100644 index 00000000..746e0d79 --- /dev/null +++ b/official/docs/csharp/v5/refunds/create.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Refund.Create parameters = new() + { + Carrier = "USPS", + TrackingCodes = new List { "EZ1000000001" } + }; + + List refunds = await client.Refund.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(refunds, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/refunds/list.cs b/official/docs/csharp/v5/refunds/list.cs new file mode 100644 index 00000000..a6eab21d --- /dev/null +++ b/official/docs/csharp/v5/refunds/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Refund.All parameters = new() + { + PageSize = 5 + }; + + RefundCollection refundCollection = await client.Refund.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(refundCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/refunds/retrieve.cs b/official/docs/csharp/v5/refunds/retrieve.cs new file mode 100644 index 00000000..e4230060 --- /dev/null +++ b/official/docs/csharp/v5/refunds/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Refund refund = await client.Refund.Retrieve("rfnd_..."); + + Console.WriteLine(JsonConvert.SerializeObject(refund, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/reports/create.cs b/official/docs/csharp/v5/reports/create.cs new file mode 100644 index 00000000..a1590f2b --- /dev/null +++ b/official/docs/csharp/v5/reports/create.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Report.Create parameters = new() + { + Type = "payment_log", + StartDate = "2022-10-01", + EndDate = "2022-10-31" + }; + + Report report = await client.Report.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(report, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/reports/list.cs b/official/docs/csharp/v5/reports/list.cs new file mode 100644 index 00000000..66fc9f6b --- /dev/null +++ b/official/docs/csharp/v5/reports/list.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Report.All parameters = new() + { + Type = "payment_log", + PageSize = 5, + StartDatetime = "2022-10-01" + }; + + ReportCollection reportCollection = await client.Report.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(reportCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/reports/retrieve.cs b/official/docs/csharp/v5/reports/retrieve.cs new file mode 100644 index 00000000..b8c13f80 --- /dev/null +++ b/official/docs/csharp/v5/reports/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Report report = await client.Report.Retrieve("plrep_..."); + + Console.WriteLine(JsonConvert.SerializeObject(report, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/returns/create.cs b/official/docs/csharp/v5/returns/create.cs new file mode 100644 index 00000000..42cd3b76 --- /dev/null +++ b/official/docs/csharp/v5/returns/create.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Shipment.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Parcel = new Parameters.Parcel.Create + { + Length = 8, + Width = 6, + Height = 5, + Weight = 10 + }, + IsReturn = true, + }; + + Shipment shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/scan-form/create.cs b/official/docs/csharp/v5/scan-form/create.cs new file mode 100644 index 00000000..873241f3 --- /dev/null +++ b/official/docs/csharp/v5/scan-form/create.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.ScanForm.Create parameters = new() + { + Shipments = new List + { + shipment + } + }; + + ScanForm scanForm = await client.ScanForm.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(scanForm, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/scan-form/list.cs b/official/docs/csharp/v5/scan-form/list.cs new file mode 100644 index 00000000..89ef518f --- /dev/null +++ b/official/docs/csharp/v5/scan-form/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.ScanForm.All parameters = new() + { + PageSize = 5 + }; + + ScanFormCollection scanFormCollection = await client.ScanForm.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(scanFormCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/scan-form/retrieve.cs b/official/docs/csharp/v5/scan-form/retrieve.cs new file mode 100644 index 00000000..b2bc7670 --- /dev/null +++ b/official/docs/csharp/v5/scan-form/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + ScanForm scanForm = await client.ScanForm.Retrieve("sf_..."); + + Console.WriteLine(JsonConvert.SerializeObject(scanForm, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/buy.cs b/official/docs/csharp/v5/shipments/buy.cs new file mode 100644 index 00000000..b0693577 --- /dev/null +++ b/official/docs/csharp/v5/shipments/buy.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Rate rate = shipment.LowestRate(); + + Parameters.Shipment.Buy parameters = new(rate); + + shipment = await client.Shipment.Buy(shipment.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/create.cs b/official/docs/csharp/v5/shipments/create.cs new file mode 100644 index 00000000..b3b8d199 --- /dev/null +++ b/official/docs/csharp/v5/shipments/create.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Create a shipment using all data in one API call + + Parameters.Shipment.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Parcel = new Parameters.Parcel.Create + { + Length = 8, + Width = 6, + Height = 5, + Weight = 10 + }, + CustomsInfo = new Parameters.CustomsInfo.Create + { + ... + } + }; + + Shipment shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + + // Create a shipment using existing addresses, parcel, and customs info + + Address toAddress = await client.Address.Retrieve("adr_..."); + Address fromAddress = await client.Address.Retrieve("adr_..."); + Parcel parcel = await client.Parcel.Retrieve("prcl_..."); + CustomsInfo customsInfo = await client.CustomsInfo.Retrieve("cstinfo_..."); + + parameters = new() + { + ToAddress = toAddress, + FromAddress = fromAddress, + Parcel = parcel, + CustomsInfo = customsInfo + }; + + shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipmentWithIds, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/label.cs b/official/docs/csharp/v5/shipments/label.cs new file mode 100644 index 00000000..dbf34765 --- /dev/null +++ b/official/docs/csharp/v5/shipments/label.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Shipment.GenerateLabel parameters = new() + { + FileFormat = "ZPL", + }; + + shipment = await client.Shipment.GenerateLabel(shipment.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/list.cs b/official/docs/csharp/v5/shipments/list.cs new file mode 100644 index 00000000..d487601f --- /dev/null +++ b/official/docs/csharp/v5/shipments/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Shipment.All parameters = new() + { + PageSize = 5 + }; + + ShipmentCollection shipmentCollection = await client.Shipment.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipmentCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/one-call-buy.cs b/official/docs/csharp/v5/shipments/one-call-buy.cs new file mode 100644 index 00000000..6f5daa3c --- /dev/null +++ b/official/docs/csharp/v5/shipments/one-call-buy.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Shipment.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Parcel = new Parameters.Parcel.Create + { + Length = 8, + Width = 6, + Height = 5, + Weight = 10 + }, + Service = "NextDayAir", + CarrierAccountIds = new List { "ca_..." } + }; + + Shipment shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipments/retrieve.cs b/official/docs/csharp/v5/shipments/retrieve.cs new file mode 100644 index 00000000..49d360d0 --- /dev/null +++ b/official/docs/csharp/v5/shipments/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipping-insurance/insure.cs b/official/docs/csharp/v5/shipping-insurance/insure.cs new file mode 100644 index 00000000..43fca98b --- /dev/null +++ b/official/docs/csharp/v5/shipping-insurance/insure.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + shipment = await client.Shipment.Insure(shipment.Id, 200); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/shipping-refund/refund.cs b/official/docs/csharp/v5/shipping-refund/refund.cs new file mode 100644 index 00000000..c8b212bc --- /dev/null +++ b/official/docs/csharp/v5/shipping-refund/refund.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + shipment = await client.Shipment.Refund(shipment.Id); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/smartrate/retrieve-estimated-delivery-date.cs b/official/docs/csharp/v5/smartrate/retrieve-estimated-delivery-date.cs new file mode 100644 index 00000000..5f79e580 --- /dev/null +++ b/official/docs/csharp/v5/smartrate/retrieve-estimated-delivery-date.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + Parameters.Shipment.RetrieveEstimatedDeliveryDate parameters = new() + { + PlannedShipDate = "2021-01-01", + }; + + List rates = await client.Shipment.RetrieveEstimatedDeliveryDate(shipment.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(rates, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/smartrate/retrieve-time-in-transit-statistics.cs b/official/docs/csharp/v5/smartrate/retrieve-time-in-transit-statistics.cs new file mode 100644 index 00000000..616f3d1d --- /dev/null +++ b/official/docs/csharp/v5/smartrate/retrieve-time-in-transit-statistics.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Shipment shipment = await client.Shipment.Retrieve("shp_..."); + + List smartRates = await client.Shipment.GetSmartRates(shipment.Id); + + Console.WriteLine(JsonConvert.SerializeObject(smartRates, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/tax-identifiers/create.cs b/official/docs/csharp/v5/tax-identifiers/create.cs new file mode 100644 index 00000000..2a7b6942 --- /dev/null +++ b/official/docs/csharp/v5/tax-identifiers/create.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Shipment.Create parameters = new() + { + ToAddress = new Parameters.Address.Create + { + Name = "Dr. Steve Brule", + Street1 = "417 Montgomery Street", + Street2 = "5th Floor", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + FromAddress = new Parameters.Address.Create + { + Company = "EasyPost", + Street1 = "417 Montgomery Street", + Street2 = "Floor 5", + City = "San Francisco", + State = "CA", + Country = "US", + Zip = "94104" + }, + Parcel = new Parameters.Parcel.Create + { + Length = 8, + Width = 6, + Height = 5, + Weight = 10 + }, + CustomsInfo = new Parameters.CustomsInfo.Create + { + ... + }, + TaxIdentifiers = new List + { + new() + { + Entity = "SENDER", + TaxId = "GB123456789", + TaxIdType = "EORI", + IssuingCountry = "GB" + } + } + }; + + Shipment shipment = await client.Shipment.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/trackers/create.cs b/official/docs/csharp/v5/trackers/create.cs new file mode 100644 index 00000000..5c81ccfb --- /dev/null +++ b/official/docs/csharp/v5/trackers/create.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Tracker.Create parameters = new() + { + TrackingCode = "EZ1000000001", + Carrier = "USPS" + }; + + Tracker tracker = await client.Tracker.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(tracker, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/trackers/list.cs b/official/docs/csharp/v5/trackers/list.cs new file mode 100644 index 00000000..fcd346f0 --- /dev/null +++ b/official/docs/csharp/v5/trackers/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Tracker.All parameters = new() + { + PageSize = 5 + }; + + TrackerCollection trackerCollection = await client.Tracker.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(trackerCollection, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/trackers/retrieve.cs b/official/docs/csharp/v5/trackers/retrieve.cs new file mode 100644 index 00000000..408bfda5 --- /dev/null +++ b/official/docs/csharp/v5/trackers/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Tracker tracker = await client.Tracker.Retrieve("trk_..."); + + Console.WriteLine(JsonConvert.SerializeObject(tracker, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/users/retrieve.cs b/official/docs/csharp/v5/users/retrieve.cs new file mode 100644 index 00000000..aeeb41cb --- /dev/null +++ b/official/docs/csharp/v5/users/retrieve.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + // Retrieve the authenticated user + User user = await client.User.RetrieveMe(); + + // Retrieve a child user + User user = await client.User.Retrieve("user_..."); + + Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/users/update.cs b/official/docs/csharp/v5/users/update.cs new file mode 100644 index 00000000..6c99c60f --- /dev/null +++ b/official/docs/csharp/v5/users/update.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + User user = await client.User.RetrieveMe(); + + Parameters.User.Update parameters = new() + { + RechargeThreshold = "50.00" + }; + + user = await client.User.Update(user.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/webhooks/create.cs b/official/docs/csharp/v5/webhooks/create.cs new file mode 100644 index 00000000..b932286a --- /dev/null +++ b/official/docs/csharp/v5/webhooks/create.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Webhook.Create parameters = new() + { + Url = "example.com" + }; + + Webhook webhook = await client.Webhook.Create(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(webhook, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/webhooks/delete.cs b/official/docs/csharp/v5/webhooks/delete.cs new file mode 100644 index 00000000..529ffeef --- /dev/null +++ b/official/docs/csharp/v5/webhooks/delete.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Webhook webhook = await client.Webhook.Retrieve("hook_..."); + + await client.Webhook.Delete(webhook.Id); + } + } diff --git a/official/docs/csharp/v5/webhooks/list.cs b/official/docs/csharp/v5/webhooks/list.cs new file mode 100644 index 00000000..73d315b5 --- /dev/null +++ b/official/docs/csharp/v5/webhooks/list.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Parameters.Webhook.All parameters = new() + { + PageSize = 5, + }; + + List webhooks = await client.Webhook.All(parameters); + + Console.WriteLine(JsonConvert.SerializeObject(webhooks, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/webhooks/retrieve.cs b/official/docs/csharp/v5/webhooks/retrieve.cs new file mode 100644 index 00000000..c69b385c --- /dev/null +++ b/official/docs/csharp/v5/webhooks/retrieve.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Webhook webhook = await client.Webhook.Retrieve("hook_..."); + + Console.WriteLine(JsonConvert.SerializeObject(webhook, Formatting.Indented)); + } + } +} diff --git a/official/docs/csharp/v5/webhooks/update.cs b/official/docs/csharp/v5/webhooks/update.cs new file mode 100644 index 00000000..14a644b0 --- /dev/null +++ b/official/docs/csharp/v5/webhooks/update.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; +using EasyPost; +using EasyPost.Models.API; +using EasyPost.Parameters; + +namespace EasyPostExamples +{ + public class Examples + { + public static async Task Main() + { + string apiKey = Environment.GetEnvironmentVariable("EASYPOST_API_KEY")!; + + var client = new EasyPost.Client(apiKey); + + Webhook webhook = await client.Webhook.Retrieve("hook_..."); + + // Update the webhook's settings + Parameters.Webhook.Update parameters = new() + { + Url = "https://example.com/webhook", + }; + + webhook = await client.Webhook.Update(webhook.Id, parameters); + + // Sending an empty parameter set will simply enable a disabled webhook + parameters = new(); + + webhook = await client.Webhook.Update(webhook.Id, parameters); + + Console.WriteLine(JsonConvert.SerializeObject(webhook, Formatting.Indented)); + } + } +} diff --git a/official/docs/curl/current/carbon-offset/buy.sh b/official/docs/curl/current/carbon-offset/buy.sh deleted file mode 100644 index b39e8135..00000000 --- a/official/docs/curl/current/carbon-offset/buy.sh +++ /dev/null @@ -1,9 +0,0 @@ -curl -X POST https://api.easypost.com/v2/shipments/shp_.../buy \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "rate": { - "id": "rate_..." - }, - "carbon_offset": true -}' diff --git a/official/docs/curl/current/carbon-offset/create.sh b/official/docs/curl/current/carbon-offset/create.sh deleted file mode 100644 index 966abf1c..00000000 --- a/official/docs/curl/current/carbon-offset/create.sh +++ /dev/null @@ -1,35 +0,0 @@ -curl -X POST https://api.easypost.com/v2/shipments \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carbon_offset": true, - "shipment": { - "to_address": { - "name": "Dr. Steve Brule", - "street1": "179 N Harbor Dr", - "city": "Redondo Beach", - "state": "CA", - "zip": "90277", - "country": "US", - "phone": "8573875756", - "email": "dr_steve_brule@gmail.com" - }, - "from_address": { - "name": "EasyPost", - "street1": "417 Montgomery Street", - "street2": "5th Floor", - "city": "San Francisco", - "state": "CA", - "zip": "94104", - "country": "US", - "phone": "4153334445", - "email": "support@easypost.com" - }, - "parcel": { - "length": "20.2", - "width": "10.9", - "height": "5", - "weight": "65.9" - } - } -}' diff --git a/official/docs/curl/current/carbon-offset/one-call-buy.sh b/official/docs/curl/current/carbon-offset/one-call-buy.sh deleted file mode 100644 index 53b05f94..00000000 --- a/official/docs/curl/current/carbon-offset/one-call-buy.sh +++ /dev/null @@ -1,37 +0,0 @@ -curl -X POST https://api.easypost.com/v2/shipments \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carbon_offset": true, - "shipment": { - "to_address": { - "name": "Dr. Steve Brule", - "street1": "179 N Harbor Dr", - "city": "Redondo Beach", - "state": "CA", - "zip": "90277", - "country": "US", - "phone": "8573875756", - "email": "dr_steve_brule@gmail.com" - }, - "from_address": { - "name": "EasyPost", - "street1": "417 Montgomery Street", - "street2": "5th Floor", - "city": "San Francisco", - "state": "CA", - "zip": "94104", - "country": "US", - "phone": "4153334445", - "email": "support@easypost.com" - }, - "parcel": { - "length": "20.2", - "width": "10.9", - "height": "5", - "weight": "65.9" - }, - "service": "Priority", - "carrier_accounts": ["ca_..."] - } -}' diff --git a/official/docs/golang/v3/addresses/create-and-verify.go b/official/docs/golang/v3/addresses/create-and-verify.go new file mode 100644 index 00000000..6096f71d --- /dev/null +++ b/official/docs/golang/v3/addresses/create-and-verify.go @@ -0,0 +1,29 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAndVerifyAddress( + &easypost.Address{ + Street1: "417 Montgomery Street", + Street2: "FL 5", + City: "San Francisco", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{}, + ) + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/create.go b/official/docs/golang/v3/addresses/create.go new file mode 100644 index 00000000..7d96f8c5 --- /dev/null +++ b/official/docs/golang/v3/addresses/create.go @@ -0,0 +1,29 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAddress( + &easypost.Address{ + Street1: "417 MONTGOMERY ST", + Street2: "FLOOR 5", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{}, + ) + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/list.go b/official/docs/golang/v3/addresses/list.go new file mode 100644 index 00000000..0f8d9274 --- /dev/null +++ b/official/docs/golang/v3/addresses/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + addresses, _ := client.ListAddresses( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(addresses) +} diff --git a/official/docs/golang/v3/addresses/retrieve.go b/official/docs/golang/v3/addresses/retrieve.go new file mode 100644 index 00000000..c35bc011 --- /dev/null +++ b/official/docs/golang/v3/addresses/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.GetAddress("adr_...") + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/verify-failure.go b/official/docs/golang/v3/addresses/verify-failure.go new file mode 100644 index 00000000..e6ce7281 --- /dev/null +++ b/official/docs/golang/v3/addresses/verify-failure.go @@ -0,0 +1,28 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAddress( + &easypost.Address{ + Street1: "UNDELIVERABLE ST", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{}, + ) + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/verify-param.go b/official/docs/golang/v3/addresses/verify-param.go new file mode 100644 index 00000000..6e3c5f78 --- /dev/null +++ b/official/docs/golang/v3/addresses/verify-param.go @@ -0,0 +1,31 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAddress( + &easypost.Address{ + Street1: "417 Montgomery Street", + Street2: "FLOOR 5", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{ + Verify: []string{"true"}, + }, + ) + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/verify-strict-param.go b/official/docs/golang/v3/addresses/verify-strict-param.go new file mode 100644 index 00000000..ac50f4d1 --- /dev/null +++ b/official/docs/golang/v3/addresses/verify-strict-param.go @@ -0,0 +1,31 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAddress( + &easypost.Address{ + Street1: "417 MONTGOMERY ST", + Street2: "FLOOR 5", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{ + VerifyStrict: []string{"true"}, + }, + ) + + fmt.Println(address) +} diff --git a/official/docs/golang/v3/addresses/verify.go b/official/docs/golang/v3/addresses/verify.go new file mode 100644 index 00000000..48d64612 --- /dev/null +++ b/official/docs/golang/v3/addresses/verify.go @@ -0,0 +1,31 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.CreateAddress( + &easypost.Address{ + Street1: "417 MONTGOMERY ST", + Street2: "FLOOR 5", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94104", + Country: "US", + Company: "EasyPost", + Phone: "415-123-4567", + }, + &easypost.CreateAddressOptions{}, + ) + + verifiedAddress, _ := client.VerifyAddress(address.ID) + + fmt.Println(verifiedAddress) +} diff --git a/official/docs/golang/v3/api-keys/retrieve.go b/official/docs/golang/v3/api-keys/retrieve.go new file mode 100644 index 00000000..11cd419a --- /dev/null +++ b/official/docs/golang/v3/api-keys/retrieve.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + // Retrieve all API keys including children + apiKeys, _ := client.GetAPIKeys() + + fmt.Println(apiKeys) + + // Retrieve API keys for a specific child user + childApiKeys, _ := client.GetAPIKeysForUser("user_...") + + fmt.Println(childApiKeys) +} diff --git a/official/docs/golang/v3/batches/add-shipments.go b/official/docs/golang/v3/batches/add-shipments.go new file mode 100644 index 00000000..ee82f360 --- /dev/null +++ b/official/docs/golang/v3/batches/add-shipments.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + + batch, _ := client.AddShipmentsToBatch("batch_...", shipment) + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/buy.go b/official/docs/golang/v3/batches/buy.go new file mode 100644 index 00000000..90c3bf1b --- /dev/null +++ b/official/docs/golang/v3/batches/buy.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + batch, _ := client.BuyBatch("batch_...") + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/create.go b/official/docs/golang/v3/batches/create.go new file mode 100644 index 00000000..7c9ef10c --- /dev/null +++ b/official/docs/golang/v3/batches/create.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + + batch, _ := client.CreateBatch(shipment) + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/label.go b/official/docs/golang/v3/batches/label.go new file mode 100644 index 00000000..fdcddd24 --- /dev/null +++ b/official/docs/golang/v3/batches/label.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + batch, _ := client.GetBatchLabels("batch_...", "PDF") + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/list.go b/official/docs/golang/v3/batches/list.go new file mode 100644 index 00000000..f44bb455 --- /dev/null +++ b/official/docs/golang/v3/batches/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + batches, _ := client.ListBatches( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(batches) +} diff --git a/official/docs/golang/v3/batches/remove-shipments.go b/official/docs/golang/v3/batches/remove-shipments.go new file mode 100644 index 00000000..a58ff225 --- /dev/null +++ b/official/docs/golang/v3/batches/remove-shipments.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + + batch, _ := client.RemoveShipmentsFromBatch("batch_...", shipment) + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/retrieve.go b/official/docs/golang/v3/batches/retrieve.go new file mode 100644 index 00000000..c71fd82b --- /dev/null +++ b/official/docs/golang/v3/batches/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + batch, _ := client.GetBatch("batch_...") + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/batches/scan-forms.go b/official/docs/golang/v3/batches/scan-forms.go new file mode 100644 index 00000000..44872afc --- /dev/null +++ b/official/docs/golang/v3/batches/scan-forms.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + batch, _ := client.CreateBatchScanForms("batch_...", "pdf") + + fmt.Println(batch) +} diff --git a/official/docs/golang/v3/billing/create-ep-credit-card.go b/official/docs/golang/v3/billing/create-ep-credit-card.go new file mode 100644 index 00000000..9979a884 --- /dev/null +++ b/official/docs/golang/v3/billing/create-ep-credit-card.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + referralUserApiKey := os.Getenv("REFERRAL_USER_API_KEY") + + creditCard, _ := client.AddReferralCustomerCreditCard(referralUserApiKey, &easypost.CreditCardOptions{ + Number: "0123456789101234", + ExpMonth: "01", + ExpYear: "2025", + Cvc: "111", + }, easypost.PrimaryPaymentMethodPriority) + + fmt.Println(creditCard) +} diff --git a/official/docs/golang/v3/billing/delete.go b/official/docs/golang/v3/billing/delete.go new file mode 100644 index 00000000..02542acf --- /dev/null +++ b/official/docs/golang/v3/billing/delete.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + err := client.DeletePaymentMethod(easypost.PrimaryPaymentMethodPriority) + + fmt.Println(err) +} diff --git a/official/docs/golang/v3/billing/fund.go b/official/docs/golang/v3/billing/fund.go new file mode 100644 index 00000000..4d3306b3 --- /dev/null +++ b/official/docs/golang/v3/billing/fund.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + fund := client.FundWallet("2000", easypost.PrimaryPaymentMethodPriority) + + fmt.Println(fund) +} diff --git a/official/docs/golang/v3/billing/list.go b/official/docs/golang/v3/billing/list.go new file mode 100644 index 00000000..0699f3a9 --- /dev/null +++ b/official/docs/golang/v3/billing/list.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + paymentMethods, _ := client.RetrievePaymentMethods() + + fmt.Println(paymentMethods) +} diff --git a/official/docs/golang/v3/brand/update.go b/official/docs/golang/v3/brand/update.go new file mode 100644 index 00000000..78659389 --- /dev/null +++ b/official/docs/golang/v3/brand/update.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + user, _ := client.RetrieveMe() + brand, _ := client.UpdateBrand( + map[string]interface{}{ + "color": "#303F9F", + }, + user.ID, + ) + + fmt.Println(brand) +} diff --git a/official/docs/golang/current/carbon-offset/buy.go b/official/docs/golang/v3/carbon-offset/buy.go similarity index 100% rename from official/docs/golang/current/carbon-offset/buy.go rename to official/docs/golang/v3/carbon-offset/buy.go diff --git a/official/docs/golang/current/carbon-offset/create.go b/official/docs/golang/v3/carbon-offset/create.go similarity index 100% rename from official/docs/golang/current/carbon-offset/create.go rename to official/docs/golang/v3/carbon-offset/create.go diff --git a/official/docs/golang/current/carbon-offset/one-call-buy.go b/official/docs/golang/v3/carbon-offset/one-call-buy.go similarity index 100% rename from official/docs/golang/current/carbon-offset/one-call-buy.go rename to official/docs/golang/v3/carbon-offset/one-call-buy.go diff --git a/official/docs/golang/v3/carrier-accounts/create.go b/official/docs/golang/v3/carrier-accounts/create.go new file mode 100644 index 00000000..d7031148 --- /dev/null +++ b/official/docs/golang/v3/carrier-accounts/create.go @@ -0,0 +1,34 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + carrierAccount, _ := client.CreateCarrierAccount( + &easypost.CarrierAccount{ + Type: "DhlEcsAccount", + Description: "CA Location DHL eCommerce Solutions Account", + Credentials: map[string]string{ + "client_id": "123456", + "client_secret": "123abc", + "distribution_center": "USLAX1", + "pickup_id": "123456", + }, + TestCredentials: map[string]string{ + "client_id": "123456", + "client_secret": "123abc", + "distribution_center": "USLAX1", + "pickup_id": "123456", + }, + }, + ) + + fmt.Println(carrierAccount) +} diff --git a/official/docs/golang/v3/carrier-accounts/delete.go b/official/docs/golang/v3/carrier-accounts/delete.go new file mode 100644 index 00000000..d57a7eb9 --- /dev/null +++ b/official/docs/golang/v3/carrier-accounts/delete.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + err := client.DeleteCarrierAccount("ca_...") + + fmt.Println(err) +} diff --git a/official/docs/golang/v3/carrier-accounts/list.go b/official/docs/golang/v3/carrier-accounts/list.go new file mode 100644 index 00000000..5bf07572 --- /dev/null +++ b/official/docs/golang/v3/carrier-accounts/list.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + carrierAccounts, _ := client.ListCarrierAccounts() + + fmt.Println(carrierAccounts) +} diff --git a/official/docs/golang/v3/carrier-accounts/retrieve.go b/official/docs/golang/v3/carrier-accounts/retrieve.go new file mode 100644 index 00000000..e1eda826 --- /dev/null +++ b/official/docs/golang/v3/carrier-accounts/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + carrierAccount, _ := client.GetCarrierAccount("ca_...") + + fmt.Println(carrierAccount) +} diff --git a/official/docs/golang/v3/carrier-accounts/update.go b/official/docs/golang/v3/carrier-accounts/update.go new file mode 100644 index 00000000..08b484ae --- /dev/null +++ b/official/docs/golang/v3/carrier-accounts/update.go @@ -0,0 +1,27 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + carrierAccount, _ := client.GetCarrierAccount("ca_...") + + carrierAccount, _ = client.UpdateCarrierAccount( + &easypost.CarrierAccount{ + ID: carrierAccount.ID, + Description: "FL Location DHL eCommerce Solutions Account", + Credentials: map[string]string{ + "pickup_id": "abc123", + }, + }, + ) + + fmt.Println(carrierAccount) +} diff --git a/official/docs/golang/v3/carrier-metadata/retrieve.go b/official/docs/golang/v3/carrier-metadata/retrieve.go new file mode 100644 index 00000000..bebbb5e8 --- /dev/null +++ b/official/docs/golang/v3/carrier-metadata/retrieve.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + // Request all metadata for all carriers + carrierMetadata, _ := client.GetCarrierMetadata() + fmt.Println(carrierMetadata) + + // Request specific metadata for specific carriers + carrierMetadataWithFilters, _ := client.GetCarrierMetadataWithCarriersAndTypes([]string{"usps"}, []string{"service_levels", "predefined_packages"}) + fmt.Println(carrierMetadataWithFilters) +} diff --git a/official/docs/golang/v3/carrier-types/list.go b/official/docs/golang/v3/carrier-types/list.go new file mode 100644 index 00000000..6dc8b72f --- /dev/null +++ b/official/docs/golang/v3/carrier-types/list.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + carrierTypes, _ := client.GetCarrierTypes() + + fmt.Println(carrierTypes) +} diff --git a/official/docs/golang/v3/child-users/create.go b/official/docs/golang/v3/child-users/create.go new file mode 100644 index 00000000..1a1c71e3 --- /dev/null +++ b/official/docs/golang/v3/child-users/create.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + userName := "Child Account Name" + user, _ := client.CreateUser( + &easypost.UserOptions{ + Name: &userName, + }, + ) + + fmt.Println(user) +} diff --git a/official/docs/golang/v3/child-users/delete.go b/official/docs/golang/v3/child-users/delete.go new file mode 100644 index 00000000..a73b54bc --- /dev/null +++ b/official/docs/golang/v3/child-users/delete.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + err := client.DeleteUser("user_...") + + fmt.Println(err) +} diff --git a/official/docs/golang/v3/customs-infos/create.go b/official/docs/golang/v3/customs-infos/create.go new file mode 100644 index 00000000..0ee1ad9e --- /dev/null +++ b/official/docs/golang/v3/customs-infos/create.go @@ -0,0 +1,35 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + customsInfo, _ := client.CreateCustomsInfo( + &easypost.CustomsInfo{ + CustomsCertify: true, + CustomsSigner: "Steve Brule", + ContentsType: "merchandise", + ContentsExplanation: "", + RestrictionType: "none", + EELPFC: "NOEEI 30.37(a)", + CustomsItems: []*easypost.CustomsItem{ + &easypost.CustomsItem{ + Description: "T-shirt", + Quantity: 1, + Value: 10.00, + Weight: 5, + OriginCountry: "US", + }, + }, + }, + ) + + fmt.Println(customsInfo) +} diff --git a/official/docs/golang/v3/customs-infos/retrieve.go b/official/docs/golang/v3/customs-infos/retrieve.go new file mode 100644 index 00000000..a0dc7b16 --- /dev/null +++ b/official/docs/golang/v3/customs-infos/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + customsInfo, _ := client.GetCustomsInfo("cstinfo_...") + + fmt.Println(customsInfo) +} diff --git a/official/docs/golang/v3/customs-items/create.go b/official/docs/golang/v3/customs-items/create.go new file mode 100644 index 00000000..eb2c4e2f --- /dev/null +++ b/official/docs/golang/v3/customs-items/create.go @@ -0,0 +1,25 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + customsItem, _ := client.CreateCustomsItem( + &easypost.CustomsItem{ + Description: "T-shirts", + Quantity: 1, + Value: 10.00, + Weight: 5, + OriginCountry: "US", + }, + ) + + fmt.Println(customsItem) +} diff --git a/official/docs/golang/v3/customs-items/retrieve.go b/official/docs/golang/v3/customs-items/retrieve.go new file mode 100644 index 00000000..ee800b89 --- /dev/null +++ b/official/docs/golang/v3/customs-items/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + customsItem, _ := client.GetCustomsItem("cstitem_...") + + fmt.Println(customsItem) +} diff --git a/official/docs/golang/v3/endshipper/buy.go b/official/docs/golang/v3/endshipper/buy.go new file mode 100644 index 00000000..06e0a97c --- /dev/null +++ b/official/docs/golang/v3/endshipper/buy.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + rate, _ := client.LowestShipmentRate(shipment) + + shipment, _ = client.BuyShipmentWithEndShipper(shipment.ID, &rate, "0", "es_...") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/endshipper/create.go b/official/docs/golang/v3/endshipper/create.go new file mode 100644 index 00000000..7caef4b5 --- /dev/null +++ b/official/docs/golang/v3/endshipper/create.go @@ -0,0 +1,30 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + endshipper, _ := client.CreateEndShipper( + &easypost.Address{ + Name: "FOO BAR", + Company: "BAZ", + Street1: "164 TOWNSEND STREET UNIT 1", + Street2: "UNIT 1", + City: "SAN FRANCISCO", + State: "CA", + Zip: "94107", + Country: "US", + Phone: "555-555-5555", + Email: "FOO@EXAMPLE.COM", + }, + ) + + fmt.Println(endshipper) +} diff --git a/official/docs/golang/v3/endshipper/list.go b/official/docs/golang/v3/endshipper/list.go new file mode 100644 index 00000000..15ee5de9 --- /dev/null +++ b/official/docs/golang/v3/endshipper/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + endshippers, _ := client.ListEndShippers( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(endshippers) +} diff --git a/official/docs/golang/v3/endshipper/retrieve.go b/official/docs/golang/v3/endshipper/retrieve.go new file mode 100644 index 00000000..ba94fbd0 --- /dev/null +++ b/official/docs/golang/v3/endshipper/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + retrievedEndShipper, _ := client.GetEndShipper("es_...") + + fmt.Println(retrievedEndShipper) +} diff --git a/official/docs/golang/v3/endshipper/update.go b/official/docs/golang/v3/endshipper/update.go new file mode 100644 index 00000000..8c970130 --- /dev/null +++ b/official/docs/golang/v3/endshipper/update.go @@ -0,0 +1,30 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + endShipper, _ := client.GetEndShipper("es_...") + + endShipper.Name = "NEW NAME" + endShipper.Company = "BAZ" + endShipper.Street1 = "164 TOWNSEND STREET UNIT 1" + endShipper.Street2 = "UNIT 1" + endShipper.City = "San Francisco" + endShipper.State = "CA" + endShipper.Zip = "94107" + endShipper.Country = "US" + endShipper.Phone = "555-555-5555" + endShipper.Email = "FOO@EXAMPLE.COM" + + updatedEndShipper, _ := client.UpdateEndShippers(endShipper) + + fmt.Println(updatedEndShipper) +} diff --git a/official/docs/golang/v3/events/list.go b/official/docs/golang/v3/events/list.go new file mode 100644 index 00000000..a187c65f --- /dev/null +++ b/official/docs/golang/v3/events/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + events, _ := client.ListEvents( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(events) +} diff --git a/official/docs/golang/v3/events/retrieve.go b/official/docs/golang/v3/events/retrieve.go new file mode 100644 index 00000000..ebb7b1fb --- /dev/null +++ b/official/docs/golang/v3/events/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + event, _ := client.GetEvent("evt_...") + + fmt.Println(event) +} diff --git a/official/docs/golang/v3/forms/create.go b/official/docs/golang/v3/forms/create.go new file mode 100644 index 00000000..65ff3714 --- /dev/null +++ b/official/docs/golang/v3/forms/create.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipmentWithForm, _ := client.GenerateShipmentForm("shp_...", "return_packing_slip") + + fmt.Println(shipmentWithForm) +} diff --git a/official/docs/golang/v3/insurance/create.go b/official/docs/golang/v3/insurance/create.go new file mode 100644 index 00000000..47c96136 --- /dev/null +++ b/official/docs/golang/v3/insurance/create.go @@ -0,0 +1,29 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("adr_...") + fromAddress, _ := client.GetAddress("adr_...") + + insurance, _ := client.CreateInsurance( + &easypost.Insurance{ + ToAddress: toAddress, + FromAddress: fromAddress, + Reference: "InsuranceRef1", + Carrier: "USPS", + TrackingCode: "9400110898825022579493", + Amount: "100.00", + }, + ) + + fmt.Println(insurance) +} diff --git a/official/docs/golang/v3/insurance/list.go b/official/docs/golang/v3/insurance/list.go new file mode 100644 index 00000000..debde788 --- /dev/null +++ b/official/docs/golang/v3/insurance/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + insurances, _ := client.ListInsurances( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(insurances) +} diff --git a/official/docs/golang/v3/insurance/retrieve.go b/official/docs/golang/v3/insurance/retrieve.go new file mode 100644 index 00000000..15f597f2 --- /dev/null +++ b/official/docs/golang/v3/insurance/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + insurance, _ := client.GetInsurance("ins_...") + + fmt.Println(insurance) +} diff --git a/official/docs/golang/v3/options/create-with-options.go b/official/docs/golang/v3/options/create-with-options.go new file mode 100644 index 00000000..f4ab9e85 --- /dev/null +++ b/official/docs/golang/v3/options/create-with-options.go @@ -0,0 +1,30 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("shp_...") + fromAddress, _ := client.GetAddress("adr_...") + parcel, _ := client.GetParcel("prcl_...") + + shipment, _ := client.CreateShipment( + &easypost.Shipment{ + ToAddress: toAddress, + FromAddress: fromAddress, + Parcel: parcel, + Options: &easypost.ShipmentOptions{ + PrintCustom1: "Custom label message", + }, + }, + ) + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/orders/buy.go b/official/docs/golang/v3/orders/buy.go new file mode 100644 index 00000000..15d3006c --- /dev/null +++ b/official/docs/golang/v3/orders/buy.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + order, _ := client.BuyOrder("order_...", "FedEx", "FEDEX_GROUND") + + fmt.Println(order) +} diff --git a/official/docs/golang/v3/orders/create.go b/official/docs/golang/v3/orders/create.go new file mode 100644 index 00000000..a227559f --- /dev/null +++ b/official/docs/golang/v3/orders/create.go @@ -0,0 +1,29 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("adr_...") + fromAddress, _ := client.GetAddress("adr_...") + shipment, _ := client.GetShipment("shp_...") + + order, _ := client.CreateOrder( + &easypost.Order{ + ToAddress: toAddress, + FromAddress: fromAddress, + Shipments: []*easypost.Shipment{ + shipment, + }, + }, + ) + + fmt.Println(order) +} diff --git a/official/docs/golang/v3/orders/one-call-buy.go b/official/docs/golang/v3/orders/one-call-buy.go new file mode 100644 index 00000000..574c82db --- /dev/null +++ b/official/docs/golang/v3/orders/one-call-buy.go @@ -0,0 +1,47 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("adr_...") + fromAddress, _ := client.GetAddress("adr_...") + + firstShipment := &easypost.Shipment{ + Parcel: &easypost.Parcel{ + PredefinedPackage: "FedExBox", + Weight: 10.4, + }, + } + + secondShipment := &easypost.Shipment{ + Parcel: &easypost.Parcel{ + PredefinedPackage: "FedExBox", + Weight: 17.5, + }, + } + + order, _ := client.CreateOrder( + &easypost.Order{ + Service: "NextDayAir", + ToAddress: toAddress, + FromAddress: fromAddress, + Shipments: []*easypost.Shipment{ + firstShipment, + secondShipment, + }, + }, + &easypost.CarrierAccount{ + ID: "ca_...", + }, + ) + + fmt.Println(order) +} diff --git a/official/docs/golang/v3/orders/retrieve.go b/official/docs/golang/v3/orders/retrieve.go new file mode 100644 index 00000000..edb6d2d9 --- /dev/null +++ b/official/docs/golang/v3/orders/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + order, _ := client.GetOrder("order_...") + + fmt.Println(order) +} diff --git a/official/docs/golang/v3/pagination/get-next-page.go b/official/docs/golang/v3/pagination/get-next-page.go new file mode 100644 index 00000000..0d56e0ea --- /dev/null +++ b/official/docs/golang/v3/pagination/get-next-page.go @@ -0,0 +1,28 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + // Get first page of results + shipments, _ := client.ListShipments( + &easypost.ListShipmentsOptions{ + PageSize: 5, + }, + ) + + // Provide the previous results page to move onto the next page + secondPage, _ := client.GetNextShipmentPage(shipments) + + // You can also ask for the next page to be of a specific size + lastPage, _ := client.GetNextShipmentPageWithPageSize(secondPage, 10) + + fmt.Println(lastPage) +} diff --git a/official/docs/golang/v3/parcels/create.go b/official/docs/golang/v3/parcels/create.go new file mode 100644 index 00000000..e132b277 --- /dev/null +++ b/official/docs/golang/v3/parcels/create.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + parcel, _ := client.CreateParcel( + &easypost.Parcel{ + Length: 20.2, + Width: 10.9, + Height: 5, + Weight: 65.9, + }, + ) + + fmt.Println(parcel) +} diff --git a/official/docs/golang/v3/parcels/retrieve.go b/official/docs/golang/v3/parcels/retrieve.go new file mode 100644 index 00000000..b595fe31 --- /dev/null +++ b/official/docs/golang/v3/parcels/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + parcel, _ := client.GetParcel("prcl_...") + + fmt.Println(parcel) +} diff --git a/official/docs/golang/v3/payloads/list.go b/official/docs/golang/v3/payloads/list.go new file mode 100644 index 00000000..d49ffef6 --- /dev/null +++ b/official/docs/golang/v3/payloads/list.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + payloads, _ := client.ListEventPayloads("evt_...") + + fmt.Println(payloads) +} diff --git a/official/docs/golang/v3/payloads/retrieve.go b/official/docs/golang/v3/payloads/retrieve.go new file mode 100644 index 00000000..071849da --- /dev/null +++ b/official/docs/golang/v3/payloads/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + payload, _ := client.GetEventPayload("evt_...", "payload_...") + + fmt.Println(payload) +} diff --git a/official/docs/golang/v3/pickups/buy.go b/official/docs/golang/v3/pickups/buy.go new file mode 100644 index 00000000..22e7bae5 --- /dev/null +++ b/official/docs/golang/v3/pickups/buy.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + rate := &easypost.PickupRate{Carrier: "UPS", Service: "Same-day Pickup"} + pickup, _ := client.BuyPickup("pickup...", rate) + + fmt.Println(pickup) +} diff --git a/official/docs/golang/v3/pickups/cancel.go b/official/docs/golang/v3/pickups/cancel.go new file mode 100644 index 00000000..b88b29ac --- /dev/null +++ b/official/docs/golang/v3/pickups/cancel.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + pickup, _ := client.CancelPickup("pickup_...") + + fmt.Println(pickup) +} diff --git a/official/docs/golang/v3/pickups/create.go b/official/docs/golang/v3/pickups/create.go new file mode 100644 index 00000000..9814b609 --- /dev/null +++ b/official/docs/golang/v3/pickups/create.go @@ -0,0 +1,32 @@ +package example + +import ( + "fmt" + "os" + "time" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + address, _ := client.GetAddress("adr_...") + shipment, _ := client.GetShipment("shp_...") + minPickupTime := time.Now() // now + maxPickupTime := time.Now().Add(time.Hour * 24 * 7) // 7 days from now + + pickup, _ := client.CreatePickup( + &easypost.Pickup{ + IsAccountAddress: false, + Address: address, + Shipment: shipment, + MinDatetime: &minPickupTime, + MaxDatetime: &maxPickupTime, + Instructions: "Special pickup instructions", + }, + ) + + fmt.Println(pickup) +} diff --git a/official/docs/golang/v3/pickups/list.go b/official/docs/golang/v3/pickups/list.go new file mode 100644 index 00000000..d6909106 --- /dev/null +++ b/official/docs/golang/v3/pickups/list.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/EasyPost/easypost-go/v3" + "os" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + pickups, _ := client.ListPickups( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(pickups) +} diff --git a/official/docs/golang/v3/pickups/retrieve.go b/official/docs/golang/v3/pickups/retrieve.go new file mode 100644 index 00000000..4438af7d --- /dev/null +++ b/official/docs/golang/v3/pickups/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + pickup, _ := client.GetPickup("pickup_...") + + fmt.Println(pickup) +} diff --git a/official/docs/golang/v3/rates/regenerate.go b/official/docs/golang/v3/rates/regenerate.go new file mode 100644 index 00000000..fc07f81d --- /dev/null +++ b/official/docs/golang/v3/rates/regenerate.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.RerateShipment("shp_...") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/rates/retrieve-stateless.go b/official/docs/golang/v3/rates/retrieve-stateless.go new file mode 100644 index 00000000..a1cd8061 --- /dev/null +++ b/official/docs/golang/v3/rates/retrieve-stateless.go @@ -0,0 +1,47 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipmentDetails := &easypost.Shipment{ + ToAddress: &easypost.Address{ + Name: "Dr. Steve Brule", + Street1: "179 N Harbor Dr", + City: "Redondo Beach", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "dr_steve_brule@gmail.com", + }, + FromAddress: &easypost.Address{ + Name: "EasyPost", + Street1: "417 Montgomery Street", + Street2: "5th Floor", + City: "San Francisco", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "support@easypost.com", + }, + Parcel: &easypost.Parcel{ + Length: 20.2, + Width: 10.9, + Height: 5, + Weight: 65.9, + }, + } + + rates, _ := client.BetaGetStatelessRates(shipmentDetails) + + fmt.Println(rates) +} diff --git a/official/docs/golang/v3/rates/retrieve.go b/official/docs/golang/v3/rates/retrieve.go new file mode 100644 index 00000000..cf3ded0d --- /dev/null +++ b/official/docs/golang/v3/rates/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + rate, _ := client.GetRate("rate...") + + fmt.Println(rate) +} diff --git a/official/docs/golang/v3/referral-customers/add-payment-method-with-bank-account.go b/official/docs/golang/v3/referral-customers/add-payment-method-with-bank-account.go new file mode 100644 index 00000000..127f4904 --- /dev/null +++ b/official/docs/golang/v3/referral-customers/add-payment-method-with-bank-account.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + paymentMethod, _ := client.BetaAddPaymentMethod("cus_...", "ba_...", easypost.PrimaryPaymentMethodPriority) + + fmt.Println(paymentMethod) +} diff --git a/official/docs/golang/v3/referral-customers/add-payment-method-with-credit-card.go b/official/docs/golang/v3/referral-customers/add-payment-method-with-credit-card.go new file mode 100644 index 00000000..0f2036d6 --- /dev/null +++ b/official/docs/golang/v3/referral-customers/add-payment-method-with-credit-card.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + paymentMethod, _ := client.BetaAddPaymentMethod("cus_...", "card_...", easypost.PrimaryPaymentMethodPriority) + + fmt.Println(paymentMethod) +} diff --git a/official/docs/golang/v3/referral-customers/create.go b/official/docs/golang/v3/referral-customers/create.go new file mode 100644 index 00000000..ef97455c --- /dev/null +++ b/official/docs/golang/v3/referral-customers/create.go @@ -0,0 +1,27 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + name := "Test Referral" + email := "test@example.com" + phone := "5555555555" + + referralUser, _ := client.CreateReferralCustomer( + &easypost.UserOptions{ + Name: &name, + Email: &email, + Phone: &phone, + }, + ) + + fmt.Println(referralUser) +} diff --git a/official/docs/golang/v3/referral-customers/list.go b/official/docs/golang/v3/referral-customers/list.go new file mode 100644 index 00000000..335680e9 --- /dev/null +++ b/official/docs/golang/v3/referral-customers/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + referralCustomerCollection, _ := client.ListReferralCustomers( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(referralCustomerCollection) +} diff --git a/official/docs/golang/v3/referral-customers/refund-by-amount.go b/official/docs/golang/v3/referral-customers/refund-by-amount.go new file mode 100644 index 00000000..6e754fbd --- /dev/null +++ b/official/docs/golang/v3/referral-customers/refund-by-amount.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + refund, _ := client.BetaRefundByAmount(2000) + + fmt.Println(refund) +} diff --git a/official/docs/golang/v3/referral-customers/refund-by-payment-log.go b/official/docs/golang/v3/referral-customers/refund-by-payment-log.go new file mode 100644 index 00000000..3953a661 --- /dev/null +++ b/official/docs/golang/v3/referral-customers/refund-by-payment-log.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + refund, _ := client.BetaRefundByPaymentLog("paylog_...") + + fmt.Println(refund) +} diff --git a/official/docs/golang/v3/referral-customers/update.go b/official/docs/golang/v3/referral-customers/update.go new file mode 100644 index 00000000..adc00221 --- /dev/null +++ b/official/docs/golang/v3/referral-customers/update.go @@ -0,0 +1,14 @@ +package example + +import ( + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + _, _ = client.UpdateReferralCustomerEmail("user_...", "new_email@example.com") +} diff --git a/official/docs/golang/v3/refunds/create.go b/official/docs/golang/v3/refunds/create.go new file mode 100644 index 00000000..261a7c25 --- /dev/null +++ b/official/docs/golang/v3/refunds/create.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + refunds, _ := client.CreateRefund( + map[string]interface{}{ + "carrier": "USPS", + "tracking_codes": []string{"EZ1000000001"}, + }, + ) + + fmt.Println(refunds) +} diff --git a/official/docs/golang/v3/refunds/list.go b/official/docs/golang/v3/refunds/list.go new file mode 100644 index 00000000..e689ce0f --- /dev/null +++ b/official/docs/golang/v3/refunds/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + refunds, _ := client.ListRefunds( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(refunds) +} diff --git a/official/docs/golang/v3/refunds/retrieve.go b/official/docs/golang/v3/refunds/retrieve.go new file mode 100644 index 00000000..29692f53 --- /dev/null +++ b/official/docs/golang/v3/refunds/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + refund, _ := client.GetRefund("shp_...") + + fmt.Println(refund) +} diff --git a/official/docs/golang/v3/reports/create.go b/official/docs/golang/v3/reports/create.go new file mode 100644 index 00000000..6db0a679 --- /dev/null +++ b/official/docs/golang/v3/reports/create.go @@ -0,0 +1,25 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + reportOptions := &easypost.Report{ + StartDate: "2022-10-01", + EndDate: "2022-10-31", + } + + report, _ := client.CreateReport( + "payment_log", + reportOptions, + ) + + fmt.Println(report) +} diff --git a/official/docs/golang/v3/reports/list.go b/official/docs/golang/v3/reports/list.go new file mode 100644 index 00000000..65cfb27f --- /dev/null +++ b/official/docs/golang/v3/reports/list.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + reportOptions := &easypost.ListReportsOptions{ + PageSize: 5, + } + + reports, _ := client.ListReports( + "payment_log", + reportOptions, + ) + + fmt.Println(reports) +} diff --git a/official/docs/golang/v3/reports/retrieve.go b/official/docs/golang/v3/reports/retrieve.go new file mode 100644 index 00000000..de3ca12f --- /dev/null +++ b/official/docs/golang/v3/reports/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + report, _ := client.GetReport("", "") + + fmt.Println(report) +} diff --git a/official/docs/golang/v3/returns/create.go b/official/docs/golang/v3/returns/create.go new file mode 100644 index 00000000..066f60c3 --- /dev/null +++ b/official/docs/golang/v3/returns/create.go @@ -0,0 +1,28 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("adr_...") + fromAddress, _ := client.GetAddress("adr_...") + parcel, _ := client.GetParcel("prcl_...") + + shipment, _ := client.CreateShipment( + &easypost.Shipment{ + ToAddress: fromAddress, + FromAddress: toAddress, + Parcel: parcel, + IsReturn: true, + }, + ) + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/scan-form/create.go b/official/docs/golang/v3/scan-form/create.go new file mode 100644 index 00000000..00492e53 --- /dev/null +++ b/official/docs/golang/v3/scan-form/create.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + scanForm, _ := client.CreateScanForm("shp_...", "shp_...") + + fmt.Println(scanForm) +} diff --git a/official/docs/golang/v3/scan-form/list.go b/official/docs/golang/v3/scan-form/list.go new file mode 100644 index 00000000..f3c43f1a --- /dev/null +++ b/official/docs/golang/v3/scan-form/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + scanForms, _ := client.ListScanForms( + &easypost.ListOptions{ + PageSize: 5, + }, + ) + + fmt.Println(scanForms) +} diff --git a/official/docs/golang/v3/scan-form/retrieve.go b/official/docs/golang/v3/scan-form/retrieve.go new file mode 100644 index 00000000..2fb3305f --- /dev/null +++ b/official/docs/golang/v3/scan-form/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + scanForm, _ := client.GetScanForm("sf_...") + + fmt.Println(scanForm) +} diff --git a/official/docs/golang/v3/shipments/buy.go b/official/docs/golang/v3/shipments/buy.go new file mode 100644 index 00000000..a46f70bc --- /dev/null +++ b/official/docs/golang/v3/shipments/buy.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + rate, _ := client.LowestShipmentRate(shipment) + + shipment, _ = client.BuyShipment(shipment.ID, &rate, "249.99") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipments/create.go b/official/docs/golang/v3/shipments/create.go new file mode 100644 index 00000000..b85a087a --- /dev/null +++ b/official/docs/golang/v3/shipments/create.go @@ -0,0 +1,50 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.CreateShipment( + &easypost.Shipment{ + ToAddress: &easypost.Address{ + Name: "Dr. Steve Brule", + Street1: "179 N Harbor Dr", + City: "Redondo Beach", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "dr_steve_brule@gmail.com", + }, + FromAddress: &easypost.Address{ + Name: "EasyPost", + Street1: "417 Montgomery Street", + Street2: "5th Floor", + City: "San Francisco", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "support@easypost.com", + }, + Parcel: &easypost.Parcel{ + Length: 20.2, + Width: 10.9, + Height: 5, + Weight: 65.9, + }, + CustomsInfo: &easypost.CustomsInfo{ + ID: "cstinfo_...", + }, + }, + ) + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipments/label.go b/official/docs/golang/v3/shipments/label.go new file mode 100644 index 00000000..b19c1775 --- /dev/null +++ b/official/docs/golang/v3/shipments/label.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipmentLabel("shp_...", "ZPL") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipments/list.go b/official/docs/golang/v3/shipments/list.go new file mode 100644 index 00000000..5a902a18 --- /dev/null +++ b/official/docs/golang/v3/shipments/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipments, _ := client.ListShipments( + &easypost.ListShipmentsOptions{ + PageSize: 5, + }, + ) + + fmt.Println(shipments) +} diff --git a/official/docs/golang/v3/shipments/one-call-buy.go b/official/docs/golang/v3/shipments/one-call-buy.go new file mode 100644 index 00000000..8f9cc779 --- /dev/null +++ b/official/docs/golang/v3/shipments/one-call-buy.go @@ -0,0 +1,50 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.CreateShipment( + &easypost.Shipment{ + CarrierAccountIDs: []string{"ca_..."}, + Service: "NextDayAir", + Parcel: &easypost.Parcel{ + Length: 20.2, + Width: 10.9, + Height: 5, + Weight: 65.9, + }, + ToAddress: &easypost.Address{ + Name: "Dr. Steve Brule", + Street1: "179 N Harbor Dr", + City: "Redondo Beach", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "dr_steve_brule@gmail.com", + }, + FromAddress: &easypost.Address{ + Name: "EasyPost", + Street1: "417 Montgomery Street", + Street2: "5th Floor", + City: "San Francisco", + State: "CA", + Zip: "90277", + Country: "US", + Phone: "4155559999", + Email: "support@easypost.com", + }, + Reference: "ShipmentRef", + }, + ) + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipments/retrieve.go b/official/docs/golang/v3/shipments/retrieve.go new file mode 100644 index 00000000..003278a1 --- /dev/null +++ b/official/docs/golang/v3/shipments/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipping-insurance/insure.go b/official/docs/golang/v3/shipping-insurance/insure.go new file mode 100644 index 00000000..bd352f21 --- /dev/null +++ b/official/docs/golang/v3/shipping-insurance/insure.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.InsureShipment("shp_...", "100.00") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/shipping-refund/refund.go b/official/docs/golang/v3/shipping-refund/refund.go new file mode 100644 index 00000000..0409125f --- /dev/null +++ b/official/docs/golang/v3/shipping-refund/refund.go @@ -0,0 +1,17 @@ +package shipping_refund + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.RefundShipment("shp_...") + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/smartrate/retrieve-estimated-delivery-date.go b/official/docs/golang/v3/smartrate/retrieve-estimated-delivery-date.go new file mode 100644 index 00000000..42250b9c --- /dev/null +++ b/official/docs/golang/v3/smartrate/retrieve-estimated-delivery-date.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + shipment, _ := client.GetShipment("shp_...") + estimatedDeliveryDates, _ := client.GetShipmentEstimatedDeliveryDate(shipment.ID, "YYYY-MM-DD") + + fmt.Println(estimatedDeliveryDates) +} diff --git a/official/docs/golang/v3/smartrate/retrieve-time-in-transit-statistics.go b/official/docs/golang/v3/smartrate/retrieve-time-in-transit-statistics.go new file mode 100644 index 00000000..84c65bcb --- /dev/null +++ b/official/docs/golang/v3/smartrate/retrieve-time-in-transit-statistics.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + smartRates, _ := client.GetShipmentSmartrates("shp_...") + + fmt.Println(smartRates) +} diff --git a/official/docs/golang/v3/tax-identifiers/create.go b/official/docs/golang/v3/tax-identifiers/create.go new file mode 100644 index 00000000..c7a4731c --- /dev/null +++ b/official/docs/golang/v3/tax-identifiers/create.go @@ -0,0 +1,35 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + toAddress, _ := client.GetAddress("adr_...") + fromAddress, _ := client.GetAddress("adr_...") + parcel, _ := client.GetParcel("prcl_...") + + shipment, _ := client.CreateShipment( + &easypost.Shipment{ + ToAddress: toAddress, + FromAddress: fromAddress, + Parcel: parcel, + TaxIdentifiers: []*easypost.TaxIdentifier{ + &easypost.TaxIdentifier{ + Entity: "SENDER", + TaxId: "GB123456789", + IssuingCountry: "GB", + TaxIdType: "EORI", + }, + }, + }, + ) + + fmt.Println(shipment) +} diff --git a/official/docs/golang/v3/trackers/create.go b/official/docs/golang/v3/trackers/create.go new file mode 100644 index 00000000..8bb6a822 --- /dev/null +++ b/official/docs/golang/v3/trackers/create.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + tracker, _ := client.CreateTracker( + &easypost.CreateTrackerOptions{ + TrackingCode: "EZ1000000001", + Carrier: "USPS", + }, + ) + + fmt.Println(tracker) +} diff --git a/official/docs/golang/v3/trackers/list.go b/official/docs/golang/v3/trackers/list.go new file mode 100644 index 00000000..db4475d7 --- /dev/null +++ b/official/docs/golang/v3/trackers/list.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + trackers, _ := client.ListTrackers( + &easypost.ListTrackersOptions{ + PageSize: 5, + }, + ) + + fmt.Println(trackers) +} diff --git a/official/docs/golang/v3/trackers/retrieve.go b/official/docs/golang/v3/trackers/retrieve.go new file mode 100644 index 00000000..a46b9d15 --- /dev/null +++ b/official/docs/golang/v3/trackers/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + tracker, _ := client.GetTracker("trk_...") + + fmt.Println(tracker) +} diff --git a/official/docs/golang/v3/users/retrieve.go b/official/docs/golang/v3/users/retrieve.go new file mode 100644 index 00000000..1d9acaba --- /dev/null +++ b/official/docs/golang/v3/users/retrieve.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + // Retrieve the authenticated user + user, _ := client.RetrieveMe() + + // Retrieve a child user + user, _ = client.GetUser("user_...") + + fmt.Println(user) +} diff --git a/official/docs/golang/v3/users/update.go b/official/docs/golang/v3/users/update.go new file mode 100644 index 00000000..a4b1911e --- /dev/null +++ b/official/docs/golang/v3/users/update.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + user, _ := client.RetrieveMe() + rechargeThreshold := "50.00" + + user, _ = client.UpdateUser( + &easypost.UserOptions{ + RechargeAmount: &rechargeThreshold, + }, + ) + + fmt.Println(user) +} diff --git a/official/docs/golang/v3/webhooks/create.go b/official/docs/golang/v3/webhooks/create.go new file mode 100644 index 00000000..a0b94ac1 --- /dev/null +++ b/official/docs/golang/v3/webhooks/create.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + webhook, _ := client.CreateWebhookWithDetails( + &easypost.CreateUpdateWebhookOptions{ + URL: "example.com", + }, + ) + + fmt.Println(webhook) +} diff --git a/official/docs/golang/v3/webhooks/delete.go b/official/docs/golang/v3/webhooks/delete.go new file mode 100644 index 00000000..df49815c --- /dev/null +++ b/official/docs/golang/v3/webhooks/delete.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + err := client.DeleteWebhook("hook_...") + + fmt.Println(err) +} diff --git a/official/docs/golang/v3/webhooks/list.go b/official/docs/golang/v3/webhooks/list.go new file mode 100644 index 00000000..bbc3e89e --- /dev/null +++ b/official/docs/golang/v3/webhooks/list.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + webhooks, _ := client.ListWebhooks() + + fmt.Println(webhooks) +} diff --git a/official/docs/golang/v3/webhooks/retrieve.go b/official/docs/golang/v3/webhooks/retrieve.go new file mode 100644 index 00000000..1475ea34 --- /dev/null +++ b/official/docs/golang/v3/webhooks/retrieve.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + webhook, _ := client.GetWebhook("hook_...") + + fmt.Println(webhook) +} diff --git a/official/docs/golang/v3/webhooks/update.go b/official/docs/golang/v3/webhooks/update.go new file mode 100644 index 00000000..55d801d3 --- /dev/null +++ b/official/docs/golang/v3/webhooks/update.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/EasyPost/easypost-go/v3" +) + +func main() { + apiKey := os.Getenv("EASYPOST_API_KEY") + client := easypost.New(apiKey) + + webhook, _ := client.UpdateWebhook("hook_...") + + fmt.Println(webhook) +} diff --git a/official/docs/java/v6/addresses/create-and-verify.java b/official/docs/java/v6/addresses/create-and-verify.java new file mode 100644 index 00000000..791f0882 --- /dev/null +++ b/official/docs/java/v6/addresses/create-and-verify.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 CreateAndVerify { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + + params.put("street1", "417 Montgomery Street"); + params.put("street2", "FL 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.createAndVerify(params); + + System.out.println(address); + } +} diff --git a/official/docs/java/v6/addresses/create.java b/official/docs/java/v6/addresses/create.java new file mode 100644 index 00000000..30aa4d72 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/addresses/list.java b/official/docs/java/v6/addresses/list.java new file mode 100644 index 00000000..2b8f4ad3 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/addresses/retrieve.java b/official/docs/java/v6/addresses/retrieve.java new file mode 100644 index 00000000..904fcc2e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Address address = client.address.retrieve("adr_..."); + + System.out.println(address); + } +} diff --git a/official/docs/java/v6/addresses/verify-failure.java b/official/docs/java/v6/addresses/verify-failure.java new file mode 100644 index 00000000..544300e2 --- /dev/null +++ b/official/docs/java/v6/addresses/verify-failure.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 VerifyFailure { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + + params.put("street1", "UNDELIVERABLE ST"); + 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/v6/addresses/verify-param.java b/official/docs/java/v6/addresses/verify-param.java new file mode 100644 index 00000000..e6959688 --- /dev/null +++ b/official/docs/java/v6/addresses/verify-param.java @@ -0,0 +1,29 @@ +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(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + + params.put("street1", "417 Montgomery Street"); + params.put("street2", "5"); + params.put("city", "SF"); + params.put("state", "CA"); + params.put("zip", "94104"); + params.put("country", "US"); + params.put("company", "EasyPost"); + params.put("phone", "415-123-4567"); + params.put("verify", true); + + Address address = client.address.create(params); + + System.out.println(address); + } +} diff --git a/official/docs/java/v6/addresses/verify-strict-param.java b/official/docs/java/v6/addresses/verify-strict-param.java new file mode 100644 index 00000000..ffa914ab --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + + params.put("street1", "417 Montgomery Street"); + params.put("city", "SF"); + params.put("state", "CA"); + params.put("zip", "94104"); + params.put("country", "US"); + params.put("company", "EasyPost"); + params.put("phone", "415-123-4567"); + params.put("verify_strict", true); + + Address address = client.address.create(params); + + System.out.println(address); + } +} diff --git a/official/docs/java/v6/addresses/verify.java b/official/docs/java/v6/addresses/verify.java new file mode 100644 index 00000000..8c21eeae --- /dev/null +++ b/official/docs/java/v6/addresses/verify.java @@ -0,0 +1,30 @@ +package addresses; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Address; +import com.easypost.service.EasyPostClient; + +import java.util.HashMap; + +public class Verify { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + + params.put("street1", "417 Montgomery Street"); + params.put("city", "SF"); + params.put("state", "CA"); + params.put("zip", "94104"); + params.put("country", "US"); + params.put("company", "EasyPost"); + params.put("phone", "415-123-4567"); + params.put("verify_strict", true); + + Address address = client.address.create(params); + + Address verifiedAddress = client.address.verify(address.getId()); + + System.out.println(verifiedAddress); + } +} diff --git a/official/docs/java/v6/api-keys/retrieve.java b/official/docs/java/v6/api-keys/retrieve.java new file mode 100644 index 00000000..54e0ae09 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/add-shipments.java b/official/docs/java/v6/batches/add-shipments.java new file mode 100644 index 00000000..749114d1 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/buy.java b/official/docs/java/v6/batches/buy.java new file mode 100644 index 00000000..e55471ed --- /dev/null +++ b/official/docs/java/v6/batches/buy.java @@ -0,0 +1,15 @@ +package batches; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Batch; +import com.easypost.service.EasyPostClient; + +public class Buy { + public static void main(String[] args) throws EasyPostException { + EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY")); + + Batch batch = client.batch.buy("batch_..."); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v6/batches/create.java b/official/docs/java/v6/batches/create.java new file mode 100644 index 00000000..c77e4248 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/label.java b/official/docs/java/v6/batches/label.java new file mode 100644 index 00000000..fba8503b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/list.java b/official/docs/java/v6/batches/list.java new file mode 100644 index 00000000..5dc76b46 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/remove-shipments.java b/official/docs/java/v6/batches/remove-shipments.java new file mode 100644 index 00000000..4fd84e6a --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/batches/retrieve.java b/official/docs/java/v6/batches/retrieve.java new file mode 100644 index 00000000..17417467 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Batch batch = client.batch.retrieve("batch_..."); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v6/batches/scan-forms.java b/official/docs/java/v6/batches/scan-forms.java new file mode 100644 index 00000000..03875e79 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Batch batch = client.batch.createScanForm("batch_..."); + + System.out.println(batch); + } +} diff --git a/official/docs/java/v6/billing/create-ep-credit-card.java b/official/docs/java/v6/billing/create-ep-credit-card.java new file mode 100644 index 00000000..5885f223 --- /dev/null +++ b/official/docs/java/v6/billing/create-ep-credit-card.java @@ -0,0 +1,17 @@ +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(System.getenv("EASYPOST_API_KEY")); + + String referralUserApiKey = System.getenv("REFERRAL_USER_API_KEY"); + + PaymentMethodObject creditCard = client.referralCustomer.addCreditCardToUser(referralUserApiKey, + "0123456789101234", 01, 2025, "111", PaymentMethod.Priority.PRIMARY); + + System.out.println(referralUser); + } +} diff --git a/official/docs/java/v6/billing/delete.java b/official/docs/java/v6/billing/delete.java new file mode 100644 index 00000000..a68b9fc1 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.billing.deletePaymentMethod(PaymentMethod.Priority.PRIMARY); + } +} diff --git a/official/docs/java/v6/billing/fund.java b/official/docs/java/v6/billing/fund.java new file mode 100644 index 00000000..a9730feb --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.billing.fundWallet("2000", PaymentMethod.Priority.PRIMARY); + } +} diff --git a/official/docs/java/v6/billing/list.java b/official/docs/java/v6/billing/list.java new file mode 100644 index 00000000..85953057 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + PaymentMethod paymentMethods = client.billing.retrievePaymentMethods(); + + System.out.println(paymentMethods); + } +} diff --git a/official/docs/java/v6/brand/update.java b/official/docs/java/v6/brand/update.java new file mode 100644 index 00000000..4d11da05 --- /dev/null +++ b/official/docs/java/v6/brand/update.java @@ -0,0 +1,23 @@ +package brand; + +import com.easypost.exception.EasyPostException; +import com.easypost.model.Brand; +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(System.getenv("EASYPOST_API_KEY")); + + User user = User.retrieveMe(); + + HashMap params = new HashMap<>(); + params.put("color", "303F9F"); + + Brand brand = client.user.updateBrand(user.getId(), params); + + System.out.println(brand); + } +} diff --git a/official/docs/java/current/carbon-offset/buy.java b/official/docs/java/v6/carbon-offset/buy.java similarity index 100% rename from official/docs/java/current/carbon-offset/buy.java rename to official/docs/java/v6/carbon-offset/buy.java diff --git a/official/docs/java/current/carbon-offset/create.java b/official/docs/java/v6/carbon-offset/create.java similarity index 100% rename from official/docs/java/current/carbon-offset/create.java rename to official/docs/java/v6/carbon-offset/create.java diff --git a/official/docs/java/current/carbon-offset/one-call-buy.java b/official/docs/java/v6/carbon-offset/one-call-buy.java similarity index 100% rename from official/docs/java/current/carbon-offset/one-call-buy.java rename to official/docs/java/v6/carbon-offset/one-call-buy.java diff --git a/official/docs/java/v6/carrier-accounts/create.java b/official/docs/java/v6/carrier-accounts/create.java new file mode 100644 index 00000000..244e50c9 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/carrier-accounts/delete.java b/official/docs/java/v6/carrier-accounts/delete.java new file mode 100644 index 00000000..06856ed3 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.carrierAccount.delete("ca_..."); + } +} diff --git a/official/docs/java/v6/carrier-accounts/list.java b/official/docs/java/v6/carrier-accounts/list.java new file mode 100644 index 00000000..65305406 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + List carrierAccounts = client.carrierAccount.all(); + + System.out.println(carrierAccounts); + } +} diff --git a/official/docs/java/v6/carrier-accounts/retrieve.java b/official/docs/java/v6/carrier-accounts/retrieve.java new file mode 100644 index 00000000..3088ff07 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + CarrierAccount carrierAccount = client.carrierAccount.retrieve("ca_..."); + + System.out.println(carrierAccount); + } +} diff --git a/official/docs/java/v6/carrier-accounts/update.java b/official/docs/java/v6/carrier-accounts/update.java new file mode 100644 index 00000000..116b4d47 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/carrier-metadata/retrieve.java b/official/docs/java/v6/carrier-metadata/retrieve.java new file mode 100644 index 00000000..036a09b2 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/carrier-types/list.java b/official/docs/java/v6/carrier-types/list.java new file mode 100644 index 00000000..ffdd95b5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + List carrierTypes = client.carrierType.all(); + + System.out.println(carrierTypes); + } +} diff --git a/official/docs/java/v6/child-users/create.java b/official/docs/java/v6/child-users/create.java new file mode 100644 index 00000000..de6ed344 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/child-users/delete.java b/official/docs/java/v6/child-users/delete.java new file mode 100644 index 00000000..64ecc3b2 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.user.delete("user_..."); + } +} diff --git a/official/docs/java/v6/customs-infos/create.java b/official/docs/java/v6/customs-infos/create.java new file mode 100644 index 00000000..1f0e864e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/customs-infos/retrieve.java b/official/docs/java/v6/customs-infos/retrieve.java new file mode 100644 index 00000000..5f340300 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + CustomsInfo customsInfo = client.customsInfo.retrieve("cstinfo_..."); + + System.out.println(customsInfo); + } +} diff --git a/official/docs/java/v6/customs-items/create.java b/official/docs/java/v6/customs-items/create.java new file mode 100644 index 00000000..4641a6f5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/customs-items/retrieve.java b/official/docs/java/v6/customs-items/retrieve.java new file mode 100644 index 00000000..a8d4263f --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + CustomsItem customsItem = client.customsItem.retrieve("cstitem_..."); + + System.out.println(customsItem); + } +} diff --git a/official/docs/java/v6/endshipper/buy.java b/official/docs/java/v6/endshipper/buy.java new file mode 100644 index 00000000..032e4a33 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/endshipper/create.java b/official/docs/java/v6/endshipper/create.java new file mode 100644 index 00000000..fa7261d9 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/endshipper/list.java b/official/docs/java/v6/endshipper/list.java new file mode 100644 index 00000000..039bc6e3 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/endshipper/retrieve.java b/official/docs/java/v6/endshipper/retrieve.java new file mode 100644 index 00000000..7573e37a --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + EndShipper endShipper = client.endShipper.retrieve("es_..."); + + System.out.println(endShipper); + } +} diff --git a/official/docs/java/v6/endshipper/update.java b/official/docs/java/v6/endshipper/update.java new file mode 100644 index 00000000..34e9e47d --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/events/list.java b/official/docs/java/v6/events/list.java new file mode 100644 index 00000000..3b2f700e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/events/retrieve.java b/official/docs/java/v6/events/retrieve.java new file mode 100644 index 00000000..d9bf1928 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Event event = client.event.retrieve("evt_..."); + + System.out.println(event); + } +} diff --git a/official/docs/java/v6/forms/create.java b/official/docs/java/v6/forms/create.java new file mode 100644 index 00000000..1cc99192 --- /dev/null +++ b/official/docs/java/v6/forms/create.java @@ -0,0 +1,37 @@ +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(System.getenv("EASYPOST_API_KEY")); + + Shipment shipment = client.shipment.retrieve("shp_..."); + Shipment boughtShipment = client.shipment.buy(shipment.getId(), shipment.lowestRate()); + + 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 shipmentWithForm = client.shipment.generateForm(boughtShipment.getId(), "return_packing_slip", + params); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v6/insurance/create.java b/official/docs/java/v6/insurance/create.java new file mode 100644 index 00000000..ebd5e08a --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/insurance/list.java b/official/docs/java/v6/insurance/list.java new file mode 100644 index 00000000..e45e26fb --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/insurance/retrieve.java b/official/docs/java/v6/insurance/retrieve.java new file mode 100644 index 00000000..501e7055 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Insurance insurance = client.insurance.retrieve("ins_..."); + + System.out.println(insurance); + } +} diff --git a/official/docs/java/v6/options/create-with-options.java b/official/docs/java/v6/options/create-with-options.java new file mode 100644 index 00000000..54fe0dac --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/orders/buy.java b/official/docs/java/v6/orders/buy.java new file mode 100644 index 00000000..47b441d9 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/orders/create.java b/official/docs/java/v6/orders/create.java new file mode 100644 index 00000000..00ecef86 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/orders/one-call-buy.java b/official/docs/java/v6/orders/one-call-buy.java new file mode 100644 index 00000000..c26de934 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/orders/retrieve.java b/official/docs/java/v6/orders/retrieve.java new file mode 100644 index 00000000..8ce37495 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Order order = client.order.retrieve("order_..."); + + System.out.println(order); + } +} diff --git a/official/docs/java/v6/pagination/get-next-page.java b/official/docs/java/v6/pagination/get-next-page.java new file mode 100644 index 00000000..2d91a0a5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/parcels/create.java b/official/docs/java/v6/parcels/create.java new file mode 100644 index 00000000..b736aaf5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/parcels/retrieve.java b/official/docs/java/v6/parcels/retrieve.java new file mode 100644 index 00000000..52c51d33 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Parcel parcel = client.parcel.retrieve("prcl_..."); + + System.out.println(parcel); + } +} diff --git a/official/docs/java/v6/payloads/list.java b/official/docs/java/v6/payloads/list.java new file mode 100644 index 00000000..7f301a0b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + List payloads = client.event.retrieveAllPayloads("evt_..."); + + System.out.println(payloads); + } +} diff --git a/official/docs/java/v6/payloads/retrieve.java b/official/docs/java/v6/payloads/retrieve.java new file mode 100644 index 00000000..9b7ebcb1 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Payload payload = client.event.retrievePayload("evt_...", "payload_..."); + + System.out.println(payload); + } +} diff --git a/official/docs/java/v6/pickups/buy.java b/official/docs/java/v6/pickups/buy.java new file mode 100644 index 00000000..106a3aab --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/pickups/cancel.java b/official/docs/java/v6/pickups/cancel.java new file mode 100644 index 00000000..41109c33 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Pickup pickup = client.pickup.cancel("pickup_..."); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v6/pickups/create.java b/official/docs/java/v6/pickups/create.java new file mode 100644 index 00000000..aee7e550 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/pickups/list.java b/official/docs/java/v6/pickups/list.java new file mode 100644 index 00000000..7f20838a --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/pickups/retrieve.java b/official/docs/java/v6/pickups/retrieve.java new file mode 100644 index 00000000..58cb6233 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Pickup pickup = client.pickup.retrieve("pickup_..."); + + System.out.println(pickup); + } +} diff --git a/official/docs/java/v6/rates/regenerate.java b/official/docs/java/v6/rates/regenerate.java new file mode 100644 index 00000000..2a783535 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Shipment shipment = client.shipment.newRates("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v6/rates/retrieve-stateless.java b/official/docs/java/v6/rates/retrieve-stateless.java new file mode 100644 index 00000000..bd0bed2e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/rates/retrieve.java b/official/docs/java/v6/rates/retrieve.java new file mode 100644 index 00000000..c3806b44 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Rate rate = client.rate.retrieve("rate_..."); + + System.out.println(rate); + } +} diff --git a/official/docs/java/v6/referral-customers/add-payment-method-with-bank-account.java b/official/docs/java/v6/referral-customers/add-payment-method-with-bank-account.java new file mode 100644 index 00000000..1d086d73 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + PaymentMethodObject paymentMethod = client.betaReferralCustomer.addPaymentMethod("cus_...", "ba_..."); + + System.out.println(paymentMethod); + } +} diff --git a/official/docs/java/v6/referral-customers/add-payment-method-with-credit-card.java b/official/docs/java/v6/referral-customers/add-payment-method-with-credit-card.java new file mode 100644 index 00000000..988db38f --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + PaymentMethodObject paymentMethod = client.betaReferralCustomer.addPaymentMethod("cus_...", "card_..."); + + System.out.println(paymentMethod); + } +} diff --git a/official/docs/java/v6/referral-customers/create.java b/official/docs/java/v6/referral-customers/create.java new file mode 100644 index 00000000..3f417b0f --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/referral-customers/list.java b/official/docs/java/v6/referral-customers/list.java new file mode 100644 index 00000000..c7427c2b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/referral-customers/refund-by-amount.java b/official/docs/java/v6/referral-customers/refund-by-amount.java new file mode 100644 index 00000000..f0b303cd --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + BetaPaymentRefund refund = client.betaReferralCustomer.refundByAmount(2000); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v6/referral-customers/refund-by-payment-log.java b/official/docs/java/v6/referral-customers/refund-by-payment-log.java new file mode 100644 index 00000000..f0b303cd --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + BetaPaymentRefund refund = client.betaReferralCustomer.refundByAmount(2000); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v6/referral-customers/update.java b/official/docs/java/v6/referral-customers/update.java new file mode 100644 index 00000000..ef78faf9 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.referralCustomer.updateEmail("new_email@example.com", "user_..."); + } +} diff --git a/official/docs/java/v6/refunds/create.java b/official/docs/java/v6/refunds/create.java new file mode 100644 index 00000000..88878800 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/refunds/list.java b/official/docs/java/v6/refunds/list.java new file mode 100644 index 00000000..36e6048b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/refunds/retrieve.java b/official/docs/java/v6/refunds/retrieve.java new file mode 100644 index 00000000..455d1d93 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Refund refund = client.refund.retrieve("rfnd_..."); + + System.out.println(refund); + } +} diff --git a/official/docs/java/v6/reports/create.java b/official/docs/java/v6/reports/create.java new file mode 100644 index 00000000..adce26d9 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/reports/list.java b/official/docs/java/v6/reports/list.java new file mode 100644 index 00000000..2cd0d79e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/reports/retrieve.java b/official/docs/java/v6/reports/retrieve.java new file mode 100644 index 00000000..4f1d08dd --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Report report = client.report.retrieve(""); + + System.out.println(report); + } +} diff --git a/official/docs/java/v6/returns/create.java b/official/docs/java/v6/returns/create.java new file mode 100644 index 00000000..28dc2aa6 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/scan-form/create.java b/official/docs/java/v6/scan-form/create.java new file mode 100644 index 00000000..dd7409d5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/scan-form/list.java b/official/docs/java/v6/scan-form/list.java new file mode 100644 index 00000000..c4da6cdc --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/scan-form/retrieve.java b/official/docs/java/v6/scan-form/retrieve.java new file mode 100644 index 00000000..8c33ba7f --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + ScanForm scanForm = client.scanform.retrieve("sf_..."); + + System.out.println(scanForm); + } +} diff --git a/official/docs/java/v6/shipments/buy.java b/official/docs/java/v6/shipments/buy.java new file mode 100644 index 00000000..92b9c25e --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Shipment shipment = client.shipment.retrieve("shp_..."); + + HashMap params = new HashMap(); + params.put("rate", shipment.lowestRate()); + params.put("insurance", "249.99"); + + Shipment boughtShipment = client.shipment.buy(shipment.getId(), params); + + System.out.println(boughtShipment); + } +} diff --git a/official/docs/java/v6/shipments/create.java b/official/docs/java/v6/shipments/create.java new file mode 100644 index 00000000..ce1c2334 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/shipments/label.java b/official/docs/java/v6/shipments/label.java new file mode 100644 index 00000000..68579696 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/shipments/list.java b/official/docs/java/v6/shipments/list.java new file mode 100644 index 00000000..e2a9eacf --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/shipments/one-call-buy.java b/official/docs/java/v6/shipments/one-call-buy.java new file mode 100644 index 00000000..3bf4e3c0 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/shipments/retrieve.java b/official/docs/java/v6/shipments/retrieve.java new file mode 100644 index 00000000..445cae7d --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Shipment shipment = client.shipment.retrieve("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v6/shipping-insurance/insure.java b/official/docs/java/v6/shipping-insurance/insure.java new file mode 100644 index 00000000..45ba936f --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/shipping-refund/refund.java b/official/docs/java/v6/shipping-refund/refund.java new file mode 100644 index 00000000..14207b32 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Shipment shipment = client.shipment.refund("shp_..."); + + System.out.println(shipment); + } +} diff --git a/official/docs/java/v6/smartrate/retrieve-estimated-delivery-date.java b/official/docs/java/v6/smartrate/retrieve-estimated-delivery-date.java new file mode 100644 index 00000000..ed268e1b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/smartrate/retrieve-time-in-transit-statistics.java b/official/docs/java/v6/smartrate/retrieve-time-in-transit-statistics.java new file mode 100644 index 00000000..5a54f52d --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + List smartrates = client.shipment.smartrates("shp_..."); + + System.out.println(smartrates); + } +} diff --git a/official/docs/java/v6/tax-identifiers/create.java b/official/docs/java/v6/tax-identifiers/create.java new file mode 100644 index 00000000..cf05112d --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/trackers/create.java b/official/docs/java/v6/trackers/create.java new file mode 100644 index 00000000..253bf2f6 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/trackers/list.java b/official/docs/java/v6/trackers/list.java new file mode 100644 index 00000000..67862868 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/trackers/retrieve.java b/official/docs/java/v6/trackers/retrieve.java new file mode 100644 index 00000000..4a803b9d --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Tracker tracker = client.tracker.retrieve("trk_..."); + + System.out.println(tracker); + } +} diff --git a/official/docs/java/v6/users/retrieve.java b/official/docs/java/v6/users/retrieve.java new file mode 100644 index 00000000..bbd4aaaf --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/users/update.java b/official/docs/java/v6/users/update.java new file mode 100644 index 00000000..d2f7ecb5 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("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/v6/webhooks/create.java b/official/docs/java/v6/webhooks/create.java new file mode 100644 index 00000000..deaa66b2 --- /dev/null +++ b/official/docs/java/v6/webhooks/create.java @@ -0,0 +1,20 @@ +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(System.getenv("EASYPOST_API_KEY")); + + HashMap params = new HashMap(); + params.put("url", "example.com"); + + Webhook webhook = client.webhook.create(params); + + System.out.println(webhook); + } +} diff --git a/official/docs/java/v6/webhooks/delete.java b/official/docs/java/v6/webhooks/delete.java new file mode 100644 index 00000000..2e15e0d3 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + client.webhook.delete("hook_..."); + } +} diff --git a/official/docs/java/v6/webhooks/list.java b/official/docs/java/v6/webhooks/list.java new file mode 100644 index 00000000..a4acaf7b --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + WebhookCollection webhooks = client.webhook.all(); + + System.out.println(webhooks); + } +} diff --git a/official/docs/java/v6/webhooks/retrieve.java b/official/docs/java/v6/webhooks/retrieve.java new file mode 100644 index 00000000..bd5441d4 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Webhook webhook = client.webhook.retrieve("hook_..."); + + System.out.println(webhook); + } +} diff --git a/official/docs/java/v6/webhooks/update.java b/official/docs/java/v6/webhooks/update.java new file mode 100644 index 00000000..6a605d60 --- /dev/null +++ b/official/docs/java/v6/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(System.getenv("EASYPOST_API_KEY")); + + Webhook webhook = client.webhook.update("hook_..."); + + System.out.println(webhook); + } +} diff --git a/official/docs/node/v6/addresses/create-and-verify.js b/official/docs/node/v6/addresses/create-and-verify.js new file mode 100644 index 00000000..6b611fd3 --- /dev/null +++ b/official/docs/node/v6/addresses/create-and-verify.js @@ -0,0 +1,18 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.createAndVerify({ + street1: '417 montgomery street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + console.log(address); +})(); diff --git a/official/docs/node/v6/addresses/create.js b/official/docs/node/v6/addresses/create.js new file mode 100644 index 00000000..0a0dcc41 --- /dev/null +++ b/official/docs/node/v6/addresses/create.js @@ -0,0 +1,18 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.create({ + street1: '417 MONTGOMERY ST', + street2: 'FLOOR 5', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + console.log(address); +})(); diff --git a/official/docs/node/v6/addresses/list.js b/official/docs/node/v6/addresses/list.js new file mode 100644 index 00000000..9a707eee --- /dev/null +++ b/official/docs/node/v6/addresses/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const addresses = await client.Address.all({ + page_size: 5, + }); + + console.log(addresses); +})(); diff --git a/official/docs/node/v6/addresses/retrieve.js b/official/docs/node/v6/addresses/retrieve.js new file mode 100644 index 00000000..46272a5e --- /dev/null +++ b/official/docs/node/v6/addresses/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const retrievedAddress = await client.Address.retrieve('adr_...'); + + console.log(retrievedAddress); +})(); diff --git a/official/docs/node/v6/addresses/verify-failure.js b/official/docs/node/v6/addresses/verify-failure.js new file mode 100644 index 00000000..322989d2 --- /dev/null +++ b/official/docs/node/v6/addresses/verify-failure.js @@ -0,0 +1,17 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.create({ + street1: 'UNDELIVERABLE ST', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + console.log(address); +})(); diff --git a/official/docs/node/v6/addresses/verify-param.js b/official/docs/node/v6/addresses/verify-param.js new file mode 100644 index 00000000..4457f8dd --- /dev/null +++ b/official/docs/node/v6/addresses/verify-param.js @@ -0,0 +1,19 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.create({ + verify: true, + street1: '417 Montgomery Street', + street2: '5', + city: 'SF', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + console.log(address); +})(); diff --git a/official/docs/node/v6/addresses/verify-strict-param.js b/official/docs/node/v6/addresses/verify-strict-param.js new file mode 100644 index 00000000..43cbbf45 --- /dev/null +++ b/official/docs/node/v6/addresses/verify-strict-param.js @@ -0,0 +1,19 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.create({ + verify_strict: true, + street1: '417 MONTGOMERY ST', + street2: 'FLOOR 5', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + console.log(address); +})(); diff --git a/official/docs/node/v6/addresses/verify.js b/official/docs/node/v6/addresses/verify.js new file mode 100644 index 00000000..2f9abb08 --- /dev/null +++ b/official/docs/node/v6/addresses/verify.js @@ -0,0 +1,19 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const address = await client.Address.create({ + street1: '417 montgomery streat', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }); + + const verifiedAddress = await client.Address.verifyAddress(address.id); + + console.log(verifiedAddress); +})(); diff --git a/official/docs/node/v6/api-keys/retrieve.js b/official/docs/node/v6/api-keys/retrieve.js new file mode 100644 index 00000000..912639cf --- /dev/null +++ b/official/docs/node/v6/api-keys/retrieve.js @@ -0,0 +1,15 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + // Retrieve all API keys including children + let apiKeys = await client.ApiKey.all(); + + console.log(apiKeys); + + // Retrieve API keys for a specific child user + let childApiKeys = await client.ApiKey.retrieveApiKeysForUser('user_...'); + + console.log(childApiKeys); +})(); diff --git a/official/docs/node/v6/batches/add-shipments.js b/official/docs/node/v6/batches/add-shipments.js new file mode 100644 index 00000000..cc07a24f --- /dev/null +++ b/official/docs/node/v6/batches/add-shipments.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + const batchWithShipments = await client.Batch.addShipments(batch.id, ['shp_...', 'shp_...']); + + console.log(batchWithShipments); +})(); diff --git a/official/docs/node/v6/batches/buy.js b/official/docs/node/v6/batches/buy.js new file mode 100644 index 00000000..2e04eb71 --- /dev/null +++ b/official/docs/node/v6/batches/buy.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + const boughtBatch = await client.Batch.buy(batch.id); + + console.log(boughtBatch); +})(); diff --git a/official/docs/node/v6/batches/create.js b/official/docs/node/v6/batches/create.js new file mode 100644 index 00000000..9609c2eb --- /dev/null +++ b/official/docs/node/v6/batches/create.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.create({ + shipments: [{ id: 'shp_...' }, { id: 'shp_...' }], + }); + + console.log(batch); +})(); diff --git a/official/docs/node/v6/batches/label.js b/official/docs/node/v6/batches/label.js new file mode 100644 index 00000000..4a513bca --- /dev/null +++ b/official/docs/node/v6/batches/label.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + const batchWithLabel = await client.Batch.generateLabel(batch.id, 'PDF'); + + console.log(batchWithLabel); +})(); diff --git a/official/docs/node/v6/batches/list.js b/official/docs/node/v6/batches/list.js new file mode 100644 index 00000000..bbae0784 --- /dev/null +++ b/official/docs/node/v6/batches/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batches = await client.Batch.all({ page_size: 5 }); + + console.log(batches); +})(); diff --git a/official/docs/node/v6/batches/remove-shipments.js b/official/docs/node/v6/batches/remove-shipments.js new file mode 100644 index 00000000..616c3412 --- /dev/null +++ b/official/docs/node/v6/batches/remove-shipments.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + const batchWithoutShipments = await client.Batch.removeShipments(batch.id, ['shp_...']); + + console.log(batchWithoutShipments); +})(); diff --git a/official/docs/node/v6/batches/retrieve.js b/official/docs/node/v6/batches/retrieve.js new file mode 100644 index 00000000..7bf1e0cf --- /dev/null +++ b/official/docs/node/v6/batches/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + console.log(batch); +})(); diff --git a/official/docs/node/v6/batches/scan-forms.js b/official/docs/node/v6/batches/scan-forms.js new file mode 100644 index 00000000..3eeb6d61 --- /dev/null +++ b/official/docs/node/v6/batches/scan-forms.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const batch = await client.Batch.retrieve('batch_...'); + + const batchWithScanForm = await client.Batch.createScanForm(batch.id); + + console.log(batchWithScanForm); +})(); diff --git a/official/docs/node/v6/billing/create-ep-credit-card.js b/official/docs/node/v6/billing/create-ep-credit-card.js new file mode 100644 index 00000000..11644570 --- /dev/null +++ b/official/docs/node/v6/billing/create-ep-credit-card.js @@ -0,0 +1,16 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); +const referralUserApiKey = process.env.REFERRAL_USER_API_KEY; + +(async () => { + const creditCard = await client.Referral.addCreditCard( + referralUserApiKey, + '0123456789101234', + '01', + '2025', + '111', + ); + + console.log(creditCard); +})(); diff --git a/official/docs/node/v6/billing/delete.js b/official/docs/node/v6/billing/delete.js new file mode 100644 index 00000000..d4737ea0 --- /dev/null +++ b/official/docs/node/v6/billing/delete.js @@ -0,0 +1,7 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + await client.Billing.deletePaymentMethod('primary'); +})(); diff --git a/official/docs/node/v6/billing/fund.js b/official/docs/node/v6/billing/fund.js new file mode 100644 index 00000000..a22fb640 --- /dev/null +++ b/official/docs/node/v6/billing/fund.js @@ -0,0 +1,7 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + await client.Billing.fund('2000', 'primary'); +})(); diff --git a/official/docs/node/v6/billing/list.js b/official/docs/node/v6/billing/list.js new file mode 100644 index 00000000..dff62610 --- /dev/null +++ b/official/docs/node/v6/billing/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const paymentMethods = await client.Billing.all(); + + console.log(paymentMethods); +})(); diff --git a/official/docs/node/v6/brand/update.js b/official/docs/node/v6/brand/update.js new file mode 100644 index 00000000..4fe3e0dc --- /dev/null +++ b/official/docs/node/v6/brand/update.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const user = await client.User.retrieveMe(); + + const brand = await client.User.updateBrand(user.id, { color: '#303F9F' }); + + console.log(brand); +})(); diff --git a/official/docs/node/current/carbon-offset/buy.js b/official/docs/node/v6/carbon-offset/buy.js similarity index 100% rename from official/docs/node/current/carbon-offset/buy.js rename to official/docs/node/v6/carbon-offset/buy.js diff --git a/official/docs/node/current/carbon-offset/create.js b/official/docs/node/v6/carbon-offset/create.js similarity index 100% rename from official/docs/node/current/carbon-offset/create.js rename to official/docs/node/v6/carbon-offset/create.js diff --git a/official/docs/node/current/carbon-offset/one-call-buy.js b/official/docs/node/v6/carbon-offset/one-call-buy.js similarity index 100% rename from official/docs/node/current/carbon-offset/one-call-buy.js rename to official/docs/node/v6/carbon-offset/one-call-buy.js diff --git a/official/docs/node/v6/carrier-accounts/create.js b/official/docs/node/v6/carrier-accounts/create.js new file mode 100644 index 00000000..a95a87b5 --- /dev/null +++ b/official/docs/node/v6/carrier-accounts/create.js @@ -0,0 +1,24 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierAccount = await client.CarrierAccount.create({ + type: 'DhlEcsAccount', + description: 'CA Location DHL eCommerce Solutions Account', + credentials: { + client_id: '123456', + client_secret: '123abc', + distribution_center: 'USLAX1', + pickup_id: '123456', + }, + test_credentials: { + client_id: '123456', + client_secret: '123abc', + distribution_center: 'USLAX1', + pickup_id: '123456', + }, + }); + + console.log(carrierAccount); +})(); diff --git a/official/docs/node/v6/carrier-accounts/delete.js b/official/docs/node/v6/carrier-accounts/delete.js new file mode 100644 index 00000000..147997d7 --- /dev/null +++ b/official/docs/node/v6/carrier-accounts/delete.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierAccount = await client.CarrierAccount.retrieve('ca_...'); + + await client.CarrierAccount.delete(carrierAccount.id); +})(); diff --git a/official/docs/node/v6/carrier-accounts/list.js b/official/docs/node/v6/carrier-accounts/list.js new file mode 100644 index 00000000..7239c1a6 --- /dev/null +++ b/official/docs/node/v6/carrier-accounts/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierAccounts = await client.CarrierAccount.all(); + + console.log(carrierAccounts); +})(); diff --git a/official/docs/node/v6/carrier-accounts/retrieve.js b/official/docs/node/v6/carrier-accounts/retrieve.js new file mode 100644 index 00000000..be2c0290 --- /dev/null +++ b/official/docs/node/v6/carrier-accounts/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierAccount = await client.CarrierAccount.retrieve('ca_...'); + + console.log(carrierAccount); +})(); diff --git a/official/docs/node/v6/carrier-accounts/update.js b/official/docs/node/v6/carrier-accounts/update.js new file mode 100644 index 00000000..243abeca --- /dev/null +++ b/official/docs/node/v6/carrier-accounts/update.js @@ -0,0 +1,14 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierAccount = await client.CarrierAccount.retrieve('ca_...'); + + const updatedCarrierAccount = await client.CarrierAccount.update(carrierAccount.id, { + description: 'FL Location DHL eCommerce Solutions Account', + credentials: { pickup_id: 'abc123' }, + }); + + console.log(updatedCarrierAccount); +})(); diff --git a/official/docs/node/v6/carrier-metadata/retrieve.js b/official/docs/node/v6/carrier-metadata/retrieve.js new file mode 100644 index 00000000..3ab984f2 --- /dev/null +++ b/official/docs/node/v6/carrier-metadata/retrieve.js @@ -0,0 +1,16 @@ +const EasyPostBetaClient = require('@easypost/api'); + +const client = new EasyPostBetaClient(process.env.EASYPOST_API_KEY); + +(async () => { + // Request all metadata for all carriers + const carrierMetadata = await client.CarrierMetadata.retrieve(); + console.log(carrierMetadata); + + // Request specific metadata for specific carriers + const carrierMetadataWithFilters = await client.CarrierMetadata.retrieve( + ['usps'], + ['service_levels', 'predefined_packages'], + ); + console.log(carrierMetadataWithFilters); +})(); diff --git a/official/docs/node/v6/carrier-types/list.js b/official/docs/node/v6/carrier-types/list.js new file mode 100644 index 00000000..8429e4df --- /dev/null +++ b/official/docs/node/v6/carrier-types/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const carrierTypes = await client.CarrierType.all(); + + console.log(carrierTypes); +})(); diff --git a/official/docs/node/v6/child-users/create.js b/official/docs/node/v6/child-users/create.js new file mode 100644 index 00000000..5cad77ad --- /dev/null +++ b/official/docs/node/v6/child-users/create.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const user = await client.User.create({ + name: 'Child Account Name', + }); + + console.log(user); +})(); diff --git a/official/docs/node/v6/child-users/delete.js b/official/docs/node/v6/child-users/delete.js new file mode 100644 index 00000000..546a7fd1 --- /dev/null +++ b/official/docs/node/v6/child-users/delete.js @@ -0,0 +1,7 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + await client.User.delete('user_...'); +})(); diff --git a/official/docs/node/v6/customs-infos/create.js b/official/docs/node/v6/customs-infos/create.js new file mode 100644 index 00000000..d65794b5 --- /dev/null +++ b/official/docs/node/v6/customs-infos/create.js @@ -0,0 +1,27 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const customsInfo = await client.CustomsInfo.create({ + eel_pfc: 'NOEEI 30.37(a)', + customs_certify: true, + customs_signer: 'Steve Brule', + contents_type: 'merchandise', + contents_explanation: '', + restriction_type: 'none', + restriction_comments: '', + customs_items: [ + { + description: 'T-shirts', + quantity: 1, + weight: 5, + value: 10, + hs_tariff_number: '123456', + origin_country: 'US', + }, + ], + }); + + console.log(customsInfo); +})(); diff --git a/official/docs/node/v6/customs-infos/retrieve.js b/official/docs/node/v6/customs-infos/retrieve.js new file mode 100644 index 00000000..426d0295 --- /dev/null +++ b/official/docs/node/v6/customs-infos/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const customsInfo = await client.CustomsInfo.retrieve('cstinfo_...'); + + console.log(customsInfo); +})(); diff --git a/official/docs/node/v6/customs-items/create.js b/official/docs/node/v6/customs-items/create.js new file mode 100644 index 00000000..966ad985 --- /dev/null +++ b/official/docs/node/v6/customs-items/create.js @@ -0,0 +1,16 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const customsItem = await client.CustomsItem.create({ + description: 'T-shirt', + quantity: 1, + value: 10, + weight: 5, + hs_tariff_number: '123456', + origin_country: 'us', + }); + + console.log(customsItem); +})(); diff --git a/official/docs/node/v6/customs-items/retrieve.js b/official/docs/node/v6/customs-items/retrieve.js new file mode 100644 index 00000000..338a0115 --- /dev/null +++ b/official/docs/node/v6/customs-items/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const customsItem = await client.CustomsItem.retrieve('cstitem_...'); + + console.log(customsItem); +})(); diff --git a/official/docs/node/v6/endshipper/buy.js b/official/docs/node/v6/endshipper/buy.js new file mode 100644 index 00000000..7d993fe5 --- /dev/null +++ b/official/docs/node/v6/endshipper/buy.js @@ -0,0 +1,17 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const shipmentWithEndShipperId = await client.Shipment.buy( + shipment.id, + shipment.lowestRate(), + null, + false, + 'es_...', + ); + + console.log(shipmentWithEndShipperId); +})(); diff --git a/official/docs/node/v6/endshipper/create.js b/official/docs/node/v6/endshipper/create.js new file mode 100644 index 00000000..cd8b9830 --- /dev/null +++ b/official/docs/node/v6/endshipper/create.js @@ -0,0 +1,19 @@ +const EasyPostClient = require('@easypost/api'); +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const endShipper = await client.EndShipper.create({ + name: 'FOO BAR', + company: 'BAZ', + street1: '164 TOWNSEND STREET UNIT 1', + street2: 'UNIT 1', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94107', + country: 'US', + phone: '555-555-5555', + email: 'FOO@EXAMPLE.COM', + }); + + console.log(endShipper); +})(); diff --git a/official/docs/node/v6/endshipper/list.js b/official/docs/node/v6/endshipper/list.js new file mode 100644 index 00000000..90e518b0 --- /dev/null +++ b/official/docs/node/v6/endshipper/list.js @@ -0,0 +1,10 @@ +const EasyPostClient = require('@easypost/api'); +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const endShippers = await client.EndShipper.all({ + page_size: 5, + }); + + console.log(endShippers); +})(); diff --git a/official/docs/node/v6/endshipper/retrieve.js b/official/docs/node/v6/endshipper/retrieve.js new file mode 100644 index 00000000..aa2f3d3d --- /dev/null +++ b/official/docs/node/v6/endshipper/retrieve.js @@ -0,0 +1,8 @@ +const EasyPostClient = require('@easypost/api'); +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const endShipper = await client.EndShipper.retrieve('es_...'); + + console.log(endShipper); +})(); diff --git a/official/docs/node/v6/endshipper/update.js b/official/docs/node/v6/endshipper/update.js new file mode 100644 index 00000000..3723724a --- /dev/null +++ b/official/docs/node/v6/endshipper/update.js @@ -0,0 +1,21 @@ +const EasyPostClient = require('@easypost/api'); +const client = new EasyPostClient(''); + +(async () => { + const endShipper = await client.EndShipper.retrieve('es_...'); + + const updatedEndShipper = await client.EndShipper.update(endShipper.id, { + name: 'NEW NAME', + company: 'BAZ', + street1: '164 TOWNSEND STREET UNIT 1', + street2: 'UNIT 1', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94107', + country: 'US', + phone: '555-555-5555', + email: 'FOO@EXAMPLE.COM', + }); + + console.log(updatedEndShipper); +})(); diff --git a/official/docs/node/v6/events/list.js b/official/docs/node/v6/events/list.js new file mode 100644 index 00000000..ee00bdb3 --- /dev/null +++ b/official/docs/node/v6/events/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const events = await client.Event.all({ + page_size: 5, + }); + + console.log(events); +})(); diff --git a/official/docs/node/v6/events/retrieve.js b/official/docs/node/v6/events/retrieve.js new file mode 100644 index 00000000..68f4a397 --- /dev/null +++ b/official/docs/node/v6/events/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const event = await client.Event.retrieve('evt_...'); + + console.log(event); +})(); diff --git a/official/docs/node/v6/forms/create.js b/official/docs/node/v6/forms/create.js new file mode 100644 index 00000000..8d998de0 --- /dev/null +++ b/official/docs/node/v6/forms/create.js @@ -0,0 +1,22 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const shipmentWithForm = shipment.generateForm(shipment.id, 'return_packing_slip', { + barcode: 'RMA12345678900', + line_items: [ + { + product: { + title: 'Square Reader', + barcode: '855658003251', + }, + units: '8', + }, + ], + }); + + console.log(shipmentWithForm); +})(); diff --git a/official/docs/node/v6/insurance/create.js b/official/docs/node/v6/insurance/create.js new file mode 100644 index 00000000..7c300fd2 --- /dev/null +++ b/official/docs/node/v6/insurance/create.js @@ -0,0 +1,16 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const insurance = await client.Insurance.create({ + to_address: { id: 'adr_...' }, + from_address: { id: 'adr_...' }, + tracking_code: '9400110898825022579493', + carrier: 'USPS', + amount: '100.00', + reference: 'insuranceRef1', + }); + + console.log(insurance); +})(); diff --git a/official/docs/node/v6/insurance/list.js b/official/docs/node/v6/insurance/list.js new file mode 100644 index 00000000..9c172c07 --- /dev/null +++ b/official/docs/node/v6/insurance/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const insurances = await client.Insurance.all({ + page_size: 5, + }); + + console.log(insurances); +})(); diff --git a/official/docs/node/v6/insurance/retrieve.js b/official/docs/node/v6/insurance/retrieve.js new file mode 100644 index 00000000..e9150953 --- /dev/null +++ b/official/docs/node/v6/insurance/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const insurance = await client.Insurance.retrieve('ins_...'); + + console.logP(insurance); +})(); diff --git a/official/docs/node/v6/options/create-with-options.js b/official/docs/node/v6/options/create-with-options.js new file mode 100644 index 00000000..828a7995 --- /dev/null +++ b/official/docs/node/v6/options/create-with-options.js @@ -0,0 +1,16 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.create({ + parcel: { id: 'prcl_...' }, + to_address: { id: 'adr_...' }, + from_address: { id: 'adr_...' }, + options: { + print_custom_1: 'Custom label message', + }, + }); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/orders/buy.js b/official/docs/node/v6/orders/buy.js new file mode 100644 index 00000000..2ea191f2 --- /dev/null +++ b/official/docs/node/v6/orders/buy.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const order = await client.Order.retrieve('order_...'); + + const boughtOrder = await client.Order.buy(order.id, 'FedEx', 'FEDEX_GROUND'); + + console.log(boughtOrder); +})(); diff --git a/official/docs/node/v6/orders/create.js b/official/docs/node/v6/orders/create.js new file mode 100644 index 00000000..d6f370ba --- /dev/null +++ b/official/docs/node/v6/orders/create.js @@ -0,0 +1,25 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const order = await client.Order.create({ + to_address: { id: 'adr_...' }, + from_address: { id: 'adr_...' }, + shipments: [ + { + parcel: { + weight: 10.2, + }, + }, + { + parcel: { + predefined_package: 'FedExBox', + weight: 17.5, + }, + }, + ], + }); + + console.log(order); +})(); diff --git a/official/docs/node/v6/orders/one-call-buy.js b/official/docs/node/v6/orders/one-call-buy.js new file mode 100644 index 00000000..76a4f53f --- /dev/null +++ b/official/docs/node/v6/orders/one-call-buy.js @@ -0,0 +1,28 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const order = await client.Order.create({ + carrier_accounts: ['ca_...'], + service: 'NextDayAir', + to_address: 'adr_...', + from_address: 'adr_...', + shipments: [ + { + parcel: { + predefined_package: 'FedExBox', + weight: 10.2, + }, + }, + { + parcel: { + predefined_package: 'FedExBox', + weight: 17.5, + }, + }, + ], + }); + + console.log(order); +})(); diff --git a/official/docs/node/v6/orders/retrieve.js b/official/docs/node/v6/orders/retrieve.js new file mode 100644 index 00000000..55922c43 --- /dev/null +++ b/official/docs/node/v6/orders/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const order = await client.Order.retrieve('order_...'); + + console.log(order); +})(); diff --git a/official/docs/node/v6/pagination/get-next-page.js b/official/docs/node/v6/pagination/get-next-page.js new file mode 100644 index 00000000..76ad922b --- /dev/null +++ b/official/docs/node/v6/pagination/get-next-page.js @@ -0,0 +1,15 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + // Get first page of results + const shipments = await client.Shipment.all({ + page_size: 5, + }); + + // Provide the previous results page to move onto the next page + const nextPage = await client.Shipment.getNextPage(shipments); + + console.log(nextPage); +})(); diff --git a/official/docs/node/v6/parcels/create.js b/official/docs/node/v6/parcels/create.js new file mode 100644 index 00000000..116eef6e --- /dev/null +++ b/official/docs/node/v6/parcels/create.js @@ -0,0 +1,14 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const parcel = await client.Parcel.create({ + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }); + + console.log(parcel); +})(); diff --git a/official/docs/node/v6/parcels/retrieve.js b/official/docs/node/v6/parcels/retrieve.js new file mode 100644 index 00000000..381e0db6 --- /dev/null +++ b/official/docs/node/v6/parcels/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const parcel = await client.Parcel.retrieve('prcl_...'); + + console.log(parcel); +})(); diff --git a/official/docs/node/v6/payloads/list.js b/official/docs/node/v6/payloads/list.js new file mode 100644 index 00000000..b200ddb0 --- /dev/null +++ b/official/docs/node/v6/payloads/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const payloads = await client.Event.retrieveAllPayloads('evt_...'); + + console.log(payloads); +})(); diff --git a/official/docs/node/v6/payloads/retrieve.js b/official/docs/node/v6/payloads/retrieve.js new file mode 100644 index 00000000..7d13cbd8 --- /dev/null +++ b/official/docs/node/v6/payloads/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const payload = await client.Event.retrievePayload('evt_...', 'payload_...'); + + console.log(payload); +})(); diff --git a/official/docs/node/v6/pickups/buy.js b/official/docs/node/v6/pickups/buy.js new file mode 100644 index 00000000..4ef131fc --- /dev/null +++ b/official/docs/node/v6/pickups/buy.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const pickup = await client.Pickup.retrieve('pickup_...'); + + const boughtPickup = await client.Pickup.buy(pickup.id, 'UPS', 'Same-day Pickup'); + + console.log(boughtPickup); +})(); diff --git a/official/docs/node/v6/pickups/cancel.js b/official/docs/node/v6/pickups/cancel.js new file mode 100644 index 00000000..b0a4a99a --- /dev/null +++ b/official/docs/node/v6/pickups/cancel.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const pickup = await client.Pickup.retrieve('pickup_...'); + + const cancelledPickup = pickup.cancel(pickup.id); + + console.log(cancelledPickup); +})(); diff --git a/official/docs/node/v6/pickups/create.js b/official/docs/node/v6/pickups/create.js new file mode 100644 index 00000000..3d5a6022 --- /dev/null +++ b/official/docs/node/v6/pickups/create.js @@ -0,0 +1,17 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const pickup = await client.Pickup.create({ + address: { id: 'adr_...' }, + shipment: { id: 'shp_...' }, + reference: 'my-first-pickup', + min_datetime: '2022-10-01 10:30:00', + max_datetime: '2022-10-02 10:30:00', + is_account_address: false, + instructions: 'Special pickup instructions', + }); + + console.log(pickup); +})(); diff --git a/official/docs/node/v6/pickups/list.js b/official/docs/node/v6/pickups/list.js new file mode 100644 index 00000000..44d7da5c --- /dev/null +++ b/official/docs/node/v6/pickups/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const pickups = await client.Pickup.all({ + page_size: 5, + }); + + console.log(pickups); +})(); diff --git a/official/docs/node/v6/pickups/retrieve.js b/official/docs/node/v6/pickups/retrieve.js new file mode 100644 index 00000000..2e0ef576 --- /dev/null +++ b/official/docs/node/v6/pickups/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const pickup = await client.Pickup.retrieve('pickup_...'); + + console.log(pickup); +})(); diff --git a/official/docs/node/v6/rates/regenerate.js b/official/docs/node/v6/rates/regenerate.js new file mode 100644 index 00000000..a1ff8952 --- /dev/null +++ b/official/docs/node/v6/rates/regenerate.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const rates = await client.Shipment.regenerateRates(shipment.id); + + console.log(rates); +})(); diff --git a/official/docs/node/v6/rates/retrieve-stateless.js b/official/docs/node/v6/rates/retrieve-stateless.js new file mode 100644 index 00000000..a1c34283 --- /dev/null +++ b/official/docs/node/v6/rates/retrieve-stateless.js @@ -0,0 +1,38 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipmentDetails = { + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + email: 'dr_steve_brule@gmail.com', + phone: '4155559999', + }, + from_address: { + street1: '417 montgomery street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + }; + + const rates = await client.BetaRate.retrieveStatelessRates(shipmentDetails); + + console.log(rates); +})(); diff --git a/official/docs/node/v6/rates/retrieve.js b/official/docs/node/v6/rates/retrieve.js new file mode 100644 index 00000000..0d514200 --- /dev/null +++ b/official/docs/node/v6/rates/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const rate = await client.Rate.retrieve('rate...'); + + console.log(rate); +})(); diff --git a/official/docs/node/v6/referral-customers/add-payment-method-with-bank-account.js b/official/docs/node/v6/referral-customers/add-payment-method-with-bank-account.js new file mode 100644 index 00000000..07cb4c58 --- /dev/null +++ b/official/docs/node/v6/referral-customers/add-payment-method-with-bank-account.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const paymentMethod = await client.BetaReferralCustomer.addPaymentMethod('cus_...', 'ba_...'); + + console.log(paymentMethod); +})(); diff --git a/official/docs/node/v6/referral-customers/add-payment-method-with-credit-card.js b/official/docs/node/v6/referral-customers/add-payment-method-with-credit-card.js new file mode 100644 index 00000000..34063d70 --- /dev/null +++ b/official/docs/node/v6/referral-customers/add-payment-method-with-credit-card.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const paymentMethod = await client.BetaReferralCustomer.addPaymentMethod('cus_...', 'card_...'); + + console.log(paymentMethod); +})(); diff --git a/official/docs/node/v6/referral-customers/create.js b/official/docs/node/v6/referral-customers/create.js new file mode 100644 index 00000000..9d5203cd --- /dev/null +++ b/official/docs/node/v6/referral-customers/create.js @@ -0,0 +1,13 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const referralCustomer = await client.ReferralCustomer.create({ + name: 'Test Referral', + email: 'test@example.com', + phone: '1111111111', + }); + + console.log(referralCustomer); +})(); diff --git a/official/docs/node/v6/referral-customers/list.js b/official/docs/node/v6/referral-customers/list.js new file mode 100644 index 00000000..d2e32bc3 --- /dev/null +++ b/official/docs/node/v6/referral-customers/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const referralCustomers = await client.ReferralCustomer.all({ + page_size: 5, + }); + + console.log(referralCustomers); +})(); diff --git a/official/docs/node/v6/referral-customers/refund-by-amount.js b/official/docs/node/v6/referral-customers/refund-by-amount.js new file mode 100644 index 00000000..aa5a0e5f --- /dev/null +++ b/official/docs/node/v6/referral-customers/refund-by-amount.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const refund = await client.BetaReferralCustomer.refundByAmount(2000); + + console.log(refund); +})(); diff --git a/official/docs/node/v6/referral-customers/refund-by-payment-log.js b/official/docs/node/v6/referral-customers/refund-by-payment-log.js new file mode 100644 index 00000000..1bb9853c --- /dev/null +++ b/official/docs/node/v6/referral-customers/refund-by-payment-log.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const refund = await client.BetaReferralCustomer.refundByPaymentLog('paylog_...'); + + console.log(refund); +})(); diff --git a/official/docs/node/v6/referral-customers/update.js b/official/docs/node/v6/referral-customers/update.js new file mode 100644 index 00000000..531930f3 --- /dev/null +++ b/official/docs/node/v6/referral-customers/update.js @@ -0,0 +1,7 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + await client.ReferralCustomer.updateEmail('user_...', 'new_email@example.com'); +})(); diff --git a/official/docs/node/v6/refunds/create.js b/official/docs/node/v6/refunds/create.js new file mode 100644 index 00000000..dbf511b9 --- /dev/null +++ b/official/docs/node/v6/refunds/create.js @@ -0,0 +1,12 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const refund = await client.Refund.create({ + carrier: 'USPS', + tracking_codes: ['EZ1000000001'], + }); + + console.log(refund); +})(); diff --git a/official/docs/node/v6/refunds/list.js b/official/docs/node/v6/refunds/list.js new file mode 100644 index 00000000..b5269563 --- /dev/null +++ b/official/docs/node/v6/refunds/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const refunds = await client.Refund.all({ + page_size: 5, + }); + + console.log(refunds); +})(); diff --git a/official/docs/node/v6/refunds/retrieve.js b/official/docs/node/v6/refunds/retrieve.js new file mode 100644 index 00000000..f312de93 --- /dev/null +++ b/official/docs/node/v6/refunds/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const refund = await client.Refund.retrieve('rfnd_...'); + + console.log(refund); +})(); diff --git a/official/docs/node/v6/reports/create.js b/official/docs/node/v6/reports/create.js new file mode 100644 index 00000000..aa366fb5 --- /dev/null +++ b/official/docs/node/v6/reports/create.js @@ -0,0 +1,13 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const report = await client.Report.create({ + type: 'payment_log', + start_date: '2022-10-01', + end_date: '2022-10-31', + }); + + console.log(report); +})(); diff --git a/official/docs/node/v6/reports/list.js b/official/docs/node/v6/reports/list.js new file mode 100644 index 00000000..550dc61a --- /dev/null +++ b/official/docs/node/v6/reports/list.js @@ -0,0 +1,10 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + // Replace `payment_log` with any of the report types listed above + const reports = await client.Report.all('payment_log', { page_size: 5 }); + + console.log(reports); +})(); diff --git a/official/docs/node/v6/reports/retrieve.js b/official/docs/node/v6/reports/retrieve.js new file mode 100644 index 00000000..6bbe30cd --- /dev/null +++ b/official/docs/node/v6/reports/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const report = await client.Report.retrieve(''); + + console.log(report); +})(); diff --git a/official/docs/node/v6/returns/create.js b/official/docs/node/v6/returns/create.js new file mode 100644 index 00000000..783decae --- /dev/null +++ b/official/docs/node/v6/returns/create.js @@ -0,0 +1,14 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.create({ + parcel: { id: 'prcl_...' }, + to_address: { id: 'adr_...' }, + from_address: { id: 'adr_...' }, + is_return: true, + }); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/scan-form/create.js b/official/docs/node/v6/scan-form/create.js new file mode 100644 index 00000000..1b5de521 --- /dev/null +++ b/official/docs/node/v6/scan-form/create.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const scanForm = await client.ScanForm.create({ + shipments: [{ id: 'shp_...' }, { id: 'shp_...' }], + }); + + console.log(scanForm); +})(); diff --git a/official/docs/node/v6/scan-form/list.js b/official/docs/node/v6/scan-form/list.js new file mode 100644 index 00000000..3d29bd3d --- /dev/null +++ b/official/docs/node/v6/scan-form/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const scanForms = await client.ScanForm.all({ + page_size: 5, + }); + + console.log(scanForms); +})(); diff --git a/official/docs/node/v6/scan-form/retrieve.js b/official/docs/node/v6/scan-form/retrieve.js new file mode 100644 index 00000000..9141e543 --- /dev/null +++ b/official/docs/node/v6/scan-form/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const scanForm = await client.ScanForm.retrieve('sf_...'); + + console.log(scanForm); +})(); diff --git a/official/docs/node/v6/shipments/buy.js b/official/docs/node/v6/shipments/buy.js new file mode 100644 index 00000000..f76dcfd3 --- /dev/null +++ b/official/docs/node/v6/shipments/buy.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const boughtShipment = await client.Shipment.buy(shipment.id, shipment.lowestRate(), 249.99); + + console.log(boughtShipment); +})(); diff --git a/official/docs/node/v6/shipments/create.js b/official/docs/node/v6/shipments/create.js new file mode 100644 index 00000000..27be7c01 --- /dev/null +++ b/official/docs/node/v6/shipments/create.js @@ -0,0 +1,48 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + let shipment; + + shipment = await client.Shipment.create({ + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + email: 'dr_steve_brule@gmail.com', + phone: '4155559999', + }, + from_address: { + street1: '417 montgomery street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + customs_info: { id: 'cstinfo_...' }, + }); + + // or create by using IDs + + shipment = await client.Shipment.create({ + to_address: { id: 'adr_...' }, + from_address: { id: 'adr_...' }, + parcel: { id: 'prcl_...' }, + customs_info: { id: 'cstinfo_...' }, + }); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/shipments/label.js b/official/docs/node/v6/shipments/label.js new file mode 100644 index 00000000..4a14ca45 --- /dev/null +++ b/official/docs/node/v6/shipments/label.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const shipmentWithLabel = await client.Shipment.convertLabelFormat(shipment.id, 'ZPL'); + + console.log(shipmentWithLabel); +})(); diff --git a/official/docs/node/v6/shipments/list.js b/official/docs/node/v6/shipments/list.js new file mode 100644 index 00000000..18a8de7a --- /dev/null +++ b/official/docs/node/v6/shipments/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipments = await client.Shipment.all({ + page_size: 5, + }); + + console.log(shipments); +})(); diff --git a/official/docs/node/v6/shipments/one-call-buy.js b/official/docs/node/v6/shipments/one-call-buy.js new file mode 100644 index 00000000..de7399ff --- /dev/null +++ b/official/docs/node/v6/shipments/one-call-buy.js @@ -0,0 +1,38 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.create({ + carrier_accounts: ['ca_...'], + service: 'NextDayAir', + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + email: 'dr_steve_brule@gmail.com', + phone: '4155559999', + }, + from_address: { + street1: '417 montgomery street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + }); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/shipments/retrieve.js b/official/docs/node/v6/shipments/retrieve.js new file mode 100644 index 00000000..194acc5a --- /dev/null +++ b/official/docs/node/v6/shipments/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/shipping-insurance/insure.js b/official/docs/node/v6/shipping-insurance/insure.js new file mode 100644 index 00000000..9a2e0964 --- /dev/null +++ b/official/docs/node/v6/shipping-insurance/insure.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const insuredShipment = await client.Shipment.insure(shipment.id, 100); + + console.log(insuredShipment); +})(); diff --git a/official/docs/node/v6/shipping-refund/refund.js b/official/docs/node/v6/shipping-refund/refund.js new file mode 100644 index 00000000..15807b59 --- /dev/null +++ b/official/docs/node/v6/shipping-refund/refund.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const refundedShipment = await client.Shipment.refund(shipment.id); + + console.log(refundedShipment); +})(); diff --git a/official/docs/node/v6/smartrate/retrieve-estimated-delivery-date.js b/official/docs/node/v6/smartrate/retrieve-estimated-delivery-date.js new file mode 100644 index 00000000..c1694009 --- /dev/null +++ b/official/docs/node/v6/smartrate/retrieve-estimated-delivery-date.js @@ -0,0 +1,14 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const estimatedDeliveryDates = await client.Shipment.retrieveEstimatedDeliveryDate( + shipment.id, + 'YYYY-MM-DD', + ); + + console.log(estimatedDeliveryDates); +})(); diff --git a/official/docs/node/v6/smartrate/retrieve-time-in-transit-statistics.js b/official/docs/node/v6/smartrate/retrieve-time-in-transit-statistics.js new file mode 100644 index 00000000..11bdcd90 --- /dev/null +++ b/official/docs/node/v6/smartrate/retrieve-time-in-transit-statistics.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.retrieve('shp_...'); + + const smartRates = shipment.getSmartrates(shipment.id); + + console.log(smartRates); +})(); diff --git a/official/docs/node/v6/tax-identifiers/create.js b/official/docs/node/v6/tax-identifiers/create.js new file mode 100644 index 00000000..209c985f --- /dev/null +++ b/official/docs/node/v6/tax-identifiers/create.js @@ -0,0 +1,47 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const shipment = await client.Shipment.create({ + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + email: 'dr_steve_brule@gmail.com', + phone: '4155559999', + }, + from_address: { + street1: '417 montgomery street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', + }, + customs_info: { + id: 'cstinfo_...', + }, + tax_identifiers: [ + { + entity: 'SENDER', + tax_id: 'GB123456789', + tax_id_type: 'IOSS', + issuing_country: 'GB', + }, + ], + }); + + console.log(shipment); +})(); diff --git a/official/docs/node/v6/trackers/create.js b/official/docs/node/v6/trackers/create.js new file mode 100644 index 00000000..debffd07 --- /dev/null +++ b/official/docs/node/v6/trackers/create.js @@ -0,0 +1,12 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const tracker = await client.Tracker.create({ + tracking_code: 'EZ1000000001', + carrier: 'USPS', + }); + + console.log(tracker); +})(); diff --git a/official/docs/node/v6/trackers/list.js b/official/docs/node/v6/trackers/list.js new file mode 100644 index 00000000..e5fb5210 --- /dev/null +++ b/official/docs/node/v6/trackers/list.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const trackers = await client.Tracker.all({ + page_size: 5, + }); + + console.log(trackers); +})(); diff --git a/official/docs/node/v6/trackers/retrieve.js b/official/docs/node/v6/trackers/retrieve.js new file mode 100644 index 00000000..44c73d96 --- /dev/null +++ b/official/docs/node/v6/trackers/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const tracker = await client.Tracker.retrieve('trk_...'); + + console.log(tracker); +})(); diff --git a/official/docs/node/v6/users/retrieve.js b/official/docs/node/v6/users/retrieve.js new file mode 100644 index 00000000..7e8c897d --- /dev/null +++ b/official/docs/node/v6/users/retrieve.js @@ -0,0 +1,15 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + let user; + + // Retrieve the authenticated user + user = await client.User.retrieveMe(); + + // Retrieve a child user + user = await client.User.retrieve('user_...'); + + console.log(user); +})(); diff --git a/official/docs/node/v6/users/update.js b/official/docs/node/v6/users/update.js new file mode 100644 index 00000000..9e94e63e --- /dev/null +++ b/official/docs/node/v6/users/update.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const user = await client.User.retrieveMe(); + + const updatedUser = await client.User.update(user.id, { recharge_threshold: '50.00' }); + + console.log(updatedUser); +})(); diff --git a/official/docs/node/v6/webhooks/create.js b/official/docs/node/v6/webhooks/create.js new file mode 100644 index 00000000..97671855 --- /dev/null +++ b/official/docs/node/v6/webhooks/create.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const webhook = await client.Webhook.create({ url: 'example.com' }); + + console.log(webhook); +})(); diff --git a/official/docs/node/v6/webhooks/delete.js b/official/docs/node/v6/webhooks/delete.js new file mode 100644 index 00000000..55799f7d --- /dev/null +++ b/official/docs/node/v6/webhooks/delete.js @@ -0,0 +1,7 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + await client.Webhook.delete('hook_...'); +})(); diff --git a/official/docs/node/v6/webhooks/list.js b/official/docs/node/v6/webhooks/list.js new file mode 100644 index 00000000..71769fe2 --- /dev/null +++ b/official/docs/node/v6/webhooks/list.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const webhooks = await client.Webhook.all(); + + console.log(webhooks); +})(); diff --git a/official/docs/node/v6/webhooks/retrieve.js b/official/docs/node/v6/webhooks/retrieve.js new file mode 100644 index 00000000..eb72321e --- /dev/null +++ b/official/docs/node/v6/webhooks/retrieve.js @@ -0,0 +1,9 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const webhook = await client.Webhook.retrieve('hook_...'); + + console.log(webhook); +})(); diff --git a/official/docs/node/v6/webhooks/update.js b/official/docs/node/v6/webhooks/update.js new file mode 100644 index 00000000..08fd7eab --- /dev/null +++ b/official/docs/node/v6/webhooks/update.js @@ -0,0 +1,11 @@ +const EasyPostClient = require('@easypost/api'); + +const client = new EasyPostClient(process.env.EASYPOST_API_KEY); + +(async () => { + const webhook = await client.Webhook.retrieve('hook_...'); + + const updatedWebhook = await client.Webhook.update(webhook.id); + + console.log(updatedWebhook); +})(); diff --git a/official/docs/php/current/referral-customers/update.php b/official/docs/php/current/referral-customers/update.php index 432a36ad..6a23d367 100644 --- a/official/docs/php/current/referral-customers/update.php +++ b/official/docs/php/current/referral-customers/update.php @@ -2,4 +2,4 @@ $client = new \EasyPost\EasyPostClient(getenv('EASYPOST_API_KEY')); -$client->referralCustomer->updateEmail('new_email@example.com', 'user_...'); +$client->referralCustomer->updateEmail('user_...', 'new_email@example.com'); diff --git a/official/docs/php/v6/addresses/create-and-verify.php b/official/docs/php/v6/addresses/create-and-verify.php new file mode 100644 index 00000000..90b44a5d --- /dev/null +++ b/official/docs/php/v6/addresses/create-and-verify.php @@ -0,0 +1,16 @@ +address->createAndVerify([ + 'street1' => '417 Montgomery Street', + 'street2' => 'FL 5', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +echo $address; diff --git a/official/docs/php/v6/addresses/create.php b/official/docs/php/v6/addresses/create.php new file mode 100644 index 00000000..c0aa6ebd --- /dev/null +++ b/official/docs/php/v6/addresses/create.php @@ -0,0 +1,16 @@ +address->create([ + 'street1' => '417 MONTGOMERY ST', + 'street2' => 'FLOOR 5', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +echo $address; diff --git a/official/docs/php/v6/addresses/list.php b/official/docs/php/v6/addresses/list.php new file mode 100644 index 00000000..1c4fc4d0 --- /dev/null +++ b/official/docs/php/v6/addresses/list.php @@ -0,0 +1,9 @@ +address->all([ + 'page_size' => 5 +]); + +echo $addresses; diff --git a/official/docs/php/v6/addresses/retrieve.php b/official/docs/php/v6/addresses/retrieve.php new file mode 100644 index 00000000..375db3f1 --- /dev/null +++ b/official/docs/php/v6/addresses/retrieve.php @@ -0,0 +1,7 @@ +address->retrieve('adr_...'); + +echo $address; diff --git a/official/docs/php/v6/addresses/verify-failure.php b/official/docs/php/v6/addresses/verify-failure.php new file mode 100644 index 00000000..f2d301b9 --- /dev/null +++ b/official/docs/php/v6/addresses/verify-failure.php @@ -0,0 +1,15 @@ +address->create([ + 'street1' => 'UNDELIVERABLE ST', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +echo $address; diff --git a/official/docs/php/v6/addresses/verify-param.php b/official/docs/php/v6/addresses/verify-param.php new file mode 100644 index 00000000..f83e2871 --- /dev/null +++ b/official/docs/php/v6/addresses/verify-param.php @@ -0,0 +1,17 @@ +address->create([ + 'verify' => true, + 'street1' => '417 Montgomery Streat', + 'street2' => '5', + 'city' => 'SF', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +echo $address; diff --git a/official/docs/php/v6/addresses/verify-strict-param.php b/official/docs/php/v6/addresses/verify-strict-param.php new file mode 100644 index 00000000..1ce06425 --- /dev/null +++ b/official/docs/php/v6/addresses/verify-strict-param.php @@ -0,0 +1,17 @@ +address->create([ + 'verify_strict' => true, + 'street1' => '417 MONTGOMERY ST', + 'street2' => 'FL 5', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +echo $address; diff --git a/official/docs/php/v6/addresses/verify.php b/official/docs/php/v6/addresses/verify.php new file mode 100644 index 00000000..1f3aa188 --- /dev/null +++ b/official/docs/php/v6/addresses/verify.php @@ -0,0 +1,18 @@ +address->create([ + 'street1' => '417 montgomery streat', + 'street2' => 'FL 5', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'company' => 'EasyPost', + 'phone' => '415-123-4567' +]); + +$verifiedAddress = $client->address->verify($address->id); + +echo $verifiedAddress; diff --git a/official/docs/php/v6/api-keys/retrieve.php b/official/docs/php/v6/api-keys/retrieve.php new file mode 100644 index 00000000..ecb9a190 --- /dev/null +++ b/official/docs/php/v6/api-keys/retrieve.php @@ -0,0 +1,13 @@ +apiKeys->all(); + +echo $apiKeys; + +// Retrieve API keys for a specific child user +$childApiKeys = $client->apiKeys->retrieveApiKeysForUser('user_...'); + +echo $childApiKeys; diff --git a/official/docs/php/v6/batches/add-shipments.php b/official/docs/php/v6/batches/add-shipments.php new file mode 100644 index 00000000..43ff3b98 --- /dev/null +++ b/official/docs/php/v6/batches/add-shipments.php @@ -0,0 +1,17 @@ +batch->retrieve('batch_...'); + +$batchWithShipments = $client->batch->addShipments( + $batch->id, + [ + 'shipments' => [ + ['id' => 'shp_...'], + ['id' => 'shp_...'], + ] + ] +); + +echo $batchWithShipments; diff --git a/official/docs/php/v6/batches/buy.php b/official/docs/php/v6/batches/buy.php new file mode 100644 index 00000000..067b7c78 --- /dev/null +++ b/official/docs/php/v6/batches/buy.php @@ -0,0 +1,9 @@ +batch->retrieve('batch_...'); + +$boughtBatch = $client->batch->buy($batch->id); + +echo $boughtBatch; diff --git a/official/docs/php/v6/batches/create.php b/official/docs/php/v6/batches/create.php new file mode 100644 index 00000000..ef91e3d6 --- /dev/null +++ b/official/docs/php/v6/batches/create.php @@ -0,0 +1,12 @@ +batch->create([ + 'shipments' => [ + ['id' => 'shp_...'], + ['id' => 'shp_...'], + ] +]); + +echo $batch; diff --git a/official/docs/php/v6/batches/label.php b/official/docs/php/v6/batches/label.php new file mode 100644 index 00000000..2f933ee0 --- /dev/null +++ b/official/docs/php/v6/batches/label.php @@ -0,0 +1,12 @@ +batch->retrieve('batch_...'); + +$batchWithLabel = $client->batch->label( + $batch->id, + ['file_format' => 'PDF'] +); + +echo $batchWithLabel; diff --git a/official/docs/php/v6/batches/list.php b/official/docs/php/v6/batches/list.php new file mode 100644 index 00000000..11afda8d --- /dev/null +++ b/official/docs/php/v6/batches/list.php @@ -0,0 +1,9 @@ +batch->all([ + 'page_size' => 5, +]); + +echo $batches; diff --git a/official/docs/php/v6/batches/remove-shipments.php b/official/docs/php/v6/batches/remove-shipments.php new file mode 100644 index 00000000..d6245178 --- /dev/null +++ b/official/docs/php/v6/batches/remove-shipments.php @@ -0,0 +1,16 @@ +batch->retrieve('batch_...'); + +$batchWithoutShipments = $client->batch->removeShipments( + $shipment->id, + [ + 'shipments' => [ + ['id' => 'shp_...'] + ] + ] +); + +echo $batchWithoutShipments; diff --git a/official/docs/php/v6/batches/retrieve.php b/official/docs/php/v6/batches/retrieve.php new file mode 100644 index 00000000..4cc687f5 --- /dev/null +++ b/official/docs/php/v6/batches/retrieve.php @@ -0,0 +1,7 @@ +batch->retrieve('batch_...'); + +echo $batch; diff --git a/official/docs/php/v6/batches/scan-forms.php b/official/docs/php/v6/batches/scan-forms.php new file mode 100644 index 00000000..b52eeffd --- /dev/null +++ b/official/docs/php/v6/batches/scan-forms.php @@ -0,0 +1,9 @@ +batch->retrieve('batch_...'); + +$batchWithScanForm = $client->batch->createScanForm($batch->id); + +echo $batchWithScanForm; diff --git a/official/docs/php/v6/billing/create-ep-credit-card.php b/official/docs/php/v6/billing/create-ep-credit-card.php new file mode 100644 index 00000000..70df9dda --- /dev/null +++ b/official/docs/php/v6/billing/create-ep-credit-card.php @@ -0,0 +1,15 @@ +referralCustomer->addCreditCard( + $referralUserApiKey, + '0123456789101234', + '01', + '2025', + '111' +); + +echo $creditCard; diff --git a/official/docs/php/v6/billing/delete.php b/official/docs/php/v6/billing/delete.php new file mode 100644 index 00000000..69d5fcda --- /dev/null +++ b/official/docs/php/v6/billing/delete.php @@ -0,0 +1,5 @@ +billing->deletePaymentMethod('primary'); diff --git a/official/docs/php/v6/billing/fund.php b/official/docs/php/v6/billing/fund.php new file mode 100644 index 00000000..74b6983e --- /dev/null +++ b/official/docs/php/v6/billing/fund.php @@ -0,0 +1,5 @@ +billing->fundWallet(2000, 'primary'); diff --git a/official/docs/php/v6/billing/list.php b/official/docs/php/v6/billing/list.php new file mode 100644 index 00000000..d5a16293 --- /dev/null +++ b/official/docs/php/v6/billing/list.php @@ -0,0 +1,7 @@ +billing->retrievePaymentMethods(); + +echo $paymentMethods; diff --git a/official/docs/php/v6/brand/update.php b/official/docs/php/v6/brand/update.php new file mode 100644 index 00000000..f62f393b --- /dev/null +++ b/official/docs/php/v6/brand/update.php @@ -0,0 +1,12 @@ +user->retrieveMe(); + +$brand = $client->user->updateBrand( + $user->id, + ['color' => '#303F9F'] +); + +echo $brand; diff --git a/official/docs/php/current/carbon-offset/buy.php b/official/docs/php/v6/carbon-offset/buy.php similarity index 100% rename from official/docs/php/current/carbon-offset/buy.php rename to official/docs/php/v6/carbon-offset/buy.php diff --git a/official/docs/php/current/carbon-offset/create.php b/official/docs/php/v6/carbon-offset/create.php similarity index 100% rename from official/docs/php/current/carbon-offset/create.php rename to official/docs/php/v6/carbon-offset/create.php diff --git a/official/docs/php/current/carbon-offset/one-call-buy.php b/official/docs/php/v6/carbon-offset/one-call-buy.php similarity index 100% rename from official/docs/php/current/carbon-offset/one-call-buy.php rename to official/docs/php/v6/carbon-offset/one-call-buy.php diff --git a/official/docs/php/v6/carrier-accounts/create.php b/official/docs/php/v6/carrier-accounts/create.php new file mode 100644 index 00000000..a2da3423 --- /dev/null +++ b/official/docs/php/v6/carrier-accounts/create.php @@ -0,0 +1,22 @@ +carrierAccount->create([ + 'type' => 'DhlEcsAccount', + 'description' => 'CA Location DHL eCommerce Solutions Account', + 'credentials' => [ + 'client_id' => '123456', + 'client_secret' => '123abc', + 'distribution_center' => 'USLAX1', + 'pickup_id' => '123456' + ], + 'test_credentials' => [ + 'client_id' => '123456', + 'client_secret' => '123abc', + 'distribution_center' => 'USLAX1', + 'pickup_id' => '123456' + ] +]); + +echo $carrierAccount; diff --git a/official/docs/php/v6/carrier-accounts/delete.php b/official/docs/php/v6/carrier-accounts/delete.php new file mode 100644 index 00000000..cd61f4c1 --- /dev/null +++ b/official/docs/php/v6/carrier-accounts/delete.php @@ -0,0 +1,7 @@ +carrierAccount->retrieve('ca_...'); + +$client->carrierAccount->delete($carrierAccount->id); diff --git a/official/docs/php/v6/carrier-accounts/list.php b/official/docs/php/v6/carrier-accounts/list.php new file mode 100644 index 00000000..4e7aa921 --- /dev/null +++ b/official/docs/php/v6/carrier-accounts/list.php @@ -0,0 +1,7 @@ +carrierAccount->all(); + +echo $carrierAccounts; diff --git a/official/docs/php/v6/carrier-accounts/retrieve.php b/official/docs/php/v6/carrier-accounts/retrieve.php new file mode 100644 index 00000000..37192569 --- /dev/null +++ b/official/docs/php/v6/carrier-accounts/retrieve.php @@ -0,0 +1,7 @@ +carrierAccount->retrieve('ca_...'); + +echo $carrierAccount; diff --git a/official/docs/php/v6/carrier-accounts/update.php b/official/docs/php/v6/carrier-accounts/update.php new file mode 100644 index 00000000..9f4982a0 --- /dev/null +++ b/official/docs/php/v6/carrier-accounts/update.php @@ -0,0 +1,17 @@ +carrierAccount->retrieve('ca_...'); + +$updatedCarrierAccount = $client->carrierAccount->update( + $carrierAccount->id, + [ + 'description' => 'FL Location DHL eCommerce Solutions Account', + 'credentials' => [ + 'pickup_id' => 'abc123', + ] + ] +); + +echo $updatedCarrierAccount; diff --git a/official/docs/php/v6/carrier-metadata/retrieve.php b/official/docs/php/v6/carrier-metadata/retrieve.php new file mode 100644 index 00000000..4810b78f --- /dev/null +++ b/official/docs/php/v6/carrier-metadata/retrieve.php @@ -0,0 +1,14 @@ +carrierMetadata->retrieve(); +echo $carrierMetadata; + +// Request specific metadata for specific carriers +$carrierMetadata = $client->carrierMetadata->retrieve( + ['usps'], + ['service_levels', 'predefined_packages'], +); +echo $carrierMetadata; diff --git a/official/docs/php/v6/carrier-types/list.php b/official/docs/php/v6/carrier-types/list.php new file mode 100644 index 00000000..43b28cd4 --- /dev/null +++ b/official/docs/php/v6/carrier-types/list.php @@ -0,0 +1,7 @@ +carrierAccount->types(); + +echo $carrierTypes; diff --git a/official/docs/php/v6/child-users/create.php b/official/docs/php/v6/child-users/create.php new file mode 100644 index 00000000..4882fb3c --- /dev/null +++ b/official/docs/php/v6/child-users/create.php @@ -0,0 +1,9 @@ +user->create([ + 'name' => 'Child Account Name' +]); + +echo $child; diff --git a/official/docs/php/v6/child-users/delete.php b/official/docs/php/v6/child-users/delete.php new file mode 100644 index 00000000..93a3859a --- /dev/null +++ b/official/docs/php/v6/child-users/delete.php @@ -0,0 +1,7 @@ +user->retrieve('user_...'); + +$client->user->delete($user->id); diff --git a/official/docs/php/v6/customs-infos/create.php b/official/docs/php/v6/customs-infos/create.php new file mode 100644 index 00000000..55e3a9a8 --- /dev/null +++ b/official/docs/php/v6/customs-infos/create.php @@ -0,0 +1,24 @@ +customsInfo->create([ + 'eel_pfc' => 'NOEEI 30.37(a)', + 'customs_certify' => true, + 'customs_signer' => 'Steve Brule', + 'contents_type' => 'merchandise', + 'contents_explanation' => '', + 'restriction_type' => 'none', + 'customs_items' => [ + [ + 'description' => 'T-shirt', + 'quantity' => 1, + 'weight' => 5, + 'value' => 10, + 'hs_tariff_number' => '123456', + 'origin_country' => 'US' + ] + ] +]); + +echo $customsInfo; diff --git a/official/docs/php/v6/customs-infos/retrieve.php b/official/docs/php/v6/customs-infos/retrieve.php new file mode 100644 index 00000000..887d4349 --- /dev/null +++ b/official/docs/php/v6/customs-infos/retrieve.php @@ -0,0 +1,7 @@ +customsInfo->retrieve('cstinfo_...'); + +echo $customsInfo; diff --git a/official/docs/php/v6/customs-items/create.php b/official/docs/php/v6/customs-items/create.php new file mode 100644 index 00000000..2d465f6c --- /dev/null +++ b/official/docs/php/v6/customs-items/create.php @@ -0,0 +1,14 @@ +customsItem->create([ + 'description' => 'T-shirt', + 'quantity' => 1, + 'weight' => 5, + 'value' => 10, + 'hs_tariff_number' => '123456', + 'origin_country' => 'US' +]); + +echo $customsItem; diff --git a/official/docs/php/v6/customs-items/retrieve.php b/official/docs/php/v6/customs-items/retrieve.php new file mode 100644 index 00000000..1d253670 --- /dev/null +++ b/official/docs/php/v6/customs-items/retrieve.php @@ -0,0 +1,7 @@ +customsItem->retrieve('cstitem_...'); + +echo $customsItem; diff --git a/official/docs/php/v6/endshipper/buy.php b/official/docs/php/v6/endshipper/buy.php new file mode 100644 index 00000000..34e586a8 --- /dev/null +++ b/official/docs/php/v6/endshipper/buy.php @@ -0,0 +1,17 @@ +shipment->retrieve('shp_...'); + +$boughtShipment = $client->shipment->buy( + $shipment->id, + [ + 'rate' => $shipment->lowestRate(), + 'insurance' => null, + 'with_carbon_offset' => false, + 'end_shipper_id' => 'es_...' + ] +); + +echo $boughtShipment; diff --git a/official/docs/php/v6/endshipper/create.php b/official/docs/php/v6/endshipper/create.php new file mode 100644 index 00000000..e2dcfb2e --- /dev/null +++ b/official/docs/php/v6/endshipper/create.php @@ -0,0 +1,20 @@ + 'FOO BAR', + 'company' => 'BAZ', + 'street1' => '164 TOWNSEND STREET UNIT 1', + 'street2' => 'UNIT 1', + 'city' => 'SAN FRANCISCO', + 'state' => 'CA', + 'zip' => '94107', + 'country' => 'US', + 'phone' => '555-555-5555', + 'email' => 'FOO@EXAMPLE.COM' +]; + +$endshipper = $client->endShipper->create($params); + +echo $endshipper; diff --git a/official/docs/php/v6/endshipper/list.php b/official/docs/php/v6/endshipper/list.php new file mode 100644 index 00000000..c9d0c7fc --- /dev/null +++ b/official/docs/php/v6/endshipper/list.php @@ -0,0 +1,9 @@ +endShipper->all([ + 'page_size' => 5 +]); + +echo $endshippers; diff --git a/official/docs/php/v6/endshipper/retrieve.php b/official/docs/php/v6/endshipper/retrieve.php new file mode 100644 index 00000000..ff484968 --- /dev/null +++ b/official/docs/php/v6/endshipper/retrieve.php @@ -0,0 +1,7 @@ +endShipper->retrieve('es_...'); + +echo $endshipper; diff --git a/official/docs/php/v6/endshipper/update.php b/official/docs/php/v6/endshipper/update.php new file mode 100644 index 00000000..6f5582df --- /dev/null +++ b/official/docs/php/v6/endshipper/update.php @@ -0,0 +1,23 @@ +endShipper->retrieve('es_...'); + +$updatedEndShipper = $client->endShipper->update( + $endShipper->id, + [ + 'name' => 'NEW NAME', + 'company' => 'BAZ', + 'street1' => '164 TOWNSEND STREET UNIT 1', + 'street2' => 'UNIT 1', + 'city' => 'SAN FRANCISCO', + 'state' => 'CA', + 'zip' => '94107', + 'country' => 'US', + 'phone' => '555-555-5555', + 'email' => 'FOO@EXAMPLE.COM', + ] +); + +echo $updatedEndShipper; diff --git a/official/docs/php/v6/events/list.php b/official/docs/php/v6/events/list.php new file mode 100644 index 00000000..3a26f24a --- /dev/null +++ b/official/docs/php/v6/events/list.php @@ -0,0 +1,9 @@ +event->all([ + 'page_size' => 5 +]); + +echo $events; diff --git a/official/docs/php/v6/events/retrieve.php b/official/docs/php/v6/events/retrieve.php new file mode 100644 index 00000000..9ed55715 --- /dev/null +++ b/official/docs/php/v6/events/retrieve.php @@ -0,0 +1,7 @@ +event->retrieve('evt_...'); + +echo $event; diff --git a/official/docs/php/v6/forms/create.php b/official/docs/php/v6/forms/create.php new file mode 100644 index 00000000..9adc4cc1 --- /dev/null +++ b/official/docs/php/v6/forms/create.php @@ -0,0 +1,23 @@ +shipment->retrieve('shp_...'); + +$formType = 'return_packing_slip'; +$formOptions = [ + 'barcode' => 'RMA12345678900', + 'line_items' => [ + [ + 'product' => [ + 'title' => 'Square Reader', + 'barcode' => '855658003251', + ], + 'units' => 8, + ], + ], +]; + +$shipmentWithForm = $client->shipment->generateForm($shipment->id, $formType, $formOptions); + +echo $shipmentWithForm; diff --git a/official/docs/php/v6/insurance/create.php b/official/docs/php/v6/insurance/create.php new file mode 100644 index 00000000..5426bf08 --- /dev/null +++ b/official/docs/php/v6/insurance/create.php @@ -0,0 +1,14 @@ +insurance->create([ + 'to_address' => ['id' => 'adr_...'], + 'from_address' => ['id' => 'adr_...'], + 'tracking_code' => '9400110898825022579493', + 'carrier' => 'USPS', + 'amount' => '100.00', + 'reference' => 'insuranceRef1' +]); + +echo $insurance; diff --git a/official/docs/php/v6/insurance/list.php b/official/docs/php/v6/insurance/list.php new file mode 100644 index 00000000..6f323b10 --- /dev/null +++ b/official/docs/php/v6/insurance/list.php @@ -0,0 +1,9 @@ +insurance->all([ + 'page_size' => 5, +]); + +echo $insurances; diff --git a/official/docs/php/v6/insurance/retrieve.php b/official/docs/php/v6/insurance/retrieve.php new file mode 100644 index 00000000..225990f3 --- /dev/null +++ b/official/docs/php/v6/insurance/retrieve.php @@ -0,0 +1,7 @@ +insurance->retrieve('ins_...'); + +echo $insurance; diff --git a/official/docs/php/v6/options/create-with-options.php b/official/docs/php/v6/options/create-with-options.php new file mode 100644 index 00000000..de55d973 --- /dev/null +++ b/official/docs/php/v6/options/create-with-options.php @@ -0,0 +1,17 @@ +shipment->create([ + 'to_address' => ['id' => 'adr_...'], + 'from_address' => ['id' => 'adr_...'], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ], + 'options' => ['print_custom_1' => 'Custom label message'] +]); + +echo $shipment; diff --git a/official/docs/php/v6/orders/buy.php b/official/docs/php/v6/orders/buy.php new file mode 100644 index 00000000..d59380c6 --- /dev/null +++ b/official/docs/php/v6/orders/buy.php @@ -0,0 +1,15 @@ +order->retrieve('order_...'); + +$boughtOrder = $client->order->buy( + $shipment->id, + [ + 'carrier' => 'FedEx', + 'service' => 'FEDEX_GROUND' + ] +); + +echo $boughtOrder; diff --git a/official/docs/php/v6/orders/create.php b/official/docs/php/v6/orders/create.php new file mode 100644 index 00000000..2954da12 --- /dev/null +++ b/official/docs/php/v6/orders/create.php @@ -0,0 +1,23 @@ +order->create([ + 'to_address' => ['id' => 'adr_...'], + 'from_address' => ['id' => 'adr_...'], + 'shipments' => [ + [ + 'parcel' => [ + 'weight' => 10.2 + ] + ], + [ + 'parcel' => [ + 'predefined_package' => 'FedExBox', + 'weight' => 17.5 + ] + ], + ], +]); + +echo $order; diff --git a/official/docs/php/v6/orders/one-call-buy.php b/official/docs/php/v6/orders/one-call-buy.php new file mode 100644 index 00000000..44bc9a99 --- /dev/null +++ b/official/docs/php/v6/orders/one-call-buy.php @@ -0,0 +1,25 @@ +order->create([ + 'carrier_accounts' => 'ca_...', + 'service' => 'NextDayAir', + 'to_address' => ['id' => 'adr_...'], + 'from_address' => ['id' => 'adr_...'], + 'shipments' => [ + [ + 'parcel' => [ + 'weight' => 10.2 + ] + ], + [ + 'parcel' => [ + 'predefined_package' => 'FedExBox', + 'weight' => 17.5 + ] + ], + ], +]); + +echo $order; diff --git a/official/docs/php/v6/orders/retrieve.php b/official/docs/php/v6/orders/retrieve.php new file mode 100644 index 00000000..04b3b753 --- /dev/null +++ b/official/docs/php/v6/orders/retrieve.php @@ -0,0 +1,7 @@ +order->retrieve('order_...'); + +echo $order; diff --git a/official/docs/php/v6/pagination/get-next-page.php b/official/docs/php/v6/pagination/get-next-page.php new file mode 100644 index 00000000..09eff162 --- /dev/null +++ b/official/docs/php/v6/pagination/get-next-page.php @@ -0,0 +1,13 @@ +shipment->all([ + 'page_size' => 5, +]); + +// Provide the previous results page to move onto the next page +$nextPage = $client->shipments->getNextPage($shipments); + +echo $nextPage; diff --git a/official/docs/php/v6/parcels/create.php b/official/docs/php/v6/parcels/create.php new file mode 100644 index 00000000..54353cc7 --- /dev/null +++ b/official/docs/php/v6/parcels/create.php @@ -0,0 +1,12 @@ +parcel->create([ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 +]); + +echo $parcel; diff --git a/official/docs/php/v6/parcels/retrieve.php b/official/docs/php/v6/parcels/retrieve.php new file mode 100644 index 00000000..5636652c --- /dev/null +++ b/official/docs/php/v6/parcels/retrieve.php @@ -0,0 +1,7 @@ +parcel->retrieve('prcl_...'); + +echo $parcel; diff --git a/official/docs/php/v6/payloads/list.php b/official/docs/php/v6/payloads/list.php new file mode 100644 index 00000000..b035d157 --- /dev/null +++ b/official/docs/php/v6/payloads/list.php @@ -0,0 +1,7 @@ +event->retrieveAllPayloads('evt_...'); + +echo $payloads; diff --git a/official/docs/php/v6/payloads/retrieve.php b/official/docs/php/v6/payloads/retrieve.php new file mode 100644 index 00000000..f2fcfc55 --- /dev/null +++ b/official/docs/php/v6/payloads/retrieve.php @@ -0,0 +1,7 @@ +event->retrievePayload('evt_...', 'payload_...'); + +echo $payload; diff --git a/official/docs/php/v6/pickups/buy.php b/official/docs/php/v6/pickups/buy.php new file mode 100644 index 00000000..bf042db6 --- /dev/null +++ b/official/docs/php/v6/pickups/buy.php @@ -0,0 +1,15 @@ +pickup->retrieve('pickup_...'); + +$boughtPickup = $client->pickup->buy( + $pickup->id, + [ + 'carrier' => 'UPS', + 'service' => 'Same-day Pickup' + ] +); + +echo $pickup; diff --git a/official/docs/php/v6/pickups/cancel.php b/official/docs/php/v6/pickups/cancel.php new file mode 100644 index 00000000..b770ce3c --- /dev/null +++ b/official/docs/php/v6/pickups/cancel.php @@ -0,0 +1,9 @@ +pickup->retrieve('pickup_...'); + +$cancelledPickup = $client->pickup->cancel($pickup->id); + +echo $cancelledPickup; diff --git a/official/docs/php/v6/pickups/create.php b/official/docs/php/v6/pickups/create.php new file mode 100644 index 00000000..6e118106 --- /dev/null +++ b/official/docs/php/v6/pickups/create.php @@ -0,0 +1,15 @@ +pickup->create([ + 'address' => ['id' => 'adr_...'], + 'shipment' => ['id' => 'shp_...'], + 'reference' => 'my-first-pickup', + 'min_datetime' => date('2022-10-01 10:30:00'), + 'max_datetime' => date('2022-10-02 10:30:00'), + 'is_account_address' => false, + 'instructions' => 'Special pickup instructions' +]); + +echo $pickup; diff --git a/official/docs/php/v6/pickups/list.php b/official/docs/php/v6/pickups/list.php new file mode 100644 index 00000000..73b565b2 --- /dev/null +++ b/official/docs/php/v6/pickups/list.php @@ -0,0 +1,9 @@ +pickup->all([ + 'page_size' => 5, +]); + +echo $pickups; diff --git a/official/docs/php/v6/pickups/retrieve.php b/official/docs/php/v6/pickups/retrieve.php new file mode 100644 index 00000000..0d93929b --- /dev/null +++ b/official/docs/php/v6/pickups/retrieve.php @@ -0,0 +1,7 @@ +pickup->retrieve('pickup_...'); + +echo $pickup; diff --git a/official/docs/php/v6/rates/regenerate.php b/official/docs/php/v6/rates/regenerate.php new file mode 100644 index 00000000..6a5f787c --- /dev/null +++ b/official/docs/php/v6/rates/regenerate.php @@ -0,0 +1,9 @@ +shipment->retrieve('shp_...'); + +$shipmentWithRegeneratedrates = $client->shipment->regenerateRates($shipment->id); + +echo $shipmentWithRegeneratedrates; diff --git a/official/docs/php/v6/rates/retrieve-stateless.php b/official/docs/php/v6/rates/retrieve-stateless.php new file mode 100644 index 00000000..c8ffaca7 --- /dev/null +++ b/official/docs/php/v6/rates/retrieve-stateless.php @@ -0,0 +1,37 @@ + [ + 'name' => 'Dr. Steve Brule', + 'street1' => '179 N Harbor Dr', + 'city' => 'Redondo Beach', + 'state' => 'CA', + 'zip' => '90277', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'dr_steve_brule@gmail.com' + ], + 'from_address' => [ + 'name' => 'EasyPost', + 'street1' => '417 Montgomery Street', + 'street2' => '5th Floor', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'support@easypost.com' + ], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ] +]; + +$rates = $client->betaRate->retrieveStatelessRates($shipmentDetails); + +echo $rates; diff --git a/official/docs/php/v6/rates/retrieve.php b/official/docs/php/v6/rates/retrieve.php new file mode 100644 index 00000000..d37ed698 --- /dev/null +++ b/official/docs/php/v6/rates/retrieve.php @@ -0,0 +1,7 @@ +rate->retrieve('rate...'); + +echo $rate; diff --git a/official/docs/php/v6/referral-customers/add-payment-method-with-bank-account.php b/official/docs/php/v6/referral-customers/add-payment-method-with-bank-account.php new file mode 100644 index 00000000..e1ab7d12 --- /dev/null +++ b/official/docs/php/v6/referral-customers/add-payment-method-with-bank-account.php @@ -0,0 +1,11 @@ +betaReferralCustomer->addPaymentMethod([ + 'cus_...', + 'ba_...', + 'primary' +]); + +echo $paymentMethod; diff --git a/official/docs/php/v6/referral-customers/add-payment-method-with-credit-card.php b/official/docs/php/v6/referral-customers/add-payment-method-with-credit-card.php new file mode 100644 index 00000000..3a581f74 --- /dev/null +++ b/official/docs/php/v6/referral-customers/add-payment-method-with-credit-card.php @@ -0,0 +1,11 @@ +betaReferralCustomer->addPaymentMethod([ + 'cus_...', + 'card_...', + 'primary' +]); + +echo $paymentMethod; diff --git a/official/docs/php/v6/referral-customers/create.php b/official/docs/php/v6/referral-customers/create.php new file mode 100644 index 00000000..bbae34c3 --- /dev/null +++ b/official/docs/php/v6/referral-customers/create.php @@ -0,0 +1,11 @@ +referralCustomer->create([ + 'name' => 'Test Referral', + 'email' => 'test@test.com', + 'phone' => '8888888888' +]); + +echo $referralUser; diff --git a/official/docs/php/v6/referral-customers/list.php b/official/docs/php/v6/referral-customers/list.php new file mode 100644 index 00000000..d14f1304 --- /dev/null +++ b/official/docs/php/v6/referral-customers/list.php @@ -0,0 +1,9 @@ +referralCustomer->all([ + 'page_size' => 5, +]); + +echo $referralUsers; diff --git a/official/docs/php/v6/referral-customers/refund-by-amount.php b/official/docs/php/v6/referral-customers/refund-by-amount.php new file mode 100644 index 00000000..31ed1cd4 --- /dev/null +++ b/official/docs/php/v6/referral-customers/refund-by-amount.php @@ -0,0 +1,7 @@ +betaReferralCustomer->refundByAmount(2000); + +echo $refund; diff --git a/official/docs/php/v6/referral-customers/refund-by-payment-log.php b/official/docs/php/v6/referral-customers/refund-by-payment-log.php new file mode 100644 index 00000000..a6dd20a0 --- /dev/null +++ b/official/docs/php/v6/referral-customers/refund-by-payment-log.php @@ -0,0 +1,7 @@ +betaReferralCustomer->refundByPaymentLog('paylog_...'); + +echo $refund; diff --git a/official/docs/php/v6/referral-customers/update.php b/official/docs/php/v6/referral-customers/update.php new file mode 100644 index 00000000..432a36ad --- /dev/null +++ b/official/docs/php/v6/referral-customers/update.php @@ -0,0 +1,5 @@ +referralCustomer->updateEmail('new_email@example.com', 'user_...'); diff --git a/official/docs/php/v6/refunds/create.php b/official/docs/php/v6/refunds/create.php new file mode 100644 index 00000000..46f72e91 --- /dev/null +++ b/official/docs/php/v6/refunds/create.php @@ -0,0 +1,10 @@ +refund->create([ + 'carrier' => 'USPS', + 'tracking_codes' => ['EZ1000000001'], +]); + +echo $refunds; diff --git a/official/docs/php/v6/refunds/list.php b/official/docs/php/v6/refunds/list.php new file mode 100644 index 00000000..e87ac30c --- /dev/null +++ b/official/docs/php/v6/refunds/list.php @@ -0,0 +1,9 @@ +refund->all([ + 'page_size' => 5, +]); + +echo $refunds; diff --git a/official/docs/php/v6/refunds/retrieve.php b/official/docs/php/v6/refunds/retrieve.php new file mode 100644 index 00000000..e8e6569a --- /dev/null +++ b/official/docs/php/v6/refunds/retrieve.php @@ -0,0 +1,7 @@ +refund->retrieve('rfnd_...'); + +echo $refund; diff --git a/official/docs/php/v6/reports/create.php b/official/docs/php/v6/reports/create.php new file mode 100644 index 00000000..99f910c3 --- /dev/null +++ b/official/docs/php/v6/reports/create.php @@ -0,0 +1,11 @@ +report->create([ + 'type' => 'payment_log', + 'start_date' => '2022-10-01', + 'end_date' => '2022-10-31', +]); + +echo $report; diff --git a/official/docs/php/v6/reports/list.php b/official/docs/php/v6/reports/list.php new file mode 100644 index 00000000..269c77d9 --- /dev/null +++ b/official/docs/php/v6/reports/list.php @@ -0,0 +1,11 @@ +report->all([ + // Replace `payment_log` with any of the report types listed above + 'type' => 'payment_log', + 'page_size' => 5, +]); + +echo $reports; diff --git a/official/docs/php/v6/reports/retrieve.php b/official/docs/php/v6/reports/retrieve.php new file mode 100644 index 00000000..0c7e5cbf --- /dev/null +++ b/official/docs/php/v6/reports/retrieve.php @@ -0,0 +1,7 @@ +report->retrieve(''); + +echo $report; diff --git a/official/docs/php/v6/returns/create.php b/official/docs/php/v6/returns/create.php new file mode 100644 index 00000000..d6b96c1a --- /dev/null +++ b/official/docs/php/v6/returns/create.php @@ -0,0 +1,36 @@ +shipment->create([ + 'to_address' => [ + 'name' => 'Dr. Steve Brule', + 'street1' => '179 N Harbor Dr', + 'city' => 'Redondo Beach', + 'state' => 'CA', + 'zip' => '90277', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'dr_steve_brule@gmail.com' + ], + 'from_address' => [ + 'name' => 'EasyPost', + 'street1' => '417 Montgomery Street', + 'street2' => '5th Floor', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'support@easypost.com' + ], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ], + 'is_return' => true +]); + +echo $shipment; diff --git a/official/docs/php/v6/scan-form/create.php b/official/docs/php/v6/scan-form/create.php new file mode 100644 index 00000000..a16e8a4c --- /dev/null +++ b/official/docs/php/v6/scan-form/create.php @@ -0,0 +1,12 @@ +scanForm->create([ + 'shipments' => [ + ['id' => 'shp_...'], + ['id' => 'shp_...'], + ] +]); + +echo $scanForm; diff --git a/official/docs/php/v6/scan-form/list.php b/official/docs/php/v6/scan-form/list.php new file mode 100644 index 00000000..cb08cef6 --- /dev/null +++ b/official/docs/php/v6/scan-form/list.php @@ -0,0 +1,9 @@ +scanForm->all([ + 'page_size' => 5 +]); + +echo $scanForms; diff --git a/official/docs/php/v6/scan-form/retrieve.php b/official/docs/php/v6/scan-form/retrieve.php new file mode 100644 index 00000000..6c095c5f --- /dev/null +++ b/official/docs/php/v6/scan-form/retrieve.php @@ -0,0 +1,7 @@ +scanForm->retrieve('sf_...'); + +echo $scanForm; diff --git a/official/docs/php/v6/shipments/buy.php b/official/docs/php/v6/shipments/buy.php new file mode 100644 index 00000000..9a9eaad8 --- /dev/null +++ b/official/docs/php/v6/shipments/buy.php @@ -0,0 +1,15 @@ +shipment->retrieve('shp_...'); + +$boughtShipment = $client->shipment->buy( + $shipment->id, + [ + 'rate' => $shipment->lowestRate(), + 'insurance' => 249.99 + ] +); + +echo $boughtShipment; diff --git a/official/docs/php/v6/shipments/create.php b/official/docs/php/v6/shipments/create.php new file mode 100644 index 00000000..de6d0643 --- /dev/null +++ b/official/docs/php/v6/shipments/create.php @@ -0,0 +1,35 @@ +shipment->create([ + 'to_address' => [ + 'name' => 'Dr. Steve Brule', + 'street1' => '179 N Harbor Dr', + 'city' => 'Redondo Beach', + 'state' => 'CA', + 'zip' => '90277', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'dr_steve_brule@gmail.com' + ], + 'from_address' => [ + 'name' => 'EasyPost', + 'street1' => '417 Montgomery Street', + 'street2' => '5th Floor', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'support@easypost.com' + ], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ] +]); + +echo $shipment; diff --git a/official/docs/php/v6/shipments/label.php b/official/docs/php/v6/shipments/label.php new file mode 100644 index 00000000..9100c44c --- /dev/null +++ b/official/docs/php/v6/shipments/label.php @@ -0,0 +1,12 @@ +shipment->retrieve('shp_...'); + +$shipmentWithLabel = $client->shipment->label( + $shipment->id, + ['file_format' => 'ZPL'] +); + +echo $shipment; diff --git a/official/docs/php/v6/shipments/list.php b/official/docs/php/v6/shipments/list.php new file mode 100644 index 00000000..3434c4b9 --- /dev/null +++ b/official/docs/php/v6/shipments/list.php @@ -0,0 +1,9 @@ +shipment->all([ + 'page_size' => 5, +]); + +echo $shipments; diff --git a/official/docs/php/v6/shipments/one-call-buy.php b/official/docs/php/v6/shipments/one-call-buy.php new file mode 100644 index 00000000..7b79f942 --- /dev/null +++ b/official/docs/php/v6/shipments/one-call-buy.php @@ -0,0 +1,37 @@ +shipment->create([ + 'carrier_accounts' => ['ca_...'], + 'service' => 'NextDayAir', + 'to_address' => [ + 'name' => 'Dr. Steve Brule', + 'street1' => '179 N Harbor Dr', + 'city' => 'Redondo Beach', + 'state' => 'CA', + 'zip' => '90277', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'dr_steve_brule@gmail.com' + ], + 'from_address' => [ + 'name' => 'EasyPost', + 'street1' => '417 Montgomery Street', + 'street2' => '5th Floor', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'support@easypost.com' + ], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ] +]); + +echo $shipment; diff --git a/official/docs/php/v6/shipments/retrieve.php b/official/docs/php/v6/shipments/retrieve.php new file mode 100644 index 00000000..9104e760 --- /dev/null +++ b/official/docs/php/v6/shipments/retrieve.php @@ -0,0 +1,7 @@ +shipment->retrieve('shp_...'); + +echo $shipment; diff --git a/official/docs/php/v6/shipping-insurance/insure.php b/official/docs/php/v6/shipping-insurance/insure.php new file mode 100644 index 00000000..ca85a188 --- /dev/null +++ b/official/docs/php/v6/shipping-insurance/insure.php @@ -0,0 +1,12 @@ +shipment->retrieve('shp_...'); + +$shipmentWithInsurance = $client->shipment->insure( + $shipment->id, + ['amount' => 100] +); + +echo $shipmentWithInsurance; diff --git a/official/docs/php/v6/shipping-refund/refund.php b/official/docs/php/v6/shipping-refund/refund.php new file mode 100644 index 00000000..9862620c --- /dev/null +++ b/official/docs/php/v6/shipping-refund/refund.php @@ -0,0 +1,9 @@ +shipment->retrieve('shp_...'); + +$refundedShipment = $client->shipment->refund($shipment->id); + +echo $refundedShipment; diff --git a/official/docs/php/v6/smartrate/retrieve-estimated-delivery-date.php b/official/docs/php/v6/smartrate/retrieve-estimated-delivery-date.php new file mode 100644 index 00000000..f3bfdcd9 --- /dev/null +++ b/official/docs/php/v6/smartrate/retrieve-estimated-delivery-date.php @@ -0,0 +1,9 @@ +shipment->retrieve('shp_...'); + +$estimatedDeliveryDates = $client->shipment->retrieveEstimatedDeliveryDate($shipment->id, 'YYYY-MM-DD'); + +echo $estimatedDeliveryDates; diff --git a/official/docs/php/v6/smartrate/retrieve-time-in-transit-statistics.php b/official/docs/php/v6/smartrate/retrieve-time-in-transit-statistics.php new file mode 100644 index 00000000..bfcebbb2 --- /dev/null +++ b/official/docs/php/v6/smartrate/retrieve-time-in-transit-statistics.php @@ -0,0 +1,9 @@ +shipment->retrieve('shp_...'); + +$smartRates = $client->shipment->getSmartrates(); + +echo $smartRates; diff --git a/official/docs/php/v6/tax-identifiers/create.php b/official/docs/php/v6/tax-identifiers/create.php new file mode 100644 index 00000000..97734193 --- /dev/null +++ b/official/docs/php/v6/tax-identifiers/create.php @@ -0,0 +1,42 @@ +shipment->create([ + 'to_address' => [ + 'name' => 'Dr. Steve Brule', + 'street1' => '179 N Harbor Dr', + 'city' => 'Redondo Beach', + 'state' => 'CA', + 'zip' => '90277', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'dr_steve_brule@gmail.com' + ], + 'from_address' => [ + 'name' => 'EasyPost', + 'street1' => '417 Montgomery Street', + 'street2' => '5th Floor', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94104', + 'country' => 'US', + 'phone' => '3331114444', + 'email' => 'support@easypost.com' + ], + 'parcel' => [ + 'length' => 20.2, + 'width' => 10.9, + 'height' => 5, + 'weight' => 65.9 + ], + 'customs_info' => ['id' => 'cstinfo_...'], + 'tax_identifiers' => [[ + 'entity' => 'SENDER', + 'tax_id' => 'GB123456789', + 'tax_id_type' => 'IOSS', + 'issuing_country' => 'GB', + ]] +]); + +echo $shipment; diff --git a/official/docs/php/v6/trackers/create.php b/official/docs/php/v6/trackers/create.php new file mode 100644 index 00000000..c0086e1c --- /dev/null +++ b/official/docs/php/v6/trackers/create.php @@ -0,0 +1,10 @@ +tracker->create([ + 'tracking_code' => 'EZ1000000001', + 'carrier' => 'USPS' +]); + +echo $tracker; diff --git a/official/docs/php/v6/trackers/list.php b/official/docs/php/v6/trackers/list.php new file mode 100644 index 00000000..a2dc21b2 --- /dev/null +++ b/official/docs/php/v6/trackers/list.php @@ -0,0 +1,9 @@ +tracker->all([ + 'page_size' => 5, +]); + +echo $trackers; diff --git a/official/docs/php/v6/trackers/retrieve.php b/official/docs/php/v6/trackers/retrieve.php new file mode 100644 index 00000000..13b8fb41 --- /dev/null +++ b/official/docs/php/v6/trackers/retrieve.php @@ -0,0 +1,7 @@ +tracker->retrieve('trk_...'); + +echo $tracker; diff --git a/official/docs/php/v6/users/retrieve.php b/official/docs/php/v6/users/retrieve.php new file mode 100644 index 00000000..beffb304 --- /dev/null +++ b/official/docs/php/v6/users/retrieve.php @@ -0,0 +1,11 @@ +user->retrieveMe(); + +// Retrieve a child user +$user = $client->user->retrieve('user_...'); + +echo $user; diff --git a/official/docs/php/v6/users/update.php b/official/docs/php/v6/users/update.php new file mode 100644 index 00000000..9e9d7062 --- /dev/null +++ b/official/docs/php/v6/users/update.php @@ -0,0 +1,12 @@ +user->retrieveMe(); + +$updatedUser = $client->user->update( + $user->id, + ['recharge_threshold' => '50.00'] +); + +echo $updatedUser; diff --git a/official/docs/php/v6/webhooks/create.php b/official/docs/php/v6/webhooks/create.php new file mode 100644 index 00000000..411911b1 --- /dev/null +++ b/official/docs/php/v6/webhooks/create.php @@ -0,0 +1,7 @@ +webhook->create(['url' => 'example.com']); + +echo $webhook; diff --git a/official/docs/php/v6/webhooks/delete.php b/official/docs/php/v6/webhooks/delete.php new file mode 100644 index 00000000..334636a5 --- /dev/null +++ b/official/docs/php/v6/webhooks/delete.php @@ -0,0 +1,7 @@ +webhook->retrieve('hook_...'); + +$client->webhook->delete($webhook->id); diff --git a/official/docs/php/v6/webhooks/list.php b/official/docs/php/v6/webhooks/list.php new file mode 100644 index 00000000..2cff5502 --- /dev/null +++ b/official/docs/php/v6/webhooks/list.php @@ -0,0 +1,7 @@ +webhook->all(); + +echo $webhooks; diff --git a/official/docs/php/v6/webhooks/retrieve.php b/official/docs/php/v6/webhooks/retrieve.php new file mode 100644 index 00000000..546060fc --- /dev/null +++ b/official/docs/php/v6/webhooks/retrieve.php @@ -0,0 +1,7 @@ +webhook->retrieve('hook_...'); + +echo $webhook; diff --git a/official/docs/php/v6/webhooks/update.php b/official/docs/php/v6/webhooks/update.php new file mode 100644 index 00000000..264f7802 --- /dev/null +++ b/official/docs/php/v6/webhooks/update.php @@ -0,0 +1,9 @@ +webhook->retrieve('hook_...'); + +$updatedWebhook = $client->webhook->update(); + +echo $updatedWebhook; diff --git a/official/docs/python/v8/addresses/create-and-verify.py b/official/docs/python/v8/addresses/create-and-verify.py new file mode 100644 index 00000000..ce435994 --- /dev/null +++ b/official/docs/python/v8/addresses/create-and-verify.py @@ -0,0 +1,17 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create_and_verify( + street1="417 Montgomery Street", + street2="FL 5", + city="San Francisco", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +print(address) diff --git a/official/docs/python/v8/addresses/create.py b/official/docs/python/v8/addresses/create.py new file mode 100644 index 00000000..1d250482 --- /dev/null +++ b/official/docs/python/v8/addresses/create.py @@ -0,0 +1,17 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create( + street1="417 MONTGOMERY ST", + street2="FLOOR 5", + city="SAN FRANCISCO", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +print(address) diff --git a/official/docs/python/v8/addresses/list.py b/official/docs/python/v8/addresses/list.py new file mode 100644 index 00000000..4a3d5ace --- /dev/null +++ b/official/docs/python/v8/addresses/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +addresses = client.address.all(page_size=5) + +print(addresses) diff --git a/official/docs/python/v8/addresses/retrieve.py b/official/docs/python/v8/addresses/retrieve.py new file mode 100644 index 00000000..1f2ed205 --- /dev/null +++ b/official/docs/python/v8/addresses/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.retrieve("adr_...") + +print(address) diff --git a/official/docs/python/v8/addresses/verify-failure.py b/official/docs/python/v8/addresses/verify-failure.py new file mode 100644 index 00000000..70c46003 --- /dev/null +++ b/official/docs/python/v8/addresses/verify-failure.py @@ -0,0 +1,16 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create( + street1="UNDELIVERABLE ST", + city="SAN FRANCISCO", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +print(address) diff --git a/official/docs/python/v8/addresses/verify-param.py b/official/docs/python/v8/addresses/verify-param.py new file mode 100644 index 00000000..cd23d607 --- /dev/null +++ b/official/docs/python/v8/addresses/verify-param.py @@ -0,0 +1,18 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create( + verify=True, + street1="417 Montgomery Streat", + street2="5", + city="SF", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +print(address) diff --git a/official/docs/python/v8/addresses/verify-strict-param.py b/official/docs/python/v8/addresses/verify-strict-param.py new file mode 100644 index 00000000..49922dbb --- /dev/null +++ b/official/docs/python/v8/addresses/verify-strict-param.py @@ -0,0 +1,18 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create( + verify_strict=True, + street1="417 MONTGOMERY ST", + street2="FLOOR 5", + city="San Francisco", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +print(address) diff --git a/official/docs/python/v8/addresses/verify.py b/official/docs/python/v8/addresses/verify.py new file mode 100644 index 00000000..868376f1 --- /dev/null +++ b/official/docs/python/v8/addresses/verify.py @@ -0,0 +1,19 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +address = client.address.create( + street1="417 MONTGOMERY ST", + street2="FLOOR 5", + city="San Francisco", + state="CA", + zip="94104", + country="US", + company="EasyPost", + phone="415-123-4567", +) + +verified_address = client.address.verify(address.id) + +print(verified_address) diff --git a/official/docs/python/v8/api-keys/retrieve.py b/official/docs/python/v8/api-keys/retrieve.py new file mode 100644 index 00000000..0214d1bd --- /dev/null +++ b/official/docs/python/v8/api-keys/retrieve.py @@ -0,0 +1,14 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +# Retrieve all API keys including children +api_keys = client.api_key.all() + +print(api_keys) + +# Retrieve API keys for a specific child user +child_api_keys = client.api_key.retrieve_api_keys_for_user("user_...") + +print(child_api_keys) diff --git a/official/docs/python/v8/batches/add-shipments.py b/official/docs/python/v8/batches/add-shipments.py new file mode 100644 index 00000000..7d06c2b8 --- /dev/null +++ b/official/docs/python/v8/batches/add-shipments.py @@ -0,0 +1,16 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +batch_with_shipments = client.batch.add_shipments( + batch.id, + shipments=[ + {"id": "shp_..."}, + {"id": "shp_..."}, + ], +) + +print(batch_with_shipments) diff --git a/official/docs/python/v8/batches/buy.py b/official/docs/python/v8/batches/buy.py new file mode 100644 index 00000000..c96fdac2 --- /dev/null +++ b/official/docs/python/v8/batches/buy.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +bought_batch = client.batch.buy(batch.id) + +print(bought_batch) diff --git a/official/docs/python/v8/batches/create.py b/official/docs/python/v8/batches/create.py new file mode 100644 index 00000000..c40e9640 --- /dev/null +++ b/official/docs/python/v8/batches/create.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.create( + shipments=[ + {"id": "shp_..."}, + {"id": "shp_..."}, + ], +) + +print(batch) diff --git a/official/docs/python/v8/batches/label.py b/official/docs/python/v8/batches/label.py new file mode 100644 index 00000000..b40a8d4a --- /dev/null +++ b/official/docs/python/v8/batches/label.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +batch_with_label = client.batch.label(batch.id, file_format="PDF") + +print(batch_with_label) diff --git a/official/docs/python/v8/batches/list.py b/official/docs/python/v8/batches/list.py new file mode 100644 index 00000000..9c2fa0da --- /dev/null +++ b/official/docs/python/v8/batches/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batches = client.batch.all(page_size=5) + +print(batches) diff --git a/official/docs/python/v8/batches/remove-shipments.py b/official/docs/python/v8/batches/remove-shipments.py new file mode 100644 index 00000000..17b06bc2 --- /dev/null +++ b/official/docs/python/v8/batches/remove-shipments.py @@ -0,0 +1,17 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +batch_without_shipments = batch.remove_shipments( + batch.id, + shipments=[ + { + "id": "shp_...", + } + ], +) + +print(batch_without_shipments) diff --git a/official/docs/python/v8/batches/retrieve.py b/official/docs/python/v8/batches/retrieve.py new file mode 100644 index 00000000..ccbe7988 --- /dev/null +++ b/official/docs/python/v8/batches/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +print(batch) diff --git a/official/docs/python/v8/batches/scan-forms.py b/official/docs/python/v8/batches/scan-forms.py new file mode 100644 index 00000000..8be7f3d8 --- /dev/null +++ b/official/docs/python/v8/batches/scan-forms.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +batch = client.batch.retrieve("batch_...") + +batch_with_scan_form = client.batch.create_scan_form(batch.id) + +print(batch_with_scan_form) diff --git a/official/docs/python/v8/billing/create-ep-credit-card.py b/official/docs/python/v8/billing/create-ep-credit-card.py new file mode 100644 index 00000000..85537e1e --- /dev/null +++ b/official/docs/python/v8/billing/create-ep-credit-card.py @@ -0,0 +1,16 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +referral_user_api_key = os.getenv("REFERRAL_USER_API_KEY") + +credit_card = client.referral_customer.add_credit_card( + referral_api_key=referral_user_api_key, + number="0123456789101234", + expiration_month="01", + expiration_year="2025", + cvc="111", +) + +print(credit_card) diff --git a/official/docs/python/v8/billing/delete.py b/official/docs/python/v8/billing/delete.py new file mode 100644 index 00000000..fd1921c5 --- /dev/null +++ b/official/docs/python/v8/billing/delete.py @@ -0,0 +1,6 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +client.billing.delete_payment_method(primary_or_secondary="primary") diff --git a/official/docs/python/v8/billing/fund.py b/official/docs/python/v8/billing/fund.py new file mode 100644 index 00000000..73deedf3 --- /dev/null +++ b/official/docs/python/v8/billing/fund.py @@ -0,0 +1,9 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +client.billing.fund_wallet( + amount="2000", + primary_or_secondary="primary", +) diff --git a/official/docs/python/v8/billing/list.py b/official/docs/python/v8/billing/list.py new file mode 100644 index 00000000..c6a900b7 --- /dev/null +++ b/official/docs/python/v8/billing/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +payment_methods = client.billing.retrieve_payment_methods() + +print(payment_methods) diff --git a/official/docs/python/v8/brand/update.py b/official/docs/python/v8/brand/update.py new file mode 100644 index 00000000..20f69307 --- /dev/null +++ b/official/docs/python/v8/brand/update.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +user = client.user.retrieve_me() + +updated_brand = client.user.update_brand(user.id, color="#303F9F") + +print(updated_brand) diff --git a/official/docs/python/current/carbon-offset/buy.py b/official/docs/python/v8/carbon-offset/buy.py similarity index 100% rename from official/docs/python/current/carbon-offset/buy.py rename to official/docs/python/v8/carbon-offset/buy.py diff --git a/official/docs/python/current/carbon-offset/create.py b/official/docs/python/v8/carbon-offset/create.py similarity index 100% rename from official/docs/python/current/carbon-offset/create.py rename to official/docs/python/v8/carbon-offset/create.py diff --git a/official/docs/python/current/carbon-offset/one-call-buy.py b/official/docs/python/v8/carbon-offset/one-call-buy.py similarity index 100% rename from official/docs/python/current/carbon-offset/one-call-buy.py rename to official/docs/python/v8/carbon-offset/one-call-buy.py diff --git a/official/docs/python/v8/carrier-accounts/create.py b/official/docs/python/v8/carrier-accounts/create.py new file mode 100644 index 00000000..6eb72f7b --- /dev/null +++ b/official/docs/python/v8/carrier-accounts/create.py @@ -0,0 +1,23 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_account = client.carrier_account.create( + type="DhlEcsAccount", + description="CA Location DHL eCommerce Solutions Account", + credentials={ + "client_id": "123456", + "client_secret": "123abc", + "distribution_center": "USLAX1", + "pickup_id": "123456", + }, + test_credentials={ + "client_id": "123456", + "client_secret": "123abc", + "distribution_center": "USLAX1", + "pickup_id": "123456", + }, +) + +print(carrier_account) diff --git a/official/docs/python/v8/carrier-accounts/delete.py b/official/docs/python/v8/carrier-accounts/delete.py new file mode 100644 index 00000000..df5bc610 --- /dev/null +++ b/official/docs/python/v8/carrier-accounts/delete.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_account = client.carrier_account.retrieve("ca_...") + +client.carrier_account.delete(carrier_account.id) diff --git a/official/docs/python/v8/carrier-accounts/list.py b/official/docs/python/v8/carrier-accounts/list.py new file mode 100644 index 00000000..9880327d --- /dev/null +++ b/official/docs/python/v8/carrier-accounts/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_accounts = client.carrier_account.all() + +print(carrier_accounts) diff --git a/official/docs/python/v8/carrier-accounts/retrieve.py b/official/docs/python/v8/carrier-accounts/retrieve.py new file mode 100644 index 00000000..60b23450 --- /dev/null +++ b/official/docs/python/v8/carrier-accounts/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_account = client.carrier_account.retrieve("ca_...") + +print(carrier_account) diff --git a/official/docs/python/v8/carrier-accounts/update.py b/official/docs/python/v8/carrier-accounts/update.py new file mode 100644 index 00000000..50d3e18d --- /dev/null +++ b/official/docs/python/v8/carrier-accounts/update.py @@ -0,0 +1,14 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_account = client.carrier_account.retrieve("ca_...") + +updated_carrier_account = client.carrier_account.update( + carrier_account.id, + description="FL Location DHL eCommerce Solutions Account", + credentials={"pickup_id": "abc123"}, +) + +print(updated_carrier_account) diff --git a/official/docs/python/v8/carrier-metadata/retrieve.py b/official/docs/python/v8/carrier-metadata/retrieve.py new file mode 100644 index 00000000..dd6fcb02 --- /dev/null +++ b/official/docs/python/v8/carrier-metadata/retrieve.py @@ -0,0 +1,15 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +# Request all metadata for all carriers +carrier_metadata = client.carrier_metadata.retrieve() + +# Request specific metadata for specific carriers +carrier_metadata = client.carrier_metadata.retrieve( + carriers=["usps"], + types=["service_levels", "predefined_packages"], +) + +print(carrier_metadata) diff --git a/official/docs/python/v8/carrier-types/list.py b/official/docs/python/v8/carrier-types/list.py new file mode 100644 index 00000000..58255948 --- /dev/null +++ b/official/docs/python/v8/carrier-types/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +carrier_types = client.carrier_account.types() + +print(carrier_types) diff --git a/official/docs/python/v8/child-users/create.py b/official/docs/python/v8/child-users/create.py new file mode 100644 index 00000000..96ae8347 --- /dev/null +++ b/official/docs/python/v8/child-users/create.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +user = client.user.create(name="Child Account Name") + +print(user) diff --git a/official/docs/python/v8/child-users/delete.py b/official/docs/python/v8/child-users/delete.py new file mode 100644 index 00000000..d2f22d19 --- /dev/null +++ b/official/docs/python/v8/child-users/delete.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +user = client.user.retrieve("user_...") + +client.user.delete(user.id) diff --git a/official/docs/python/v8/customs-infos/create.py b/official/docs/python/v8/customs-infos/create.py new file mode 100644 index 00000000..220eba36 --- /dev/null +++ b/official/docs/python/v8/customs-infos/create.py @@ -0,0 +1,25 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +customs_info = client.customs_info.create( + eel_pfc="NOEEI 30.37(a)", + customs_certify=True, + customs_signer="Steve Brule", + contents_type="merchandise", + contents_explanation="", + restriction_type="none", + customs_items=[ + { + "description": "Sweet shirts", + "quantity": 2, + "weight": 11, + "value": 23, + "hs_tariff_number": "654321", + "origin_country": "US", + } + ], +) + +print(customs_info) diff --git a/official/docs/python/v8/customs-infos/retrieve.py b/official/docs/python/v8/customs-infos/retrieve.py new file mode 100644 index 00000000..2b2c21bc --- /dev/null +++ b/official/docs/python/v8/customs-infos/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +customs_info = client.customs_info.retrieve("cstinfo_...") + +print(customs_info) diff --git a/official/docs/python/v8/customs-items/create.py b/official/docs/python/v8/customs-items/create.py new file mode 100644 index 00000000..601a6284 --- /dev/null +++ b/official/docs/python/v8/customs-items/create.py @@ -0,0 +1,15 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +customs_item = client.customs_item.create( + description="T-shirt", + quantity=1, + value=10, + weight=5, + hs_tariff_number="123456", + origin_country="us", +) + +print(customs_item) diff --git a/official/docs/python/v8/customs-items/retrieve.py b/official/docs/python/v8/customs-items/retrieve.py new file mode 100644 index 00000000..515c414f --- /dev/null +++ b/official/docs/python/v8/customs-items/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +customs_item = client.customs_item.retrieve("cstitem_...") + +print(customs_item) diff --git a/official/docs/python/v8/endshipper/buy.py b/official/docs/python/v8/endshipper/buy.py new file mode 100644 index 00000000..56192fe4 --- /dev/null +++ b/official/docs/python/v8/endshipper/buy.py @@ -0,0 +1,14 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +bought_shipment = client.shipment.buy( + shipment.id, + rate=shipment.lowest_rate(), + end_shipper_id="es_...", +) + +print(bought_shipment) diff --git a/official/docs/python/v8/endshipper/create.py b/official/docs/python/v8/endshipper/create.py new file mode 100644 index 00000000..f2485b65 --- /dev/null +++ b/official/docs/python/v8/endshipper/create.py @@ -0,0 +1,19 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +end_shipper = client.end_shipper.create( + name="FOO BAR", + company="BAZ", + street1="164 TOWNSEND STREET UNIT 1", + street2="UNIT 1", + city="SAN FRANCISCO", + state="CA", + zip="94107", + country="US", + phone="555-555-5555", + email="FOO@EXAMPLE.COM", +) + +print(end_shipper) diff --git a/official/docs/python/v8/endshipper/list.py b/official/docs/python/v8/endshipper/list.py new file mode 100644 index 00000000..7f099248 --- /dev/null +++ b/official/docs/python/v8/endshipper/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +end_shippers = client.end_shipper.all(page_size=5) + +print(end_shippers) diff --git a/official/docs/python/v8/endshipper/retrieve.py b/official/docs/python/v8/endshipper/retrieve.py new file mode 100644 index 00000000..132e99b9 --- /dev/null +++ b/official/docs/python/v8/endshipper/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +retrieved_endshipper = client.end_shipper.retrieve("es_...") + +print(retrieved_endshipper) diff --git a/official/docs/python/v8/endshipper/update.py b/official/docs/python/v8/endshipper/update.py new file mode 100644 index 00000000..3dea9d4c --- /dev/null +++ b/official/docs/python/v8/endshipper/update.py @@ -0,0 +1,22 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +end_shipper = client.end_shipper.retrieve("es_...") + +updated_end_shipper = client.end_shipper.update( + end_shipper.id, + name="NEW NAME", + company="BAZ", + street1="164 TOWNSEND STREET UNIT 1", + street2="UNIT 1", + city="SAN FRANCISCO", + state="CA", + zip="94107", + country="US", + phone="555-555-5555", + email="FOO@EXAMPLE.COM", +) + +print(updated_end_shipper) diff --git a/official/docs/python/v8/events/list.py b/official/docs/python/v8/events/list.py new file mode 100644 index 00000000..c2db8139 --- /dev/null +++ b/official/docs/python/v8/events/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +events = client.event.all(page_size=5) + +print(events) diff --git a/official/docs/python/v8/events/retrieve.py b/official/docs/python/v8/events/retrieve.py new file mode 100644 index 00000000..c9c83e86 --- /dev/null +++ b/official/docs/python/v8/events/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +event = client.event.retrieve("evt_...") + +print(event) diff --git a/official/docs/python/v8/forms/create.py b/official/docs/python/v8/forms/create.py new file mode 100644 index 00000000..060fc018 --- /dev/null +++ b/official/docs/python/v8/forms/create.py @@ -0,0 +1,24 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +form_type = "return_packing_slip" +form_options = { + "barcode": "RMA12345678900", + "line_items": [ + { + "product": { + "title": "Square Reader", + "barcode": "855658003251", + }, + "units": 8, + }, + ], +} + +shipment_with_form = client.shipment.generate_form(shipment.id, form_type, form_options) + +print(shipment_with_form) diff --git a/official/docs/python/v8/insurance/create.py b/official/docs/python/v8/insurance/create.py new file mode 100644 index 00000000..f60ca981 --- /dev/null +++ b/official/docs/python/v8/insurance/create.py @@ -0,0 +1,15 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +insurance = client.insurance.create( + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + tracking_code="9400110898825022579493", + carrier="USPS", + amount="100.00", + reference="insuranceRef1", +) + +print(insurance) diff --git a/official/docs/python/v8/insurance/list.py b/official/docs/python/v8/insurance/list.py new file mode 100644 index 00000000..064c7e83 --- /dev/null +++ b/official/docs/python/v8/insurance/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +insurances = client.insurance.all(page_size=5) + +print(insurances) diff --git a/official/docs/python/v8/insurance/retrieve.py b/official/docs/python/v8/insurance/retrieve.py new file mode 100644 index 00000000..52ee898c --- /dev/null +++ b/official/docs/python/v8/insurance/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +insurance = client.insurance.retrieve("ins_...") + +print(insurance) diff --git a/official/docs/python/v8/options/create-with-options.py b/official/docs/python/v8/options/create-with-options.py new file mode 100644 index 00000000..66a4d5aa --- /dev/null +++ b/official/docs/python/v8/options/create-with-options.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.create( + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + parcel={"id": "prcl_..."}, + options={"print_custom_1": "Custom label message"}, +) + +print(shipment) diff --git a/official/docs/python/v8/orders/buy.py b/official/docs/python/v8/orders/buy.py new file mode 100644 index 00000000..64312d0f --- /dev/null +++ b/official/docs/python/v8/orders/buy.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +order = client.order.retrieve("order_...") +bought_order = client.order.buy( + order.id, + carrier="FedEx", + service="FEDEX_GROUND", +) + +print(order) diff --git a/official/docs/python/v8/orders/create.py b/official/docs/python/v8/orders/create.py new file mode 100644 index 00000000..85546ace --- /dev/null +++ b/official/docs/python/v8/orders/create.py @@ -0,0 +1,25 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +order = client.order.create( + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + shipments=[ + { + "parcel": { + "predefined_package": "FedExBox", + "weight": 10.2, + } + }, + { + "parcel": { + "predefined_package": "FedExBox", + "weight": 17.5, + } + }, + ], +) + +print(order) diff --git a/official/docs/python/v8/orders/one-call-buy.py b/official/docs/python/v8/orders/one-call-buy.py new file mode 100644 index 00000000..be9f2f84 --- /dev/null +++ b/official/docs/python/v8/orders/one-call-buy.py @@ -0,0 +1,27 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +order = client.order.create( + carrier_accounts=["ca_..."], + service="NextDayAir", + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + shipments=[ + { + "parcel": { + "predefined_package": "FedExBox", + "weight": 10.2, + } + }, + { + "parcel": { + "predefined_package": "FedExBox", + "weight": 17.5, + } + }, + ], +) + +print(order) diff --git a/official/docs/python/v8/orders/retrieve.py b/official/docs/python/v8/orders/retrieve.py new file mode 100644 index 00000000..d430c514 --- /dev/null +++ b/official/docs/python/v8/orders/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +order = client.order.retrieve("order_...") + +print(order) diff --git a/official/docs/python/v8/pagination/get-next-page.py b/official/docs/python/v8/pagination/get-next-page.py new file mode 100644 index 00000000..67d4b7cd --- /dev/null +++ b/official/docs/python/v8/pagination/get-next-page.py @@ -0,0 +1,14 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +# Get first page of results +shipments = client.shipment.all( + page_size=5, +) + +# Provide the previous results page to move onto the next page +next_page = client.shipments.get_next_page(shipments) + +print(next_page) diff --git a/official/docs/python/v8/parcels/create.py b/official/docs/python/v8/parcels/create.py new file mode 100644 index 00000000..e9cea728 --- /dev/null +++ b/official/docs/python/v8/parcels/create.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +parcel = client.parcel.create( + length=20.2, + width=10.9, + height=5, + weight=65.9, +) + +print(parcel) diff --git a/official/docs/python/v8/parcels/retrieve.py b/official/docs/python/v8/parcels/retrieve.py new file mode 100644 index 00000000..390846fa --- /dev/null +++ b/official/docs/python/v8/parcels/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +parcel = client.parcel.retrieve("prcl_...") + +print(parcel) diff --git a/official/docs/python/v8/payloads/list.py b/official/docs/python/v8/payloads/list.py new file mode 100644 index 00000000..2245179e --- /dev/null +++ b/official/docs/python/v8/payloads/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +payload = client.event.retrieve_all_payloads("evt_...") + +print(payload) diff --git a/official/docs/python/v8/payloads/retrieve.py b/official/docs/python/v8/payloads/retrieve.py new file mode 100644 index 00000000..f19485f0 --- /dev/null +++ b/official/docs/python/v8/payloads/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +payload = client.event.retrieve_payload("evt_...", "payload_...") + +print(payload) diff --git a/official/docs/python/v8/pickups/buy.py b/official/docs/python/v8/pickups/buy.py new file mode 100644 index 00000000..350f25d9 --- /dev/null +++ b/official/docs/python/v8/pickups/buy.py @@ -0,0 +1,15 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + + +pickup = client.pickup.retrieve("pickup_...") + +bought_pickup = client.pickup.buy( + pickup.id, + carrier="UPS", + service="Same-day Pickup", +) + +print(bought_pickup) diff --git a/official/docs/python/v8/pickups/cancel.py b/official/docs/python/v8/pickups/cancel.py new file mode 100644 index 00000000..30121123 --- /dev/null +++ b/official/docs/python/v8/pickups/cancel.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +pickup = client.pickup.retrieve("pickup_...") + +cancelled_pickup = client.pickup.cancel(pickup.id) + +print(cancelled_pickup) diff --git a/official/docs/python/v8/pickups/create.py b/official/docs/python/v8/pickups/create.py new file mode 100644 index 00000000..75b72595 --- /dev/null +++ b/official/docs/python/v8/pickups/create.py @@ -0,0 +1,16 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +pickup = client.pickup.create( + address={"id": "adr_..."}, + shipment={"id": "shp_..."}, + reference="my-first-pickup", + min_datetime="2022-10-01 10:30:00", + max_datetime="2022-10-02 10:30:00", + is_account_address=False, + instructions="Special pickup instructions", +) + +print(pickup) diff --git a/official/docs/python/v8/pickups/list.py b/official/docs/python/v8/pickups/list.py new file mode 100644 index 00000000..23e38b7f --- /dev/null +++ b/official/docs/python/v8/pickups/list.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +pickups = client.pickup.all( + page_size=5, +) + +print(pickups) diff --git a/official/docs/python/v8/pickups/retrieve.py b/official/docs/python/v8/pickups/retrieve.py new file mode 100644 index 00000000..955ae2d9 --- /dev/null +++ b/official/docs/python/v8/pickups/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +pickup = client.pickup.retrieve("pickup_...") + +print(pickup) diff --git a/official/docs/python/v8/rates/regenerate.py b/official/docs/python/v8/rates/regenerate.py new file mode 100644 index 00000000..218e736e --- /dev/null +++ b/official/docs/python/v8/rates/regenerate.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +shipment_with_regenerated_rates = client.shipment.regenerate_rates(shipment.id) + +print(shipment_with_regenerated_rates) diff --git a/official/docs/python/v8/rates/retrieve-stateless.py b/official/docs/python/v8/rates/retrieve-stateless.py new file mode 100644 index 00000000..88911ef5 --- /dev/null +++ b/official/docs/python/v8/rates/retrieve-stateless.py @@ -0,0 +1,38 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment_details = { + "to_address": { + "name": "Dr. Steve Brule", + "street1": "179 N Harbor Dr", + "city": "Redondo Beach", + "state": "CA", + "zip": "90277", + "country": "US", + "phone": "4153334444", + "email": "dr_steve_brule@gmail.com", + }, + "from_address": { + "name": "EasyPost", + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334444", + "email": "support@easypost.com", + }, + "parcel": { + "length": 20.2, + "width": 10.9, + "height": 5, + "weight": 65.9, + }, +} + +rates = client.beta_rate.retrieve_stateless_rates(**shipment_details) + +print(rates) diff --git a/official/docs/python/v8/rates/retrieve.py b/official/docs/python/v8/rates/retrieve.py new file mode 100644 index 00000000..22d9eb3f --- /dev/null +++ b/official/docs/python/v8/rates/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +rate = client.rate.retrieve("rate...") + +print(rate) diff --git a/official/docs/python/v8/referral-customers/add-payment-method-with-bank-account.py b/official/docs/python/v8/referral-customers/add-payment-method-with-bank-account.py new file mode 100644 index 00000000..d88f9867 --- /dev/null +++ b/official/docs/python/v8/referral-customers/add-payment-method-with-bank-account.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +payment_method = client.beta_referral_customer.add_payment_method( + stripe_customer_id="cus_...", + payment_method_reference="ba_...", + primary_or_secondary="primary", +) + +print(payment_method) diff --git a/official/docs/python/v8/referral-customers/add-payment-method-with-credit-card.py b/official/docs/python/v8/referral-customers/add-payment-method-with-credit-card.py new file mode 100644 index 00000000..99dcb803 --- /dev/null +++ b/official/docs/python/v8/referral-customers/add-payment-method-with-credit-card.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +payment_method = client.beta_referral_customer.add_payment_method( + stripe_customer_id="cus_...", + payment_method_reference="card_...", + primary_or_secondary="primary", +) + +print(payment_method) diff --git a/official/docs/python/v8/referral-customers/create.py b/official/docs/python/v8/referral-customers/create.py new file mode 100644 index 00000000..aefba7ef --- /dev/null +++ b/official/docs/python/v8/referral-customers/create.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +referral_user = client.referral_customer.create( + name="test test", + email="test@test.com", + phone="8888888888", +) + +print(referral_user) diff --git a/official/docs/python/v8/referral-customers/list.py b/official/docs/python/v8/referral-customers/list.py new file mode 100644 index 00000000..71b53384 --- /dev/null +++ b/official/docs/python/v8/referral-customers/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +referral_users = client.referral_customer.all(page_size=5) + +print(referral_users) diff --git a/official/docs/python/v8/referral-customers/refund-by-amount.py b/official/docs/python/v8/referral-customers/refund-by-amount.py new file mode 100644 index 00000000..31780c8e --- /dev/null +++ b/official/docs/python/v8/referral-customers/refund-by-amount.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +refund = client.beta_referral_customer.refund_by_amount(refund_amount=2000) + +print(refund) diff --git a/official/docs/python/v8/referral-customers/refund-by-payment-log.py b/official/docs/python/v8/referral-customers/refund-by-payment-log.py new file mode 100644 index 00000000..496e4cdd --- /dev/null +++ b/official/docs/python/v8/referral-customers/refund-by-payment-log.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +refund = client.beta_referral_customer.refund_by_payment_log(payment_log_id="paylog_...") + +print(refund) diff --git a/official/docs/python/v8/referral-customers/update.py b/official/docs/python/v8/referral-customers/update.py new file mode 100644 index 00000000..34d156d2 --- /dev/null +++ b/official/docs/python/v8/referral-customers/update.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +user = client.user.retrieve("usr_...") + +client.referral_customer.update_email( + user.id, + "new_email@example.com", + "user_...", +) diff --git a/official/docs/python/v8/refunds/create.py b/official/docs/python/v8/refunds/create.py new file mode 100644 index 00000000..0fba5df5 --- /dev/null +++ b/official/docs/python/v8/refunds/create.py @@ -0,0 +1,11 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +refunds = client.refund.create( + carrier="USPS", + tracking_codes=["EZ1000000001"], +) + +print(refunds) diff --git a/official/docs/python/v8/refunds/list.py b/official/docs/python/v8/refunds/list.py new file mode 100644 index 00000000..13e64adb --- /dev/null +++ b/official/docs/python/v8/refunds/list.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +refunds = client.refund.all( + page_size=5, +) + +print(refunds) diff --git a/official/docs/python/v8/refunds/retrieve.py b/official/docs/python/v8/refunds/retrieve.py new file mode 100644 index 00000000..b2639c5d --- /dev/null +++ b/official/docs/python/v8/refunds/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +refund = client.refund.retrieve("rfnd_...") + +print(refund) diff --git a/official/docs/python/v8/reports/create.py b/official/docs/python/v8/reports/create.py new file mode 100644 index 00000000..8cb8eec6 --- /dev/null +++ b/official/docs/python/v8/reports/create.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +report = client.report.create( + type="payment_log", + start_date="2022-10-01", + end_date="2022-10-31", +) + +print(report) diff --git a/official/docs/python/v8/reports/list.py b/official/docs/python/v8/reports/list.py new file mode 100644 index 00000000..363f8463 --- /dev/null +++ b/official/docs/python/v8/reports/list.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +reports = client.report.all( + # Replace `payment_log` with any of the report types listed above + type="payment_log", + page_size=5, +) + +print(reports) diff --git a/official/docs/python/v8/reports/retrieve.py b/official/docs/python/v8/reports/retrieve.py new file mode 100644 index 00000000..e047308a --- /dev/null +++ b/official/docs/python/v8/reports/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +report = client.report.retrieve("") + +print(report) diff --git a/official/docs/python/v8/returns/create.py b/official/docs/python/v8/returns/create.py new file mode 100644 index 00000000..bc84e9b3 --- /dev/null +++ b/official/docs/python/v8/returns/create.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.create( + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + parcel={"id": "prcl_..."}, + is_return=True, +) + +print(shipment) diff --git a/official/docs/python/v8/scan-form/create.py b/official/docs/python/v8/scan-form/create.py new file mode 100644 index 00000000..5686f984 --- /dev/null +++ b/official/docs/python/v8/scan-form/create.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +scan_form = client.scan_form.create( + shipments=[ + {"id": "shp_..."}, + {"id": "shp_..."}, + ] +) + +print(scan_form) diff --git a/official/docs/python/v8/scan-form/list.py b/official/docs/python/v8/scan-form/list.py new file mode 100644 index 00000000..10acba44 --- /dev/null +++ b/official/docs/python/v8/scan-form/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +scan_forms = client.scan_form.all(page_size=5) + +print(scan_forms) diff --git a/official/docs/python/v8/scan-form/retrieve.py b/official/docs/python/v8/scan-form/retrieve.py new file mode 100644 index 00000000..b846487f --- /dev/null +++ b/official/docs/python/v8/scan-form/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +scan_form = client.scan_form.retrieve("sf_...") + +print(scan_form) diff --git a/official/docs/python/v8/shipments/buy.py b/official/docs/python/v8/shipments/buy.py new file mode 100644 index 00000000..887d4c44 --- /dev/null +++ b/official/docs/python/v8/shipments/buy.py @@ -0,0 +1,14 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +bought_shipment = client.shipment.buy( + shipment.id, + rate=shipment.lowest_rate(), + insurance=249.99, +) + +print(bought_shipment) diff --git a/official/docs/python/v8/shipments/create.py b/official/docs/python/v8/shipments/create.py new file mode 100644 index 00000000..4e237b4e --- /dev/null +++ b/official/docs/python/v8/shipments/create.py @@ -0,0 +1,46 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.create( + to_address={ + "name": "Dr. Steve Brule", + "street1": "179 N Harbor Dr", + "city": "Redondo Beach", + "state": "CA", + "zip": "90277", + "country": "US", + "phone": "4153334444", + "email": "dr_steve_brule@gmail.com", + }, + from_address={ + "name": "EasyPost", + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334444", + "email": "support@easypost.com", + }, + parcel={ + "length": 20.2, + "width": 10.9, + "height": 5, + "weight": 65.9, + }, + customs_info={"id": "cstinfo_..."}, +) + +# or create by using IDs + +shipment = client.shipment.create( + to_address={"id": "adr_..."}, + from_address={"id": "adr_..."}, + parcel={"id": "prcl_..."}, + customs_info={"id": "cstinfo_..."}, +) + +print(shipment) diff --git a/official/docs/python/v8/shipments/label.py b/official/docs/python/v8/shipments/label.py new file mode 100644 index 00000000..87b34792 --- /dev/null +++ b/official/docs/python/v8/shipments/label.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +shipment_with_label = client.shipment.label(shipment.id, file_format="ZPL") + +print(shipment_with_label) diff --git a/official/docs/python/v8/shipments/list.py b/official/docs/python/v8/shipments/list.py new file mode 100644 index 00000000..e44684a2 --- /dev/null +++ b/official/docs/python/v8/shipments/list.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipments = client.shipment.all( + page_size=5, +) + +print(shipments) diff --git a/official/docs/python/v8/shipments/one-call-buy.py b/official/docs/python/v8/shipments/one-call-buy.py new file mode 100644 index 00000000..2fd13610 --- /dev/null +++ b/official/docs/python/v8/shipments/one-call-buy.py @@ -0,0 +1,38 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.create( + carrier_accounts=["ca_..."], + service="NextDayAir", + to_address={ + "name": "Dr. Steve Brule", + "street1": "179 N Harbor Dr", + "city": "Redondo Beach", + "state": "CA", + "zip": "90277", + "country": "US", + "phone": "4153334444", + "email": "dr_steve_brule@gmail.com", + }, + from_address={ + "name": "EasyPost", + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334444", + "email": "support@easypost.com", + }, + parcel={ + "length": 20.2, + "width": 10.9, + "height": 5, + "weight": 65.9, + }, +) + +print(shipment) diff --git a/official/docs/python/v8/shipments/retrieve.py b/official/docs/python/v8/shipments/retrieve.py new file mode 100644 index 00000000..bce3ecb1 --- /dev/null +++ b/official/docs/python/v8/shipments/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +print(shipment) diff --git a/official/docs/python/v8/shipping-insurance/insure.py b/official/docs/python/v8/shipping-insurance/insure.py new file mode 100644 index 00000000..a9ac67d0 --- /dev/null +++ b/official/docs/python/v8/shipping-insurance/insure.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +insured_shipment = client.shipment.insure(shipment.id, amount=100) + +print(insured_shipment) diff --git a/official/docs/python/v8/shipping-refund/refund.py b/official/docs/python/v8/shipping-refund/refund.py new file mode 100644 index 00000000..daed2757 --- /dev/null +++ b/official/docs/python/v8/shipping-refund/refund.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +refunded_shipment = client.shipment.refund(shipment.id) + +print(refunded_shipment) diff --git a/official/docs/python/v8/smartrate/retrieve-estimated-delivery-date.py b/official/docs/python/v8/smartrate/retrieve-estimated-delivery-date.py new file mode 100644 index 00000000..ca30eb89 --- /dev/null +++ b/official/docs/python/v8/smartrate/retrieve-estimated-delivery-date.py @@ -0,0 +1,13 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +estimated_delivery_dates = client.shipment.retrieve_estimated_delivery_date( + shipment.id, + planned_ship_date="YYYY-MM-DD", +) + +print(estimated_delivery_dates) diff --git a/official/docs/python/v8/smartrate/retrieve-time-in-transit-statistics.py b/official/docs/python/v8/smartrate/retrieve-time-in-transit-statistics.py new file mode 100644 index 00000000..99b75687 --- /dev/null +++ b/official/docs/python/v8/smartrate/retrieve-time-in-transit-statistics.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.retrieve("shp_...") + +smart_rates = client.shipment.get_smart_rates(shipment.id) + +print(smart_rates) diff --git a/official/docs/python/v8/tax-identifiers/create.py b/official/docs/python/v8/tax-identifiers/create.py new file mode 100644 index 00000000..101f8459 --- /dev/null +++ b/official/docs/python/v8/tax-identifiers/create.py @@ -0,0 +1,45 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +shipment = client.shipment.create( + to_address={ + "name": "Dr. Steve Brule", + "street1": "179 N Harbor Dr", + "city": "Redondo Beach", + "state": "CA", + "zip": "90277", + "country": "US", + "phone": "4153334444", + "email": "dr_steve_brule@gmail.com", + }, + from_address={ + "name": "EasyPost", + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334444", + "email": "support@easypost.com", + }, + parcel={ + "length": 20.2, + "width": 10.9, + "height": 5, + "weight": 65.9, + }, + customs_info={"id": "cstinfo_..."}, + tax_identifiers=[ + { + "entity": "SENDER", + "tax_id": "GB123456789", + "tax_id_type": "IOSS", + "issuing_country": "GB", + } + ], +) + +print(shipment) diff --git a/official/docs/python/v8/trackers/create.py b/official/docs/python/v8/trackers/create.py new file mode 100644 index 00000000..a3704c37 --- /dev/null +++ b/official/docs/python/v8/trackers/create.py @@ -0,0 +1,11 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +tracker = client.tracker.create( + tracking_code="EZ1000000001", + carrier="USPS", +) + +print(tracker) diff --git a/official/docs/python/v8/trackers/list.py b/official/docs/python/v8/trackers/list.py new file mode 100644 index 00000000..6300d8f6 --- /dev/null +++ b/official/docs/python/v8/trackers/list.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +trackers = client.tracker.all( + page_size=5, +) + +print(trackers) diff --git a/official/docs/python/v8/trackers/retrieve.py b/official/docs/python/v8/trackers/retrieve.py new file mode 100644 index 00000000..d409dda7 --- /dev/null +++ b/official/docs/python/v8/trackers/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +tracker = client.tracker.retrieve("trk_...") + +print(tracker) diff --git a/official/docs/python/v8/users/retrieve.py b/official/docs/python/v8/users/retrieve.py new file mode 100644 index 00000000..d91f1ef7 --- /dev/null +++ b/official/docs/python/v8/users/retrieve.py @@ -0,0 +1,12 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +# Retrieve the authenticated user +user = client.user.retrieve_me() + +# Retrieve a child user +user = client.user.retrieve("user_...") + +print(user) diff --git a/official/docs/python/v8/users/update.py b/official/docs/python/v8/users/update.py new file mode 100644 index 00000000..feb7a466 --- /dev/null +++ b/official/docs/python/v8/users/update.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +user = client.user.retrieve_me() + +updated_user = client.user.update(user.id, recharge_threshold="50.00") + +print(updated_user) diff --git a/official/docs/python/v8/webhooks/create.py b/official/docs/python/v8/webhooks/create.py new file mode 100644 index 00000000..563a0d4d --- /dev/null +++ b/official/docs/python/v8/webhooks/create.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +webhook = client.webhook.create(url="example.com") + +print(webhook) diff --git a/official/docs/python/v8/webhooks/delete.py b/official/docs/python/v8/webhooks/delete.py new file mode 100644 index 00000000..55a5ffcd --- /dev/null +++ b/official/docs/python/v8/webhooks/delete.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +webhook = client.webhook.retrieve("hook_...") + +client.webhook.delete(webhook.id) diff --git a/official/docs/python/v8/webhooks/list.py b/official/docs/python/v8/webhooks/list.py new file mode 100644 index 00000000..c33a3e95 --- /dev/null +++ b/official/docs/python/v8/webhooks/list.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +webhooks = client.webhook.all() + +print(webhooks) diff --git a/official/docs/python/v8/webhooks/retrieve.py b/official/docs/python/v8/webhooks/retrieve.py new file mode 100644 index 00000000..5eb0be88 --- /dev/null +++ b/official/docs/python/v8/webhooks/retrieve.py @@ -0,0 +1,8 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +webhook = client.webhook.retrieve("hook_...") + +print(webhook) diff --git a/official/docs/python/v8/webhooks/update.py b/official/docs/python/v8/webhooks/update.py new file mode 100644 index 00000000..ccf8fa2c --- /dev/null +++ b/official/docs/python/v8/webhooks/update.py @@ -0,0 +1,10 @@ +import easypost +import os + +client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) + +webhook = client.webhook.retrieve("hook_...") + +updated_webhook = client.webhook.update(webhook.id) + +print(updated_webhook) diff --git a/official/docs/ruby/v5/addresses/create-and-verify.rb b/official/docs/ruby/v5/addresses/create-and-verify.rb new file mode 100644 index 00000000..9199bc9b --- /dev/null +++ b/official/docs/ruby/v5/addresses/create-and-verify.rb @@ -0,0 +1,16 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create_and_verify( + street1: '417 Montgomery Street', + street2: 'FL 5', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +puts address diff --git a/official/docs/ruby/v5/addresses/create.rb b/official/docs/ruby/v5/addresses/create.rb new file mode 100644 index 00000000..abe38d81 --- /dev/null +++ b/official/docs/ruby/v5/addresses/create.rb @@ -0,0 +1,16 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create( + street1: '417 MONTGOMERY ST', + street2: 'FLOOR 5', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +puts address diff --git a/official/docs/ruby/v5/addresses/list.rb b/official/docs/ruby/v5/addresses/list.rb new file mode 100644 index 00000000..05963408 --- /dev/null +++ b/official/docs/ruby/v5/addresses/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +addresses = client.address.all( + page_size: 5, +) + +puts addresses diff --git a/official/docs/ruby/v5/addresses/retrieve.rb b/official/docs/ruby/v5/addresses/retrieve.rb new file mode 100644 index 00000000..d5d2c4c6 --- /dev/null +++ b/official/docs/ruby/v5/addresses/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.retrieve('adr_...') + +puts address diff --git a/official/docs/ruby/v5/addresses/verify-failure.rb b/official/docs/ruby/v5/addresses/verify-failure.rb new file mode 100644 index 00000000..526f058d --- /dev/null +++ b/official/docs/ruby/v5/addresses/verify-failure.rb @@ -0,0 +1,15 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create( + street1: 'UNDELIVERABLE ST', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +puts address diff --git a/official/docs/ruby/v5/addresses/verify-param.rb b/official/docs/ruby/v5/addresses/verify-param.rb new file mode 100644 index 00000000..f72a07f9 --- /dev/null +++ b/official/docs/ruby/v5/addresses/verify-param.rb @@ -0,0 +1,17 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create( + verify: true, + street1: '417 Montgomery Street', + street2: '5', + city: 'SF', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +puts address diff --git a/official/docs/ruby/v5/addresses/verify-strict-param.rb b/official/docs/ruby/v5/addresses/verify-strict-param.rb new file mode 100644 index 00000000..48cb7535 --- /dev/null +++ b/official/docs/ruby/v5/addresses/verify-strict-param.rb @@ -0,0 +1,17 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create( + verify_strict: true, + street1: '417 MONTGOMERY ST', + street2: 'FLOOR 5', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +puts address diff --git a/official/docs/ruby/v5/addresses/verify.rb b/official/docs/ruby/v5/addresses/verify.rb new file mode 100644 index 00000000..98293c89 --- /dev/null +++ b/official/docs/ruby/v5/addresses/verify.rb @@ -0,0 +1,18 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +address = client.address.create( + street1: '417 MONTGOMERY ST', + street2: 'FLOOR 5', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94104', + country: 'US', + company: 'EasyPost', + phone: '415-123-4567', +) + +verified_address = client.address.verify(address.id) + +puts verified_address diff --git a/official/docs/ruby/v5/api-keys/retrieve.rb b/official/docs/ruby/v5/api-keys/retrieve.rb new file mode 100644 index 00000000..3a582be6 --- /dev/null +++ b/official/docs/ruby/v5/api-keys/retrieve.rb @@ -0,0 +1,13 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +# Retrieve all API keys including children +api_keys = client.api_key.all + +puts api_keys + +# Retrieve API keys for a specific child user +child_api_keys = client.api_key.retrieve_api_keys_for_user('user_...') + +puts child_api_keys diff --git a/official/docs/ruby/v5/batches/add-shipments.rb b/official/docs/ruby/v5/batches/add-shipments.rb new file mode 100644 index 00000000..1b00251f --- /dev/null +++ b/official/docs/ruby/v5/batches/add-shipments.rb @@ -0,0 +1,15 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_batch = client.batch.retrieve('batch_...') + +batch = client.batch.add_shipments( + retrieved_batch.id, + shipments: [ + { id: 'shp_...' }, + { id: 'shp_...' }, + ], +) + +puts batch diff --git a/official/docs/ruby/v5/batches/buy.rb b/official/docs/ruby/v5/batches/buy.rb new file mode 100644 index 00000000..a5d342ea --- /dev/null +++ b/official/docs/ruby/v5/batches/buy.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +batch = client.batch.buy('batch_...') + +puts batch diff --git a/official/docs/ruby/v5/batches/create.rb b/official/docs/ruby/v5/batches/create.rb new file mode 100644 index 00000000..7d578395 --- /dev/null +++ b/official/docs/ruby/v5/batches/create.rb @@ -0,0 +1,15 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_batch = client.batch.retrieve('batch_...') + +batch = client.batch.create( + retrieved_batch.id, + shipments: [ + { id: 'shp_...' }, + { id: 'shp_...' }, + ], +) + +puts batch diff --git a/official/docs/ruby/v5/batches/label.rb b/official/docs/ruby/v5/batches/label.rb new file mode 100644 index 00000000..10682df0 --- /dev/null +++ b/official/docs/ruby/v5/batches/label.rb @@ -0,0 +1,12 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_batch = client.batch.retrieve('batch_...') + +label_batch = client.batch.label( + retrieved_batch.id, + file_format: 'PDF', +) + +puts label_batch diff --git a/official/docs/ruby/v5/batches/list.rb b/official/docs/ruby/v5/batches/list.rb new file mode 100644 index 00000000..76eee306 --- /dev/null +++ b/official/docs/ruby/v5/batches/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +batches = client.batch.all( + page_size: 5, +) + +puts batches diff --git a/official/docs/ruby/v5/batches/remove-shipments.rb b/official/docs/ruby/v5/batches/remove-shipments.rb new file mode 100644 index 00000000..17a899d9 --- /dev/null +++ b/official/docs/ruby/v5/batches/remove-shipments.rb @@ -0,0 +1,14 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_batch = client.batch.retrieve('batch_...') + +batch = client.batch.remove_shipments( + retrieved_batch, + shipments: [ + { id: 'shp_...' }, + ], +) + +puts batch diff --git a/official/docs/ruby/v5/batches/retrieve.rb b/official/docs/ruby/v5/batches/retrieve.rb new file mode 100644 index 00000000..0bc1b7c5 --- /dev/null +++ b/official/docs/ruby/v5/batches/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +batch = client.batch.retrieve('batch_...') + +puts batch diff --git a/official/docs/ruby/v5/batches/scan-forms.rb b/official/docs/ruby/v5/batches/scan-forms.rb new file mode 100644 index 00000000..8ca6d966 --- /dev/null +++ b/official/docs/ruby/v5/batches/scan-forms.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_batch = client.batch.retrieve('batch_...') + +batch = client.batch.create_scan_form(retrieved_batch.id) + +puts batch diff --git a/official/docs/ruby/v5/billing/create-ep-credit-card.rb b/official/docs/ruby/v5/billing/create-ep-credit-card.rb new file mode 100644 index 00000000..f1605a7a --- /dev/null +++ b/official/docs/ruby/v5/billing/create-ep-credit-card.rb @@ -0,0 +1,15 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +referral_user_api_key = ENV['REFERRAL_USER_API_KEY'] + +credit_card = client.referral_customer.add_credit_card( + referral_user_api_key, + '0123456789101234', + '01', + '2025', + '111', +) + +puts credit_card diff --git a/official/docs/ruby/v5/billing/delete.rb b/official/docs/ruby/v5/billing/delete.rb new file mode 100644 index 00000000..7f1527af --- /dev/null +++ b/official/docs/ruby/v5/billing/delete.rb @@ -0,0 +1,5 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +client.referral_customer.delete('primary') diff --git a/official/docs/ruby/v5/billing/fund.rb b/official/docs/ruby/v5/billing/fund.rb new file mode 100644 index 00000000..a5f85fd2 --- /dev/null +++ b/official/docs/ruby/v5/billing/fund.rb @@ -0,0 +1,5 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +client.billing.fund_wallet('2000', 'primary') diff --git a/official/docs/ruby/v5/billing/list.rb b/official/docs/ruby/v5/billing/list.rb new file mode 100644 index 00000000..87a23db7 --- /dev/null +++ b/official/docs/ruby/v5/billing/list.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +payment_methods = client.billing.retrieve_payment_methods + +puts payment_methods diff --git a/official/docs/ruby/v5/brand/update.rb b/official/docs/ruby/v5/brand/update.rb new file mode 100644 index 00000000..c81cdf91 --- /dev/null +++ b/official/docs/ruby/v5/brand/update.rb @@ -0,0 +1,12 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +user = client.user.retrieve_me + +brand = client.user.update_brand( + user.id, + color: '#303F9F', +) + +puts brand diff --git a/official/docs/ruby/current/carbon-offset/buy.rb b/official/docs/ruby/v5/carbon-offset/buy.rb similarity index 100% rename from official/docs/ruby/current/carbon-offset/buy.rb rename to official/docs/ruby/v5/carbon-offset/buy.rb diff --git a/official/docs/ruby/current/carbon-offset/create.rb b/official/docs/ruby/v5/carbon-offset/create.rb similarity index 100% rename from official/docs/ruby/current/carbon-offset/create.rb rename to official/docs/ruby/v5/carbon-offset/create.rb diff --git a/official/docs/ruby/current/carbon-offset/one-call-buy.rb b/official/docs/ruby/v5/carbon-offset/one-call-buy.rb similarity index 100% rename from official/docs/ruby/current/carbon-offset/one-call-buy.rb rename to official/docs/ruby/v5/carbon-offset/one-call-buy.rb diff --git a/official/docs/ruby/v5/carrier-accounts/create.rb b/official/docs/ruby/v5/carrier-accounts/create.rb new file mode 100644 index 00000000..5ed373bf --- /dev/null +++ b/official/docs/ruby/v5/carrier-accounts/create.rb @@ -0,0 +1,22 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +carrier_account = client.carrier_account.create( + type: 'DhlEcsAccount', + description: 'CA Location DHL eCommerce Solutions Account', + credentials: { + client_id: '123456', + client_secret: '123abc', + distribution_center: 'USLAX1', + pickup_id: '123456', + }, + test_credentials: { + client_id: '123456', + client_secret: '123abc', + distribution_center: 'USLAX1', + pickup_id: '123456', + }, +) + +puts carrier_account diff --git a/official/docs/ruby/v5/carrier-accounts/delete.rb b/official/docs/ruby/v5/carrier-accounts/delete.rb new file mode 100644 index 00000000..75f082cd --- /dev/null +++ b/official/docs/ruby/v5/carrier-accounts/delete.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_carrier_account = client.carrier_account.retrieve('ca_...') + +client.carrier_account.delete(retrieved_carrier_account.id) diff --git a/official/docs/ruby/v5/carrier-accounts/list.rb b/official/docs/ruby/v5/carrier-accounts/list.rb new file mode 100644 index 00000000..5c221313 --- /dev/null +++ b/official/docs/ruby/v5/carrier-accounts/list.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +carrier_accounts = client.carrier_account.all + +puts carrier_accounts diff --git a/official/docs/ruby/v5/carrier-accounts/retrieve.rb b/official/docs/ruby/v5/carrier-accounts/retrieve.rb new file mode 100644 index 00000000..49b5ee21 --- /dev/null +++ b/official/docs/ruby/v5/carrier-accounts/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +carrier_account = client.carrier_account.retrieve('ca_...') + +puts carrier_account diff --git a/official/docs/ruby/v5/carrier-accounts/update.rb b/official/docs/ruby/v5/carrier-accounts/update.rb new file mode 100644 index 00000000..98cf68d1 --- /dev/null +++ b/official/docs/ruby/v5/carrier-accounts/update.rb @@ -0,0 +1,12 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retreived_carrier_account = client.carrier_account.retrieve('ca_...') + +carrier_account = client.carrier_account.update( + retreived_carrier_account.id, + description: 'FL Location DHL eCommerce Solutions Account', +) + +puts carrier_account diff --git a/official/docs/ruby/v5/carrier-metadata/retrieve.rb b/official/docs/ruby/v5/carrier-metadata/retrieve.rb new file mode 100644 index 00000000..06e92aa5 --- /dev/null +++ b/official/docs/ruby/v5/carrier-metadata/retrieve.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +# Request all metadata for all carriers +carrier_metadata = client.carrier_metadata.retrieve +puts carrier_metadata + +# Request specific metadata for specific carriers +usps_carrier_metadata = client.carrier_metadata.retrieve('usps', %w[service_levels predefined_packages]) +puts usps_carrier_metadata diff --git a/official/docs/ruby/v5/carrier-types/list.rb b/official/docs/ruby/v5/carrier-types/list.rb new file mode 100644 index 00000000..f29f4ed7 --- /dev/null +++ b/official/docs/ruby/v5/carrier-types/list.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +carrier_types = client.carrier_account.types + +puts carrier_types diff --git a/official/docs/ruby/v5/child-users/create.rb b/official/docs/ruby/v5/child-users/create.rb new file mode 100644 index 00000000..8aec71d9 --- /dev/null +++ b/official/docs/ruby/v5/child-users/create.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +user = client.user.create( + name: 'Child Account Name', +) + +puts user diff --git a/official/docs/ruby/v5/child-users/delete.rb b/official/docs/ruby/v5/child-users/delete.rb new file mode 100644 index 00000000..61040a7c --- /dev/null +++ b/official/docs/ruby/v5/child-users/delete.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_user = client.user.retrieve('user_...') + +client.user.delete(retrieved_user.id) diff --git a/official/docs/ruby/v5/customs-infos/create.rb b/official/docs/ruby/v5/customs-infos/create.rb new file mode 100644 index 00000000..cd52b940 --- /dev/null +++ b/official/docs/ruby/v5/customs-infos/create.rb @@ -0,0 +1,24 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +customs_info = client.customs_info.create( + customs_certify: true, + customs_signer: 'Steve Brule', + contents_type: 'merchandise', + contents_explanation: '', + restriction_type: 'none', + eel_pfc: 'NOEEI 30.37(a)', + customs_items: [ + { + description: 'T-shirt', + quantity: 1, + weight: 5, + value: 10, + hs_tariff_number: '123456', + origin_country: 'US', + }, + ], +) + +puts customs_info diff --git a/official/docs/ruby/v5/customs-infos/retrieve.rb b/official/docs/ruby/v5/customs-infos/retrieve.rb new file mode 100644 index 00000000..3a0691d1 --- /dev/null +++ b/official/docs/ruby/v5/customs-infos/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +customs_info = client.customs_info.retrieve('cstinfo_...') + +puts customs_info diff --git a/official/docs/ruby/v5/customs-items/create.rb b/official/docs/ruby/v5/customs-items/create.rb new file mode 100644 index 00000000..0c1b4aba --- /dev/null +++ b/official/docs/ruby/v5/customs-items/create.rb @@ -0,0 +1,14 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +customs_item = client.customs_item.create( + description: 'T-shirt', + quantity: 1, + weight: 5, + value: 10, + hs_tariff_number: '123456', + origin_country: 'us', +) + +puts customs_item diff --git a/official/docs/ruby/v5/customs-items/retrieve.rb b/official/docs/ruby/v5/customs-items/retrieve.rb new file mode 100644 index 00000000..7761094c --- /dev/null +++ b/official/docs/ruby/v5/customs-items/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +customs_item = client.customs_item.retrieve('cstitem_...') + +puts customs_item diff --git a/official/docs/ruby/v5/endshipper/buy.rb b/official/docs/ruby/v5/endshipper/buy.rb new file mode 100644 index 00000000..f1a94059 --- /dev/null +++ b/official/docs/ruby/v5/endshipper/buy.rb @@ -0,0 +1,16 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') +end_shipper = client.end_shipper.retrieve('es_...') + +shipment = client.shipment.buy( + retrieved_shipment.id, + rate: shipment.lowest_rate, + insurance: nil, + with_carbon_offset: false, + end_shipper_id: end_shipper.id, +) + +puts shipment diff --git a/official/docs/ruby/v5/endshipper/create.rb b/official/docs/ruby/v5/endshipper/create.rb new file mode 100644 index 00000000..62c49e71 --- /dev/null +++ b/official/docs/ruby/v5/endshipper/create.rb @@ -0,0 +1,18 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +end_shipper = client.end_shipper.create( + name: 'FOO BAR', + company: 'BAZ', + street1: '164 TOWNSEND STREET UNIT 1', + street2: 'UNIT 1', + city: 'SAN FRANCISCO', + state: 'CA', + zip: '94107', + country: 'US', + phone: '555-555-5555', + email: 'FOO@EXAMPLE.COM', +) + +puts end_shipper diff --git a/official/docs/ruby/v5/endshipper/list.rb b/official/docs/ruby/v5/endshipper/list.rb new file mode 100644 index 00000000..91353c0c --- /dev/null +++ b/official/docs/ruby/v5/endshipper/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +end_shippers = client.end_shipper.all( + page_size: 5, +) + +puts end_shippers diff --git a/official/docs/ruby/v5/endshipper/retrieve.rb b/official/docs/ruby/v5/endshipper/retrieve.rb new file mode 100644 index 00000000..645ed45b --- /dev/null +++ b/official/docs/ruby/v5/endshipper/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +end_shipper = client.end_shipper.retrieve('es_...') + +puts end_shipper diff --git a/official/docs/ruby/v5/endshipper/update.rb b/official/docs/ruby/v5/endshipper/update.rb new file mode 100644 index 00000000..fe22c429 --- /dev/null +++ b/official/docs/ruby/v5/endshipper/update.rb @@ -0,0 +1,21 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_endshipper = client.end_shipper.retrieve('es_...') + +update_data = { + 'name' => 'New Name', + 'street1' => '388 Townsend St', + 'street2' => 'Apt 20', + 'city' => 'San Francisco', + 'state' => 'CA', + 'zip' => '94107', + 'country' => 'US', + 'email' => 'test@example.com', + 'phone' => '5555555555', +} + +end_shipper = client.end_shipper.update(retrieved_endshipper.id, update_data) + +puts end_shipper diff --git a/official/docs/ruby/v5/events/list.rb b/official/docs/ruby/v5/events/list.rb new file mode 100644 index 00000000..74a638a0 --- /dev/null +++ b/official/docs/ruby/v5/events/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +events = client.event.all( + page_size: 5, +) + +puts events diff --git a/official/docs/ruby/v5/events/retrieve.rb b/official/docs/ruby/v5/events/retrieve.rb new file mode 100644 index 00000000..ee35f492 --- /dev/null +++ b/official/docs/ruby/v5/events/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +event = client.event.retrieve('evt_...') + +puts event diff --git a/official/docs/ruby/v5/forms/create.rb b/official/docs/ruby/v5/forms/create.rb new file mode 100644 index 00000000..6804df27 --- /dev/null +++ b/official/docs/ruby/v5/forms/create.rb @@ -0,0 +1,24 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.event.retrieve('shp_...') + +form_type = 'return_packing_slip' +form_options = { + type: 'return_packing_slip', + barcode: 'RMA12345678900', + line_items: [ + { + product: { + title: 'Square Reader', + barcode: '855658003251', + }, + units: '8', + }, + ], +} + +shipment = client.shipment.generate_form(retrieved_shipment.id, form_type, form_options) + +puts shipment diff --git a/official/docs/ruby/v5/insurance/create.rb b/official/docs/ruby/v5/insurance/create.rb new file mode 100644 index 00000000..7710ae7e --- /dev/null +++ b/official/docs/ruby/v5/insurance/create.rb @@ -0,0 +1,18 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +insurance = client.insurance.create( + to_address: { + id: 'adr_...', + }, + from_address: { + id: 'adr_...', + }, + tracking_code: '9400110898825022579493', + carrier: 'USPS', + reference: 'insuranceRef1', + amount: '100.00', +) + +puts insurance diff --git a/official/docs/ruby/v5/insurance/list.rb b/official/docs/ruby/v5/insurance/list.rb new file mode 100644 index 00000000..45f1f9cd --- /dev/null +++ b/official/docs/ruby/v5/insurance/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +insurances = client.insurance.all( + page_size: 5, +) + +puts insurances diff --git a/official/docs/ruby/v5/insurance/retrieve.rb b/official/docs/ruby/v5/insurance/retrieve.rb new file mode 100644 index 00000000..cdfc9f2f --- /dev/null +++ b/official/docs/ruby/v5/insurance/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +insurance = client.insurance.retrieve('ins_...') + +puts insurance diff --git a/official/docs/ruby/v5/options/create-with-options.rb b/official/docs/ruby/v5/options/create-with-options.rb new file mode 100644 index 00000000..fb1d3651 --- /dev/null +++ b/official/docs/ruby/v5/options/create-with-options.rb @@ -0,0 +1,20 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.create( + to_address: { + id: 'adr_...', + }, + from_address: { + id: 'adr_...', + }, + parcel: { + id: 'prcl_...', + }, + options: { + print_custom_1: 'Custom label message', + }, +) + +puts shipment diff --git a/official/docs/ruby/v5/orders/buy.rb b/official/docs/ruby/v5/orders/buy.rb new file mode 100644 index 00000000..794a7c90 --- /dev/null +++ b/official/docs/ruby/v5/orders/buy.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_order = client.order.retrieve('order_...') + +order = client.order.buy(retrieved_order.id, carrier: 'FedEx', service: 'FEDEX_GROUND') + +puts order diff --git a/official/docs/ruby/v5/orders/create.rb b/official/docs/ruby/v5/orders/create.rb new file mode 100644 index 00000000..3b74b996 --- /dev/null +++ b/official/docs/ruby/v5/orders/create.rb @@ -0,0 +1,27 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +order = client.order.create( + to_address: { + id: 'adr_...', + }, + from_address: { + id: 'adr_...', + }, + shipments: [ + { + parcel: { + weight: 10.2, + }, + }, + { + parcel: { + predefined_package: 'FedExBox', + weight: 17.5, + }, + }, + ], +) + +puts order diff --git a/official/docs/ruby/v5/orders/one-call-buy.rb b/official/docs/ruby/v5/orders/one-call-buy.rb new file mode 100644 index 00000000..8fe90fc9 --- /dev/null +++ b/official/docs/ruby/v5/orders/one-call-buy.rb @@ -0,0 +1,29 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +order = client.order.create( + to_address: { + id: 'adr_...', + }, + from_address: { + id: 'adr_...', + }, + shipments: [ + { + parcel: { + weight: 10.2, + }, + }, + { + parcel: { + predefined_package: 'FedExBox', + weight: 17.5, + }, + }, + ], + service: 'NextDayAir', + carrier_accounts: ['ca_...'], +) + +puts order diff --git a/official/docs/ruby/v5/orders/retrieve.rb b/official/docs/ruby/v5/orders/retrieve.rb new file mode 100644 index 00000000..55bd53e1 --- /dev/null +++ b/official/docs/ruby/v5/orders/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +order = client.order.retrieve('order_...') + +puts order diff --git a/official/docs/ruby/v5/pagination/get-next-page.rb b/official/docs/ruby/v5/pagination/get-next-page.rb new file mode 100644 index 00000000..7f19bd87 --- /dev/null +++ b/official/docs/ruby/v5/pagination/get-next-page.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +# Get first page of results +shipments = client.shipment.all(page_size: 5) + +# Provide the previous results page to move onto the next page +next_page = client.shipment.get_next_page(shipments) + +puts next_page diff --git a/official/docs/ruby/v5/parcels/create.rb b/official/docs/ruby/v5/parcels/create.rb new file mode 100644 index 00000000..b659c61b --- /dev/null +++ b/official/docs/ruby/v5/parcels/create.rb @@ -0,0 +1,12 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +parcel = client.parcel.create( + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, +) + +puts parcel diff --git a/official/docs/ruby/v5/parcels/retrieve.rb b/official/docs/ruby/v5/parcels/retrieve.rb new file mode 100644 index 00000000..0a825e2a --- /dev/null +++ b/official/docs/ruby/v5/parcels/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +parcel = client.parcel.retrieve('prcl_...') + +puts parcel diff --git a/official/docs/ruby/v5/payloads/list.rb b/official/docs/ruby/v5/payloads/list.rb new file mode 100644 index 00000000..2e932948 --- /dev/null +++ b/official/docs/ruby/v5/payloads/list.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +payloads = client.event.retrieve_all_payloads('evt_...') + +puts payloads diff --git a/official/docs/ruby/v5/payloads/retrieve.rb b/official/docs/ruby/v5/payloads/retrieve.rb new file mode 100644 index 00000000..85b66b38 --- /dev/null +++ b/official/docs/ruby/v5/payloads/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +payload = client.event.retrieve_payload('evt_...', 'payload_...') + +puts payload diff --git a/official/docs/ruby/v5/pickups/buy.rb b/official/docs/ruby/v5/pickups/buy.rb new file mode 100644 index 00000000..f2a63671 --- /dev/null +++ b/official/docs/ruby/v5/pickups/buy.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_pickup = client.pickup.retrieve('pickup_...') + +pickup = client.pickup.buy(retrieved_pickup.id, carrier: 'UPS', service: 'Same-Day Pickup') + +puts pickup diff --git a/official/docs/ruby/v5/pickups/cancel.rb b/official/docs/ruby/v5/pickups/cancel.rb new file mode 100644 index 00000000..9ebe2040 --- /dev/null +++ b/official/docs/ruby/v5/pickups/cancel.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_pickup = client.pickup.retrieve('pickup_...') + +pickup = client.pickup.cancel(retrieved_pickup.id) + +puts pickup diff --git a/official/docs/ruby/v5/pickups/create.rb b/official/docs/ruby/v5/pickups/create.rb new file mode 100644 index 00000000..3296843e --- /dev/null +++ b/official/docs/ruby/v5/pickups/create.rb @@ -0,0 +1,19 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +pickup = client.pickup.create( + reference: 'my-first-pickup', + min_datetime: '2022-10-01 10:30:00', + max_datetime: '2022-10-02 10:30:00', + shipment: { + id: 'shp_...', + }, + address: { + id: 'adr_...', + }, + is_account_address: false, + instructions: 'Special pickup instructions', +) + +puts pickup diff --git a/official/docs/ruby/v5/pickups/list.rb b/official/docs/ruby/v5/pickups/list.rb new file mode 100644 index 00000000..c5733602 --- /dev/null +++ b/official/docs/ruby/v5/pickups/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +pickups = client.pickup.all( + page_size: 5, +) + +puts pickups diff --git a/official/docs/ruby/v5/pickups/retrieve.rb b/official/docs/ruby/v5/pickups/retrieve.rb new file mode 100644 index 00000000..7713f714 --- /dev/null +++ b/official/docs/ruby/v5/pickups/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +pickup = client.pickup.retrieve('pickup_...') + +puts pickup diff --git a/official/docs/ruby/v5/rates/regenerate.rb b/official/docs/ruby/v5/rates/regenerate.rb new file mode 100644 index 00000000..83d91cb0 --- /dev/null +++ b/official/docs/ruby/v5/rates/regenerate.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +shipment = client.shipment.regenerate_rates(retrieved_shipment.id) + +puts shipment diff --git a/official/docs/ruby/v5/rates/retrieve-stateless.rb b/official/docs/ruby/v5/rates/retrieve-stateless.rb new file mode 100644 index 00000000..772ce6a4 --- /dev/null +++ b/official/docs/ruby/v5/rates/retrieve-stateless.rb @@ -0,0 +1,37 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment_details = { + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + phone: '4155559999', + email: 'dr_steve_brule@gmail.com', + }, + from_address: { + name: 'EasyPost', + street1: '417 Montgomery Street', + street2: '5th Floor', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + phone: '4153334445', + email: 'support@easypost.com', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, +} + +rates = client.beta_rate.retrieve_stateless_rates(shipment_details) + +puts rates diff --git a/official/docs/ruby/v5/rates/retrieve.rb b/official/docs/ruby/v5/rates/retrieve.rb new file mode 100644 index 00000000..1c2c224d --- /dev/null +++ b/official/docs/ruby/v5/rates/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +rate = client.rate.retrieve('rate...') + +puts rate diff --git a/official/docs/ruby/v5/referral-customers/add-payment-method-with-bank-account.rb b/official/docs/ruby/v5/referral-customers/add-payment-method-with-bank-account.rb new file mode 100644 index 00000000..59fa2887 --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/add-payment-method-with-bank-account.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +payment_method = client.beta_referral_customer.add_payment_method( + 'cus_...', + 'ba_...', + 'primary', +) + +puts payment_method diff --git a/official/docs/ruby/v5/referral-customers/add-payment-method-with-credit-card.rb b/official/docs/ruby/v5/referral-customers/add-payment-method-with-credit-card.rb new file mode 100644 index 00000000..b4f134ae --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/add-payment-method-with-credit-card.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +payment_method = client.beta_referral_customer.add_payment_method( + 'cus_...', + 'card_...', + 'primary', +) + +puts payment_method diff --git a/official/docs/ruby/v5/referral-customers/create.rb b/official/docs/ruby/v5/referral-customers/create.rb new file mode 100644 index 00000000..4af94ccd --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/create.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +referral_user = client.referral_customer.create( + name: 'test user', + email: 'email@example.com', + phone: '8888888888', +) + +puts referral_user diff --git a/official/docs/ruby/v5/referral-customers/list.rb b/official/docs/ruby/v5/referral-customers/list.rb new file mode 100644 index 00000000..8efaa96a --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +referral_users = client.referral_customer.all( + page_size: 5, +) + +puts referral_users diff --git a/official/docs/ruby/v5/referral-customers/refund-by-amount.rb b/official/docs/ruby/v5/referral-customers/refund-by-amount.rb new file mode 100644 index 00000000..502b7480 --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/refund-by-amount.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +refund = client.beta_referral_customer.refund_by_amount(2000) + +puts refund diff --git a/official/docs/ruby/v5/referral-customers/refund-by-payment-log.rb b/official/docs/ruby/v5/referral-customers/refund-by-payment-log.rb new file mode 100644 index 00000000..3b18ec7e --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/refund-by-payment-log.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +refund = client.beta_referral_customer.refund_by_payment_log('paylog_...') + +puts refund diff --git a/official/docs/ruby/v5/referral-customers/update.rb b/official/docs/ruby/v5/referral-customers/update.rb new file mode 100644 index 00000000..d2b56d35 --- /dev/null +++ b/official/docs/ruby/v5/referral-customers/update.rb @@ -0,0 +1,10 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +message = client.referral_customer.update_email( + 'new_email@example.com', + 'user_...', +) + +puts message diff --git a/official/docs/ruby/v5/refunds/create.rb b/official/docs/ruby/v5/refunds/create.rb new file mode 100644 index 00000000..9af43215 --- /dev/null +++ b/official/docs/ruby/v5/refunds/create.rb @@ -0,0 +1,10 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +refunds = client.refund.create( + carrier: 'USPS', + tracking_codes: ['EZ1000000001'], +) + +puts refunds diff --git a/official/docs/ruby/v5/refunds/list.rb b/official/docs/ruby/v5/refunds/list.rb new file mode 100644 index 00000000..263d28d4 --- /dev/null +++ b/official/docs/ruby/v5/refunds/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +refunds = client.refund.all( + page_size: 5, +) + +puts refunds diff --git a/official/docs/ruby/v5/refunds/retrieve.rb b/official/docs/ruby/v5/refunds/retrieve.rb new file mode 100644 index 00000000..8c588641 --- /dev/null +++ b/official/docs/ruby/v5/refunds/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +refund = client.refund.retrieve('rfnd_...') + +puts refund diff --git a/official/docs/ruby/v5/reports/create.rb b/official/docs/ruby/v5/reports/create.rb new file mode 100644 index 00000000..84e8e9da --- /dev/null +++ b/official/docs/ruby/v5/reports/create.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +report = client.report.create( + type: 'payment_log', + start_date: '2022-10-01', + end_date: '2022-10-31', +) + +puts report diff --git a/official/docs/ruby/v5/reports/list.rb b/official/docs/ruby/v5/reports/list.rb new file mode 100644 index 00000000..46dc3e39 --- /dev/null +++ b/official/docs/ruby/v5/reports/list.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +reports = client.report.all( + # Replace `payment_log` with any of the report types listed above + type: 'payment_log', + page_size: 5, +) + +puts reports diff --git a/official/docs/ruby/v5/reports/retrieve.rb b/official/docs/ruby/v5/reports/retrieve.rb new file mode 100644 index 00000000..f68672da --- /dev/null +++ b/official/docs/ruby/v5/reports/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +report = client.report.retrieve('') + +puts report diff --git a/official/docs/ruby/v5/returns/create.rb b/official/docs/ruby/v5/returns/create.rb new file mode 100644 index 00000000..7d588d5f --- /dev/null +++ b/official/docs/ruby/v5/returns/create.rb @@ -0,0 +1,36 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.create( + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + phone: '8573875756', + email: 'dr_steve_brule@gmail.com', + }, + from_address: { + name: 'EasyPost', + street1: '417 Montgomery Street', + street2: '5th Floor', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + phone: '4153334445', + email: 'support@easypost.com', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + is_return: true, +) + +puts shipment diff --git a/official/docs/ruby/v5/scan-form/create.rb b/official/docs/ruby/v5/scan-form/create.rb new file mode 100644 index 00000000..1d5627af --- /dev/null +++ b/official/docs/ruby/v5/scan-form/create.rb @@ -0,0 +1,16 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +scan_form = client.scan_form.create( + shipments: [ + { + id: 'shp_...', + }, + { + id: 'shp_...', + }, + ], +) + +puts scan_form diff --git a/official/docs/ruby/v5/scan-form/list.rb b/official/docs/ruby/v5/scan-form/list.rb new file mode 100644 index 00000000..6edaaa10 --- /dev/null +++ b/official/docs/ruby/v5/scan-form/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +scan_forms = client.scan_form.all( + page_size: 5, +) + +puts scan_forms diff --git a/official/docs/ruby/v5/scan-form/retrieve.rb b/official/docs/ruby/v5/scan-form/retrieve.rb new file mode 100644 index 00000000..edd3f7a3 --- /dev/null +++ b/official/docs/ruby/v5/scan-form/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +scan_form = client.scan_form.retrieve('sf_...') + +puts scan_form diff --git a/official/docs/ruby/v5/shipments/buy.rb b/official/docs/ruby/v5/shipments/buy.rb new file mode 100644 index 00000000..506465e5 --- /dev/null +++ b/official/docs/ruby/v5/shipments/buy.rb @@ -0,0 +1,13 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +shipment = client.shipment.buy( + retrieved_shipment.id, + rate: shipment.lowest_rate, + insurance: '244.99', +) + +puts shipment diff --git a/official/docs/ruby/v5/shipments/create.rb b/official/docs/ruby/v5/shipments/create.rb new file mode 100644 index 00000000..13e6d435 --- /dev/null +++ b/official/docs/ruby/v5/shipments/create.rb @@ -0,0 +1,38 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.create( + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + phone: '4155559999', + email: 'dr_steve_brule@gmail.com', + }, + from_address: { + name: 'EasyPost', + street1: '417 Montgomery Street', + street2: '5th Floor', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + phone: '4153334445', + email: 'support@easypost.com', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + customs_info: { + id: 'cstinfo_...', + }, +) + +puts shipment diff --git a/official/docs/ruby/v5/shipments/label.rb b/official/docs/ruby/v5/shipments/label.rb new file mode 100644 index 00000000..9e8e6ebc --- /dev/null +++ b/official/docs/ruby/v5/shipments/label.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +shipment = shipment.label(retrieved_shipment.id, file_format: 'ZPL') + +puts shipment diff --git a/official/docs/ruby/v5/shipments/list.rb b/official/docs/ruby/v5/shipments/list.rb new file mode 100644 index 00000000..f7f5f9c9 --- /dev/null +++ b/official/docs/ruby/v5/shipments/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipments = client.shipment.all( + page_size: 5, +) + +puts shipments diff --git a/official/docs/ruby/v5/shipments/one-call-buy.rb b/official/docs/ruby/v5/shipments/one-call-buy.rb new file mode 100644 index 00000000..9eb4648b --- /dev/null +++ b/official/docs/ruby/v5/shipments/one-call-buy.rb @@ -0,0 +1,37 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.create( + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + phone: '8573875756', + email: 'dr_steve_brule@gmail.com', + }, + from_address: { + name: 'EasyPost', + street1: '417 Montgomery Street', + street2: '5th Floor', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + phone: '4153334445', + email: 'support@easypost.com', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + service: 'NextDayAir', + carrier_accounts: ['ca_...'], +) + +puts shipment diff --git a/official/docs/ruby/v5/shipments/retrieve.rb b/official/docs/ruby/v5/shipments/retrieve.rb new file mode 100644 index 00000000..766fd692 --- /dev/null +++ b/official/docs/ruby/v5/shipments/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.retrieve('shp_...') + +puts shipment diff --git a/official/docs/ruby/v5/shipping-insurance/insure.rb b/official/docs/ruby/v5/shipping-insurance/insure.rb new file mode 100644 index 00000000..24fe3995 --- /dev/null +++ b/official/docs/ruby/v5/shipping-insurance/insure.rb @@ -0,0 +1,8 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') +shipment = client.shipment.insure(retrieved_shipment.id, amount: 100) + +puts shipment diff --git a/official/docs/ruby/v5/shipping-refund/refund.rb b/official/docs/ruby/v5/shipping-refund/refund.rb new file mode 100644 index 00000000..18b3ba6a --- /dev/null +++ b/official/docs/ruby/v5/shipping-refund/refund.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +shipment = client.shipment.refund(retrieved_shipment.id) + +puts shipment diff --git a/official/docs/ruby/v5/smartrate/retrieve-estimated-delivery-date.rb b/official/docs/ruby/v5/smartrate/retrieve-estimated-delivery-date.rb new file mode 100644 index 00000000..1182e77c --- /dev/null +++ b/official/docs/ruby/v5/smartrate/retrieve-estimated-delivery-date.rb @@ -0,0 +1,12 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +estimated_delivery_dates = client.shipment.retrieve_estimated_delivery_date( + retrieved_shipment.id, + 'YYYY-MM-DD', +) + +puts estimated_delivery_dates diff --git a/official/docs/ruby/v5/smartrate/retrieve-time-in-transit-statistics.rb b/official/docs/ruby/v5/smartrate/retrieve-time-in-transit-statistics.rb new file mode 100644 index 00000000..ee784a35 --- /dev/null +++ b/official/docs/ruby/v5/smartrate/retrieve-time-in-transit-statistics.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_shipment = client.shipment.retrieve('shp_...') + +shipment = client.shipment.get_smartrates(retrieved_shipment.id) + +puts shipment diff --git a/official/docs/ruby/v5/tax-identifiers/create.rb b/official/docs/ruby/v5/tax-identifiers/create.rb new file mode 100644 index 00000000..f00bec37 --- /dev/null +++ b/official/docs/ruby/v5/tax-identifiers/create.rb @@ -0,0 +1,46 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +shipment = client.shipment.create( + to_address: { + name: 'Dr. Steve Brule', + street1: '179 N Harbor Dr', + city: 'Redondo Beach', + state: 'CA', + zip: '90277', + country: 'US', + phone: '8573875756', + email: 'dr_steve_brule@gmail.com', + }, + from_address: { + name: 'EasyPost', + street1: '417 Montgomery Street', + street2: '5th Floor', + city: 'San Francisco', + state: 'CA', + zip: '94104', + country: 'US', + phone: '4153334445', + email: 'support@easypost.com', + }, + parcel: { + length: 20.2, + width: 10.9, + height: 5, + weight: 65.9, + }, + customs_info: { + id: 'cstinfo_...', + }, + tax_identifiers: [ + { + entity: 'SENDER', + tax_id: 'GB123456789', + tax_id_type: 'EORI', + issuing_country: 'GB', + }, + ], +) + +puts shipment diff --git a/official/docs/ruby/v5/trackers/create.rb b/official/docs/ruby/v5/trackers/create.rb new file mode 100644 index 00000000..9d43196a --- /dev/null +++ b/official/docs/ruby/v5/trackers/create.rb @@ -0,0 +1,10 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +tracker = client.tracker.create( + tracking_code: 'EZ1000000001', + carrier: 'USPS', +) + +puts tracker diff --git a/official/docs/ruby/v5/trackers/list.rb b/official/docs/ruby/v5/trackers/list.rb new file mode 100644 index 00000000..74d4acff --- /dev/null +++ b/official/docs/ruby/v5/trackers/list.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +trackers = client.tracker.all( + page_size: 5, +) + +puts trackers diff --git a/official/docs/ruby/v5/trackers/retrieve.rb b/official/docs/ruby/v5/trackers/retrieve.rb new file mode 100644 index 00000000..609a583c --- /dev/null +++ b/official/docs/ruby/v5/trackers/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +tracker = client.tracker.retrieve('trk_...') + +puts tracker diff --git a/official/docs/ruby/v5/users/retrieve.rb b/official/docs/ruby/v5/users/retrieve.rb new file mode 100644 index 00000000..17242bbd --- /dev/null +++ b/official/docs/ruby/v5/users/retrieve.rb @@ -0,0 +1,11 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +# Retrieve the authenticated user +user = client.user.retrieve_me + +# Retrieve a child user +user = client.user.retrieve('user_...') + +puts user diff --git a/official/docs/ruby/v5/users/update.rb b/official/docs/ruby/v5/users/update.rb new file mode 100644 index 00000000..7f4bc086 --- /dev/null +++ b/official/docs/ruby/v5/users/update.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_user = client.user.retrieve_me + +user = client.user.update(retrieved_user.id, name: 'New Name') + +puts user diff --git a/official/docs/ruby/v5/webhooks/create.rb b/official/docs/ruby/v5/webhooks/create.rb new file mode 100644 index 00000000..842e90fe --- /dev/null +++ b/official/docs/ruby/v5/webhooks/create.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +webhook = client.webhook.create( + url: 'example.com', +) + +puts webhook diff --git a/official/docs/ruby/v5/webhooks/delete.rb b/official/docs/ruby/v5/webhooks/delete.rb new file mode 100644 index 00000000..60e81931 --- /dev/null +++ b/official/docs/ruby/v5/webhooks/delete.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +webhook = client.webhook.retrieve('hook_...') + +client.webhook.delete(webhook.id) diff --git a/official/docs/ruby/v5/webhooks/list.rb b/official/docs/ruby/v5/webhooks/list.rb new file mode 100644 index 00000000..8bade75a --- /dev/null +++ b/official/docs/ruby/v5/webhooks/list.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +webhooks = client.webhook.all + +puts webhooks diff --git a/official/docs/ruby/v5/webhooks/retrieve.rb b/official/docs/ruby/v5/webhooks/retrieve.rb new file mode 100644 index 00000000..a32c61e4 --- /dev/null +++ b/official/docs/ruby/v5/webhooks/retrieve.rb @@ -0,0 +1,7 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +webhook = client.webhook.retrieve('hook_...') + +puts webhook diff --git a/official/docs/ruby/v5/webhooks/update.rb b/official/docs/ruby/v5/webhooks/update.rb new file mode 100644 index 00000000..2daeee59 --- /dev/null +++ b/official/docs/ruby/v5/webhooks/update.rb @@ -0,0 +1,9 @@ +require 'easypost' + +client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY']) + +retrieved_webhook = client.webhook.retrieve('hook_...') + +webhook = client.webhook.update(retrieved_webhook.id) + +puts webhook diff --git a/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset.py b/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset.py deleted file mode 100644 index b0e507ff..00000000 --- a/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset.py +++ /dev/null @@ -1,13 +0,0 @@ -import easypost -import os - -client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY")) - -# Calculate the carbon emissions and cost to offset carbon emissions -shipment = client.shipment.create( - with_carbon_offset=True, - to_address=to_address, - from_address=from_address, - parcel=parcel, - customs_info=customs_info, -) diff --git a/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset_response.json b/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset_response.json deleted file mode 100644 index 4f3ade71..00000000 --- a/official/landing_pages/carbon_offset/create_shipment_with_carbon_offset_response.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "id": "shp_...", - "object": "Shipment", - "mode": "test", - "to_address": { - "id": "adr_...", - "object": "Address", - "name": "Dr. Steve Brule", - "company": null, - "street1": "179 N Harbor Dr", - "street2": null, - "city": "Redondo Beach", - "state": "CA", - "zip": "90277", - "country": "US", - "phone": "4153334444", - "mode": "test", - "carrier_facility": null, - "residential": null, - "email": "dr_steve_brule@gmail.com", - "created_at": "2023-04-22T05:39:56Z", - "updated_at": "2023-04-22T05:39:56Z" - }, - "from_address": { - "id": "adr_...", - "object": "Address", - "name": "EasyPost", - "company": null, - "street1": "417 Montgomery Street", - "street2": "5th Floor", - "city": "San Francisco", - "state": "CA", - "zip": "94104", - "country": "US", - "phone": "4153334444", - "email": "support@easypost.com", - "mode": "test", - "carrier_facility": null, - "residential": null, - "created_at": "2023-04-22T05:39:57Z", - "updated_at": "2023-04-22T05:39:57Z" - }, - "parcel": { - "id": "prcl_...", - "object": "Parcel", - "length": 20.2, - "width": 10.9, - "height": 5.0, - "predefined_package": null, - "weight": 140.8, - "created_at": "2023-04-22T05:39:57Z", - "updated_at": "2023-04-22T05:39:57Z" - }, - "customs_info": {}, - "rates": [ - { - "id": "rate_...", - "object": "Rate", - "billing_type": "easypost", - "carrier_account_id": "ca_...", - "service": "FirstClass", - "rate": "9.50", - "carrier": "USPS", - "carbon_offset": { - "object": "CarbonOffset", - "grams": 152, - "price": "0.11", - "currency": "USD" - }, - "shipment_id": "shp_...", - "delivery_days": 4, - "delivery_date": "2023-04-26T05:40:57Z", - "delivery_date_guaranteed": false, - "created_at": "2023-04-22T05:40:57Z", - "updated_at": "2023-04-22T05:40:57Z" - }, - { - "id": "rate_...", - "object": "Rate", - "billing_type": "easypost", - "carrier_account_id": "ca_...", - "service": "Priority", - "rate": "27.40", - "carrier": "USPS", - "carbon_offset": { - "object": "CarbonOffset", - "grams": 152, - "price": "0.11", - "currency": "USD" - }, - "shipment_id": "shp_...", - "delivery_days": 2, - "delivery_date": "2023-04-24T05:40:57Z", - "delivery_date_guaranteed": false, - "created_at": "2023-04-22T05:40:57Z", - "updated_at": "2023-04-22T05:40:57Z" - }, - { - "id": "rate_...", - "object": "Rate", - "billing_type": "easypost", - "carrier_account_id": "ca_...", - "service": "Express", - "rate": "35.48", - "carrier": "USPS", - "carbon_offset": { - "object": "CarbonOffset", - "grams": 152, - "price": "0.11", - "currency": "USD" - }, - "shipment_id": "shp_...", - "delivery_days": 1, - "delivery_date": "2023-04-23T05:40:57Z", - "delivery_date_guaranteed": true, - "created_at": "2023-04-22T05:40:57Z", - "updated_at": "2023-04-22T05:40:57Z" - } - ], - "scan_form": null, - "selected_rate": null, - "postage_label": null, - "tracking_code": null, - "refund_status": null, - "insurance": null, - "created_at": "2023-04-22T05:40:57Z", - "updated_at": "2023-04-22T05:40:57Z" -}