Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions pkg/hackers/structuredscopes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hackers

import (
"context"
"fmt"

"github.com/liamg/hackerone/pkg/api"
)

type getStructuredScopesResponse struct {
Data []api.StructuredScope `json:"data"`
Links api.Links `json:"links"`
}

// GetStructuredScopes returns a list of structured scopes for a given program. If there are further pages, nextPage will be >0.
func (a *API) GetStructuredScopes(ctx context.Context, handle string, pageOptions *api.PageOptions) (programs []api.StructuredScope, nextPage int, err error) {
var response getStructuredScopesResponse
path := fmt.Sprintf(
"/hackers/programs/%s/structured_scopes?page[number]=%d&page[size]=%d",
handle,
pageOptions.GetPageNumber(),
pageOptions.GetPageSize(),
)
if err := a.client.Get(ctx, path, &response); err != nil {
return nil, 0, err
}
if response.Links.Next != "" {
nextPage = pageOptions.GetPageNumber() + 1
}
return response.Data, nextPage, nil
}