Skip to content

Commit

Permalink
add delete method for resource service (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalii Velikodnyi <[email protected]>
  • Loading branch information
vvelikodny and Vitalii Velikodnyi authored May 21, 2022
1 parent abe179e commit 9cde9a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ResourceService interface {
Create(ctx context.Context, req *CreateRequest) (*Resource, error)
Get(ctx context.Context, id int64) (*Resource, error)
Update(ctx context.Context, id int64, req *UpdateRequest) (*Resource, error)
Delete(ctx context.Context, resourceID int64) error
}

type Protocol string
Expand Down
9 changes: 9 additions & 0 deletions resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ func (s *Service) Update(ctx context.Context, id int64, req *UpdateRequest) (*Re

return &resource, nil
}

func (s *Service) Delete(ctx context.Context, resourceID int64) error {
path := fmt.Sprintf("/cdn/resources/%d", resourceID)
if err := s.r.Request(ctx, http.MethodDelete, path, nil, nil); err != nil {
return fmt.Errorf("request: %w", err)
}

return nil
}

0 comments on commit 9cde9a1

Please sign in to comment.