Documentation ¶
Index ¶
- func DefaultBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
- func DefaultRetryPolicy(resp *http.Response, err error) (bool, error)
- func ExecuteGet[T any](ctx context.Context, apiClient *Client, url string, params any) (*T, error)
- func ExecutePost[T any](ctx context.Context, apiClient *Client, url string, body any) (*T, error)
- func ExecuteRawGet(ctx context.Context, apiClient *Client, url string) (*http.Response, error)
- func GetRawInspection(ctx context.Context, apiClient *Client, id string) (*json.RawMessage, error)
- type Backoff
- type CheckForRetry
- type Client
- type ClientCfg
- type GetAccountsActivityLogRequestParams
- type GetAccountsActivityLogResponse
- type GetSheqsyCompanyResponse
- type HTTPDoer
- type Header
- type Inspection
- type InspectionReportExportCompletionResponse
- type ListInspectionsParams
- type ListInspectionsResponse
- type Opt
- type WhoAmIResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackoff ¶
DefaultBackoff provides a default callback for Backoff which will perform exponential backoff based on the attempt number and limited by the provided minimum and maximum durations. It also tries to parse XRateLimitReset response header when a http.StatusTooManyRequests (HTTP Code 429) is found in the resp parameter. Hence it will return the number of seconds the server states it may be ready to process more requests from this client.
func DefaultRetryPolicy ¶
DefaultRetryPolicy provides a default callback for CheckForRetry.
func ExecuteGet ¶
func ExecutePost ¶
func ExecuteRawGet ¶
func GetRawInspection ¶
GetRawInspection returns the JSON Raw Message of an inspection response
Types ¶
type Backoff ¶
Backoff specifies a policy for how long to wait between retries. It is called after a failing request to determine the amount of time that should pass before trying again.
type CheckForRetry ¶
CheckForRetry specifies a policy for handling retries. It is called following each request with the response and error values returned by the http.Client. If it returns false, the Client stops retrying and returns the response to the caller. If it returns an error, that error value is returned in lieu of the error from the request.
type Client ¶
type Client struct { BaseURL string Duration time.Duration CheckForRetry CheckForRetry RetryMax int RetryWaitMin time.Duration RetryWaitMax time.Duration // contains filtered or unexported fields }
func (*Client) HTTPClient ¶
HTTPClient returns the http Client used by APIClient
func (*Client) HTTPTransport ¶
HTTPTransport returns the http Transport used by APIClient
type GetAccountsActivityLogRequestParams ¶
type GetAccountsActivityLogRequestParams struct { OrgID string `json:"org_id"` PageSize int `json:"page_size"` PageToken string `json:"page_token"` Filters accountsActivityLogFilter `json:"filters"` }
GetAccountsActivityLogRequestParams contains fields required to make a post request to activity log history api
func NewGetAccountsActivityLogRequest ¶
func NewGetAccountsActivityLogRequest(pageSize int, from time.Time, events []string) *GetAccountsActivityLogRequestParams
NewGetAccountsActivityLogRequest build a request for AccountsActivityLog for now it serves the purposes only for inspection.deleted. If we need later, we can change this builder
type GetAccountsActivityLogResponse ¶
type GetAccountsActivityLogResponse struct { Activities []activityResponse NextPageToken string `json:"next_page_token"` }
GetAccountsActivityLogResponse is the response from activity log history api
func ListOrganisationActivityLog ¶
func ListOrganisationActivityLog(ctx context.Context, apiClient *Client, request *GetAccountsActivityLogRequestParams) (*GetAccountsActivityLogResponse, error)
type GetSheqsyCompanyResponse ¶
type GetSheqsyCompanyResponse struct { CompanyID int `json:"companyId"` CompanyName string `json:"companyName"` Name interface{} `json:"name"` CompanyUID string `json:"companyUId"` }
func GetSheqsyCompany ¶
func GetSheqsyCompany(ctx context.Context, apiClient *Client, companyID string) (*GetSheqsyCompanyResponse, error)
GetSheqsyCompany returns the details for the selected company
type Inspection ¶
Inspection represents some properties present in an inspection
type InspectionReportExportCompletionResponse ¶
type InspectionReportExportCompletionResponse struct { Status string `json:"status"` URL string `json:"url,omitempty"` }
InspectionReportExportCompletionResponse represents the response of report export completion status
type ListInspectionsParams ¶
type ListInspectionsParams struct { ModifiedAfter time.Time `url:"modified_after,omitempty"` TemplateIDs []string `url:"template,omitempty"` Archived string `url:"archived,omitempty"` Completed string `url:"completed,omitempty"` Limit int `url:"limit,omitempty"` }
ListInspectionsParams is a list of all parameters we can set when fetching inspections
type ListInspectionsResponse ¶
type ListInspectionsResponse struct { Count int `json:"count"` Total int `json:"total"` Inspections []Inspection `json:"audits"` }
ListInspectionsResponse represents the response of listing inspections
func ListInspections ¶
func ListInspections(ctx context.Context, apiClient *Client, params *ListInspectionsParams) (*ListInspectionsResponse, error)
ListInspections retrieves the list of inspections from SafetyCulture
type Opt ¶
type Opt func(*Client)
Opt is an option to configure the Client
func OptAddTLSCert ¶
OptAddTLSCert adds a certificate at the supplied path to the cert pool
func OptSetInsecureTLS ¶
OptSetInsecureTLS sets whether TLS certs should be verified
func OptSetProxy ¶
OptSetProxy sets the proxy URL to use for API requests
func OptSetTimeout ¶
OptSetTimeout sets the timeout for the request