Skip to content

Commit

Permalink
Merge pull request #141 from EasyPost/smartrate
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 authored Jul 15, 2024
2 parents b79c16e + 6196a67 commit 5010ea0
Show file tree
Hide file tree
Showing 29 changed files with 787 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Parameters.Shipment.RecommendShipDateForShipment parameters = new()
{
DesiredDeliveryDate = "2024-07-18",
};

List<RecommendShipDateForShipmentResult> rates = await client.Shipment.RecommendShipDate("shp_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(rates, Formatting.Indented));
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Parameters.SmartRate.EstimateDeliveryDateForZipPair estimateDeliveryDateForZipPairParameters = new()
{
OriginPostalCode = address1Parameters.Zip,
DestinationPostalCode = address2Parameters.Zip,
PlannedShipDate = Fixtures.PlannedShipDate,
Carriers = ["USPS"],
};

EstimateDeliveryDateForZipPairResult results = await client.SmartRate.EstimateDeliveryDate(estimateDeliveryDateForZipPairParameters);

Console.WriteLine(JsonConvert.SerializeObject(results, Formatting.Indented));
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Parameters.SmartRate.RecommendShipDateForZipPair recommendShipDateForZipPairParameters = new()
{
OriginPostalCode = address1Parameters.Zip,
DestinationPostalCode = address2Parameters.Zip,
DesiredDeliveryDate = Fixtures.DesiredDeliveryDate,
Carriers = ["USPS"],
};

RecommendShipDateForZipPairResult results = await client.SmartRate.RecommendShipDate(recommendShipDateForZipPairParameters);

Console.WriteLine(JsonConvert.SerializeObject(results, Formatting.Indented));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
curl -X GET https://api.easypost.com/v2/shipments/shp_.../smartrate/precision_shipping?desired_delivery_date=yyyy-mm-dd \
-u "EASYPOST_API_KEY":
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
curl -X POST https://api.easypost.com/v2/smartrate/deliver_by \
-u "EASYPOST_API_KEY": \
-H 'Content-Type: application/json' \
-d '{
"from_zip": "10001",
"planned_ship_date": "2024-07-18",
"to_zip": "10002",
"carriers": [UPS],
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
curl -X POST https://api.easypost.com/v2/smartrate/deliver_on \
-u "EASYPOST_API_KEY": \
-H 'Content-Type: application/json' \
-d '{
"from_zip": "10001",
"desired_delivery_date": "2024-07-18",
"to_zip": "10002",
"carriers": [UPS],
}'
9 changes: 9 additions & 0 deletions official/docs/golang/current/carrier-accounts/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,14 @@ func main() {
},
)

// For UPS account creation, please use below method instead

createUpsParameters := &easypost.UpsCarrierAccountCreationParameters{
AccountNumber: "123456789",
Type: "UpsAccount",
}

carrierAccount, err := client.CreateUpsCarrierAccount(createUpsParameters)

fmt.Println(carrierAccount)
}
8 changes: 8 additions & 0 deletions official/docs/golang/current/carrier-accounts/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ func main() {
},
)

// For UPS account update, please use below method instead

updateParameters := &easypost.UpsCarrierAccountUpdateParameters{
AccountNumber: "987654321",
}

carrierAccount, err := client.UpdateUpsCarrierAccount(carrierAccount.ID, updateParameters)

fmt.Println(carrierAccount)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package example

import (
"fmt"

"github.com/EasyPost/easypost-go/v4"
)

func main() {
client := easypost.New("EASYPOST_API_KEY")

rates, _ := client.RecommendShipDateForShipment("shp_...", "YYYY-MM-DD")

fmt.Println(rates)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package example

import (
"fmt"

"github.com/EasyPost/easypost-go/v4"
)

func main() {
client := easypost.New("EASYPOST_API_KEY")

params := &easypost.EstimateDeliveryDateForZipPairParams{
OriginPostalCode: "10001",
DestinationPostalCode: "10002",
Carriers: []string{"UPS", "FedEx"},
PlannedShipDate: "2024-07-18",
}

estimates, _ := client.EstimateDeliveryDateForZipPair(params)

fmt.Println(estimates)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package example

import (
"fmt"

"github.com/EasyPost/easypost-go/v4"
)

func main() {
client := easypost.New("EASYPOST_API_KEY")

params := &easypost.RecommendShipDateForZipPairParams{
OriginPostalCode: "10001",
DestinationPostalCode: "10002",
Carriers: []string{"UPS", "FedEx"},
DesiredDeliveryDate: "2024-07-18",
}

recommendations, _ := client.RecommendShipDateForZipPair(params)

fmt.Println(recommendations)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package shipments;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Shipment;
import com.easypost.model.RecommendShipDateForShipmentResult;
import com.easypost.service.EasyPostClient;

import java.util.List;

public class RetrieveRecommendShipDate {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

Shipment shipment = client.shipment.retrieve("shp_...");
List<RecommendShipDateForShipmentResult> rates = client.shipment
.recommendShipDate(shipment.getId(), "YYYY-MM-DD");

System.out.println(rates);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package shipments;

import com.easypost.exception.EasyPostException;
import com.easypost.model.EstimateDeliveryDateForZipPairResult;
import com.easypost.service.EasyPostClient;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class RetrieveRecommendShipDate {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");
Map<String, Object> params = new HashMap<String, Object>();
params.put("from_zip", "10001");
params.put("to_zip", "10002");
params.put("planned_ship_date", "2024-07-18");
params.put("carriers", Collections.singletonList("UPS"));

EstimateDeliveryDateForZipPairResult results = client.smartRate
.estimateDeliveryDate(params);

System.out.println(results);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package shipments;

import com.easypost.exception.EasyPostException;
import com.easypost.model.RecommendShipDateForZipPairResult;
import com.easypost.service.EasyPostClient;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class RetrieveRecommendShipDate {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");
Map<String, Object> params = new HashMap<String, Object>();
params.put("from_zip", "10001");
params.put("to_zip", "10002");
params.put("desired_delivery_date", "2024-07-18");
params.put("carriers", Collections.singletonList("UPS"));

RecommendShipDateForZipPairResult results = client.smartRate
.recommendShipDate(params);

System.out.println(results);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
const rates = await client.Shipment.recommendShipDate('shp_...', 'YYYY-MM-DD');

console.log(rates);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient('EASYPOST_API_KEY');

const params = {
from_zip: '10001',
to_zip: '10002',
planned_ship_date: '2024-07-18',
carriers: ['UPS'],
};

(async () => {
const results = await client.SmartRate.estimateDeliveryDate(params);

console.log(results);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient('EASYPOST_API_KEY');

const params = {
from_zip: '10001',
to_zip: '10002',
desired_delivery_date: '2024-07-18',
carriers: ['UPS'],
};

(async () => {
const results = await client.SmartRate.recommendShipDate(params);

console.log(results);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$client = new \EasyPost\EasyPostClient('EASYPOST_API_KEY');

$rates = $client->shipment->recommendShipDate('shp_...', 'YYYY-MM-DD');

echo $rates;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$client = new \EasyPost\EasyPostClient('EASYPOST_API_KEY');

$params = [
'from_zip' => '10001',
'to_zip' => '10002',
'planned_ship_date' => '2024-07-18',
'carriers' => ['UPS'],
];

$results = $client->smartRate->estimateDeliveryDate($params);

echo $results;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$client = new \EasyPost\EasyPostClient('EASYPOST_API_KEY');

$params = [
'from_zip' => '10001',
'to_zip' => '10002',
'desired_delivery_date' => '2024-07-18',
'carriers' => ['UPS'],
];

$results = $client->smartRate->recommendShipDate($params);

echo $results;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

estimated_delivery_dates = client.shipment.recommend_ship_date(
"shp_...",
desired_delivery_date="YYYY-MM-DD",
)

print(estimated_delivery_dates)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

params = {
"from_zip": "10001",
"to_zip": "10002",
"planned_ship_date": "2024-07-18",
"carriers": ["usps"],
}

results = client.smartrate.estimate_delivery_date(**params)

print(results)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

params = {
"from_zip": "10001",
"to_zip": "10002",
"desired_delivery_date": "2024-07-18",
"carriers": ["usps"],
}

results = client.smartrate.recommend_ship_date(**params)

print(results)
Loading

0 comments on commit 5010ea0

Please sign in to comment.