XeroAPI / xero-php-oauth2

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

Invalid value for 'earnings_type' #175

Closed placeposition closed 3 years ago

placeposition commented 4 years ago

SDK you're using (please complete the following information):

Describe the bug

Details

Type: InvalidArgumentException Message: Invalid value for 'earnings_type', must be one of 'Allowance', 'Backpay', 'Bonus', 'Commission', 'LumpSum', 'OtherEarnings', 'OvertimeEarnings', 'RegularEarnings', 'StatutoryAdoptionPay', 'StatutoryMaternityPay', 'StatutoryPaternityPay', 'StatutorySharedParentalPay', 'StatutorySickPay', 'Tips(Direct)', 'Tips(Non-Direct)' File:vendor/xeroapi/xero-php-oauth2/lib/Models/PayrollUk/EarningsRate.php Line: 425

Expected behavior I expect a response which is an array of earning rates using https://developer.xero.com/documentation/payroll-api-uk/earningrates

My code:


        $_oauth = $this->getToken($reader, $writer, $tenant->id, $session->getUserId());

        if (isset($_oauth['token'])) {

            $config = \XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken((string)$_oauth['token']);        
            $apiInstance = new \XeroAPI\XeroPHP\Api\PayrollUkApi(
                // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
                // This is optional, `GuzzleHttp\Client` will be used as default.
                new \GuzzleHttp\Client(),
                $config
            );

            $page = 1;
            //'earnings_type=="RegularEarnings"'

            try {

                $result = $apiInstance->getEarningsRates($_oauth['tenant_id'], $page);
                print_r($result);

                /*

                foreach($result->getEarningsRates() AS $er) {

                    $_er = json_decode($er, true);

                    $xero['api']['earningRates'][] = $_er;
                }

                */

            //  return $this->getSuccess($response, $xero);

            } catch (Exception $e) {

                return $this->badRequest($response, ['error' => $e->getMessage()]);
            }
        }
SidneyAllen commented 3 years ago

@placeposition - thanks for the feedback.

We added missing earning types enums in version 2.4.4 of our OpenAPI spec and have rebuilt the SDK. Your issue should be resolved.

Cheers