zendesk_api_client_rb
zendesk_api_client_rb copied to clipboard
CreateOrUpdate for Organisation not consistent with current expectation.
CreateOrUpdate works as expected for User
ZendeskAPI::User.create_or_update!(client, {email: '[email protected]'}) # displays created record
ZendeskAPI::User.create_or_update!(client, {email: '[email protected]'}) # displays created record
CreateOrUpdate throws an error on multiple calls for Organization
ZendeskAPI::Organization.create_or_update!(client, {name: 'Lorem Ipsum'}) # displays created record
ZendeskAPI::Organization.create_or_update!(client, {name: 'Lorem Ipsum'}) # ZendeskAPI::Error::RecordInvalid (ZendeskAPI::Error::RecordInvalid: {"name"=>[{"description"=>"Name: Lorem Ipsum has already been taken", "error"=>"DuplicateValue"}]})
I handled it with a temporal fix shown below.
def organization
ZendeskAPI::Organization.create_or_update!(Zendesk.client, {name: 'Lorem Ipsum'})
rescue ZendeskAPI::Error::RecordInvalid
Zendesk.client.search(query: "type:organization Lorem Ipsum").fetch.first
end
Just out of curiosity, have you tried the "raw" calls to the zendesk API. Organizations does have an endpoint create_or_update and I'm wondering if the endpoint is properly matched and mapped here.