-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add get_next_page code examples (#113)
* Add get_next_page code examples * Lints * Add curl example * Lint * Lint the right curl command * Typo
- Loading branch information
1 parent
22b9ed0
commit 91e3f5a
Showing
10 changed files
with
598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ venv | |
/style_suppressions.xml | ||
/.dummy | ||
/.eslintignore | ||
*.sw* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, Object> 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
$client = new \EasyPost\EasyPostClient(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 | ||
$nextPage = $client->shipments->getNextPage($shipments); | ||
|
||
echo $nextPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.