zVPS / royal-mail-click-drop-rest-api-client

Royal Mail Click and Drop PHP REST API Client https://api.parcel.royalmail.com/
GNU General Public License v3.0
2 stars 4 forks source link

Fatal error: Uncaught Error: Class 'BigDecimal' not found (Part 2) #7

Closed sunil11475-dev closed 2 years ago

sunil11475-dev commented 2 years ago

I know it's duplicate question, I am sure I had this issue last year and @Caffe1neAdd1ct updated something which resolve this issue. So, I am trying to create test label request but i am getting below error. Now surprising thing is on my live server this code is working perfectly only having issue with test below code - I am adding the address and all details manually but not sure what is wrong?

Fatal error: Uncaught Error: Class 'BigDecimal' not found in application/libraries/royalmailcnd/vendor/zvps/royal-mail-click-and-drop-rest-api-client/lib/ObjectSerializer.php:293 Stack trace: #0 application/libraries/royalmailcnd/vendor/zvps/royal-mail-click-and-drop-rest-api-client/lib/ObjectSerializer.php(310): RoyalMail\ClickAndDrop\Rest\Api\ObjectSerializer::deserialize(0, 'BigDecimal', NULL) #1 application/libraries/royalmailcnd/vendor/zvps/royal-mail-click-and-drop-rest-api-client/lib/ObjectSerializer.php(310): RoyalMail\ClickAndDrop\Rest\Api\ObjectSerializer::deserialize(Object(stdClass), '\\RoyalMail\\Clic...', NULL) #2 application/libraries/royalmailcnd/vendor/zvps/royal-mail-click-and-drop-rest-api-client/lib/ObjectSerializer.php(246): RoyalMail\ClickAndDrop\Rest\Api\ObjectSerializer::deserialize(Object(stdClass), '\\RoyalMail\\Clic...', NULL) #3 application/libraries/royalmailcn in application/libraries/royalmailcnd/vendor/zvps/royal-mail-click-and-drop-rest-api-client/lib/ObjectSerializer.php on line 293

Data i am sending -

                $postarray["items"][] = array(
                      "orderReference" => (string)"1234567",
                      "recipient" => array(
                            "address" => array(
                              "fullName" => (string)"Buyer name",
                              "addressLine1" => (string)"Buyer address 1",
                              "addressLine2" => (string)"Buyer address 2",
                              "addressLine3" => (string)"",
                              "city" => (string)"Manchester",
                              "county" => (string)"Lanc",
                              "postcode" => (string)"M1 1AA",
                              "countryCode" => (string)"GB"
                            ),
                        "phoneNumber" => "",
                        "emailAddress" => "",
                      ),
                      "packages" => array(
                        array(
                          "weightInGrams"=>250,
                          "packageFormatIdentifier" => "largeLetter",
                        ),
                      ),
                      "orderDate" => gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z"),
                      "specialInstructions" => "",
                      "subtotal" => 0,
                      "shippingCostCharged" => 0,
                      "total" => 0,
                      "postageDetails" => array(
                        "serviceCode" => "CRL48",
                        "requestSignatureUponDelivery" => false,
                       ),
                      "label" => array(
                          "includeLabelInResponse" => false,
                          "includeCN" => false,
                          "includeReturnsLabel" => false
                        )
                );
Caffe1neAdd1ct commented 2 years ago

https://github.com/zVPS/royal-mail-click-drop-rest-api-client/issues/4

Similar to this issue, going to guess it's a return type which needs switching to a string as PHP doesn't have an in-built type for this.

Have a look at the class it should be returning for this call and see what types have been declared :)

sunil11475-dev commented 2 years ago

@Caffe1neAdd1ct I am using same libraries path for testing which used in live function.

I have attached the file in this post. Please check ObjectSerializer.txt

I have updated with new ObjectSerializer.php file and it showing error on ObjectSerializer.php on line 299

sunil11475-dev commented 2 years ago

@Caffe1neAdd1ct found the solution - (float)

                      "packages" => array(
                        array(
                          "weightInGrams"=>(float)250,
                          "packageFormatIdentifier" => "largeLetter",
                        ),
                      ),
                      "orderDate" => gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z"),
                      "specialInstructions" => "",
                      "subtotal" => (float)0,
                      "shippingCostCharged" => (float)0,
                      "total" => (float)0,
sunil11475-dev commented 2 years ago

Now, Another questions - I am try to add SKU and Qty on label - Is that correct way to do this - > https://github.com/zVPS/royal-mail-click-drop-rest-api-client/blob/main/docs/Model/ProductItemRequest.md

                      "packages" => array(
                        array(
                          "weightInGrams"=>(float)250,
                          "packageFormatIdentifier" => "largeLetter",
                          "contents" => array(
                            array("SKU" => 'Hello_Test1',"quantity" => (float)9),
                            array("SKU" => 'Hello_Test2',"quantity" => (float)3),
                            array("SKU" => 'Hello_Test3',"quantity" => (float)2)
                          )
                        ),
                      ),
sunil11475-dev commented 2 years ago

@Caffe1neAdd1ct no worries. found the solution for this also -

["SKU" => (string)"Hello_Test3","quantity" =>(int)2,"unitValue"=>(float)0,"unitWeightInGrams"=>(float)0]

may help someone

thanks