XeroAPI / xero-node

Xero Node SDK for OAuth 2.0 generated from XeroAPI/Xero-OpenAPI
http://developer.xero.com/
MIT License
197 stars 159 forks source link

fix: idempotencyKey should be optional in header cause it is a optional params in all API #651

Closed madison890000 closed 1 year ago

madison890000 commented 1 year ago

Resolves https://github.com/XeroAPI/xero-node/issues/649

madison890000 commented 1 year ago

Description

As described in issue 649, in the xero-node 4.36.0 version, the optional parameter idempotencyKey has been added to all APIs (This allows you to safely retry requests without the risk of duplicate processing. 128 character max.). However, the order of adding idempotencyKey in different APIs is not consistent, and not all APIs have added the idempotencyKey parameter as the last optional parameter. This resulted in a break change when upgrading from xero-node 4.35.0 to 4.36.0, which was not reflected in https://github.com/XeroAPI/xero-node/pull/648. This may have been an oversight.

Based on the following two reasons, I am trying to submit this Pull Request to fix the issue:

  1. 4.36.0 has already been released, and reordering it to the end will cause a break change in 4.36.0.
  2. It is mentioned in https://github.com/XeroAPI/xero-node/issues/649#issuecomment-1704429964 that passing null/undefined does not solve the problem.

My proposed solution in this Pull Request is to not adjust the existing order of the idempotencyKey parameter, but to check for null values and then include the value in the header, in accordance with the definition of optional.

Please note that I have not fixed all APIs currently, but I have only fixed the updateOrCreateInvoices function. If you accept this solution, I will synchronize the fix for all APIs and add corresponding unit tests.

Types of Changes