Sha256: 0cd9284e66e55f273db5ee1fe3a3729f97ad6ed0b20946675f9a1e6507f79424

Contents?: true

Size: 834 Bytes

Versions: 21

Compression:

Stored size: 834 Bytes

Contents

class Zendesk2::Client::DestroyUser < Zendesk2::Client::Request
  request_method :delete
  request_path { |r| "/users/#{r.user_id}.json" }

  def user_id
    @_user_id ||= params.fetch("user").fetch("id").to_i
  end

  def mock
    ticket_count = service.data[:tickets].values.select { |t| t["requester_id"].to_i == user_id }.size

    if ticket_count < 1
      service.data[:identities].each { |k,v| service.data[:identities].delete(k) if v["user_id"] == user_id }

      mock_response("user" => self.delete!(:users, user_id))
    else
      error!(:invalid, "details" => {
        "base" => [{
          "type"        => "User is requester on #{ticket_count} ticket(s) that are not closed.",
          "description" => "Base User is requester on #{ticket_count} ticket(s) that are not closed."
        }]
      })
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.7.5 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.7.4 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.7.2 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.7.1 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.7.0 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.6.1 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.17 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.16 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.15 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.14 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.13 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.12 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.11 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.10 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.9 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.8 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.7 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.6 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.5 lib/zendesk2/client/requests/destroy_user.rb
zendesk2-1.5.4 lib/zendesk2/client/requests/destroy_user.rb