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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A PHP SDK for the UPS REST API, brought to you by [ShipStream](https://shipstrea
composer require shipstream/ups-rest-php-sdk
```

**Note:** The latest version is compatible only with PHP 8.x. For PHP 7.4 support, please append the `^1.0` version constraint to the above command.
**Note:** The latest version supports PHP 8.2 or above. For PHP 7.4 support, please append the `^1.0` version constraint to the above command.

## Basic Usage

Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-curl": "*",
"ext-json": "*",
"jane-php/open-api-runtime": "^7.6",
"php-http/curl-client": "^2.3",
"symfony/polyfill-php81": "^1.28"
"jane-php/open-api-runtime": "^7.10",
"php-http/curl-client": "^2.3"
},
"require-dev": {
"jane-php/open-api-3": "^7.6",
"jane-php/open-api-3": "^7.10",
"nyholm/psr7": "^1.8",
"phpunit/phpunit": "^9.6"
},
Expand All @@ -39,7 +38,7 @@
"php-http/discovery": true
},
"platform": {
"php": "8.0"
"php": "8.1"
},
"sort-packages": true
}
Expand Down
380 changes: 168 additions & 212 deletions src/Api/Client.php

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/Api/Endpoint/AcceptanceAuditPreCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ class AcceptanceAuditPreCheck extends \ShipStream\Ups\Api\Runtime\Client\BaseEnd
protected $version;
/**
* Enables shippers perform pre-checks before shipping dangerous goods using the chemical record identifier and the commodity's regulated level code.
*
* @param string $version API version
* @param \ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYAPCRequestWrapper $requestBody
* @param \ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYAPCRequestWrapper $requestBody
* @param array $headerParameters {
* @var string $transId An identifier unique to the request. Length 32
* @var string $transactionSrc An identifier of the client/source application that is making the request.Length 512
Expand Down Expand Up @@ -66,19 +65,19 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYAPCResponseWrapper', 'json');
}
if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (400 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AcceptanceAuditPreCheckBadRequestException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (401 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (401 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AcceptanceAuditPreCheckUnauthorizedException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (403 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (403 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AcceptanceAuditPreCheckForbiddenException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (429 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (429 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AcceptanceAuditPreCheckTooManyRequestsException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
throw new \ShipStream\Ups\Api\Exception\UnexpectedStatusCodeException($status, $body);
Expand Down
15 changes: 6 additions & 9 deletions src/Api/Endpoint/AddressValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class AddressValidation extends \ShipStream\Ups\Api\Runtime\Client\BaseEndpoint
protected $version;
/**
* The Address Validation Street Level API can be used to check addresses against the United States Postal Service database of valid addresses in the U.S. and Puerto Rico.
*
* @param int $requestoption Identifies the optional processing to be performed. If not present or invalid value then an error will be sent back.

Valid values:
Expand All @@ -17,13 +16,11 @@ class AddressValidation extends \ShipStream\Ups\Api\Runtime\Client\BaseEndpoint
- 3 - Address Validation and Address Classification.

For a list of valid values, refer to Address Validation API Supported Countries or Territories in the Appendix.

* @param string $version Identifies the version of the API.

Valid values:
- v2

* @param \ShipStream\Ups\Api\Model\XAVRequestWrapper $requestBody
* @param \ShipStream\Ups\Api\Model\XAVRequestWrapper $requestBody
* @param array $queryParameters {
* @var string $regionalrequestindicator Valid values: True or False. If True, either the region element or any combination of Political Division 1, Political Division 2, PostcodePrimaryLow and the PostcodeExtendedLow fields will be recognized for validation in addition to the urbanization element. If False or no indicator, street level address validation is provided
* @var int $maximumcandidatelistsize Valid values: 0 – 50 The maximum number of Candidates to return for this request. If not provided, the default size of 15 is returned.
Expand Down Expand Up @@ -81,19 +78,19 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'ShipStream\Ups\Api\Model\XAVResponseWrapper', 'json');
}
if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (400 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AddressValidationBadRequestException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (401 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (401 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AddressValidationUnauthorizedException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (403 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (403 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AddressValidationForbiddenException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (429 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (429 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AddressValidationTooManyRequestsException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
throw new \ShipStream\Ups\Api\Exception\UnexpectedStatusCodeException($status, $body);
Expand Down
9 changes: 4 additions & 5 deletions src/Api/Endpoint/AuthorizeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class AuthorizeClient extends \ShipStream\Ups\Api\Runtime\Client\BaseEndpoint im
{
/**
* The Authorize Client endpoint initiates the OAuth Authorization Code flow by redirecting the user to UPS for logging-in and authorize the client application. To begin the authorization flow, the application constructs a URL using the application's client Id, the redirect URI, the scope of permissions requested, and a random string used for subsequent verification. A successful response redirects back to the client with an authorization code that can be exchanged for an access token.
*
* @param array $queryParameters {
* @var string $client_id The public identifier for your application, obtained when you, the developer first registered the application.
* @var string $redirect_uri URL that tells the authorization server where to send the user back to after they approve the request.
Expand Down Expand Up @@ -67,16 +66,16 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re
if (302 === $status) {
return null;
}
if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (400 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AuthorizeClientBadRequestException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (401 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (401 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AuthorizeClientUnauthorizedException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (403 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (403 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AuthorizeClientForbiddenException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (429 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (429 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\AuthorizeClientTooManyRequestsException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
throw new \ShipStream\Ups\Api\Exception\UnexpectedStatusCodeException($status, $body);
Expand Down
13 changes: 6 additions & 7 deletions src/Api/Endpoint/ChemicalReferenceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ class ChemicalReferenceData extends \ShipStream\Ups\Api\Runtime\Client\BaseEndpo
protected $version;
/**
* The Chemical Reference Data endpoint of the Dangerous Goods API allows shippers look up hazardous material reference information by ID number and shipping name of the specified regulated good.
*
* @param string $version Version of the API. Valid values:
v1
v1801. Length 5
* @param \ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYRequestWrapper $requestBody
* @param \ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYRequestWrapper $requestBody
* @param array $headerParameters {
* @var string $transId An identifier unique to the request. Length 32
* @var string $transactionSrc An identifier of the client/source application that is making the request.Length 512
Expand Down Expand Up @@ -68,19 +67,19 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'ShipStream\Ups\Api\Model\DANGEROUSGOODSUTILITYResponseWrapper', 'json');
}
if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (400 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\ChemicalReferenceDataBadRequestException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (401 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (401 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\ChemicalReferenceDataUnauthorizedException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (403 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (403 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\ChemicalReferenceDataForbiddenException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (429 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (429 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\ChemicalReferenceDataTooManyRequestsException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
throw new \ShipStream\Ups\Api\Exception\UnexpectedStatusCodeException($status, $body);
Expand Down
12 changes: 5 additions & 7 deletions src/Api/Endpoint/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class Delete extends \ShipStream\Ups\Api\Runtime\Client\BaseEndpoint implements
protected $version;
/**
* The Paperless Document API web service allows the users to upload their own customized trade documents for customs clearance to Forms History.
*
* @param string $version Version of API

Valid values:
- v2

* @param array $headerParameters {
* @var string $transId An identifier unique to the request. Length 32
* @var string $transactionSrc An identifier of the client/source application that is making the request.Length 512
Expand Down Expand Up @@ -69,19 +67,19 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'ShipStream\Ups\Api\Model\PAPERLESSDOCUMENTDeleteResponseWrapper', 'json');
}
if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (400 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\DeleteBadRequestException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (401 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (401 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\DeleteUnauthorizedException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (403 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (403 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\DeleteForbiddenException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
if (is_null($contentType) === false && (429 === $status && mb_strpos($contentType, 'application/json') !== false)) {
if (is_null($contentType) === false && (429 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \ShipStream\Ups\Api\Exception\DeleteTooManyRequestsException($serializer->deserialize($body, 'ShipStream\Ups\Api\Model\ErrorResponse', 'json'), $response);
}
throw new \ShipStream\Ups\Api\Exception\UnexpectedStatusCodeException($status, $body);
Expand Down
Loading