-
-
Notifications
You must be signed in to change notification settings - Fork 236
Description
Describe the Bug
updateMany for organizations appears to have an incorrect type definition and example in:
/node-zendesk/dist/types/clients/core/organizations.d.ts
The current type definition for client.organizations.updateMany
(method) Organizations.updateMany(organizations: object[]): Promise<{
response: object;
result: object[];
}>
With the example
const updatedOrganizations = await client.organizations.updateMany([{ id: 1, name: 'Updated Org1' }, { id: 2, name: 'Updated Org2' }]);
Things work if I change the type definition param to object
instead of object[]
and use a parameter such as:
const updatedOrganizations = await client.organizations.updateMany({organizations: [{ id: 1, name: 'Updated Org1' }, { id: 2, name: 'Updated Org2' }]});
Example Code
Doesn't work
const updatedOrganizations = await client.organizations.updateMany([{ id: 1, name: 'Updated Org1' }, { id: 2, name: 'Updated Org2' }]);
Works:
const updatedOrganizations = await client.organizations.updateMany({organizations: [{ id: 1, name: 'Updated Org1' }, { id: 2, name: 'Updated Org2' }]});
Expected Behavior
Multiple organizations to be updated
Actual Behavior
with debug turned on:
{
type: 'debug::request',
detail: {
username: 'redacted,
token: 'redacted',
subdomain: 'redacted',
throwOriginalException: true,
debug: true,
endpointUri: 'redacted,
get: [Function: get],
headers: {
Authorization: 'Basic redacted=',
'Content-Type': 'application/json',
Accept: 'application/json',
'User-Agent': 'node-zendesk/6.0.1 (node/20.11.0)'
},
uri: 'https://redacted/api/v2/organizations/update_many.json',
method: 'PUT',
body: undefined
},
result: 'undefined'
}
{
type: 'debug::response',
detail: {
json: [Function: json],
status: 400,
headers: { get: [Function: get] },
statusText: 'Bad Request'
},
result: 'undefined'
}
{
type: 'debug::result',
detail: {
error: 'ParameterMissing',
description: 'Parameter organizations or (organization and ids/external_ids) is required'
},
result: 'undefined'
}
Error updating orgs: Zendesk Error (400): Bad Request [
{
id: 1,
organization_fields: {
redacted: 10,
}
},
{
id: 2,
organization_fields: {
redacted: 12,
}
}
]
"Fixed" type definition:
(method) Organizations.updateMany(organizations: object): Promise<{
response: object;
result: object[];
}>
Debug info after editing the type definition:
{
type: 'debug::request',
detail: {
username: 'redacted',
token: 'redacted,
subdomain: 'redacted',
throwOriginalException: true,
debug: true,
endpointUri: 'https://redacted.zendesk.com/api/v2',
get: [Function: get],
headers: {
Authorization: 'Basic redacted=',
'Content-Type': 'application/json',
Accept: 'application/json',
'User-Agent': 'node-zendesk/6.0.1 (node/20.11.0)'
},
uri: 'https://redacted.zendesk.com/api/v2/organizations/update_many.json',
method: 'PUT',
body: '{"organizations":[{"id":1,"organization_fields":{"redacted":10}},{"id":2,"organization_fields":{"redacted":12,}}]}'
},
result: 'undefined'
}
{
type: 'debug::response',
detail: {
json: [Function: json],
status: 200,
headers: { get: [Function: get] },
statusText: 'OK'
},
result: 'undefined'
}
{
type: 'debug::result',
detail: {
job_status: {
id: 'V3-redacted',
job_type: 'Batch Update Organization',
url: 'https://redacted.zendesk.com/api/v2/job_statuses/V3-redacted.json',
total: 2,
progress: null,
status: 'queued',
message: null,
results: null
}
},
result: 'undefined'
}
And the organizations are updated in Zendesk.
Environment Information
node-zendesk
6.0.1:- Node.js version: 20.11
- Operating System: mac os
- Any other relevant software versions?
Additional Context
Add any other context about the problem here.