Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EasyPost-Official" Version="7.0.0" />
<PackageReference Include="EasyPost-Official" Version="7.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
14 changes: 9 additions & 5 deletions official/docs/csharp/current/shipments/create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,33 @@ public static async Task Main()
Height = 5,
Weight = 10
},
CustomsInfo = new EasyPost.Parameters.CustomsInfo.Create
LineItems = new List<EasyPost.Parameters.ILineItemParameter>
{
// ...
new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
Comment on lines +46 to +48

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. examples.csproj now references EasyPost-Official 7.5.0, which has shipment line items.

new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
}
};

EasyPost.Models.API.Shipment shipment = await client.Shipment.Create(parameters);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));

// Create a shipment using existing addresses, parcel, and customs info
// Create a shipment using existing addresses and parcel

EasyPost.Models.API.Address toAddress = await client.Address.Retrieve("adr_...");
EasyPost.Models.API.Address fromAddress = await client.Address.Retrieve("adr_...");
EasyPost.Models.API.Parcel parcel = await client.Parcel.Retrieve("prcl_...");
EasyPost.Models.API.CustomsInfo customsInfo = await client.CustomsInfo.Retrieve("cstinfo_...");

parameters = new()
{
ToAddress = toAddress,
FromAddress = fromAddress,
Parcel = parcel,
CustomsInfo = customsInfo
LineItems = new List<EasyPost.Parameters.ILineItemParameter>
{
new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
}
};

shipment = await client.Shipment.Create(parameters);
Expand Down
13 changes: 10 additions & 3 deletions official/docs/curl/current/shipments/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ curl -X POST https://api.easypost.com/v2/shipments \
"height": "5",
"weight": "65.9"
},
"customs_info": {
"id": "cstinfo_..."
}
"line_items": [
{
"total_line_value": "129.00",
"item_description": "Mugs"
},
{
"total_line_value": "45.50",
"item_description": "T-shirts"
}
]
}
}'
11 changes: 9 additions & 2 deletions official/docs/golang/current/shipments/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ func create() {
Height: 5,
Weight: 65.9,
},
CustomsInfo: &easypost.CustomsInfo{
ID: "cstinfo_...",
LineItems: []*easypost.LineItem{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. go.mod now requires easypost-go v5.6.0, which has Shipment.LineItems.

{
TotalLineValue: "129.00",
ItemDescription: "Mugs",
},
{
TotalLineValue: "45.50",
ItemDescription: "T-shirts",
},
},
},
)
Expand Down
17 changes: 14 additions & 3 deletions official/docs/java/current/shipments/create.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
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 {
Expand Down Expand Up @@ -37,14 +39,23 @@ public static void main(String[] args) throws EasyPostException {
parcelMap.put("height", 5);
parcelMap.put("weight", 65.9);

HashMap<String, Object> customsInfoMap = new HashMap<String, Object>();
customsInfoMap.put("id", "cstinfo_...");
HashMap<String, Object> mugLineItem = new HashMap<String, Object>();
mugLineItem.put("total_line_value", "129.00");
mugLineItem.put("item_description", "Mugs");

HashMap<String, Object> shirtLineItem = new HashMap<String, Object>();
shirtLineItem.put("total_line_value", "45.50");
shirtLineItem.put("item_description", "T-shirts");

List<HashMap<String, Object>> lineItems = new ArrayList<HashMap<String, Object>>();
lineItems.add(mugLineItem);
lineItems.add(shirtLineItem);

HashMap<String, Object> params = new HashMap<String, Object>();
params.put("to_address", toAddressMap);
params.put("from_address", fromAddressMap);
params.put("parcel", parcelMap);
params.put("customs_info", customsInfoMap);
params.put("line_items", lineItems);

Shipment shipment = client.shipment.create(params);

Expand Down
10 changes: 8 additions & 2 deletions official/docs/node/current/shipments/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ const client = new EasyPostClient('EASYPOST_API_KEY');
height: 5,
weight: 65.9,
},
customs_info: { id: 'cstinfo_...' },
line_items: [
{ total_line_value: '129.00', item_description: 'Mugs' },
{ total_line_value: '45.50', item_description: 'T-shirts' },
],
});

// or create by using IDs
Expand All @@ -41,7 +44,10 @@ const client = new EasyPostClient('EASYPOST_API_KEY');
to_address: { id: 'adr_...' },
from_address: { id: 'adr_...' },
parcel: { id: 'prcl_...' },
customs_info: { id: 'cstinfo_...' },
line_items: [
{ total_line_value: '129.00', item_description: 'Mugs' },
{ total_line_value: '45.50', item_description: 'T-shirts' },
],
});

console.log(shipment);
Expand Down
10 changes: 10 additions & 0 deletions official/docs/php/current/shipments/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
'width' => 10.9,
'height' => 5,
'weight' => 65.9
],
'line_items' => [
[
'total_line_value' => '129.00',
'item_description' => 'Mugs'
],
[
'total_line_value' => '45.50',
'item_description' => 'T-shirts'
]
]
]);

Expand Down
10 changes: 8 additions & 2 deletions official/docs/python/current/shipments/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"height": 5,
"weight": 65.9,
},
customs_info={"id": "cstinfo_..."},
line_items=[
{"total_line_value": "129.00", "item_description": "Mugs"},
{"total_line_value": "45.50", "item_description": "T-shirts"},
],
)

# or create by using IDs
Expand All @@ -39,7 +42,10 @@
to_address={"id": "adr_..."},
from_address={"id": "adr_..."},
parcel={"id": "prcl_..."},
customs_info={"id": "cstinfo_..."},
line_items=[
{"total_line_value": "129.00", "item_description": "Mugs"},
{"total_line_value": "45.50", "item_description": "T-shirts"},
],
)

print(shipment)
13 changes: 10 additions & 3 deletions official/docs/ruby/current/shipments/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@
height: 5,
weight: 65.9,
},
customs_info: {
id: 'cstinfo_...',
},
line_items: [
{
total_line_value: '129.00',
item_description: 'Mugs',
},
{
total_line_value: '45.50',
item_description: 'T-shirts',
},
],
)

puts shipment
Loading