Sha256: 7702364a501ed4cf3eb40fcd2730272bef7656796c89d424f3534edbc9ba5226

Contents?: true

Size: 1.9 KB

Versions: 11

Compression:

Stored size: 1.9 KB

Contents

class Zendesk2::Client
  class Real
    def update_ticket(params={})
      id = params.delete("id")

      request(
        :method => :put,
        :path   => "/tickets/#{id}.json",
        :body   => {
          "ticket" => params
        },
      )
    end
  end
  class Mock
    def update_ticket(params={})
      ticket_id = params.delete("id")
      body      = self.data[:tickets][ticket_id].merge!(params)

      if comment = params["comment"]
        audit_id = self.class.new_id
        self.data[:ticket_audits][audit_id] = {
          "id"         => audit_id,
          "ticket_id"  => ticket_id,
          "created_at" => Time.now,
          "author_id"  => current_user["id"],
          "via"        => {
            "channel" => "api",
            "source"  => {
              "form" => {},
              "to"   => {},
              "rel"  => nil,
            }
          },
          "metadata" => {
            "system" => {
              "client"     => Zendesk2::Client::USER_AGENT,
              "ip_address" => "127.0.0.1",
              "location"   => "Oakland, CA, United States",
              "latitude"   => 37.83449999999999,
              "longitude"  => -122.2647,
            },
            "custom" => {},
          },
          "events" => [
            "id"          => self.class.new_id,
            "type"        => "Comment",
            "author_id"   => current_user["id"],
            "body"        => comment["body"],
            "html_body"   => "<p>#{comment["body"]}</p>",
            "public"      => comment["public"].nil? ? true : comment["public"],
            "trusted"     => comment["trusted"].nil? ? true : comment["trusted"],
            "attachments" => comment["attachments"] || [],
          ]
        }
      end

      response(
        :method => :put,
        :path   => "/tickets/#{ticket_id}.json",
        :body   => {
          "ticket" => body
        },
      )
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zendesk2-0.3.0 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.7 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.6 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.5 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.4 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.3 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.2 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.1 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.2.0 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.1.3 lib/zendesk2/client/requests/update_ticket.rb
zendesk2-0.1.2 lib/zendesk2/client/requests/update_ticket.rb