Sha256: dc340e6e21809a3acb6db905dd83ac3ab6a3b4cc7210e9ef59fe58702b892b62

Contents?: true

Size: 1.31 KB

Versions: 53

Compression:

Stored size: 1.31 KB

Contents

class Ey::Core::Client
  class Real
    def get_users(params={})
      query = Ey::Core.paging_parameters(params)
      url   = params.delete("url")

      request(
        :params => params,
        :path   => "/users",
        :query  => query,
        :url    => url,
      )
    end
  end # Real
  class Mock
    def get_users(params={})
      resources = if url = params.delete("url")
                    if account_id = path_params(url)["accounts"]
                      account = self.find(:accounts, account_id)

                      if url.index("/owners")
                        account[:account_owners].inject({}){|r,id| r.merge(id => self.data[:users][id])}
                      elsif url.index("/users")
                        account[:account_users].inject({}){|r,id| r.merge(id => self.data[:users][id])}
                      else
                        raise "Mock doesn't know how to handle url: #{url}"
                      end
                    else []
                    end
                  else
                    self.data[:users]
                  end

      headers, users_page = search_and_page(params, :users, search_keys: %w[name email first_name last_name], resources: resources)

      response(
        :body    => {"users" => users_page},
        :headers => headers
      )
    end
  end # Mock
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
ey-core-3.6.4 lib/ey-core/requests/get_users.rb
ey-core-3.6.3 lib/ey-core/requests/get_users.rb
ey-core-3.6.1 lib/ey-core/requests/get_users.rb
groove-ey-core-3.6.3 lib/ey-core/requests/get_users.rb
groove-ey-core-3.6.2 lib/ey-core/requests/get_users.rb
groove-ey-core-3.6.1 lib/ey-core/requests/get_users.rb
ey-core-3.5.0 lib/ey-core/requests/get_users.rb
ey-core-3.4.4 lib/ey-core/requests/get_users.rb
ey-core-3.4.2 lib/ey-core/requests/get_users.rb
ey-core-3.4.1 lib/ey-core/requests/get_users.rb
ey-core-3.4.0 lib/ey-core/requests/get_users.rb
ey-core-3.3.1 lib/ey-core/requests/get_users.rb
ey-core-3.3.0 lib/ey-core/requests/get_users.rb
ey-core-3.2.6 lib/ey-core/requests/get_users.rb
ey-core-3.2.5 lib/ey-core/requests/get_users.rb
ey-core-3.2.4 lib/ey-core/requests/get_users.rb
ey-core-3.2.3 lib/ey-core/requests/get_users.rb
ey-core-3.2.2 lib/ey-core/requests/get_users.rb
ey-core-3.2.1 lib/ey-core/requests/get_users.rb
ey-core-3.2.0 lib/ey-core/requests/get_users.rb