Skip to content

Commit f2bfa76

Browse files
committed
Merge pull request #7 from proclame/return-negotiated-rates-c
2 parents beef972 + 44da841 commit f2bfa76

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

demo/create-label.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use RahulGodiyal\PhpUpsApiWrapper\Entity\ShipmentRequest;
2121
use RahulGodiyal\PhpUpsApiWrapper\Entity\Shipper;
2222
use RahulGodiyal\PhpUpsApiWrapper\Entity\ShipQuery;
23+
use RahulGodiyal\PhpUpsApiWrapper\Entity\ShippingRatingOptions;
2324
use RahulGodiyal\PhpUpsApiWrapper\Entity\ShipTo;
2425
use RahulGodiyal\PhpUpsApiWrapper\Entity\UnitOfMeasurement;
2526
use RahulGodiyal\PhpUpsApiWrapper\Ship;
@@ -162,6 +163,13 @@
162163
$shipment->setService($service);
163164
$shipment->setPackage($package);
164165
$shipment->setReferenceNumber($shipmentReferenceNumber); // optional
166+
167+
/************ ShippingRatingOptions **********/
168+
$shippingRatingOptions = new ShippingRatingOptions(); // optional
169+
$shippingRatingOptions->setNegotiatedRatesIndicator(true); // optional
170+
$shipment->setShippingRatingOptions($shippingRatingOptions); // optional
171+
/************ End ShippingRatingOptions **********/
172+
165173
/************ End Shipment **********/
166174

167175
/************ Label Specification **********/

src/Entity/Shipment.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ class Shipment
1313
private Service $service;
1414
private Package $package;
1515
private ReferenceNumber $referenceNumber;
16+
private ShippingRatingOptions $shippingRatingOptions;
1617

1718
public function __construct()
1819
{
1920
$this->returnService = new ReturnService();
2021
$this->paymentInformation = new PaymentInformation();
2122
$this->referenceNumber = new ReferenceNumber();
23+
$this->shippingRatingOptions = new ShippingRatingOptions();
2224
}
2325

2426
public function setDescription(string $description): self
@@ -120,6 +122,17 @@ public function getPackage(): Package
120122
return $this->package;
121123
}
122124

125+
public function setShippingRatingOptions(ShippingRatingOptions $shippingRatingOptions): self
126+
{
127+
$this->shippingRatingOptions = $shippingRatingOptions;
128+
return $this;
129+
}
130+
131+
public function getShippingRatingOptions(): ShippingRatingOptions
132+
{
133+
return $this->shippingRatingOptions;
134+
}
135+
123136
public function toArray(): array
124137
{
125138
$shipment = [
@@ -148,6 +161,10 @@ public function toArray(): array
148161
if ($this->referenceNumber->exists()) {
149162
$shipment["ReferenceNumber"] = $this->referenceNumber->toArray();
150163
}
164+
165+
if ($this->shippingRatingOptions->exists()) {
166+
$shipment["ShipmentRatingOptions"] = $this->shippingRatingOptions->toArray();
167+
}
151168

152169
return $shipment;
153170
}

src/Entity/ShippingRatingOptions.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace RahulGodiyal\PhpUpsApiWrapper\Entity;
4+
5+
class ShippingRatingOptions
6+
{
7+
private bool $negotiatedRatesIndicator = false;
8+
private bool $frsShipmentIndicator = false;
9+
private bool $rateChartIndicator = false;
10+
11+
public function exists(): bool
12+
{
13+
return $this->negotiatedRatesIndicator || $this->frsShipmentIndicator || $this->rateChartIndicator;
14+
}
15+
16+
public function setNegotiatedRatesIndicator(bool $negotiatedRatesIndicator): self
17+
{
18+
$this->negotiatedRatesIndicator = $negotiatedRatesIndicator;
19+
return $this;
20+
}
21+
22+
public function getNegotiatedRatesIndicator(): bool
23+
{
24+
return $this->negotiatedRatesIndicator;
25+
}
26+
27+
public function setFrsShipmentIndicator(bool $frsShipmentIndicator): self
28+
{
29+
$this->frsShipmentIndicator = $frsShipmentIndicator;
30+
return $this;
31+
}
32+
33+
public function getFrsShipmentIndicator(): bool
34+
{
35+
return $this->frsShipmentIndicator;
36+
}
37+
38+
public function setRateChartIndicator(bool $rateChartIndicator): self
39+
{
40+
$this->rateChartIndicator = $rateChartIndicator;
41+
return $this;
42+
}
43+
44+
public function getRateChartIndicator(): bool
45+
{
46+
return $this->rateChartIndicator;
47+
}
48+
49+
public function toArray(): array
50+
{
51+
$options = [];
52+
53+
if ($this->negotiatedRatesIndicator) {
54+
$options["NegotiatedRatesIndicator"] = "";
55+
}
56+
57+
if ($this->frsShipmentIndicator) {
58+
$options["FRSShipmentIndicator"] = "";
59+
}
60+
61+
if (!empty($this->rateChartIndicator)) {
62+
$options["RateChartIndicator"] = "";
63+
}
64+
65+
return $options;
66+
}
67+
}

0 commit comments

Comments
 (0)