add owner/github_id/:id endpoint
This commit is contained in:
parent
bce9ea5b46
commit
245edc5f55
|
@ -1,9 +1,10 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Queries::Organization < Query
|
class Queries::Organization < Query
|
||||||
params :id, :login
|
params :id, :login, :github_id
|
||||||
|
|
||||||
def find
|
def find
|
||||||
return Models::Organization.find_by_id(id) if id
|
return Models::Organization.find_by_id(id) if id
|
||||||
|
return Models::Organization.find_by_github_id(github_id) if github_id
|
||||||
return Models::Organization.where('lower(login) = ?'.freeze, login.downcase).first if login
|
return Models::Organization.where('lower(login) = ?'.freeze, login.downcase).first if login
|
||||||
raise WrongParams, 'missing organization.id or organization.login'.freeze
|
raise WrongParams, 'missing organization.id or organization.login'.freeze
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Travis::API::V3
|
||||||
def query(type, main_type: self.main_type, params: self.params)
|
def query(type, main_type: self.main_type, params: self.params)
|
||||||
main_type = type if main_type == :owner
|
main_type = type if main_type == :owner
|
||||||
params = params.merge("#{type}.login" => params["owner.login".freeze]) if params["owner.login".freeze]
|
params = params.merge("#{type}.login" => params["owner.login".freeze]) if params["owner.login".freeze]
|
||||||
|
params = params.merge("#{type}.github_id" => params["owner.github_id".freeze]) if params["owner.github_id".freeze]
|
||||||
Queries[type].new(params, main_type, service: @service)
|
Queries[type].new(params, main_type, service: @service)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Queries::User < Query
|
class Queries::User < Query
|
||||||
params :id, :login, :email
|
params :id, :login, :email, :github_id
|
||||||
|
|
||||||
def find
|
def find
|
||||||
return Models::User.find_by_id(id) if id
|
return Models::User.find_by_id(id) if id
|
||||||
|
return Models::User.find_by_github_id(github_id) if github_id
|
||||||
return Models::User.where('lower(login) = ?'.freeze, login.downcase).first if login
|
return Models::User.where('lower(login) = ?'.freeze, login.downcase).first if login
|
||||||
return find_by_email(email) if email
|
return find_by_email(email) if email
|
||||||
raise WrongParams, 'missing user.id or user.login'.freeze
|
raise WrongParams, 'missing user.id or user.login'.freeze
|
||||||
|
|
|
@ -12,6 +12,7 @@ module Travis::API::V3
|
||||||
return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze
|
return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze
|
||||||
access_control = AccessControl.new(env)
|
access_control = AccessControl.new(env)
|
||||||
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
|
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
|
||||||
|
p factory
|
||||||
env_params = params(env)
|
env_params = params(env)
|
||||||
|
|
||||||
raise NotFound unless factory
|
raise NotFound unless factory
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Travis::API::V3
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :owner do
|
resource :owner do
|
||||||
route '/owner/({owner.login}|{user.login}|{organization.login})'
|
route '/owner/({owner.login}|{user.login}|{organization.login}|github_id/{owner.github_id})'
|
||||||
get :find
|
get :find
|
||||||
get :repositories, '/repos'
|
get :repositories, '/repos'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user