Sha256: 114c968c03a778582df2064029c2b5b6bdd3fbebaa6c9c99216422c9f6cf3491

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 Bytes

Contents

class Zendesk2::Client
  class Real
    def get_user(params={})
      id = params["id"]

      request(
        :method => :get,
        :path => "/users/#{id}.json"
      )
    end
  end # Real

  class Mock
    def get_user(params={})
      id = require_parameters(params, "id").to_i

      identities = self.data[:identities].values.select { |i| i["user_id"] == id }
      identity = identities.find { |i| i["type"] == "email" && i["primary"] } || identities.find { |i| i["type"] == "email" }

      # @todo what happens if no identity?

      response(
        :path  => "/users/#{id}.json",
        :body  => {
          "user" => find!(:users, id).merge("email" => identity["value"]),
        },
      )
    end
  end # Mock
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zendesk2-1.2.7 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.6 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.5 lib/zendesk2/client/requests/get_user.rb