Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAuthToken ¶
func WithAuthToken(t string) clientOpts
WithAuthtoken is an option to add an API KEY as a bearer token to requests
func WithBaseURL ¶
func WithBaseURL(s string) clientOpts
WithBaseURL is an option to overwrite the BaseURL
func WithClient ¶
WithClient is an option to overwrite the default client
func WithUserAgent ¶
func WithUserAgent(u string) clientOpts
WithUserAgent is an option to overwrite the UserAgent
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the structure use to communicate with the climatiq API
func NewClient ¶
func NewClient(opts ...clientOpts) *Client
NewClient returns an instantiated instance of a client with the ability to override values with various options
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, searchReq *SearchRequest) (*SearchResponse, error)
Search GETS the emission factors based on the query or parameters provided
type SearchRequest ¶
type SearchRequest struct { DataVersion string `url:"data_version"` Query string `url:"query,omitempty"` ActivityID string `url:"activity_id,omitempty"` Category string `url:"category,omitempty"` Sector string `url:"sector,omitempty"` Source string `url:"source,omitempty"` SourceDataset string `url:"source_dataset,omitempty"` Year int `url:"year,omitempty"` Region string `url:"region,omitempty"` UnitType string `url:"unit_type,omitempty"` // enum TODO SourceLCAActivity string `url:"source_lca_activity,omitempty"` CalculationMethod string `url:"calculation_method,omitempty"` AllowedDataQualityFlags []string `url:"allowed_data_quality_flags,omitempty"` AccessType string `url:"access_type,omitempty"` Page int `url:"page,omitempty"` ResultsPerPage int `url:"results_per_page,omitempty"` // MAX 100 }
SearchRequest contains query parameters to get emission factors. All fields are transformed into a query string that is sent in a GET request.
dataVersion is REQUIRED
type SearchResponse ¶
type SearchResponse struct { Results []SearchResults `json:"results"` CurrentPage int `json:"current_page"` LastPage int `json:"last_page"` TotalResults int `json:"total_results"` }
type SearchResults ¶
type SearchResults struct { ID string `json:"id"` ActivityID string `json:"activity_id"` AccessType string `json:"access_type"` Name string `json:"name"` Category string `json:"category"` Sector string `json:"sector"` Source string `json:"source"` SourceLink string `json:"source_link"` Uncertainty int `json:"uncertainty"` // number or nil Year int `json:"year"` YearReleased int `json:"year_released"` Region string `json:"region"` RegionName string `json:"region_name"` Description string `json:"description"` // UnitType []UnitTypes `json:"unit_type"` // TODO Unit string `json:"unit"` SourceLCAActivity string `json:"source_lca_activity"` SupportedCalculationMethods []string `json:"supported_calculation_methods"` Factor float64 `json:"factor"` // number or null // FactorCalculationMethod ConversionValue `json:"factor_calculation_method"` // TODO FactorCalculationOrigin string `json:"factor_calculation_origin"` // climatiq or source }