zendesk / zendesk_api_client_rb Goto Github PK
View Code? Open in Web Editor NEWOfficial Ruby Zendesk API Client
Home Page: http://developer.zendesk.com/
License: Apache License 2.0
Official Ruby Zendesk API Client
Home Page: http://developer.zendesk.com/
License: Apache License 2.0
I found that a call to create an organization fails. It appears that the required values are being removed on the Zendesk side?
>> org = client.organization.create({:name => 'Testing'})
WARNING: Removed restricted keys ["name"] from parameters according to whitelist
the server responded with status 422
{"details"=>{"name"=>[{"description"=>"Name cannot be blank", "type"=>"blank"}]}, "description"=>"Record validation errors", "error"=>"RecordInvalid"}
=> nil
This problem was just recently reported here (https://support.zendesk.com/entries/21475108-x-zendesk-api-warn-removed-restricted-keys-error) by someone else when creating a user.
Note, I have also tried it this way with the same results
org = Zendesk::Organization.create(client, {:name => 'Testing'})
And also this way:
>> org = Zendesk::Organization.new(client, {:name => 'Testing'})
=> organization: #<Zendesk::Trackie name="Testing">
>> org.name
=> "Testing"
>> org.save
WARNING: Removed restricted keys ["name"] from parameters according to whitelist
the server responded with status 422
{"details"=>{"name"=>[{"description"=>"Name cannot be blank", "type"=>"blank"}]}, "description"=>"Record validation errors", "error"=>"RecordInvalid"}
=> false
Unable to install the gem.
The following line in my gemfile doesn't install the gem.
gem 'zendesk_api_client_rb'
It appears the gem is not registered with RubyGems. Also failing to install from git source. Please update readme with instructions on how users should install.
You say to add this into the gemfile
gem "zendesk", :git => "git://github.com/zendesk/zendesk_api_client_rb.git"
When it should probably be more like this
gem "zendesk", :git => "git://github.com/zendesk/zendesk_api_client_rb.git", :tag => 'v0.0.1'
Semantics, but it allows for us to rely on your releases to be consistent
Hey,
Is there currently a way to hit the API call '/api/v2/tickets/{id}/metrics.json' via the gem?
As currently a call like:
Zendesk.client.tickets.find(:id=>1).metrics
Makes two REST requests. One for the ticket object ('GET /api/v2/tickets/{id}.json') and the other for the ticket_metric object.
Hello,
I am creating tickets using the ruby client for a bulk import and wanted to know if custom fields are accessible?
I'm unable to post a ticket in my rails app. Here's a gist with all the information I could get:
https://gist.github.com/4017925
I am able to post the ticket if I edit lib/zendesk_api/client.rb and comment out builder.request :multipart
. Of course that's no solution, because it would break file uploads.
So I'm attempting to wipeout my ticket fields for an acc, but it doesn't seem to be working.
I've copied the console session below, any ideas?
Sorry for being so vague, not sure how else to phrase this.
Loading development environment (Rails 3.2.11)
[1] pry(main)> ZendeskClient.instance.ticket_fields.to_a.size
=> 7
[2] pry(main)> ZendeskClient.instance.ticket_fields.to_a.each {|f| f.destroy }; nil
=> nil
[3] pry(main)> ZendeskClient.instance.ticket_fields.to_a.each {|f| puts f.destroyed? }; nil
true
true
true
true
true
true
true
=> nil
[4] pry(main)> ^D
robertross:~/Sites/someapp (master) $ rails c
Loading development environment (Rails 3.2.11)
[1] pry(main)> ZendeskClient.instance.ticket_fields.to_a.each {|f| puts f.destroyed? }; nil
false
false
false
false
false
false
false
=> nil
[2] pry(main)>
I was able to configure a client, but when I try to access a topic, I get a following error
client.topics.find(:id =>'21472643')
RuntimeError: missing dependency for Faraday::Adapter::Patron: no such file to load -- patron
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/middleware.rb:20:in new' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:43:in
build'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in to_app' from (irb):57:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in each' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in to_app' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:74:in
app'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in run_request' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in
get'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/actions.rb:69:in orig_find' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in
send'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in find' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:62:in
find'
from (irb):57
this error happens when I call a find in other collections:
client.users.find(:id => '217679681')
RuntimeError: missing dependency for Faraday::Adapter::Patron: no such file to load -- patron
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/middleware.rb:20:innew' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:43:in
build'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from (irb):32:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:ineach' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:74:in
app'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:226:inrun_request' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in
get'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/actions.rb:69:inorig_find' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in
send'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:infind' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:62:in
find'
from (irb):32
client.tickets[2]
RuntimeError: missing dependency for Faraday::Adapter::Patron: no such file to load -- patron
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/middleware.rb:20:innew' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:43:in
build'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from (irb):44:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:ineach' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:74:in
app'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:226:inrun_request' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in
get'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:146:insend' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:146:in
orig_fetch'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:insend' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in
fetch'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:163:into_a' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:216:in
method_missing'
from (irb):44>> client.tickets.first
RuntimeError: missing dependency for Faraday::Adapter::Patron: no such file to load -- patron
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/middleware.rb:20:innew' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:43:in
build'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from (irb):45:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:ineach' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:in
inject'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/builder.rb:78:into_app' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:74:in
app'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:226:inrun_request' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in
get'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:146:insend' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:146:in
orig_fetch'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:insend' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in
fetch'
from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:163:into_a' from /Users/naoyamakino/.rvm/gems/ree-1.8.7-2011.03@themis/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:216:in
method_missing'
do you have any idea why this happens?
I appreciate your help and thanks for working on this.
regards
Hey there, is it possible to get views count using the ruby gem? e.g (via the Zendesk API)
curl https://{subdomain}.zendesk.com/api/v2/views/{id}/count.json \
-v -u {email_address}:{password}
Hey guys,
Does anyone know what the best practice way to catch Faraday/HTTP Net exceptions with the zendesk api gem?
I'm hitting timeout issues when iterating through .each_page on the Search API
e.g
client.search(:query => "my search query").each_page do |resource, page|
# all resources will be yielded along with the page
end
insert_callback only works when the connection successfully returns and not when there is a timeout.
e.g
client.insert_callback do |env|
puts env[:response_headers]
end
The Collection#each_page
does a very useful thing, namely allow you to iterate through a collection without worrying about doing pagination manually. However, given the name of the method, I was very surprised that the first parameter passed to the block was an element of the collection, rather than the "page" - I initially expected the first parameter to be a collection containing all the elements on the page.
Also, the variable naming in the README example for using each_page
with 2 params is a bit misleading; it might be clearer if you call the second parameter page_number
, rather than page
.
One potential improvement: make the "paper over page boundaries" behaviour either the default or a configurable option of the #each
method, and repurposing #each_page
to iterate through pages, not items.
Github version is 0.1.0 while rubygem is still 0.0.9
This is critical because the attachment fix is included in 0.1.0
I am just starting to dig into the Zendesk API and this client. I am creating a customer portal integrated with other applications, part of it's functionality will be Zendesk tickets.
This gem seems almost perfect (as long as client is the actual end-user and not a Zendesk admin user). However, it seems that the Zendesk API calls are only available to Zendesk Admin users and thus the "client" needs to be an Admin user and not an end-user.
Or am I confused on this?
If this is the case then calling client.tickets does not help me as it will give me all the tickets in my system.
I need the API gem to authenticate with an admin user but then set client to the current end-user using the system. Thus when I call client.tickets I will get only that end-user's tickets.
I appreciate any direction in how to use this gem properly.
update:
I just tried to use the account API token as the password for the admin user and an end-user and on both accounts the client.current_user was set to "Anonymous user".
This seems like an error if I understand the documentation correctly.
I just installed the gem on a new project and now the app won't load. Running Rails 3.0.10.
I get this error:
/Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:479:in `load_missing_constant': ZendeskAPI is not missing constant User! (ArgumentError)
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:183:in `const_missing_not_from_s3_library'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:181:in `each'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:181:in `const_missing_not_from_s3_library'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/association.rb:233:in `const_get'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/association.rb:233:in `get_class'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/association.rb:120:in `has'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/resources/misc.rb:4
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:2
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api/client.rb:7
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/zendesk_api-0.0.9/lib/zendesk_api.rb:7
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
from /Users/gregdevore/Rails/screensteps_live/config/application.rb:7
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.10/lib/rails/commands.rb:21:in `require'
from /Users/gregdevore/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.10/lib/rails/commands.rb:21
from script/rails:6:in `require'
from script/rails:6
Can we move the repo to "zendesk_api", since that's the name of the gem and the file we're supposed to require?
The following code makes a request to the API, even though it is impossible to find the associated record because the _id column is nil.
# client is already initialized and valid
result = client.tickets.find(id: 3)
puts result.assignee_id == nil
# makes invalid request to Zendesk API, resulting in a 404.
result.assignee
Using 0.1.9 version of the gem.
Hello,
I started playing with the gem, It seems to work as I successfully created a user and a ticket but I keep getting lot's of 404 in my rails console.
Anyone know what's up with that ?
ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:42:in `block in save_associations'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:40:in `each'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:40:in `save_associations'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:20:in `save'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/rescue.rb:26:in `block (2 levels) in rescue_client_error'
/home/pate/something/git/rails_site/bazaar/lib/zendesk/client.rb:26:in `create_ticket'
(pry):45:in `<main>'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:249:in `eval'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:249:in `re'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:227:in `rep'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:207:in `block (3 levels) in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:206:in `loop'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:206:in `block (2 levels) in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:205:in `catch'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:205:in `block in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:204:in `catch'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:204:in `repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_class.rb:139:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
{"error"=>"RecordNotFound", "description"=>"Not found"}
the server responded with status 404
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/response/raise_error.rb:6:in `on_complete'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/response.rb:9:in `block in call'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/response.rb:63:in `on_complete'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/response.rb:8:in `call'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/request/authorization.rb:36:in `call'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in `run_request'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in `get'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/association.rb:145:in `block (2 levels) in has'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/rescue.rb:35:in `rescue_client_error'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/association.rb:144:in `block in has'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:42:in `block in save_associations'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:40:in `each'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:40:in `save_associations'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/actions.rb:20:in `save'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/bundler/gems/zendesk_api_client_rb-497c1c8dae6f/lib/zendesk_api/rescue.rb:26:in `block (2 levels) in rescue_client_error'
/home/pate/something/git/rails_site/bazaar/lib/zendesk/client.rb:26:in `create_ticket'
(pry):45:in `<main>'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:249:in `eval'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:249:in `re'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:227:in `rep'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:207:in `block (3 levels) in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:206:in `loop'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:206:in `block (2 levels) in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:205:in `catch'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:205:in `block in repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:204:in `catch'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_instance.rb:204:in `repl'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/pry-0.9.9.6/lib/pry/pry_class.rb:139:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
/home/pate/.rvm/gems/ruby-1.9.3-p194@bazaar/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n <title>The page you were looking for doesn't exist (404)</title>\n <link href=\"/external/error_pages.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />\n</head>\n\n<body>\n <!-- This file lives in public/404.html -->\n <div class=\"dialog\">\n <div id=\"contents\">\n <h1>Oops.<br/>The page you were looking for doesn't exist.</h1>\n <div class=\"box home\">\n <p>You may have mistyped the address or the page may have moved.</p>\n <ul><li><a href=\"/\">Take me back to the home page</a></li></ul>\n </div>\n </div>\n </div>\n</body>\n</html>\n"
=> true
zendesk_client = ZendeskAPI::Client.new do |config|
config.url = "url v2"
config.username = "login"
config.password = "pass"
config.retry = true
require 'logger'
config.logger = Logger.new(STDOUT)
end
zendesk_client.tickets.create(:subject => 'test api')
This code produces the following error:
NoMethodError (undefined method
merge' for #JSON::Ext::Generator::State:0xb38db004)`
However I can get access to existed tickets, for example
zendesk_client.tickets.find(:id => 123)
works as expected.
some tests are highly dependend on how zendesk account is configured
e.g. we add x-on-behalf-of to gem
but when we want to test is it really works, we have to check current user ( client.users.find(:id =-> :me) )
we can create that user and after each test ensure to delete it - but if we could cache vcr cassetes as long as the api would not change we would be able to reuse them
problem is with authorization data that are stored as part of url - and you don't want to share them from obvious reason - still it would be good to solve this issue
what's your thoughts ?
The scenario is:
external_id
external_id
and get no resultsexternal_id = SecureRandom.uuid
#=> "7cfde8e8-5004-4911-9d62-e21e68447d9b"
zendesk_ticket = ::ZendeskAPI::Ticket.new(ZENDESK_CLIENT, {
:subject => subject,
:group_id => group_id,
:external_id => "1234-5678",
:comment => {
:value => comment,
:public => false
},
:requester => {
:name => name,
:email => email
}
})
zendesk_ticket.save
found_ticket = ::ZendeskAPI::Search.search(ZENDESK_CLIENT, {
:query => "type:ticket external_id:#{external_id}"
}).first
# found_ticket will be nil here
Hi,
How search an end-user by email ? it's seems to work only with id.
In a Rails 2.3.x application that has a User model, the Zendesk gem appears to fail to initialize.
/lib/zendesk/association.rb#get_class and self.get_class.
Faraday: you may want to install system_timer for reliable timeouts
Faraday: you may want to install system_timer for reliable timeouts
/home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:443:in load_missing_constant': Zendesk is not missing constant User! (ArgumentError) from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:106:in
const_missing_not_from_s3_library'
from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/aws-s3/lib/aws/s3/extensions.rb:206:in rake_original_const_missing' from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in
const_missing'
from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:124:in send' from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:124:in
const_missing'
from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/bundler/gems/zendesk_api_client_rb-0f33b3cc8681/lib/zendesk/association.rb:194:in const_get' from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/bundler/gems/zendesk_api_client_rb-0f33b3cc8681/lib/zendesk/association.rb:194:in
get_class'
from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/bundler/gems/zendesk_api_client_rb-0f33b3cc8681/lib/zendesk/association.rb:84:in `has'
from /home/mark/.rvm/gems/ruby-1.8.7-p358@mygems/bundler/gems/zendesk_api_client_rb-0f33b3cc8681/lib/zendesk/resources/misc.rb:4
It appears that it might only need to be scoped with "Zendesk::" before it to work.
I can't get the gem to work in my Rails 2.3 application and I'm trying to narrow the problems down. So, this was found trying to test in IRB outside of my Rails application, ran into some problems.
With the older rails app, I have older RSpec dependencies as well.
After cloning the repository (0.0.2) and with "rspec (1.3.2)", "rspec-rails (1.3.4)", the "rake install" failed.
$ rake install
rake aborted!
no such file to load -- rspec/core/rake_task
In order to install, I had to modify Rakefile and comment out:
Following the current README documentation will lead to errors on the Ruby Gems Version of this Library when using token auth.
require 'zendesk_api'
client = ZendeskAPI::Client.new do |config|
# Mandatory:
config.url = "<- your-zendesk-url ->" # e.g. https://mydesk.zendesk.com/api/v2
config.username = "[email protected]"
# Choose one of the following depending on your authentication choice
config.token = "your zendesk token"
config.password = "your zendesk password"
# Optional:
# Retry uses middleware to notify the user
# when hitting the rate limit, sleep automatically,
# then retry the request.
config.retry = true
# Logger prints to STDERR by default, to e.g. print to stdout:
require 'logger'
config.logger = Logger.new(STDOUT)
# Changes Faraday adapter
# config.adapter = :patron
# Merged with the default client options hash
# config.client_options = { :ssl => false }
# When getting the error 'hostname does not match the server certificate'
# use the API at https://yoursubdomain.zendesk.com/api/v2
end
Resulting in the error
NoMethodError: undefined method `token=' for #<ZendeskAPI::Configuration:0x007fe3c32caef8>
from /Users/ben/Dropbox/Web/zendesk/hubby/app/models/zendesk.rb:14:in `block in assign_desk'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@general/gems/zendesk_api-0.1.3/lib/zendesk_api/client.rb:72:in `initialize'
from /Users/ben/Dropbox/Web/zendesk/hubby/app/models/zendesk.rb:6:in `new'
from /Users/ben/Dropbox/Web/zendesk/hubby/app/models/zendesk.rb:6:in `assign_desk'
from (irb):4
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@general/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@general/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@general/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
The Ruby Gems version has not been updated yet.
In order this get this working either modify the config code to:
config.username = "[email protected]/token" # add /token
config.password = "your zendesk token" # Use password field and not token
Or in your Gemfile use
gem 'zendesk_api', :git => 'git://github.com/zendesk/zendesk_api_client_rb.git'
This will get the latest version of the ruby gem library when you re-run 'bundle install' in the console.
Hey,
i'm getting the following error when sending an attached file that has been uploaded from the client.
@ticket= ZendeskAPI::Ticket.new(@client , :subject => subject, :comment => { :value => params[:feedback_text] },:requester_id => zendesk_user['id'])
@ticket.comment.uploads << params[:file]
@ticket.save
gives me
{"error"=>"RecordInvalid", "description"=>"Record validation errors", "details"=>{"filename"=>[{"description"=>"cannot be blank"}]}}
This only happens with files that are uploaded to the controller from the client using POST (ActionDispatch::Http::UploadedFile)
I'm using v0.1.1 of the gem.
Hi,
when I load a ticket with client.tickets.find(id: 1)
, it does not retrieve the comments. ticket.comment
and ticket.comments
returns nil. I can successfully add one comment to an existing ticket by using Zendesk::Ticket#comment=
, but it will replace the existing comment.
So, how would you add a comment to an existing ticket, without overwriting the existing one ?
Thanks.
There appears to be minor caching bug when organizations are paged. The following symptoms are observed:
In trying to iterated over every single organization the following should work
client = ZendeskAPI::Client.new # config the client
page = 1
loop do
orgs = client.organizations.page(page)
break if orgs.empty?
page += 1
orgs.each{|o| puts o.name }
end
Luckily, there is a workaround, just use next:
orgs = client.organizations
loop do
orgs.each{|o| puts o.name }
orgs.next
break if orgs.empty?
end
When paging through tickets using:
@client.search(query: query).each_page(&:block)
there is the occasional error:
{"error"=>"unavailable", "description"=>"Sorry, we could not complete your search query. Please try again in a moment."}
Stacktrace:
the server responded with status 500
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response/raise_error.rb:8:in `on_complete'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:9:in `block in call'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:63:in `on_complete'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/authorization.rb:36:in `call'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in `run_request'
/var/lib/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/connection.rb:87:in `get'
/var/lib/gems/1.9.1/gems/zendesk_api-0.2.6/lib/zendesk_api/collection.rb:174:in `fetch'
/var/lib/gems/1.9.1/gems/zendesk_api-0.2.6/lib/zendesk_api/rescue.rb:43:in `block (2 levels) in rescue_client_error'
/var/lib/gems/1.9.1/gems/zendesk_api-0.2.6/lib/zendesk_api/collection.rb:201:in `to_a'
/var/lib/gems/1.9.1/gems/zendesk_api-0.2.6/lib/zendesk_api/collection.rb:285:in `method_missing'
/var/lib/gems/1.9.1/gems/zendesk_api-0.2.6/lib/zendesk_api/collection.rb:210:in `each_page'
How is it possible to recover and retry the fetch in those cases?
Hi,
Thank you for a cool gem. I managed to fetch ticket, but to create one. I am getting this error with this configuration:
@client = Zendesk.configure do |config|
# Mandatory:
# Must be https URL unless it is localhost or 127.0.0.1
config.url = params[:url]
config.username = params[:username]
config.password = params[:password]
# Optional:
# Retry uses middleware to notify the user
# when hitting the rate limit, sleep automatically,
# then retry the request.
config.retry = true
# Logger prints to STDOUT by default
config.logger = true
# Logger prints out requests to STDERR
require 'logger'
config.logger = Logger.new(STDERR)
# Changes Faraday adapter
# config.adapter = :net_http
# Merged with the default client options hash
# config.client_options = { :ssl => true }
# When getting the error 'hostname does not match the server certificate'
# use the API at https://yoursubdomain.zendesk.com/api/v2
end
Zendesk::Ticket.create(client, :subject => "Test Ticket", :description => "This is a test", :submitter_id => client.me.id, :priority => "urgent")
'1.9.3p194 :003 >
post https://zaloraindonesia1338549562.zendesk.com/api/v2/tickets
Accept: "application/json"
Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
User-Agent: "Zendesk API 0.0.4"
Authorization: "Basic ZmZpcmRhdXNAemFsb3JhLmNvLmlkOlBAc3N3MHJk"
IOError: not opened for reading
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:207:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:207:in
to_a'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:207:inas_json' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:55:in
block in as_json'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:77:incheck_for_circular_references' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:54:in
as_json'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:242:inblock in as_json' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:242:in
each'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:242:inmap' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:242:in
as_json'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:47:inblock in encode' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:77:in
check_for_circular_references'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:46:inencode' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:252:in
block in encode_json'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:252:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/json/encoding.rb:252:in
map'
... 48 levels...
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/response.rb:8:incall' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/response/logger.rb:20:in
call'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/response.rb:8:incall' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/response.rb:8:in
call'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/connection.rb:226:inrun_request' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.1/lib/faraday/connection.rb:99:in
post'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/zendesk_api_client_rb-8314bc2e174e/lib/zendesk/actions.rb:38:insave' from /usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/zendesk_api_client_rb-8314bc2e174e/lib/zendesk/rescue.rb:10:in
block (2 levels) in rescue_client_error'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/zendesk_api_client_rb-8314bc2e174e/lib/zendesk/actions.rb:82:increate' from /usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/zendesk_api_client_rb-8314bc2e174e/lib/zendesk/rescue.rb:10:in
block (2 levels) in rescue_client_error'
from (irb):2
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:instart' from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in
start'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in<top (required)>' from script/rails:6:in
require'
from script/rails:6:in `
We run the client inside a Rails app and have one of our models named Ticket. Loading the client and calling user.requested_tickets
result in an error:
rails_console > user.requested_tickets
NoMethodError: undefined method `resource_name' for Ticket:Class
from /Users/michael/.rvm/gems/ruby-1.9.3-p125/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:24:in `initialize'
from /Users/michael/.rvm/gems/ruby-1.9.3-p125/gems/zendesk_api-0.0.9/lib/zendesk_api/association.rb:205:in `new'
from /Users/michael/.rvm/gems/ruby-1.9.3-p125/gems/zendesk_api-0.0.9/lib/zendesk_api/association.rb:205:in `block in has_many'
Renaming our model removes the problem so it seems like a name space issue.
Looking in the code around the Associations#get_class
line 233 seems it load the class from a global scope which finds our Ticket class first. A few quick fix ideas like replacing
get_const
with some ZendeskAPI scope like ZendeskAPi.get_const
or ZendeskAPI.get_class
resulted in specs failing.
grosser/const_get_cleanup
This is more a design issue rather than a specific bug, but I personally find having to handle API error cases with callbacks instead of exceptions bewildering (so much so that we've created our own wrapper for the zendesk_api
gem). Here's an example from #71:
class SearchError < Exception; end
client.insert_callback do |env|
if env[:status] == 500 && env[:url].request_uri =~ %r{/search}
# Must not be a Faraday::Error::ClientError, but could be any standard ruby error
raise SearchError
end
end
This pattern forces each app that uses the zendesk_api
gem to know intimate details of the Zendesk REST API (the error conditions for which aren't documented anywhere, to my knowledge). While I understand the perils of abstracting away the distributed nature of the API access completely, this feels like a very leaky abstraction - isn't the whole point of a wrapper to hide precisely these kinds of details from the application developer?
My proposed solution would be to raise (and document!) pre-defined exceptions for error cases known in advance (e.g. authentication error, validation errors, transient unavailability errors) by default, or alternatively follow the Rails method semantics and have methods ending with !
raise exceptions and methods without !
returning false or nil.
bundle exec rake
Failed examples:
rspec ./spec/collection_spec.rb:181 # Zendesk::Collection with real data pagination with no options should find the next page by calling fetch
rspec ./spec/collection_spec.rb:189 # Zendesk::Collection with real data pagination with no options should find the prev page by calling fetch
rspec ./spec/collection_spec.rb:201 # Zendesk::Collection with real data pagination with options should increase page option and not call fetch
rspec ./spec/collection_spec.rb:205 # Zendesk::Collection with real data pagination with options should decrease page option and not call fetch
rspec ./spec/collection_spec.rb:216 # Zendesk::Collection with real data pagination with options with page == 1 should do nothing on #prev
rake aborted!
Is there any plan to add persistent caching to this gem? Or, is it already supported, and I've just missed it?
For our use, it would be ok (even good) to very aggressively cache API responses. We're calculating some stats for a dashboard that require us to load several months worth of tickets for each client. However, it's not important that the stats are live -- they can be a bit out of date. So we could cache all that stuff for a week or so. This would massively reduce the number of requests we need to make as well as making our dashboard much quicker.
Any tips?
From what I can figure out, it looks like methods correspond to URLs, with some intelligence/guessing:
# the query option is silently dropped
# https://github.com/zendesk/zendesk_api_client_rb/issues/47 maybe?
> $zendesk.ticket(query: 'moon').first
get https://juniper.zendesk.com/api/v2/tickets
# typos are passed to ZenDesk API
> $zendesk.tickts(query: 'moon').first
get https://juniper.zendesk.com/api/v2/tickts?query=moon
the server responded with status 404
{"error"=>"InvalidEndpoint", "description"=>"Not found"}
# notice that user becomes users:
> $zendesk.user(query: 'moon').count
get https://juniper.zendesk.com/api/v2/users?query=moon
$zendesk.search(query: 'moon').first
NoMethodError: undefined method `superclass' for ZendeskAPI::Search:Module
How would I run a search, such as the following (which is a valid call)?
# simple
curl "https://juniper.zendesk.com/api/v2/search.json?query=type:moon" -v -u email:pasword
# typed:
curl "https://juniper.zendesk.com/api/v2/search.json?query=type:ticket%20moon" -v -u email:pasword
Edit: #29 suggests client.users.search(:query => email)
. How would I find this user's tickets?
Thanks!
client.users.search(:query => '[email protected]').first
NoMethodError: undefined method map' for #<String:0x000000092b9590> from /app/vendor/bundle/ruby/1.9.1/gems/zendesk_api-0.2.2/lib/zendesk_api/collection.rb:189:in
fetch'
from /app/vendor/bundle/ruby/1.9.1/gems/zendesk_api-0.2.2/lib/zendesk_api/rescue.rb:28:in block (2 levels) in rescue_client_error' from /app/vendor/bundle/ruby/1.9.1/gems/zendesk_api-0.2.2/lib/zendesk_api/collection.rb:201:in
to_a'
from /app/vendor/bundle/ruby/1.9.1/gems/zendesk_api-0.2.2/lib/zendesk_api/collection.rb:285:in method_missing' from (irb):8 from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in
start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in start' from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in
<top (required)>'
from script/rails:6:in require' from script/rails:6:in
Recently the API changed from returning a nil to raising a 404.
Old Example:
client.organizations.find(:id => 123)
#=> nil
New behavior:
client.organizations.find(:id => 123)
ZendeskAPI::Organization - find
the server responded with status 404
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/response/raise_error.rb:6:in `on_complete'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/response.rb:9:in `call'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/response.rb:63:in `on_complete'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/response.rb:8:in `call'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/request/authorization.rb:36:in `call'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in `run_request'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in `get'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/zendesk_api-0.0.9/lib/zendesk_api/actions.rb:69:in `orig_find'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in `send'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/zendesk_api-0.0.9/lib/zendesk_api/rescue.rb:26:in `find'
/home/mark/.rvm/gems/ruby-1.8.7-p358@canvas/gems/zendesk_api-0.0.9/lib/zendesk_api/collection.rb:62:in `find'
(irb):3:in `test_crap'
(irb):9:in `irb_binding'
/home/mark/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
/home/mark/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/irb/workspace.rb:52
{"error"=>"RecordNotFound", "description"=>"Not found"}
=> nil
No matter what I do, I cannot catch/rescue the exception. A begin/rescue surrounding block never fires the contents of the rescue and yet the call fails. It appears to be putting the above error output directly to StandardError console output and skipping anything that I can catch.
How should code look that tries to do a find where the value is wrong and be able to handle the exception?
When using the resource style of the api erros are "swalloved".
i.e
client.tickets.create(:subject => "ticket.subject", :description => "ticket.description", :requester_id => "10001", :submitter_id => "10001", ...)
will not throw an error. but only logg the error But
client.connection.get("/api/v2/users/10001/tickets/requested.json")
throws an Faraday::Error::ClientError
.
Is this intentional and is there a way to get the error in the first example?
Docs say to do client.tickets.create(:description => "...
That doesn't work. I get errors back saying that WARNING: Removed restricted keys ["description", "subject", etc.
If I do this:
client.tickets.create(:ticket => {:description => "blah..."})
then that works.
But I can't figure out how to set the requester.
Docs here say I should be able to pass in a request-email and it will either find or create the requester. If I do this:
c.tickets.create(:ticket => {:description => "Test", 'requester-name' => "Greg DeVore", 'requester-email' => "[email protected]"})
I get a warning that restricted params requester-name and requester-email have been removed and the ticket is created as if I submitted it.
I can create user, but how can I upload user's photo?
Currently, unauthenticated looks like this. Presumably, it would be nice to have this error noticed, and an exception thrown. Would be happy to work on such a commit should that be desirous.
Edit: also good to handle: (Stripe rubygem has a good way of handling errors like this https://github.com/stripe/stripe-ruby/tree/master/lib/stripe/errors)
{"error"=>{"title"=>"Forbidden", "message"=>"You do not have access to this page. Please contact the account owner of this help desk for further help."}}
Accept: "application/json"
Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
User-Agent: "ZendeskAPI API 0.1.7"
Status 401
server: "nginx/1.0.15"
date: "Wed, 24 Oct 2012 20:55:16 GMT"
content-type: "application/json; charset=utf-8"
connection: "close"
status: "401 Unauthorized"
www-authenticate: "Basic realm=\"Web Password\""
content-length: "38"
x-zendesk-origin-server: "app29.sys.zendesk.com"
{"error"=>"Couldn't authenticate you"}
#<ZendeskAPI::Collection:0x007fc9fa67d740> - fetch
the server responded with status 401
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/response/raise_error.rb:8:in `on_complete'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/response.rb:9:in `block in call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/response.rb:63:in `on_complete'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/request/authorization.rb:36:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in `run_request'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/faraday-0.8.4/lib/faraday/connection.rb:87:in `get'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/zendesk_api-0.1.7/lib/zendesk_api/collection.rb:158:in `fetch'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/zendesk_api-0.1.7/lib/zendesk_api/rescue.rb:26:in `block (2 levels) in rescue_client_error'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/zendesk_api-0.1.7/lib/zendesk_api/collection.rb:197:in `to_a'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/zendesk_api-0.1.7/lib/zendesk_api/collection.rb:277:in `method_missing'
/Users/peter/Rails/myapp/app/controllers/support_controller.rb:80:in `twilio_inbound'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:414:in `_run__1479243886447860838__process_action__2262410119493339627__callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:17:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:121:in `process'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:45:in `process'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal.rb:203:in `dispatch'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_controller/metal.rb:246:in `block in action'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:36:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-pjax-0.6.0/lib/rack/pjax.rb:12:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.9/lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.9/lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.9/lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/remotipart-1.0.2/lib/remotipart/middleware.rb:30:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__1722688666307380800__call__2508220806090863030__callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/peter/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/peter/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/peter/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
{"error"=>"Couldn't authenticate you"}
Started GET "/zendesk" for 127.0.0.1 at 2012-10-24 13:55:16 -0700
Processing by SupportController#twilio_inbound as HTML
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.7079ms)
MOPED: 127.0.0.1:27017 QUERY database=jnprmongo_development collection=users selector={"$query"=>{}, "$orderby"=>{:_id=>-1}} flags=[] limit=-1 skip=0 fields=nil (0.2961ms)
Completed 500 Internal Server Error in 783ms
NoMethodError (undefined method `priority=' for nil:NilClass):
app/controllers/support_controller.rb:81:in `twilio_inbound'
Rendered /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
Rendered /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.7ms)
Just getting started..
client.tickets.first.to_json
I'll see the results printed out in the console, but after that execution halts-- I have to force quit the server and start again.
In the readme you say that 'Configuration is done through a block returning an instance of ZendeskAPI::Client'. Where in your opinion should be this block? I guess that having such code in model or controller action is not the best approach.
Is there any way to initialize zendesk api gem somewhere so that then I'll be able just to call for example @zendesk_client.tickets
anywhere in Rails?
Thanks.
I'd like to code proper request specs in my Rails app.
One part involves ticket Zendesk, but there is no test config.
Any guideline please?
Hello again,
I was able to get things moving with ticket.create and wanted to try ticket.import.
losedticket=client.tickets.import( :subject => ": Ticket IMPORT",
:description => "ran the scripts on their DB and it is fixed",
:submitter_id => client.users.find(:id => 'me'),
:priority => "normal",
:requester_id => user[0].id,
:assignee_id => "239174448",
:group_id => "20056381",
:comments => "This is a comment",
:fields => [{:id =>20972946, :value => 17}],
:tags => ["Import", "Test"],
:status => "pending")
My other API calls go fine but this one is oddly silent in it's failure. Also, comments seem to be blocked on create? Is that expected? API message below:
x-zendesk-api-version: "v2"
x-zendesk-api-warn: "Removed restricted keys ["comments"] from parameters according to whitelist"
Thanks in advance!
Howdy!
Back with another good one here. After looping over all the organizations and putting them into a simple "name"=>"orgId" hash I'm now trying to find all the orgs that have 0 tickets. To do this I'm calling the client like so:
tix = client.ticket(:organization_id => 22227936)
puts tix.count
It works on the first call and I see a GET request in the logs and the count is correct.
GET https://solium.zendesk.com/api/v2/tickets?organization_id=22227936
The issue is subsequent calls are not issuing the GET request as I'd expect. A simple example is:
tix = client.ticket(:organization_id => 22227936) # => does a get
puts tix.count # => has correct count
tickets = client.ticket(:organization_id => 143898) # => doesn't issue a get
puts tickets.count # => gets old count from tix
Instinct tells me I need to flush the client or something but I'm not clear on how.
As ever, thanks for your help!
How do I search using the API client? The documentation shows the API supports it using a "search" action on a user (for instance). - http://developer.zendesk.com/documentation/rest_api/users.html
Specifically, I'm trying to search for a user by email.
All the following attempts return the full list of users paged in 100's.
zendesk_user = Zendesk::User.find(client, {:email => '[email protected]'})
zendesk_user = Zendesk::User.find(client, :params => {:search => '[email protected]'})
zendesk_user = Zendesk::User.find(client, :search => {:email => '[email protected]'})
How do I use the API client to search for Users, Organizations, etc? I looked in the gem but didn't see any code or tests for this feature.
Hi guys,
I'm trying to create tickets with the gem but normally I got an error, the code I'm using is as follows:
ticket = api.tickets.create :subject => 'testing', :description => 'testing', :submitter_id => api.current_user.id
The actual code is on this line of my project:
I tried without my wrapper and even when I can create a ticket without a problem the gem is throwin an exception, I'll update this issue with the exception as soon as I can.
Thanks in advance.
# broken:
> t.tags
=> ["sms"]
1.9.3-p194 :049 > t.tags << 'wqer'
=> ["sms", "wqer"]
1.9.3-p194 :050 > t.save
# <snip>
> t.tags
=> ["sms"]
# working:
> t.tags
=> ["sms"]
1.9.3-p194 :049 > t.tags = ['sms', 'wqer']
=> ["sms", "wqer"]
1.9.3-p194 :050 > t.save
# <snip>
> t.tags
=> ["sms", "wqer" ]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.