# README

dp-search-scrubber-api SDK

Overview

The scrubber API contains a Go client for interacting with the API. The client contains a methods for each API endpoint so that any Go application wanting to interact with the scrubber api can do so. Please refer to the swagger specification as the source of truth of how each endpoint works.

Example use of the API SDK

Initialise new Scrubber API client

package main

import (
	"context"
	"github.com/ONSdigital/dp-search-scrubber-api/sdk"
)

func main() {
    // code

	scrubberAPIClient := sdk.NewClient("http://localhost:28700")

    // code
}

Get Scrubber Results

Use the GetScrubber method to send a request to find scrubber results based on query parameters.

    // Set query parameters - no limit to which keys and values you set - please refer to swagger spec for list of available parameters
    opt := sdk.OptInit()
    opt.Q("E00000013,01220")

    resp, err := scrubberAPIClient.GetScrubber(ctx, opt)
    if err != nil {
        // handle error
    }

Handling errors

The error returned from the method contains status code that can be accessed via Status() method and similar to extracting the error message using Error() method; see snippet below:

    _, err := scrubberAPIClient.GetScrubber(ctx, Options{})
    if err != nil {
        // Retrieve status code from error
        statusCode := err.Status()
        // Retrieve error message from error
        errorMessage := err.Error()

        // log message, below uses "github.com/ONSdigital/log.go/v2/log" package
        log.Error(ctx, "failed to retrieve scrubber results", err, log.Data{"code": statusCode})

        return err
    }

# Packages

No description provided by the author
No description provided by the author

# Functions

New creates a new instance of Client with a given Scrubber API url.
NewWithHealthClient creates a new instance of Scrubber API Client, reusing the URL and Clienter from the provided healthcheck client.
empty Options.

# Constants

List of available headers.
No description provided by the author

# Structs

No description provided by the author
Options is a struct containing for customised options for the scrubber API client.
No description provided by the author

# Interfaces

Clienter interface for scrubber API client.