Class: Gitea::RepoHooksResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/gitea/resources/repo_hooks.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Gitea::Resource

Instance Method Details

#create(owner:, repo:, url:, type:, **args) ⇒ Object



13
14
15
16
# File 'lib/gitea/resources/repo_hooks.rb', line 13

def create(owner:, repo:, url:, type:, **args)
  data = {config: {content_type: "json", url: url}, type: type}
  Hook.new post_request("repos/#{owner}/#{repo}/hooks", body: args.merge(data)).body
end

#delete(owner:, repo:, id:) ⇒ Object



26
27
28
# File 'lib/gitea/resources/repo_hooks.rb', line 26

def delete(owner:, repo:, id:)
  delete_request("repos/#{owner}/#{repo}/hooks/#{id}")
end

#get(owner:, repo:, id:) ⇒ Object



9
10
11
# File 'lib/gitea/resources/repo_hooks.rb', line 9

def get(owner:, repo:, id:)
  Hook.new get_request("repos/#{owner}/#{repo}/hooks/#{id}").body
end

#list(owner:, repo:, **params) ⇒ Object



4
5
6
7
# File 'lib/gitea/resources/repo_hooks.rb', line 4

def list(owner:, repo:, **params)
  response = get_request("repos/#{owner}/#{repo}/hooks", params: params)
  Collection.from_response(response, type: Hook)
end

#test(owner:, repo:, id:) ⇒ Object



18
19
20
# File 'lib/gitea/resources/repo_hooks.rb', line 18

def test(owner:, repo:, id:)
  post_request("repos/#{owner}/#{repo}/hooks/#{id}/tests", body: {})
end

#update(owner:, repo:, id:, **args) ⇒ Object



22
23
24
# File 'lib/gitea/resources/repo_hooks.rb', line 22

def update(owner:, repo:, id:, **args)
  Hook.new patch_request("repos/#{owner}/#{repo}/hooks/#{id}", body: args).body
end