Sha256: 8271a2df3c96d2d69c4bd8009fac1e0f2070d34ca4ad56e8e2787b6474af953a

Contents?: true

Size: 709 Bytes

Versions: 14

Compression:

Stored size: 709 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   = params["id"]

      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

14 entries across 14 versions & 1 rubygems

Version Path
zendesk2-1.2.4 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.3 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.2 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.1 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.2.0 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.1.3 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.1.2 lib/zendesk2/client/requests/get_user.rb
zendesk2-1.0.0 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.5.4 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.5.3 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.5.2 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.5.1 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.5.0 lib/zendesk2/client/requests/get_user.rb
zendesk2-0.4.5 lib/zendesk2/client/requests/get_user.rb