Class: Ghub::Endpoints::Branches::Signature::Root

Inherits:
Object
  • Object
show all
Includes:
Pipeable
Defined in:
lib/ghub/endpoints/branches/signature/root.rb

Overview

Provides access to the branch signature API endpoint.

Constant Summary collapse

PATH =
"repos/%<owner>s/%<repository>s/branches/%<branch>s/protection/required_signatures"

Instance Method Summary collapse

Constructor Details

#initialize(path: PATH) ⇒ Root

Returns a new instance of Root.



17
18
19
20
# File 'lib/ghub/endpoints/branches/signature/root.rb', line 17

def initialize(path: PATH, **)
  super(**)
  @path = path
end

Instance Method Details

#create(owner, repository, branch) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/ghub/endpoints/branches/signature/root.rb', line 30

def create owner, repository, branch
  pipe format(path, owner:, repository:, branch:),
       to(api, :post),
       try(:parse, catch: JSON::ParserError),
       validate(response, as: :to_h),
       to(model, :for)
end

#destroy(owner, repository, branch) ⇒ Object



38
39
40
# File 'lib/ghub/endpoints/branches/signature/root.rb', line 38

def destroy owner, repository, branch
  api.delete format(path, owner:, repository:, branch:)
end

#show(owner, repository, branch) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ghub/endpoints/branches/signature/root.rb', line 22

def show owner, repository, branch
  pipe format(path, owner:, repository:, branch:),
       to(api, :get),
       try(:parse, catch: JSON::ParserError),
       validate(response, as: :to_h),
       to(model, :for)
end