XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
90 stars 64 forks source link

getPayItems - Uncaught InvalidArgumentException: Invalid value for enum #297

Closed portbury closed 1 year ago

portbury commented 1 year ago

SDK you're using:

Describe the bug When attempting to access a list of pay items for a tenant, an unhandled exception is thrown.

Uncaught InvalidArgumentException: Invalid value for enum '\XeroAPI\XeroPHP\Models\PayrollAu\EarningsType', must be one of: 'FIXED', 'ORDINARYTIMEEARNINGS', 'OVERTIMEEARNINGS', 'ALLOWANCE', 'LUMPSUMD', 'EMPLOYMENTTERMINATIONPAYMENT', 'LUMPSUMA', 'LUMPSUMB', 'BONUSESANDCOMMISSIONS', 'LUMPSUME', 'LUMPSUMW', 'DIRECTORSFEES' in ...../vendor/xeroapi/xero-php-oauth2/lib/PayrollAuObjectSerializer.php:335

To Reproduce Steps to reproduce the behavior:

  1. Connect to PayrollAuApi
  2. Make a getPayItems request

Refer screenshot code snipped below. Exception occurs on final line where $resultPayItems is declared.

Expected behavior List of pay items is returned

Screenshots Sample code:

image

Notes It looks like this issue occurred previous in issue #101.

RettBehrens commented 1 year ago

Hi @portbury can you share a Xero-Correlation-Id for the request error? There were new EarningsTypes added in 2.15.0 release to reflect new options in AU Payroll API

portbury commented 1 year ago

Hi @RettBehrens

I have appended WithHttpInfo to the getPayItems function to get the Xero-Correlation-Id but the variable is returning null. I also tried wrapping the logic in a try/catch block, but $resultPayItems is being reported as undefined in the catch exception.

image
RettBehrens commented 1 year ago

@portbury what's your app Client ID? I can check the logs to confirm but I suspect the response body contains a newly added Earnings Type not present in 2.9.0 and you'll need to update to the latest SDK version to capture new Earnings Type options

portbury commented 1 year ago

Hi @RettBehrens

My goodness, I feel very silly... I didn't realise I was running an SDK build so old. I updated my composer to 2.16.0 and everything's working perfectly now.

I appreciate your help here!

Mark