Sha256: f4c983feab00c7a521eb7da961a5d7e48a25526ff531cce8459536ac9c6efef2

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

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

      request(
        :method => :put,
        :path   => "/users/#{id}.json",
        :body   => {
          "user" => params
        },
      )
    end
  end
  class Mock
    def update_user(params={})
      id   = params.delete("id")
      path = "/users/#{id}.json"
      if params["email"] && self.data[:users].find{|k,u| u["email"] == params["email"] && k != id}
        response(
          :method => :put,
          :path   => path,
          :status => 422,
          :body   => {
            "error"       => "RecordInvalid",
            "description" => "Record validation errors", "details" => {
            "email"       => [ {
                "description" => "Email: #{params["email"]} is already being used by another user"
              } ]
            }
          }
        )
      else
        body = self.data[:users][id].merge!(params)
        response(
          :method => :put,
          :path   => path,
          :body   => {
            "user" => body
          },
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk2-0.1.1 lib/zendesk2/client/requests/update_user.rb
zendesk2-0.1.0 lib/zendesk2/client/requests/update_user.rb
zendesk2-0.0.23 lib/zendesk2/client/requests/update_user.rb
zendesk2-0.0.22 lib/zendesk2/client/requests/update_user.rb