-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreftaxonomylocale.go
78 lines (67 loc) · 2.83 KB
/
reftaxonomylocale.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package phoebe
import (
"context"
"fmt"
"net/http"
"github.com/phoebe-bird/phoebe-go/internal/apijson"
"github.com/phoebe-bird/phoebe-go/internal/param"
"github.com/phoebe-bird/phoebe-go/internal/requestconfig"
"github.com/phoebe-bird/phoebe-go/option"
)
// RefTaxonomyLocaleService contains methods and other services that help with
// interacting with the phoebe API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewRefTaxonomyLocaleService] method instead.
type RefTaxonomyLocaleService struct {
Options []option.RequestOption
}
// NewRefTaxonomyLocaleService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewRefTaxonomyLocaleService(opts ...option.RequestOption) (r *RefTaxonomyLocaleService) {
r = &RefTaxonomyLocaleService{}
r.Options = opts
return
}
// Returns the list of supported locale codes and names for species common names,
// with the last time they were updated. Use the accept-language header to get
// translated language names when available.
//
// NOTE: The locale codes and names are stable but the other fields in this result
// are not yet finalized and should be used with caution.
func (r *RefTaxonomyLocaleService) List(ctx context.Context, query RefTaxonomyLocaleListParams, opts ...option.RequestOption) (res *[]RefTaxonomyLocaleListResponse, err error) {
if query.AcceptLanguage.Present {
opts = append(opts, option.WithHeader("Accept-Language", fmt.Sprintf("%s", query.AcceptLanguage)))
}
opts = append(r.Options[:], opts...)
path := "ref/taxa-locales/ebird"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
type RefTaxonomyLocaleListResponse struct {
Code string `json:"code"`
LastUpdated string `json:"lastUpdated"`
Name string `json:"name"`
JSON refTaxonomyLocaleListResponseJSON `json:"-"`
}
// refTaxonomyLocaleListResponseJSON contains the JSON metadata for the struct
// [RefTaxonomyLocaleListResponse]
type refTaxonomyLocaleListResponseJSON struct {
Code apijson.Field
LastUpdated apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RefTaxonomyLocaleListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r refTaxonomyLocaleListResponseJSON) RawJSON() string {
return r.raw
}
type RefTaxonomyLocaleListParams struct {
AcceptLanguage param.Field[string] `header:"Accept-Language"`
}