aphjsonapi

package
v0.0.0-...-9ff59ee Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package aphjsapi provides additional interfaces, wrapper and helper functions for original jsapi package("github.com/manyminds/api2go/jsapi")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAttributeFields

func GetAttributeFields(data interface{}) []string

GetAttributeNames returns all JSAONAPI attribute names of data interface

func GetFilterAttributes

func GetFilterAttributes(data interface{}) []string

GetFilterAttributes gets all the JSONAPI attributes that are allowed to match filter query params

func GetTypeName

func GetTypeName(data interface{}) string

GetTypeName gets the type name(type field) from a jsapi implementing interface. It is recommended to implement jsapi.EntityNamer interface to reduce the use of reflection

func MapFieldsToDbRow

func MapFieldsToDbRow(data interface{}) map[string]string

MapFieldsToDbRow maps jsapi attributes to database row names

func MarshalToStructWrapper

func MarshalToStructWrapper(data interface{}, ep jsapi.ServerInformation) (*jsapi.Document, error)

MarshalToStructWrapper adds relationship information and returns a jsapi.Document structure for further json encoding

func MarshalWithPagination

func MarshalWithPagination(data interface{}, ep jsapi.ServerInformation, opt *pagination.Props) (*jsapi.Document, error)

MarshalWithPagination adds pagination information for collection resource

Types

type AttributeToDbRowMapper

type AttributeToDbRowMapper interface {
	GetMap() map[string]string
}

AttributeToDbRowMapper is an interface to provide mapping between jsapi attribute and database row names. This is useful for implementing filter query parameter

type MarshalRelatedRelations

type MarshalRelatedRelations interface {
	GetRelatedLinksInfo() []RelationShipLink
}

MarshalRelatedRelations is an interface for creating related relationship links

type MarshalSelfRelations

type MarshalSelfRelations interface {
	GetSelfLinksInfo() []RelationShipLink
}

MarshalSelfRelations is an interface for creating self relationship links

type Permission

type Permission struct {
	ID          string `json:"-"`
	Permission  string `json:"permission"`
	Description string `json:"description"`
}

func (Permission) GetID

func (p Permission) GetID() string
type RelationShipLink struct {
	Name string
	// To override the default links, it will be appended to
	// the base url.
	SuffixFragment string
}

RelationshipLink is a container type for having information about relationship links

func GetAllRelationships

func GetAllRelationships(data interface{}) []RelationShipLink

GetAllRelationships returns all relationships of data interface

type RelationshipAttribute

type RelationshipAttribute interface {
	GetAttributeFields(string) []string
}

RelationshipAttributes is an interface to provide attribute fields of relationship resources. This is mandatory for supporting sparse fieldset query parameter.

type Role

type Role struct {
	ID          string        `json:"-"`
	Role        string        `json:"role"`
	Description string        `json:"description"`
	Permissions []*Permission `json:"-"`
	Users       []*User       `json:"-"`
}

func (*Role) GetID

func (r *Role) GetID() string

func (*Role) GetRelatedLinksInfo

func (r *Role) GetRelatedLinksInfo() []RelationShipLink

func (*Role) GetSelfLinksInfo

func (r *Role) GetSelfLinksInfo() []RelationShipLink

type User

type User struct {
	ID    string  `json:"-"`
	Name  string  `json:"name,omitempty" filter:"-"`
	Email string  `json:"email,omitempty" filter:"-"`
	Roles []*Role `json:"-"`
}

func (*User) GetID

func (u *User) GetID() string

GetID satisfies jsonapi.MarshalIdentifier interface

func (*User) GetReferencedIDs

func (u *User) GetReferencedIDs() []jsonapi.ReferenceID

GetReferencedIDs satisfies jsonapi.MarshalLinkedRelations interface

func (*User) GetReferencedStructs

func (u *User) GetReferencedStructs() []jsonapi.MarshalIdentifier

GetReferencedStructs satisfies jsonapi.MarshalIncludedRelations interface

func (*User) GetReferences

func (u *User) GetReferences() []jsonapi.Reference

GetReferences satisfies jsonapi.MarshalReferences interface

func (*User) GetRelatedLinksInfo

func (u *User) GetRelatedLinksInfo() []RelationShipLink

GetSelfLinksInfo satisfies MarshalRelatedRelations interface

func (*User) GetSelfLinksInfo

func (u *User) GetSelfLinksInfo() []RelationShipLink

GetSelfLinksInfo satisfies MarshalSelfRelations interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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