Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 36 additions and 2 deletions.
  1. +7 −2 lib/zendesk2/client.rb
  2. +29 −0 lib/zendesk2/client/requests/update_request.rb
View
9 lib/zendesk2/client.rb
@@ -59,6 +59,7 @@ class Zendesk2::Client < Cistern::Service
request :update_topic
request :update_topic_comment
request :update_organization
+ request :update_request
request :update_ticket
request :update_user
@@ -89,11 +90,15 @@ def initialize(options={})
password = options[:password] || Zendesk2.defaults[:password]
@token = options[:token]
- raise "Missing required options: [:username, :password]" unless @username && password
+ raise "Missing required options: [:username, :password]" unless @username && (password || @token)
@connection = Faraday.new({url: @url}.merge(connection_options)) do |builder|
# response
- builder.use Faraday::Request::BasicAuthentication, @username, password
+ if @token
+ builder.use Faraday::Request::BasicAuthentication, "#{@username}/token", @token
+ else
+ builder.use Faraday::Request::BasicAuthentication, @username, password
+ end
builder.use Faraday::Response::RaiseError
builder.response :json
View
29 lib/zendesk2/client/requests/update_request.rb
@@ -0,0 +1,29 @@
+class Zendesk2::Client
+ class Real
+ def update_request(params={})
+ id = params.delete("id")
+
+ request(
+ :method => :put,
+ :path => "/requests/#{id}.json",
+ :body => {
+ "request" => params
+ },
+ )
+ end
+ end
+ class Mock
+ def update_request(params={})
+ id = params.delete("id")
+ body = self.data[:tickets][id].merge!(params)
+
+ response(
+ :method => :put,
+ :path => "/tickets/#{id}.json",
+ :body => {
+ "request" => body
+ },
+ )
+ end
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.