lanej / zendesk2

Zendesk API V2 client using Cistern
http://lanej.io/zendesk2/
MIT License
25 stars 28 forks source link

Could zendesk2 create ticket comments? #34

Open ivan-garanin opened 9 years ago

ivan-garanin commented 9 years ago

I have got ticket:

<Zendesk2::Client::Ticket
    id=886,
    assignee_id=nil,
    collaborator_ids=[],
    created_at=2015-06-18 16:35:12 UTC,
    custom_fields=[],
    description="test",
    due_at=nil,
    external_id="",
    forum_topic_id=nil,
    group_id=25818508,
    has_incidents=false,
    organization_id=nil,
    priority="",
    problem_id=nil,
    recipient="",
    requester_id=1069516038,
    satisfaction_rating=nil,
    sharing_agreement_ids=[],
    status="new",
    subject="test",
    submitter_id=1069516038,
    tags=[],
    type="",
    updated_at=2015-06-18 16:35:12 UTC,
    url="https://ray1434039174.zendesk.com/api/v2/tickets/886.json",
    via={"channel"=>"api", "source"=>{"from"=>{}, "to"=>{}, "rel"=>nil}}

I would like to create one more comment to this ticket with this command:

ticket.comments.create({:body => 'test2', :html_body => '<p>test2</p>', :trusted => true, :public => true, :author_id => 1069516038})

and I got this error:

NotImplementedError: NotImplementedError
from /Users/ivangaranin/.rvm/gems/ruby-2.2.0-preview1/gems/zendesk2-1.5.17/lib/zendesk2/client/model.rb:7:in `save!'

Could you help me ? Thank you, Ivan

lanej commented 9 years ago

@ivan-garanin i see why you think that should work and it's definitely a bug i will fix soon.

Easy workaround is to use ticket#comment @ https://github.com/lanej/zendesk2/blob/master/lib/zendesk2/client/models/ticket.rb#L97.

ticket.comment('test2', :html_body => '<p>test2</p>', :trusted => true, :public => true, :author_id => 1069516038})
ivan-garanin commented 9 years ago

I tried to do somethig like this:

ticket.comments.create('test2', :html_body => '<p>test2</p>', :trusted => true, :public => true,  :author_id => 1069516038)

And got:

 ArgumentError: wrong number of arguments (2 for 0..1)
from /Users/ivangaranin/.rvm/gems/ruby-2.2.0-preview1/gems/zendesk2-1.5.17/lib/zendesk2/paged_collection.rb:76:in `create' 

I hope this will help you in your hunt:

~> ticket.comments.new(:body => 'test2', :html_body => '<p>test2</p>', :trusted => true, :public => true,
:author_id => 1069516038)
 =>   <Zendesk2::Client::TicketComment
    id=nil,
    body="test2",
    html_body="<p>test2</p>",
    public=true,
    trusted=nil,
    author_id=nil,
    attachments=nil `

~> ticket.save
NotImplementedError: NotImplementedError
from /Users/ivangaranin/.rvm/gems/ruby-2.2.0-preview1/gems/zendesk2-1.5.17/lib/zendesk2/client/model.rb:7:in `save!' 

as you see author_id is blank and trusted too

lanej commented 9 years ago

@ivan-garanin found the issue. see my workaround in the comment above. specifically take note of the different method ticket.comment(body, options).

ivan-garanin commented 9 years ago

Sorry for the carelessness. This helped me! Thank you !