zendesk_api_client_rb icon indicating copy to clipboard operation
zendesk_api_client_rb copied to clipboard

CreateOrUpdate for Organisation not consistent with current expectation.

Open ghost opened this issue 4 years ago • 2 comments

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"}]})

ghost avatar Jun 23 '21 09:06 ghost

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

ghost avatar Jun 29 '21 13:06 ghost

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.

cryptomail avatar Sep 13 '23 16:09 cryptomail