initial work on star and unstar endpoints
This commit is contained in:
parent
480aac2171
commit
c96e8e2ff1
5
lib/travis/api/v3/models/starred_repository.rb
Normal file
5
lib/travis/api/v3/models/starred_repository.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Travis::API::V3
|
||||
class Models::StarredRepository < Model
|
||||
has_many :repositories
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ module Travis::API::V3
|
|||
has_many :tokens, dependent: :destroy
|
||||
has_many :organizations, through: :memberships
|
||||
has_many :repositories, as: :owner
|
||||
has_many :starred_repositories, #TODO
|
||||
has_one :subscription, as: :owner
|
||||
|
||||
serialize :github_oauth_token, Extensions::EncryptedColumn.new(disable: true)
|
||||
|
|
|
@ -10,6 +10,14 @@ module Travis::API::V3
|
|||
write?
|
||||
end
|
||||
|
||||
def star?
|
||||
write?
|
||||
end
|
||||
|
||||
def unstar?
|
||||
write?
|
||||
end
|
||||
|
||||
def create_request?
|
||||
write?
|
||||
end
|
||||
|
|
10
lib/travis/api/v3/queries/starred_repositories.rb
Normal file
10
lib/travis/api/v3/queries/starred_repositories.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Travis::API::V3
|
||||
class Queries::StarredRepositories < Query
|
||||
|
||||
def for_user(user)
|
||||
all.where(<<-SQL, 'User'.freeze, user.id)
|
||||
SQL
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -69,6 +69,8 @@ module Travis::API::V3
|
|||
|
||||
post :enable, '/enable'
|
||||
post :disable, '/disable'
|
||||
post :star, '/star'
|
||||
post :unstar, '/unstar'
|
||||
|
||||
resource :branch do
|
||||
route '/branch/{branch.name}'
|
||||
|
|
11
lib/travis/api/v3/services/repository/star.rb
Normal file
11
lib/travis/api/v3/services/repository/star.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Travis::API::V3
|
||||
class Services::Repository::Star < Service
|
||||
def run!
|
||||
super(true)
|
||||
end
|
||||
|
||||
def check_access(repository)
|
||||
access_control.permissions(repository).star!
|
||||
end
|
||||
end
|
||||
end
|
11
lib/travis/api/v3/services/repository/unstar.rb
Normal file
11
lib/travis/api/v3/services/repository/unstar.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Travis::API::V3
|
||||
class Services::Repository::Unstar < Service
|
||||
def run!
|
||||
super(true)
|
||||
end
|
||||
|
||||
def check_access(repository)
|
||||
access_control.permissions(repository).unstar!
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user