From 7690fde2b065c87ed024a45d2f9401f51750c567 Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Thu, 25 Jan 2024 13:55:31 +0100 Subject: [PATCH 1/6] Update README.md Include Trade Documents Upload API --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1a35f06..409a45e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ FedEx Rest API documentation https://developer.fedex.com/api/en-us/get-started.h - [ ] Postal Code Validation API - [x] Rate Quotes API - [ ] Service Availability API +- [ ] Trade Documents Upload API ### Other - [x] [oAuth authorization](#authorization) From 6541db83010082fac28ccb9d73b59d4097d4c2dd Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Tue, 6 Feb 2024 16:43:15 +0100 Subject: [PATCH 2/6] progress: UploadDocument --- src/FedexRest/Services/AbstractRequest.php | 4 +- .../TradeDocument/Entity/Document.php | 56 ++++++++++++ .../Services/TradeDocument/Entity/Meta.php | 88 +++++++++++++++++++ .../Services/TradeDocument/UploadDocument.php | 57 ++++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/FedexRest/Services/TradeDocument/Entity/Document.php create mode 100644 src/FedexRest/Services/TradeDocument/Entity/Meta.php create mode 100644 src/FedexRest/Services/TradeDocument/UploadDocument.php diff --git a/src/FedexRest/Services/AbstractRequest.php b/src/FedexRest/Services/AbstractRequest.php index 572c355..7c6438b 100644 --- a/src/FedexRest/Services/AbstractRequest.php +++ b/src/FedexRest/Services/AbstractRequest.php @@ -16,6 +16,8 @@ abstract class AbstractRequest implements RequestInterface public string $api_endpoint = ''; protected string $access_token; + + protected string $content_type = 'application/json'; protected Client $http_client; /** @@ -65,7 +67,7 @@ public function request() $this->http_client = new Client([ 'headers' => [ 'Authorization' => "Bearer {$this->access_token}", - 'Content-Type' => 'application/json' + 'Content-Type' => $this->content_type ], ]); } diff --git a/src/FedexRest/Services/TradeDocument/Entity/Document.php b/src/FedexRest/Services/TradeDocument/Entity/Document.php new file mode 100644 index 0000000..fa5b29f --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/Entity/Document.php @@ -0,0 +1,56 @@ +workflowName = $workflowName; + return $this; + } + + public function setName(string $name): Document + { + $this->name = $name; + return $this; + } + + public function setContentType(string $contentType): Document + { + $this->contentType = $contentType; + return $this; + } + + public function setMeta(Meta $meta): Document + { + $this->meta = $meta; + return $this; + } + + public function setCarrierCode(string $carrierCode): Document + { + $this->carrierCode = $carrierCode; + return $this; + } + + public function prepare(): array + { + $data = [ + 'workflowName' => $this->workflowName, + 'name' => $this->name, + 'contentType' => $this->contentType, + 'meta' => $this->meta->prepare(), + ]; + if (!empty($this->carrierCode)) { + $data['carrierCode'] = $this->carrierCode; + } + return $data; + } +} \ No newline at end of file diff --git a/src/FedexRest/Services/TradeDocument/Entity/Meta.php b/src/FedexRest/Services/TradeDocument/Entity/Meta.php new file mode 100644 index 0000000..0ad54b6 --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/Entity/Meta.php @@ -0,0 +1,88 @@ +shipDocumentType = $shipDocumentType; + return $this; + } + + public function setOriginCountryCode(string $originCountryCode): Meta + { + $this->originCountryCode = $originCountryCode; + return $this; + } + + public function setDestinationCountryCode(string $destinationCountryCode): Meta + { + $this->destinationCountryCode = $destinationCountryCode; + return $this; + } + + public function setFormCode(string $formCode): Meta + { + $this->formCode = $formCode; + return $this; + } + + public function setTrackingNumber(string $trackingNumber): Meta + { + $this->trackingNumber = $trackingNumber; + return $this; + } + + public function setShipmentDate(string $shipmentDate): Meta + { + $this->shipmentDate = $shipmentDate; + return $this; + } + + public function setOriginLocationCode(string $originLocationCode): Meta + { + $this->originLocationCode = $originLocationCode; + return $this; + } + + public function setDestinationLocationCode(string $destinationLocationCode): Meta + { + $this->destinationLocationCode = $destinationLocationCode; + return $this; + } + + public function prepare(): array + { + $data = [ + 'shipDocumentType' => $this->shipDocumentType, + 'originCountryCode' => $this->originCountryCode, + 'destinationCountryCode' => $this->destinationCountryCode, + ]; + if (!empty($this->formCode)) { + $data['formCode'] = $this->formCode; + } + if (!empty($this->trackingNumber)) { + $data['trackingNumber'] = $this->trackingNumber; + } + if (!empty($this->shipmentDate)) { + $data['shipmentDate'] = $this->shipmentDate; + } + if (!empty($this->originLocationCode)) { + $data['originLocationCode'] = $this->originLocationCode; + } + if (!empty($this->destinationLocationCode)) { + $data['destinationLocationCode'] = $this->destinationLocationCode; + } + return $data; + } +} diff --git a/src/FedexRest/Services/TradeDocument/UploadDocument.php b/src/FedexRest/Services/TradeDocument/UploadDocument.php new file mode 100644 index 0000000..17b4d80 --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/UploadDocument.php @@ -0,0 +1,57 @@ +attachment = $attachment; + return $this; + } + + public function setDocument(Document $document): UploadDocument + { + $this->document = $document; + return $this; + } + + public function prepare(): array { + return [ + 'attachment' => $this->attachment, + 'document' => $this->document->prepare(), + ]; + } + + public function setApiEndpoint() + { + return '/documents/v1/etds/upload'; + } + + /** + * @throws MissingAccessTokenException + * @throws GuzzleException + */ + public function request() { + parent::request(); + try { + $query = $this->http_client->post($this->getApiUri($this->api_endpoint), [ + 'multipart' => $this->prepare(), + 'http_errors' => FALSE, + ]); + return ($this->raw === true) ? $query : json_decode($query->getBody()->getContents()); + } catch (\Exception $e) { + return $e->getMessage(); + } + } +} From 3803a9f4f786913a5b25c2f27b6a906f014d07e8 Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Wed, 7 Feb 2024 12:30:27 +0100 Subject: [PATCH 3/6] TradeDocument/UploadDocument implementation --- .../Services/TradeDocument/UploadDocument.php | 16 +++++- .../TradeDocument/UploadDocumentTest.php | 49 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php diff --git a/src/FedexRest/Services/TradeDocument/UploadDocument.php b/src/FedexRest/Services/TradeDocument/UploadDocument.php index 17b4d80..d9bbbf6 100644 --- a/src/FedexRest/Services/TradeDocument/UploadDocument.php +++ b/src/FedexRest/Services/TradeDocument/UploadDocument.php @@ -10,6 +10,8 @@ class UploadDocument extends AbstractRequest { + protected string $production_url = 'https://documentapi.prod.fedex.com'; + protected string $testing_url = 'https://documentapitest.prod.fedex.com/sandbox'; protected string $content_type = 'multipart/form-data'; public string $attachment; public Document $document; @@ -28,8 +30,18 @@ public function setDocument(Document $document): UploadDocument public function prepare(): array { return [ - 'attachment' => $this->attachment, - 'document' => $this->document->prepare(), + [ + 'name' => 'attachment', + 'contents' => $this->attachment, + 'filename' => $this->document->name, + 'headers' => [ + 'Content-Type' => $this->document->contentType + ] + ], + [ + 'name' => 'document', + 'contents' => json_encode($this->document->prepare()) + ] ]; } diff --git a/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php new file mode 100644 index 0000000..53814d9 --- /dev/null +++ b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php @@ -0,0 +1,49 @@ +auth = (new Authorize) + ->setClientId('l7749d031872cf4b55a7889376f360d045') + ->setClientSecret('bd59d91084e8482895d4ae2fb4fb79a3'); + } + + public function testHasAccountNumber() + { + $meta = (new Meta()) + ->setShipDocumentType('COMMERCIAL_INVOICE') + ->setFormCode('USMCA') + ->setTrackingNumber('794791292805') + ->setShipmentDate('2021-02-17T00:00:00') + ->setOriginLocationCode('GVTKK') + ->setOriginCountryCode('US') + ->setDestinationLocationCode('DEL') + ->setDestinationCountryCode('IN'); + $document = (new Document()) + ->setWorkflowName('ETDPreshipment') + ->setCarrierCode('FDXE') + ->setName('file.txt') + ->setContentType('text/plain') + ->setMeta($meta); + $request = (new UploadDocument()) + ->setAccessToken((string) $this->auth->authorize()->access_token) + ->setDocument($document) + ->setAttachment('file.txt') + ->request(); + Assert::assertInstanceOf(\stdClass::class, $request); + Assert::assertNotEmpty($request->output->meta->docId); + } +} \ No newline at end of file From 409e885105128e7549de06155c875bdba731d6c9 Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Wed, 7 Feb 2024 17:05:06 +0100 Subject: [PATCH 4/6] UploadImages implemented --- .../TradeDocument/Entity/ImageDocument.php | 54 +++++++++++++++ .../TradeDocument/Entity/ImageMeta.php | 30 ++++++++ .../Services/TradeDocument/Entity/Rule.php | 21 ++++++ .../Services/TradeDocument/UploadImages.php | 69 +++++++++++++++++++ .../TradeDocument/UploadDocumentTest.php | 27 +++++++- 5 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php create mode 100644 src/FedexRest/Services/TradeDocument/Entity/ImageMeta.php create mode 100644 src/FedexRest/Services/TradeDocument/Entity/Rule.php create mode 100644 src/FedexRest/Services/TradeDocument/UploadImages.php diff --git a/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php b/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php new file mode 100644 index 0000000..4603dfc --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php @@ -0,0 +1,54 @@ +referenceId = $referenceId; + return $this; + } + public function setName(string $name): ImageDocument + { + $this->name = $name; + return $this; + } + + public function setContentType(string $contentType): ImageDocument + { + $this->contentType = $contentType; + return $this; + } + + public function setMeta(ImageMeta $meta): ImageDocument + { + $this->meta = $meta; + return $this; + } + + public function setRules(Rule $rule): ImageDocument + { + $this->rules = $rule; + return $this; + } + + public function prepare(): array + { + return [ + 'document' => [ + 'referenceId' => $this->referenceId, + 'name' => $this->name, + 'contentType' => $this->contentType, + 'meta' => $this->meta->prepare(), + ], + 'rules' => $this->rules->prepare(), + ]; + } +} \ No newline at end of file diff --git a/src/FedexRest/Services/TradeDocument/Entity/ImageMeta.php b/src/FedexRest/Services/TradeDocument/Entity/ImageMeta.php new file mode 100644 index 0000000..9241f81 --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/Entity/ImageMeta.php @@ -0,0 +1,30 @@ +imageType = $imageType; + return $this; + } + + public function setImageIndex(string $imageIndex): ImageMeta + { + $this->imageIndex = $imageIndex; + return $this; + } + + public function prepare(): array + { + return [ + 'imageType' => $this->imageType, + 'imageIndex' => $this->imageIndex, + ]; + } +} diff --git a/src/FedexRest/Services/TradeDocument/Entity/Rule.php b/src/FedexRest/Services/TradeDocument/Entity/Rule.php new file mode 100644 index 0000000..c735011 --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/Entity/Rule.php @@ -0,0 +1,21 @@ +workflowName = $workflowName; + return $this; + } + + public function prepare(): array + { + return [ + 'workflowName' => $this->workflowName, + ]; + } +} \ No newline at end of file diff --git a/src/FedexRest/Services/TradeDocument/UploadImages.php b/src/FedexRest/Services/TradeDocument/UploadImages.php new file mode 100644 index 0000000..8b0573f --- /dev/null +++ b/src/FedexRest/Services/TradeDocument/UploadImages.php @@ -0,0 +1,69 @@ +attachment = $attachment; + return $this; + } + + public function setDocument(ImageDocument $document): UploadImages + { + $this->document = $document; + return $this; + } + + public function prepare(): array { + return [ + [ + 'name' => 'attachment', + 'contents' => $this->attachment, + 'filename' => $this->document->name, + 'headers' => [ + 'Content-Type' => $this->document->contentType + ] + ], + [ + 'name' => 'document', + 'contents' => json_encode($this->document->prepare()) + ] + ]; + } + + public function setApiEndpoint() + { + return '/documents/v1/lhsimages/upload'; + } + + /** + * @throws MissingAccessTokenException + * @throws GuzzleException + */ + public function request() { + parent::request(); + try { + $query = $this->http_client->post($this->getApiUri($this->api_endpoint), [ + 'multipart' => $this->prepare(), + 'http_errors' => FALSE, + ]); + return ($this->raw === true) ? $query : json_decode($query->getBody()->getContents()); + } catch (\Exception $e) { + return $e->getMessage(); + } + } +} diff --git a/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php index 53814d9..fbedcb9 100644 --- a/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php +++ b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php @@ -4,8 +4,12 @@ use FedexRest\Authorization\Authorize; use FedexRest\Services\TradeDocument\Entity\Document; +use FedexRest\Services\TradeDocument\Entity\ImageDocument; +use FedexRest\Services\TradeDocument\Entity\ImageMeta; use FedexRest\Services\TradeDocument\Entity\Meta; +use FedexRest\Services\TradeDocument\Entity\Rule; use FedexRest\Services\TradeDocument\UploadDocument; +use FedexRest\Services\TradeDocument\UploadImages; use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; @@ -21,7 +25,7 @@ protected function setUp(): void ->setClientSecret('bd59d91084e8482895d4ae2fb4fb79a3'); } - public function testHasAccountNumber() + public function testUploadDocument() { $meta = (new Meta()) ->setShipDocumentType('COMMERCIAL_INVOICE') @@ -46,4 +50,25 @@ public function testHasAccountNumber() Assert::assertInstanceOf(\stdClass::class, $request); Assert::assertNotEmpty($request->output->meta->docId); } + + public function testUploadImages() + { + $meta = (new ImageMeta()) + ->setImageType('SIGNATURE') + ->setImageIndex('IMAGE_1'); + $rules = (new Rule())->setWorkflowName('LetterheadSignature'); + $document = (new ImageDocument()) + ->setReferenceId('1234') + ->setName('LH2.PNG') + ->setContentType('image/png') + ->setMeta($meta) + ->setRules($rules); + $request = (new UploadImages()) + ->setAccessToken((string) $this->auth->authorize()->access_token) + ->setDocument($document) + ->setAttachment('file.PNG') + ->request(); + Assert::assertInstanceOf(\stdClass::class, $request); + Assert::assertNotEmpty($request->errors); + } } \ No newline at end of file From 737e605ec9bcfe8487278be51a0219aec326f030 Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Thu, 1 Aug 2024 16:45:33 +0200 Subject: [PATCH 5/6] UploadImages & test fixed --- .../TradeDocument/Entity/ImageDocument.php | 18 ++------ .../Services/TradeDocument/UploadImages.php | 22 ++++++++-- .../TradeDocument/UploadDocumentTest.php | 40 ++++++++++++------ tests/FedexRest/resources/document.txt | 1 + tests/FedexRest/resources/signature.png | Bin 0 -> 825 bytes 5 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 tests/FedexRest/resources/document.txt create mode 100644 tests/FedexRest/resources/signature.png diff --git a/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php b/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php index 4603dfc..a0cd799 100644 --- a/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php +++ b/src/FedexRest/Services/TradeDocument/Entity/ImageDocument.php @@ -7,7 +7,6 @@ class ImageDocument public string $referenceId; public string $name; public string $contentType; - public Rule $rules; public ImageMeta $meta; public function setReferenceId(string $referenceId): ImageDocument @@ -33,22 +32,13 @@ public function setMeta(ImageMeta $meta): ImageDocument return $this; } - public function setRules(Rule $rule): ImageDocument - { - $this->rules = $rule; - return $this; - } - public function prepare(): array { return [ - 'document' => [ - 'referenceId' => $this->referenceId, - 'name' => $this->name, - 'contentType' => $this->contentType, - 'meta' => $this->meta->prepare(), - ], - 'rules' => $this->rules->prepare(), + 'referenceId' => $this->referenceId, + 'name' => $this->name, + 'contentType' => $this->contentType, + 'meta' => $this->meta->prepare(), ]; } } \ No newline at end of file diff --git a/src/FedexRest/Services/TradeDocument/UploadImages.php b/src/FedexRest/Services/TradeDocument/UploadImages.php index 8b0573f..e31d76c 100644 --- a/src/FedexRest/Services/TradeDocument/UploadImages.php +++ b/src/FedexRest/Services/TradeDocument/UploadImages.php @@ -5,6 +5,7 @@ use FedexRest\Exceptions\MissingAccessTokenException; use FedexRest\Services\AbstractRequest; use FedexRest\Services\TradeDocument\Entity\ImageDocument; +use FedexRest\Services\TradeDocument\Entity\Rule; use GuzzleHttp\Exception\GuzzleException; class UploadImages extends AbstractRequest @@ -16,6 +17,8 @@ class UploadImages extends AbstractRequest public string $attachment; public ImageDocument $document; + public Rule $rules; + public function setAttachment(string $attachment): UploadImages { $this->attachment = $attachment; @@ -28,8 +31,23 @@ public function setDocument(ImageDocument $document): UploadImages return $this; } + public function setRules(Rule $rules): UploadImages + { + $this->rules = $rules; + return $this; + } + public function prepare(): array { + $document = [ + 'document' => $this->document->prepare(), + 'rules' => $this->rules->prepare(), + ]; + // The order of the parameters in the request is fixed. You have to put the "document" param before the "attachment" param. return [ + [ + 'name' => 'document', + 'contents' => json_encode($document) + ], [ 'name' => 'attachment', 'contents' => $this->attachment, @@ -37,10 +55,6 @@ public function prepare(): array { 'headers' => [ 'Content-Type' => $this->document->contentType ] - ], - [ - 'name' => 'document', - 'contents' => json_encode($this->document->prepare()) ] ]; } diff --git a/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php index fbedcb9..4b69aa5 100644 --- a/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php +++ b/tests/FedexRest/Tests/TradeDocument/UploadDocumentTest.php @@ -29,30 +29,37 @@ public function testUploadDocument() { $meta = (new Meta()) ->setShipDocumentType('COMMERCIAL_INVOICE') - ->setFormCode('USMCA') - ->setTrackingNumber('794791292805') - ->setShipmentDate('2021-02-17T00:00:00') - ->setOriginLocationCode('GVTKK') + //->setFormCode('USMCA') + //->setTrackingNumber('794791292805') + //->setShipmentDate('2021-02-17T00:00:00') + //->setOriginLocationCode('GVTKK') ->setOriginCountryCode('US') - ->setDestinationLocationCode('DEL') + //->setDestinationLocationCode('DEL') ->setDestinationCountryCode('IN'); $document = (new Document()) ->setWorkflowName('ETDPreshipment') - ->setCarrierCode('FDXE') + //->setCarrierCode('FDXE') ->setName('file.txt') ->setContentType('text/plain') ->setMeta($meta); + $path = __DIR__.'/../../resources/document.txt'; + $content = file_get_contents($path); $request = (new UploadDocument()) ->setAccessToken((string) $this->auth->authorize()->access_token) ->setDocument($document) - ->setAttachment('file.txt') + ->setAttachment($content) ->request(); - Assert::assertInstanceOf(\stdClass::class, $request); - Assert::assertNotEmpty($request->output->meta->docId); + $this->assertObjectHasProperty('customerTransactionId', $request); + $this->assertObjectNotHasProperty('errors', $request); + $this->assertObjectHasProperty('output', $request); + $this->assertObjectHasProperty('meta', $request->output); + $this->assertObjectHasProperty('docId', $request->output->meta); + $this->assertNotEmpty($request->output->meta->docId); } public function testUploadImages() { + //$this->markTestIncomplete('Always fails with: "Invalid request: invalid input : WorkFlow Name"'); $meta = (new ImageMeta()) ->setImageType('SIGNATURE') ->setImageIndex('IMAGE_1'); @@ -61,14 +68,19 @@ public function testUploadImages() ->setReferenceId('1234') ->setName('LH2.PNG') ->setContentType('image/png') - ->setMeta($meta) - ->setRules($rules); + ->setMeta($meta); + $path = __DIR__.'/../../resources/signature.png'; + $content = file_get_contents($path); $request = (new UploadImages()) ->setAccessToken((string) $this->auth->authorize()->access_token) ->setDocument($document) - ->setAttachment('file.PNG') + ->setRules($rules) + ->setAttachment($content) ->request(); - Assert::assertInstanceOf(\stdClass::class, $request); - Assert::assertNotEmpty($request->errors); + $this->assertObjectHasProperty('customerTransactionId', $request); + $this->assertObjectNotHasProperty('errors', $request); + $this->assertObjectHasProperty('output', $request); + $this->assertObjectHasProperty('documentReferenceId', $request->output); + $this->assertNotEmpty($request->output->documentReferenceId); } } \ No newline at end of file diff --git a/tests/FedexRest/resources/document.txt b/tests/FedexRest/resources/document.txt new file mode 100644 index 0000000..e07beac --- /dev/null +++ b/tests/FedexRest/resources/document.txt @@ -0,0 +1 @@ +Invoice \ No newline at end of file diff --git a/tests/FedexRest/resources/signature.png b/tests/FedexRest/resources/signature.png new file mode 100644 index 0000000000000000000000000000000000000000..076e7860774e1b4afea0ddf26cc55532f972c202 GIT binary patch literal 825 zcmV-91IGM`P)x3H!m-Hu;|PkYM=I#L#WsnqiJ}j}mWQ|-yQrP+gN%qJ6ug@fYCf18A>>mH&@B8rR+CAqM zZ`Wqrxi%zrHw=FC!9JIDaVGmDN|+P2)WV7D;d7-rg7HASO*|Zd-<_R^3t1~%u(mO{ zAcMyvi#sx8+73=D$x|8sG$e(xY&>{U@^A%El2^qi%)SCFm{fuw08{cL=AfgXk$ha( z{56*JF_v*D>A13W83qZ6mdlVlU#TpyPiZ@ODo6Y_l1x==DkZAZG>mDut0V#wfescd z?X9SJ?NFjqA4|zgIJUmyuacCF;iE~vM^Qf5WyvTUJ3-RImaSAUOOt@*EF?X3+3**` ztMYIr->Q`oHCtQnfhnYd@hH(_dtgXP&f9RWs;`CGxAIT(_hIz?75*C_0ojc_Jo7Z`-8 ztFo#VUii_wswMeIlDb18aKkPnutLIkEYX?wBZ=OOS*W(O4l%Bug}tz90)5+>#@yKg00YM%V>^1=8JGhy!d2hQ7|BqbRrtD?u9 zdMTEGjU%M|8M0r)r90KGd37*|TEAV@VdyT8Fj%^i0o()|=TjuPZhFkxO#O`xk6Q#D zKmLQ2iKcURK6BEy@Os?;xw-Z?>>vn&AP9mW{xkjpr^Am+{g<~D00000NkvXXu0mjf DqUwWc literal 0 HcmV?d00001 From b74b3445fd0585478f6c7d847bc3d01f4d1c3aab Mon Sep 17 00:00:00 2001 From: Daniel Zambo Date: Fri, 2 Aug 2024 09:45:16 +0200 Subject: [PATCH 6/6] Revert content type settings --- src/FedexRest/Services/AbstractRequest.php | 4 +--- src/FedexRest/Services/TradeDocument/UploadDocument.php | 1 - src/FedexRest/Services/TradeDocument/UploadImages.php | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/FedexRest/Services/AbstractRequest.php b/src/FedexRest/Services/AbstractRequest.php index 7c6438b..572c355 100644 --- a/src/FedexRest/Services/AbstractRequest.php +++ b/src/FedexRest/Services/AbstractRequest.php @@ -16,8 +16,6 @@ abstract class AbstractRequest implements RequestInterface public string $api_endpoint = ''; protected string $access_token; - - protected string $content_type = 'application/json'; protected Client $http_client; /** @@ -67,7 +65,7 @@ public function request() $this->http_client = new Client([ 'headers' => [ 'Authorization' => "Bearer {$this->access_token}", - 'Content-Type' => $this->content_type + 'Content-Type' => 'application/json' ], ]); } diff --git a/src/FedexRest/Services/TradeDocument/UploadDocument.php b/src/FedexRest/Services/TradeDocument/UploadDocument.php index d9bbbf6..c0f8bef 100644 --- a/src/FedexRest/Services/TradeDocument/UploadDocument.php +++ b/src/FedexRest/Services/TradeDocument/UploadDocument.php @@ -12,7 +12,6 @@ class UploadDocument extends AbstractRequest protected string $production_url = 'https://documentapi.prod.fedex.com'; protected string $testing_url = 'https://documentapitest.prod.fedex.com/sandbox'; - protected string $content_type = 'multipart/form-data'; public string $attachment; public Document $document; diff --git a/src/FedexRest/Services/TradeDocument/UploadImages.php b/src/FedexRest/Services/TradeDocument/UploadImages.php index e31d76c..11a44d0 100644 --- a/src/FedexRest/Services/TradeDocument/UploadImages.php +++ b/src/FedexRest/Services/TradeDocument/UploadImages.php @@ -13,7 +13,6 @@ class UploadImages extends AbstractRequest protected string $production_url = 'https://documentapi.prod.fedex.com'; protected string $testing_url = 'https://documentapitest.prod.fedex.com/sandbox'; - protected string $content_type = 'multipart/form-data'; public string $attachment; public ImageDocument $document;