inital commit
This commit is contained in:
@@ -47,7 +47,7 @@ type Submission struct {
|
||||
// Returns [ErrNotFound] if FA renders a "submission not found" system message,
|
||||
// [ErrUnauthorized] for restricted-visibility submissions when called
|
||||
// without valid cookies, or a wrapped parse error if the markup has shifted.
|
||||
func (c *Client) GetSubmission(ctx context.Context, id SubmissionID) (*Submission, error) {
|
||||
func (c *Client) GetSubmission(ctx context.Context, id SubmissionID, opts ...Option) (*Submission, error) {
|
||||
if id <= 0 {
|
||||
return nil, fmt.Errorf("fa: GetSubmission: id must be > 0")
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (c *Client) GetSubmission(ctx context.Context, id SubmissionID) (*Submissio
|
||||
}
|
||||
out = s
|
||||
return nil
|
||||
})
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -72,13 +72,14 @@ func (c *Client) GetSubmission(ctx context.Context, id SubmissionID) (*Submissio
|
||||
//
|
||||
// Returns the number of bytes written. Errors from the writer are wrapped
|
||||
// as-is; HTTP errors come back as [*HTTPError].
|
||||
func (c *Client) Download(ctx context.Context, sub *Submission, w io.Writer) (int64, error) {
|
||||
func (c *Client) Download(ctx context.Context, sub *Submission, w io.Writer, opts ...Option) (int64, error) {
|
||||
if sub == nil {
|
||||
return 0, errors.New("fa: Download: nil submission")
|
||||
}
|
||||
if sub.FileURL == "" {
|
||||
return 0, errors.New("fa: Download: submission has no FileURL")
|
||||
}
|
||||
ctx = c.applyRequestOptions(ctx, opts)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, sub.FileURL, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
||||
Reference in New Issue
Block a user