Sha256: 78a09ef763994e165797780e24c5b9882fcaf2453c3284b227506f4cdef518b3
Contents?: true
Size: 1.28 KB
Versions: 9
Compression:
Stored size: 1.28 KB
Contents
class Zendesk2::Client class Real def destroy_user(params={}) id = params["id"] request( :method => :delete, :path => "/users/#{id}.json" ) end end class Mock def destroy_user(params={}) id = params["id"] path = "/users/#{id}.json" tickets = self.data[:tickets].values.select{|t| t["requester_id"] == id}.size find!(:users, id) if tickets < 1 self.data[:identities].each { |k,v| self.data[:identities].delete(k) if v["user_id"] == id } body = self.data[:users].delete(id) response( :method => :delete, :path => path, :body => { "user" => body, }, ) else response( :method => :delete, :path => path, :status => 422, :body => { "error" => "RecordInvalid", "description" => "Record validation errors", "details" => { "base" => [{ "type" => "User is requester on #{tickets} ticket(s) that are not closed.", "description" => "Base User is requester on #{tickets} ticket(s) that are not closed." }] } } ) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems