diff --git a/.gitignore b/.gitignore index 29c7040c..3344581a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ venv /style_suppressions.xml /.dummy /.eslintignore +*.sw* diff --git a/official/docs/csharp/current/pagination/get-next-page.cs b/official/docs/csharp/current/pagination/get-next-page.cs new file mode 100644 index 00000000..31d460a0 --- /dev/null +++ b/official/docs/csharp/current/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/curl/current/pagination/get-next-page.sh b/official/docs/curl/current/pagination/get-next-page.sh new file mode 100644 index 00000000..6c473ec1 --- /dev/null +++ b/official/docs/curl/current/pagination/get-next-page.sh @@ -0,0 +1,7 @@ +# Get first page of results +curl -X 'GET https://api.easypost.com/v2/shipments?page_size=5' \ + -u "$EASYPOST_API_KEY": + +# Provide the ID of the last element of the previous page in the before_id param +curl -X 'GET https://api.easypost.com/v2/shipments?page_size=5&before_id=shp_...' \ + -u "$EASYPOST_API_KEY": diff --git a/official/docs/golang/current/pagination/get-next-page.go b/official/docs/golang/current/pagination/get-next-page.go new file mode 100644 index 00000000..0d56e0ea --- /dev/null +++ b/official/docs/golang/current/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/java/current/pagination/get-next-page.java b/official/docs/java/current/pagination/get-next-page.java new file mode 100644 index 00000000..2d91a0a5 --- /dev/null +++ b/official/docs/java/current/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/node/current/pagination/get-next-page.js b/official/docs/node/current/pagination/get-next-page.js new file mode 100644 index 00000000..76ad922b --- /dev/null +++ b/official/docs/node/current/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/php/current/pagination/get-next-page.php b/official/docs/php/current/pagination/get-next-page.php new file mode 100644 index 00000000..09eff162 --- /dev/null +++ b/official/docs/php/current/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/python/current/pagination/get-next-page.py b/official/docs/python/current/pagination/get-next-page.py new file mode 100644 index 00000000..67d4b7cd --- /dev/null +++ b/official/docs/python/current/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/responses/pagination/pagination-get-next-page.json b/official/docs/responses/pagination/pagination-get-next-page.json new file mode 100644 index 00000000..d16b3fde --- /dev/null +++ b/official/docs/responses/pagination/pagination-get-next-page.json @@ -0,0 +1,452 @@ +{ + "shipments": [ + { + "created_at": "2023-07-10T17:30:14Z", + "is_return": false, + "messages": [], + "mode": "test", + "options": { + "currency": "USD", + "payment": { + "type": "SENDER" + }, + "date_advance": 0 + }, + "reference": null, + "status": "unknown", + "tracking_code": "9400100105440232838888", + "updated_at": "2023-07-10T17:30:16Z", + "batch_id": null, + "batch_status": null, + "batch_message": null, + "customs_info": { + "id": "cstinfo_f85189b578ec4706ac387b76cec7ff01", + "object": "CustomsInfo", + "created_at": "2022-10-17T17:17:38Z", + "updated_at": "2022-10-17T17:17:38Z", + "contents_explanation": "", + "contents_type": "merchandise", + "customs_certify": true, + "customs_signer": "Steve Brule", + "eel_pfc": "NOEEI 30.37(a)", + "non_delivery_option": "return", + "restriction_comments": null, + "restriction_type": "none", + "mode": "test", + "declaration": null, + "customs_items": [ + { + "id": "cstitem_fa0aa9aa3a8f41639295c10aa7469480", + "object": "CustomsItem", + "created_at": "2022-10-17T17:17:38Z", + "updated_at": "2022-10-17T17:17:38Z", + "description": "T-shirt", + "hs_tariff_number": "123456", + "origin_country": "US", + "quantity": 1, + "value": "10.0", + "weight": 5.0, + "code": "123", + "mode": "test", + "manufacturer": null, + "currency": null, + "eccn": null, + "printed_commodity_identifier": null + } + ] + }, + "from_address": { + "id": "adr_6e0ac14a1f4711eeacd5ac1f6bc539ae", + "object": "Address", + "created_at": "2023-07-10T17:30:14+00:00", + "updated_at": "2023-07-10T17:30:14+00:00", + "name": "EasyPost", + "company": null, + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334445", + "email": "support@easypost.com", + "mode": "test", + "carrier_facility": null, + "residential": null, + "federal_tax_id": null, + "state_tax_id": null, + "verifications": {} + }, + "insurance": null, + "order_id": "order_2666c9282ad54765b74b9be1c0cccf09", + "parcel": { + "id": "prcl_2498d756b1c740b484f5665e5fdd697f", + "object": "Parcel", + "created_at": "2023-07-10T17:30:14Z", + "updated_at": "2023-07-10T17:30:14Z", + "length": null, + "width": null, + "height": null, + "predefined_package": null, + "weight": 10.2, + "mode": "test" + }, + "postage_label": { + "object": "PostageLabel", + "id": "pl_ce7b1a9249794cd697c87395d660d8f6", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:16Z", + "date_advance": 0, + "integrated_form": "none", + "label_date": "2023-07-10T17:30:15Z", + "label_resolution": 300, + "label_size": "4x6", + "label_type": "default", + "label_file_type": "image/png", + "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20230710/e657608f44b6ec482c86742b7b8ea5d74d.png", + "label_pdf_url": null, + "label_zpl_url": null, + "label_epl2_url": null, + "label_file": null + }, + "rates": [ + { + "id": "rate_d669ba48a22b4f7f9a07939bf509de2a", + "object": "Rate", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:15Z", + "mode": "test", + "service": "Express", + "carrier": "USPS", + "rate": "31.25", + "currency": "USD", + "retail_rate": "35.80", + "retail_currency": "USD", + "list_rate": "31.25", + "list_currency": "USD", + "billing_type": "easypost", + "delivery_days": null, + "delivery_date": null, + "delivery_date_guaranteed": false, + "est_delivery_days": null, + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier_account_id": "ca_b25657e9896e4d63ac8151ac346ac41e" + }, + { + "id": "rate_ee0ba720bd6a4338b2945db6e450baba", + "object": "Rate", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:15Z", + "mode": "test", + "service": "Priority", + "carrier": "USPS", + "rate": "7.15", + "currency": "USD", + "retail_rate": "10.20", + "retail_currency": "USD", + "list_rate": "8.24", + "list_currency": "USD", + "billing_type": "easypost", + "delivery_days": 2, + "delivery_date": null, + "delivery_date_guaranteed": false, + "est_delivery_days": 2, + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier_account_id": "ca_b25657e9896e4d63ac8151ac346ac41e" + }, + { + "id": "rate_fd2144b885dd4725bfdf4ece351e9231", + "object": "Rate", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:15Z", + "mode": "test", + "service": "GroundAdvantage", + "carrier": "USPS", + "rate": "4.81", + "currency": "USD", + "retail_rate": "4.81", + "retail_currency": "USD", + "list_rate": "4.81", + "list_currency": "USD", + "billing_type": "easypost", + "delivery_days": null, + "delivery_date": null, + "delivery_date_guaranteed": false, + "est_delivery_days": null, + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier_account_id": "ca_b25657e9896e4d63ac8151ac346ac41e" + }, + { + "id": "rate_5dff1ed420df4a58833d9b47563565f6", + "object": "Rate", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:15Z", + "mode": "test", + "service": "First", + "carrier": "USPS", + "rate": "4.81", + "currency": "USD", + "retail_rate": "4.81", + "retail_currency": "USD", + "list_rate": "4.81", + "list_currency": "USD", + "billing_type": "easypost", + "delivery_days": 3, + "delivery_date": null, + "delivery_date_guaranteed": false, + "est_delivery_days": 3, + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier_account_id": "ca_b25657e9896e4d63ac8151ac346ac41e" + } + ], + "refund_status": null, + "scan_form": { + "id": "sf_3684195c590740a88bc2c2cf5f25acb1", + "object": "ScanForm", + "created_at": "2022-10-17T17:17:39Z", + "updated_at": "2022-10-17T17:17:40Z", + "tracking_codes": ["9405500106068143632993"], + "address": { + "id": "adr_99962d534e3f11ed846dac1f6b0a0d1e", + "object": "Address", + "created_at": "2022-10-17T17:17:38+00:00", + "updated_at": "2022-10-17T17:17:38+00:00", + "name": "EasyPost", + "company": null, + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334445", + "email": "support@easypost.com", + "mode": "test", + "carrier_facility": null, + "residential": null, + "federal_tax_id": null, + "state_tax_id": null, + "verifications": {} + }, + "status": "created", + "message": null, + "form_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/scan_form/20221017/58d6eef422424d02bd4105029666d614.pdf", + "form_file_type": null, + "batch_id": "batch_879633ae98a847409f0ca5b22c9872f4", + "confirmation": null + }, + "selected_rate": { + "id": "rate_5dff1ed420df4a58833d9b47563565f6", + "object": "Rate", + "created_at": "2023-07-10T17:30:15Z", + "updated_at": "2023-07-10T17:30:15Z", + "mode": "test", + "service": "First", + "carrier": "USPS", + "rate": "4.81", + "currency": "USD", + "retail_rate": "4.81", + "retail_currency": "USD", + "list_rate": "4.81", + "list_currency": "USD", + "billing_type": "easypost", + "delivery_days": 3, + "delivery_date": null, + "delivery_date_guaranteed": false, + "est_delivery_days": 3, + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier_account_id": "ca_b25657e9896e4d63ac8151ac346ac41e" + }, + "tracker": { + "id": "trk_1c56526a89e04c4c80013fd763f91228", + "object": "Tracker", + "mode": "test", + "tracking_code": "9400100105440232838888", + "status": "pre_transit", + "status_detail": "status_update", + "created_at": "2023-07-10T17:30:16Z", + "updated_at": "2023-07-10T17:30:16Z", + "signed_by": null, + "weight": null, + "est_delivery_date": "2023-07-10T17:30:16Z", + "shipment_id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "carrier": "USPS", + "tracking_details": [ + { + "object": "TrackingDetail", + "message": "Pre-Shipment Info Sent to USPS", + "description": null, + "status": "pre_transit", + "status_detail": "status_update", + "datetime": "2023-06-10T17:30:16Z", + "source": "USPS", + "carrier_code": null, + "tracking_location": { + "object": "TrackingLocation", + "city": null, + "state": null, + "country": null, + "zip": null + } + }, + { + "object": "TrackingDetail", + "message": "Shipping Label Created", + "description": null, + "status": "pre_transit", + "status_detail": "status_update", + "datetime": "2023-06-11T06:07:16Z", + "source": "USPS", + "carrier_code": null, + "tracking_location": { + "object": "TrackingLocation", + "city": "HOUSTON", + "state": "TX", + "country": null, + "zip": "77063" + } + } + ], + "fees": [], + "carrier_detail": { + "object": "CarrierDetail", + "service": "First-Class Package Service", + "container_type": null, + "est_delivery_date_local": null, + "est_delivery_time_local": null, + "origin_location": "HOUSTON TX, 77001", + "origin_tracking_location": { + "object": "TrackingLocation", + "city": "HOUSTON", + "state": "TX", + "country": null, + "zip": "77063" + }, + "destination_location": "CHARLESTON SC, 29401", + "destination_tracking_location": null, + "guaranteed_delivery_date": null, + "alternate_identifier": null, + "initial_delivery_attempt": null + }, + "public_url": "https://track.easypost.com/djE6dHJrXzFjNTY1MjZhODllMDRjNGM4MDAxM2ZkNzYzZjkxMjI4" + }, + "to_address": { + "id": "adr_6e09528d1f4711ee9deaac1f6bc53342", + "object": "Address", + "created_at": "2023-07-10T17:30:14+00:00", + "updated_at": "2023-07-10T17:30:15+00:00", + "name": "DR. STEVE BRULE", + "company": null, + "street1": "179 N HARBOR DR", + "street2": null, + "city": "REDONDO BEACH", + "state": "CA", + "zip": "90277-2506", + "country": "US", + "phone": "8573875756", + "email": "DR_STEVE_BRULE@GMAIL.COM", + "mode": "test", + "carrier_facility": null, + "residential": false, + "federal_tax_id": null, + "state_tax_id": null, + "verifications": { + "zip4": { + "success": true, + "errors": [], + "details": null + }, + "delivery": { + "success": true, + "errors": [], + "details": { + "latitude": 33.8436, + "longitude": -118.39177, + "time_zone": "America/Los_Angeles" + } + } + } + }, + "usps_zone": 4, + "return_address": { + "id": "adr_6e0ac14a1f4711eeacd5ac1f6bc539ae", + "object": "Address", + "created_at": "2023-07-10T17:30:14+00:00", + "updated_at": "2023-07-10T17:30:14+00:00", + "name": "EasyPost", + "company": null, + "street1": "417 Montgomery Street", + "street2": "5th Floor", + "city": "San Francisco", + "state": "CA", + "zip": "94104", + "country": "US", + "phone": "4153334445", + "email": "support@easypost.com", + "mode": "test", + "carrier_facility": null, + "residential": null, + "federal_tax_id": null, + "state_tax_id": null, + "verifications": {} + }, + "buyer_address": { + "id": "adr_6e09528d1f4711ee9deaac1f6bc53342", + "object": "Address", + "created_at": "2023-07-10T17:30:14+00:00", + "updated_at": "2023-07-10T17:30:15+00:00", + "name": "DR. STEVE BRULE", + "company": null, + "street1": "179 N HARBOR DR", + "street2": null, + "city": "REDONDO BEACH", + "state": "CA", + "zip": "90277-2506", + "country": "US", + "phone": "8573875756", + "email": "DR_STEVE_BRULE@GMAIL.COM", + "mode": "test", + "carrier_facility": null, + "residential": false, + "federal_tax_id": null, + "state_tax_id": null, + "verifications": { + "zip4": { + "success": true, + "errors": [], + "details": null + }, + "delivery": { + "success": true, + "errors": [], + "details": { + "latitude": 33.8436, + "longitude": -118.39177, + "time_zone": "America/Los_Angeles" + } + } + } + }, + "forms": [], + "fees": [ + { + "object": "Fee", + "type": "LabelFee", + "amount": "0.00000", + "charged": true, + "refunded": false + }, + { + "object": "Fee", + "type": "PostageFee", + "amount": "4.81000", + "charged": true, + "refunded": false + } + ], + "id": "shp_06a2ad37dc1c425c88c593f3e9cf5ea4", + "object": "Shipment" + } + ], + "has_more": false +} diff --git a/official/docs/ruby/current/pagination/get-next-page.rb b/official/docs/ruby/current/pagination/get-next-page.rb new file mode 100644 index 00000000..7f19bd87 --- /dev/null +++ b/official/docs/ruby/current/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