Skip to content
39 changes: 35 additions & 4 deletions src/FedexRest/Entity/PackageSpecialServicesRequested.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

namespace FedexRest\Entity;

use FedexRest\Services\Ship\Type\PackageSpecialServiceType;

class PackageSpecialServicesRequested
{

public array $specialServiceTypes;
public ?DangerousGoodsDetail $dangerousGoodsDetail;
public ?Weight $dryIceWeight;
public ?$signatureOptionType;
public ?PackageSpecialServiceType $dangerousGoods;

/**
* @param array $specialServiceTypes
Expand Down Expand Up @@ -38,6 +42,16 @@ public function setDangerousGoodsDetail(?DangerousGoodsDetail $dangerousGoodsDet
$this->dangerousGoodsDetail = $dangerousGoodsDetail;
return $this;
}

/**
* @param ?DangerousGoods $dangerousGoods
* @return $this
*/
public function setDangerousGoods(?PackageSpecialServiceType $dangerousGoods): PackageSpecialServicesRequested
{
$this->dangerousGoods = $dangerousGoods;
return $this;
}

/**
* @param ?Weight $dryIceWeight
Expand All @@ -48,12 +62,26 @@ public function setDryIceWeight(?Weight $dryIceWeight): PackageSpecialServicesRe
$this->dryIceWeight = $dryIceWeight;
return $this;
}


/**
* @param ?PackageSpecialServiceType $signatureOptionType
* @return $this
*/
public function setSignatureOptionType(?PackageSpecialServiceType $signatureOptionType): PackageSpecialServicesRequested {
$this->signatureOptionType = $signatureOptionType;
return $this;

}

public function prepare(): array {
$data = [];

if (!empty($this->setSpecialServiceTypes)) {
$data['specialServiceTypes'] = $this->setSpecialServiceTypes;
if (!empty($this->specialServiceTypes)) {
$data['specialServiceTypes'] = $this->specialServiceTypes;
}

if (!empty($this->dangerousGoods)) {
$data['dangerousGoods'] = $this->dangerousGoods;
}

if (!empty($this->dangerousGoodsDetail)) {
Expand All @@ -63,7 +91,10 @@ public function prepare(): array {
if (!empty($this->dryIceWeight)) {
$data['dryIceWeight'] = $this->dryIceWeight->prepare();
}


if (!empty($this->signatureOptionType)) {
$data['signatureOptionType'] = $this->signatureOptionType;
}
return $data;
}

Expand Down
38 changes: 33 additions & 5 deletions src/FedexRest/Services/Rates/CreateRatesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
use FedexRest\Services\Ship\Entity\Label;
use FedexRest\Services\Ship\Entity\ShipmentSpecialServices;
use FedexRest\Services\Ship\Entity\ShippingChargesPayment;
use FedexRest\Services\Ship\Entity\SmartPostInfoDetail;
use FedexRest\Services\Ship\Entity\CustomsClearanceDetail;
use GuzzleHttp\Exception\GuzzleException;

class CreateRatesRequest extends AbstractRequest
{

protected Person $shipper;
protected Person $recipient;
protected Label $label;
Expand All @@ -24,10 +27,12 @@ class CreateRatesRequest extends AbstractRequest
protected array $rateRequestTypes;
protected string $packagingType = '';
protected string $pickupType = '';
protected ?SmartPostInfoDetail $smart_post;
protected int $accountNumber;
protected array $lineItems = [];
protected ShipmentSpecialServices $shipmentSpecialServices;
protected ShippingChargesPayment $shippingChargesPayment;
protected ?CustomsClearanceDetail $customsClearanceDetail;
protected int $totalWeight;
protected string $preferredCurrency = '';
protected int $totalPackageCount;
Expand Down Expand Up @@ -154,6 +159,15 @@ public function getPickupType(): string
return $this->pickupType;
}

/**
* @param SmartPostInfoDetail $SmartPostInfoDetail
* @return $this
*/
public function setSmartPost(SmartPostInfoDetail $smartPost): CreateRatesRequest {
$this->smart_post = $smartPost;
return $this;
}

/**
* @param int $accountNumber
* @return $this
Expand Down Expand Up @@ -229,6 +243,15 @@ public function getShippingChargesPayment(): ShippingChargesPayment
{
return $this->shippingChargesPayment;
}

/**
* @param CustomsClearanceDetail $customsClearanceDetail
* @return $this
*/
public function setCustomsClearanceDetail(CustomsClearanceDetail $customsClearanceDetail) {
$this->customsClearanceDetail = $customsClearanceDetail;
return $this;
}

/**
* @param int $totalWeight
Expand Down Expand Up @@ -306,24 +329,24 @@ public function getServicesNeededOnRateFailure(): bool
return $this->servicesNeededOnRateFailure;
}

public function setVariableOptions(?string $variableOptions): CreateRatesRequest
public function setVariableOptions(string $variableOptions): CreateRatesRequest
{
$this->variableOptions = $variableOptions;
return $this;
}

public function getVariableOptions(): ?string
public function getVariableOptions(): string
{
return $this->variableOptions;
}

public function setRateSortOrder(?string $rateSortOrder): CreateRatesRequest
public function setRateSortOrder(string $rateSortOrder): CreateRatesRequest
{
$this->rateSortOrder = $rateSortOrder;
return $this;
}

public function getRateSortOrder(): ?string
public function getRateSortOrder(): string
{
return $this->rateSortOrder;
}
Expand Down Expand Up @@ -383,11 +406,16 @@ public function getRequestedShipment(): array
'recipient' => $this->recipient->prepare(),
'pickupType' => $this->pickupType,
'requestedPackageLineItems' => $line_items,
'smartPostInfoDetail' => $this->smart_post,
];

if (!empty($this->shipmentSpecialServices)) {
$data['shipmentSpecialServices'] = $this->shipmentSpecialServices->prepare();
}

if (!empty($this->customsClearanceDetail)) {
$data['customsClearanceDetail'] = $this->customsClearanceDetail->prepare();
}

if (!empty($this->serviceType)) {
$data['serviceType'] = $this->serviceType;
Expand Down Expand Up @@ -421,7 +449,7 @@ public function getRequestedShipment(): array
}

public function prepare(): array
{
{
return [
'accountNumber' => [
'value' => $this->accountNumber,
Expand Down
116 changes: 116 additions & 0 deletions src/FedexRest/Services/Ship/Entity/Commodities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

namespace FedexRest\Services\Ship\Entity;

use FedexRest\Entity\Weight;
use FedexRest\Services\Ship\Entity\Value;

class Commodities
{
public string $name;
public string $description;
public string $countryOfManufacture;
public string $quantity;
public string $harmonizedCode;
public ?Weight $weight;
public ?Value $customsValue;

/**
* @param string $name
* @return $this
*/
public function setName(string $name): Commodities
{
$this->name = $name;
return $this;
}

/**
* @param string $description
* @return $this
*/
public function setDescription(string $description): Commodities
{
$this->description = $description;
return $this;
}

/**
* @param string $countryOfManufacture
* @return $this
*/
public function setCountryOfManufacture(string $countryOfManufacture): Commodities
{
$this->countryOfManufacture = $countryOfManufacture;
return $this;
}

/**
* @param string $countryOfManufacture
* @return $this
*/
public function setQuantity(string $quantity): Commodities
{
$this->quantity = $quantity;
return $this;
}

/**
* @param string $harmonizedCode
* @return $this
*/
public function setHarmonizedCode(string $harmonizedCode): Commodities
{
$this->harmonizedCode = $harmonizedCode;
return $this;
}

/**
* @param Value $customsValue
* @return $this
*/
public function setCustomsValue(Value $customsValue): Commodities
{
$this->customsValue = $customsValue;
return $this;
}

/**
* @param Weight $weight
* @return $this
*/
public function setWeight(Weight $weight): Commodities
{
$this->weight = $weight;
return $this;
}


public function prepare(): array {
$data = [];
if (!empty($this->name)) {
$data['name'] = ($this->name);
}
if (!empty($this->description)) {
$data['description'] = ($this->description);
}
if (!empty($this->countryOfManufacture)) {
$data['countryOfManufacture'] = ($this->countryOfManufacture);
}
if (!empty($this->quantity)) {
$data['quantity'] = ($this->quantity);
}
if (!empty($this->harmonizedCode)) {
$data['harmonizedCode'] = ($this->harmonizedCode);
}
if (!empty($this->weight)) {
$data['weight'] = ($this->weight);
}
if (!empty($this->customsValue)) {
$data['customsValue'] = ($this->customsValue);
}
return $data;
}


}
46 changes: 46 additions & 0 deletions src/FedexRest/Services/Ship/Entity/CustomsClearanceDetail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace FedexRest\Services\Ship\Entity;

use FedexRest\Services\Ship\Entity\Commodities;
use FedexRest\Services\Ship\Entity\DutiesPayment;

class CustomsClearanceDetail
{
public ?Commodities $commodities;
public ?DutiesPayment $dutiesPayment;

/**
* @param Commodities $commodities
* @return $this
*/
public function setCommodities(?Commodities $commodities): CustomsClearanceDetail
{
$this->commodities = $commodities;
return $this;
}

/**
* @param DutiesPayment $dutiesPayment
* @return $this
*/
public function setDutiesPayment(?DutiesPayment $dutiesPayment): CustomsClearanceDetail
{
$this->dutiesPayment = $dutiesPayment;
return $this;
}


public function prepare(): array {
$data = [];
if (!empty($this->commodities)) {
$data['commodities'] = (array($this->commodities->prepare()));
}
if (!empty($this->dutiesPayment)) {
$data['dutiesPayment'] = ($this->dutiesPayment);
}
return $data;
}


}
44 changes: 44 additions & 0 deletions src/FedexRest/Services/Ship/Entity/DutiesPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace FedexRest\Services\Ship\Entity;

use FedexRest\Services\Ship\Type\PaymentType;

class DutiesPayment
{
public ?PaymentType $paymentType;
public string $payor;

/**
* @param PaymentType $paymentType
* @return $this
*/
public function setPaymentType(?PaymentType $paymentType): DutiesPayment
{
$this->paymentType = $paymentType;
return $this;
}

/**
* @param array $payor
* @return $this
*/
public function setPayor(string $payor = NULL): DutiesPayment
{
$this->payor = array('responsibleParty'=>$payor);
return $this;
}

public function prepare(): array {
$data = [];
if (!empty($this->paymentType)) {
$data['paymentType'] = ($this->paymentType);
}
if (!empty($this->payor)) {
$data['payor'] = ($this->payor);
}
return $data;
}


}
Loading