Documentation
¶
Overview ¶
Package user wraps Geni's User resource and all /user/* endpoints — the authenticated user's account plus their followed listings, uploaded media, and metadata.
Index ¶
- type AddRequest
- type AddResult
- type Client
- func (c *Client) Add(ctx context.Context, req *AddRequest) (*AddResult, error)
- func (c *Client) Albums(ctx context.Context, page int) (*photoalbum.BulkResponse, error)
- func (c *Client) FollowedDocuments(ctx context.Context, page int) (*document.BulkResponse, error)
- func (c *Client) FollowedProfiles(ctx context.Context, page int) (*profile.BulkResponse, error)
- func (c *Client) FollowedProjects(ctx context.Context, page int) (*project.BulkResponse, error)
- func (c *Client) FollowedSurnames(ctx context.Context, page int) (*surname.BulkResponse, error)
- func (c *Client) Get(ctx context.Context) (*User, error)
- func (c *Client) Labels(ctx context.Context, page int) (*LabelsResponse, error)
- func (c *Client) ManagedProfiles(ctx context.Context, page int) (*profile.BulkResponse, error)
- func (c *Client) MaxFamily(ctx context.Context, page int) (*profile.BulkResponse, error)
- func (c *Client) Metadata(ctx context.Context, userIds ...string) (*Metadata, error)
- func (c *Client) UpdateMetadata(ctx context.Context, data json.RawMessage) (*Metadata, error)
- func (c *Client) UploadedDocuments(ctx context.Context, page int) (*document.BulkResponse, error)
- func (c *Client) UploadedPhotos(ctx context.Context, page int) (*photo.BulkResponse, error)
- func (c *Client) UploadedVideos(ctx context.Context, page int) (*video.BulkResponse, error)
- type LabelsResponse
- type Metadata
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRequest ¶ added in v1.1.0
type AddRequest struct {
// Email is the new user's email address.
Email string `json:"email"`
// FirstName is the new user's first name.
FirstName string `json:"first_name"`
// LastName is the new user's last name.
LastName string `json:"last_name"`
// Gender is the new user's gender: "m", "f", or "u".
Gender string `json:"gender"`
}
AddRequest is the body for Client.Add. Geni's /user/add endpoint requires all four fields, so none carry omitempty — an empty value is sent through for the server to reject explicitly.
type AddResult ¶ added in v1.1.0
type AddResult struct {
// User is the created account, as returned in the response body.
User *User
// AccessToken is the new account's OAuth access token.
AccessToken string
}
AddResult is the outcome of Client.Add: the newly-created user plus the OAuth access token Geni issues for that account. The token arrives in the X-API-OAuth-access_token response header (not the body); it lets the caller immediately act on behalf of the new user.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a transport.Client with the user-scoped endpoints.
func (*Client) Add ¶ added in v1.1.0
Add creates a new Geni user account. Geni issues a fresh OAuth access token for the new account and returns it in the X-API-OAuth-access_token response header; it is surfaced as AddResult.AccessToken so the caller can immediately act as the new user.
All four AddRequest fields are required by Geni; Gender must be "m", "f", or "u".
func (*Client) Albums ¶
func (c *Client) Albums(ctx context.Context, page int) (*photoalbum.BulkResponse, error)
Albums returns the paginated list of the authenticated user's photo albums.
func (*Client) FollowedDocuments ¶
FollowedDocuments returns the paginated list of documents the authenticated user follows.
func (*Client) FollowedProfiles ¶
FollowedProfiles returns the paginated list of profiles the authenticated user follows. page is 1-indexed; values ≤0 omit the parameter (Geni defaults to page 1). Max 50 per page.
func (*Client) FollowedProjects ¶
FollowedProjects returns the paginated list of projects the authenticated user follows.
func (*Client) FollowedSurnames ¶
FollowedSurnames returns the paginated list of surnames the authenticated user follows.
func (*Client) Get ¶
Get returns the authenticated user — the account behind the OAuth token. Use this to ground "me" in API workflows that need to know who's calling.
func (*Client) Labels ¶
Labels returns the paginated list of label strings the authenticated user has applied to their tree.
func (*Client) ManagedProfiles ¶
ManagedProfiles returns the paginated list of profiles the authenticated user manages.
func (*Client) MaxFamily ¶
MaxFamily returns the paginated list of profiles in the user's "max family" — Geni's term for the set of relatives the user can see at maximum depth.
func (*Client) Metadata ¶
Metadata returns the authenticated user's application-specific metadata (the JSON blob previously stored via UpdateMetadata).
If userIds is non-empty, the call requests metadata for those user ids instead of the calling user — Geni's docs describe the ids parameter as "Comma separated list of ids of users you would like to get metadata for".
func (*Client) UpdateMetadata ¶
UpdateMetadata replaces the authenticated user's application- specific metadata with the supplied JSON blob. The data is opaque to the client — Geni stores whatever the caller sends.
Wire detail: Geni's /user/update-metadata expects the `data` field as a JSON-encoded *string*, not as a nested object (sending it as an object returns a 500 "no implicit conversion of ActionController::Parameters into String"). The client serialises the supplied RawMessage to a string before sending.
func (*Client) UploadedDocuments ¶
UploadedDocuments returns the paginated list of documents the authenticated user has uploaded.
func (*Client) UploadedPhotos ¶
UploadedPhotos returns the paginated list of photos the authenticated user has uploaded.
func (*Client) UploadedVideos ¶
UploadedVideos returns the paginated list of videos the authenticated user has uploaded.
type LabelsResponse ¶
type LabelsResponse struct {
Results []string `json:"results,omitempty"`
Page int `json:"page,omitempty"`
NextPage string `json:"next_page,omitempty"`
PrevPage string `json:"prev_page,omitempty"`
}
LabelsResponse is the paginated envelope returned by Client.Labels. Each result is a label string — Geni's docs describe my-labels' results as "Array of Strings". Named with the Response suffix because the bare "Labels" identifier collides with Ginkgo's dot-imported `Labels` symbol in test files.
type Metadata ¶
type Metadata struct {
Data json.RawMessage `json:"data,omitempty"`
}
Metadata is Geni's /user/metadata response. Data is the application-specific JSON blob the caller previously stored via Client.UpdateMetadata; the client leaves it as a raw message so callers can unmarshal into whatever structure their app uses.
type User ¶
type User struct {
// ID is the user's identifier.
ID string `json:"id,omitempty"`
// Guid is the user's globally unique identifier.
Guid string `json:"guid,omitempty"`
// Name is the user's display name.
Name string `json:"name,omitempty"`
// AccountType is the subscription tier: "basic", "plus", or "pro".
AccountType string `json:"account_type,omitempty"`
}
User is Geni's User resource — the authenticated user's account. Distinct from profile.Profile (which describes a node in the tree); a single account may manage many profiles.
The public docs list only `name` and `account_type` on this object, and the sandbox returns exactly those two — ID and Guid below are captured defensively in case production differs, but you should not depend on them being populated. The JSON decoder is permissive (extra fields are silently ignored).