ips

package module
v0.0.0-...-9fc4bae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2017 License: MIT Imports: 4 Imported by: 0

README

Invision Community API for Go

Golang client for the IPS forum API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code string `json:"errorCode"`
	Name string `json:"errorMessage"`
}

APIError represents the return payload of a failed API request

func (APIError) Error

func (err APIError) Error() string

type Client

type Client struct {
	Info ClientInfo
	// contains filtered or unexported fields
}

Client represents a RESTful client for IPS 4 API

func NewClient

func NewClient(endpoint, key string) (*Client, error)

NewClient creates a client for connecting to the server and pings the /core/hello endpoint in order to check if the key is valid and the endpoint is online

func (*Client) GetMember

func (client *Client) GetMember(id string) (member MemberGet, err error)

GetMember implements GET /core/members/{id} and returns a Member object https://invisioncommunity.com/developers/rest-api?endpoint=core/members/GETitem

type ClientInfo

type ClientInfo struct {
	CommunityName string `json:"communityName"` // The name of the community
	CommunityURL  string `json:"communityUrl"`  // The community URL
	IPSVersion    string `json:"ipsVersion"`    // The Invision Community version number
}

ClientInfo represents the response from the /core/hello endpoint which includes basic information about the running instance of Invision Community.

type Field

type Field struct {
	Name  string `json:"name"`  // Field name
	Value string `json:"value"` // Field value
}

Field represents a custom field in a member's profile

type FieldGroup

type FieldGroup struct {
	Name   string           `json:"name"`   // Group name
	Fields map[string]Field `json:"fields"` // Array of field objects
}

FieldGroup represents a group of custom fields in a member's profile

type FieldGroups

type FieldGroups map[string]string

FieldGroups is a simpler structure for the above types that the official API uses. Those types are actually just maps keyed by numbers (y'know, like arrays, but more awkward). So this fix just unwraps the nested maps into flat maps and uses the names as keys.

type Group

type Group struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	FormattedName string `json:"formattedName"`
}

Group represents a forum member group

type MemberGet

type MemberGet struct {
	ID                    int                    `json:"id"`                    // ID number
	Name                  string                 `json:"name"`                  // Username
	Title                 string                 `json:"title"`                 // Member title
	Timezone              string                 `json:"timeZone"`              // Member timezone
	FormattedName         string                 `json:"formattedName"`         // Username with group formatting
	PrimaryGroup          Group                  `json:"primaryGroup"`          // Primary group
	SecondaryGroups       []Group                `json:"secondaryGroups"`       // Secondary groups
	Email                 string                 `json:"email"`                 // Email address
	Joined                time.Time              `json:"joined"`                // Registration date
	RegistrationIPAddress string                 `json:"registrationIpAddress"` // IP address when registered
	WarningPoints         int                    `json:"warningPoints"`         // Number of warning points the member has been issued
	ReputationPoints      int                    `json:"reputationPoints"`      // Number of reputation points member has
	PhotoURL              string                 `json:"photoUrl"`              // URL to photo (which will be the site's default if they haven't set one)
	ProfileURL            string                 `json:"profileUrl"`            // URL to profile
	Validating            bool                   `json:"validating"`            // Whether or not the validating flag is set on the member account
	Posts                 int                    `json:"posts"`                 // Number of content item submissions member has made
	LastActivity          time.Time              `json:"lastActivity"`          // Last activity date on the site
	LastVisit             time.Time              `json:"lastVisit"`             // Last distinct visit date on the site
	LastPost              time.Time              `json:"lastPost"`              // Latest content submission date
	ProfileViews          int                    `json:"profileViews"`          // Number of times member's profile has been viewed
	Birthday              string                 `json:"birthday"`              // Member birthday in MM/DD/YYYY format (or MM/DD format if no year has been supplied)
	OriginalCustomFields  map[string]FieldGroup  `json:"CustomFields"`          // Custom profile fields
	CustomFields          map[string]FieldGroups // some plonker decided the above field should be the worst possible format for such a simple data structure
}

MemberGet represents a forum user response from a GET request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL