Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateOrUpdate for Organisation not consistent with current expectation. #457

Open
ghost opened this issue Jun 23, 2021 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Jun 23, 2021

CreateOrUpdate works as expected for User

ZendeskAPI::User.create_or_update!(client, {email: 'lorem@ipsum.com'}) # displays created record
ZendeskAPI::User.create_or_update!(client, {email: 'lorem@ipsum.com'}) # 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 ghost changed the title CreateOrUpdate for Organisation not consistent across expected implementation CreateOrUpdate for Organisation not consistent with current expectation. Jun 23, 2021
@ghost
Copy link
Author

ghost commented Jun 29, 2021

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

@cryptomail
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant