4eeadd06a5
* refactor: move more commands to internal/cmd Part of https://github.com/ooni/probe/issues/1335. We would like all commands to be at the same level of engine rather than inside engine (now that we can do it). * fix: update .gitignore * refactor: also move jafar outside engine * We should be good now?
30 lines
681 B
Go
30 lines
681 B
Go
package probeservices
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
|
)
|
|
|
|
type checkReportIDResponse struct {
|
|
Found bool `json:"found"`
|
|
}
|
|
|
|
// CheckReportID checks whether the given ReportID exists.
|
|
func (c Client) CheckReportID(ctx context.Context, reportID string) (bool, error) {
|
|
query := url.Values{}
|
|
query.Add("report_id", reportID)
|
|
var response checkReportIDResponse
|
|
err := (httpx.Client{
|
|
BaseURL: c.BaseURL,
|
|
HTTPClient: c.HTTPClient,
|
|
Logger: c.Logger,
|
|
UserAgent: c.UserAgent,
|
|
}).GetJSONWithQuery(ctx, "/api/_/check_report_id", query, &response)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return response.Found, nil
|
|
}
|