resources

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Key
	Attributes BalanceAttributes `json:"attributes"`
}

type BalanceAttributes

type BalanceAttributes struct {
	// Referral codes which can be used to build a referral link and send it to friends. Returned only for the single user.
	ActiveReferralCodes *[]string `json:"active_referral_codes,omitempty"`
	// Amount of points
	Amount int64 `json:"amount"`
	// Referral codes used by invited users. Returned only for the single user.
	ConsumedReferralCodes *[]string `json:"consumed_referral_codes,omitempty"`
	// Unix timestamp of balance creation
	CreatedAt int32 `json:"created_at"`
	// Whether the user was not referred by anybody, but the balance with some events was reserved. It happens when the user fulfills some event before the balance creation.
	IsDisabled bool `json:"is_disabled"`
	// The level indicates how many possibilities the user has
	Level int `json:"level"`
	// Rank of the user in the full leaderboard. Returned only for the single user.
	Rank *int `json:"rank,omitempty"`
	// Unix timestamp of the last points accruing
	UpdatedAt int32 `json:"updated_at"`
}

type BalanceListResponse

type BalanceListResponse struct {
	Data     []Balance       `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*BalanceListResponse) GetMeta

func (r *BalanceListResponse) GetMeta(out interface{}) error

func (*BalanceListResponse) PutMeta

func (r *BalanceListResponse) PutMeta(v interface{}) (err error)

type BalanceResponse

type BalanceResponse struct {
	Data     Balance  `json:"data"`
	Included Included `json:"included"`
}

type CreateBalance

type CreateBalance struct {
	Key
	Attributes CreateBalanceAttributes `json:"attributes"`
}

type CreateBalanceAttributes

type CreateBalanceAttributes struct {
	// referrer code from the link
	ReferredBy string `json:"referred_by"`
}

type CreateBalanceListRequest

type CreateBalanceListRequest struct {
	Data     []CreateBalance `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*CreateBalanceListRequest) GetMeta

func (r *CreateBalanceListRequest) GetMeta(out interface{}) error

func (*CreateBalanceListRequest) PutMeta

func (r *CreateBalanceListRequest) PutMeta(v interface{}) (err error)

type CreateBalanceRelationships

type CreateBalanceRelationships struct {
	ReferredBy Relation `json:"referred_by"`
}

type CreateBalanceRequest

type CreateBalanceRequest struct {
	Data     CreateBalance `json:"data"`
	Included Included      `json:"included"`
}

type Details

type Details json.RawMessage

func (Details) MarshalJSON

func (d Details) MarshalJSON() ([]byte, error)

MarshalJSON - casts Details to []byte

func (*Details) Scan

func (r *Details) Scan(src interface{}) error

Scan - implements db driver method for auto unmarshal

func (Details) String

func (d Details) String() string

func (*Details) UnmarshalJSON

func (d *Details) UnmarshalJSON(data []byte) error

UnmarshalJSON - casts data to Details

func (Details) Value

func (r Details) Value() (driver.Value, error)

Value - implements db driver method for auto marshal

type Event

type Event struct {
	Key
	Attributes    EventAttributes     `json:"attributes"`
	Relationships *EventRelationships `json:"relationships,omitempty"`
}

type EventAttributes

type EventAttributes struct {
	// Unix timestamp of event creation
	CreatedAt int32     `json:"created_at"`
	Meta      EventMeta `json:"meta"`
	// How many points were accrued. Required only for `claimed` events. This is necessary, as the reward might change over time, while the certain balance should be left intact.
	PointsAmount *int64 `json:"points_amount,omitempty"`
	// See `filter[status]` parameter for explanation
	Status string `json:"status"`
	// Unix timestamp of the event status change
	UpdatedAt int32 `json:"updated_at"`
}

type EventListResponse

type EventListResponse struct {
	Data     []Event         `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*EventListResponse) GetMeta

func (r *EventListResponse) GetMeta(out interface{}) error

func (*EventListResponse) PutMeta

func (r *EventListResponse) PutMeta(v interface{}) (err error)

type EventMeta

type EventMeta struct {
	// Some events require dynamic data, which can be filled into `static` template.
	Dynamic *json.RawMessage `json:"dynamic,omitempty"`
	Static  EventStaticMeta  `json:"static"`
}

type EventRelationships

type EventRelationships struct {
	Balance Relation `json:"balance"`
}

type EventResponse

type EventResponse struct {
	Data     Event    `json:"data"`
	Included Included `json:"included"`
}

type EventStaticMeta

type EventStaticMeta struct {
	// Page where you can fulfill the event
	ActionUrl   *string `json:"action_url,omitempty"`
	Description string  `json:"description"`
	// General event expiration date (UTC RFC3339)
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	// Event frequency, which means how often you can fulfill certain task and claim the reward.
	Frequency string `json:"frequency"`
	Logo *string `json:"logo,omitempty"`
	// Unique event code name
	Name string `json:"name"`
	// Reward amount in points
	Reward           int64  `json:"reward"`
	ShortDescription string `json:"short_description"`
	// General event starting date (UTC RFC3339)
	StartsAt *time.Time `json:"starts_at,omitempty"`
	Title    string     `json:"title"`
}

Primary event metadata in plain JSON. This is a template to be filled by `dynamic` when it's present.

type Flag

type Flag struct {
	Name  string `json:"name"`
	Value int32  `json:"value"`
}

type Flagger

type Flagger interface {
	IsFlag() bool
}

type Flags

type Flags struct {
	Mask   int32  `json:"mask"`
	Values []Flag `json:"flags"`
}

func FlagsFromMask

func FlagsFromMask(mask int32, allFlags map[int32]string) Flags

type Included

type Included struct {
	// contains filtered or unexported fields
}

Included - an array of Resource objects that are related to the primary data and/or each other (“included resources”).

func (*Included) Add

func (c *Included) Add(includes ...Resource)

Add - adds new include into collection. If one already present - skips it

func (Included) MarshalJSON

func (c Included) MarshalJSON() ([]byte, error)

MarshalJSON - marshals include collection as array of json objects

func (*Included) MustBalance

func (c *Included) MustBalance(key Key) *Balance

MustBalance - returns Balance from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustCreateBalance

func (c *Included) MustCreateBalance(key Key) *CreateBalance

MustCreateBalance - returns CreateBalance from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustEvent

func (c *Included) MustEvent(key Key) *Event

MustEvent - returns Event from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustPointPrice

func (c *Included) MustPointPrice(key Key) *PointPrice

MustPointPrice - returns PointPrice from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustVerifyPassport

func (c *Included) MustVerifyPassport(key Key) *VerifyPassport

MustVerifyPassport - returns VerifyPassport from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustWithdraw

func (c *Included) MustWithdraw(key Key) *Withdraw

MustWithdraw - returns Withdraw from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustWithdrawal

func (c *Included) MustWithdrawal(key Key) *Withdrawal

MustWithdrawal - returns Withdrawal from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) UnmarshalJSON

func (c *Included) UnmarshalJSON(data []byte) error

UmarshalJSON - unmarshal array of json objects into include collection

type Key

type Key struct {
	ID   string       `json:"id"`
	Type ResourceType `json:"type"`
}

func NewKeyInt64

func NewKeyInt64(id int64, resourceType ResourceType) Key

func (Key) AsRelation

func (r Key) AsRelation() *Relation

func (*Key) GetKey

func (r *Key) GetKey() Key

func (Key) GetKeyP

func (r Key) GetKeyP() *Key
type Links struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Self  string `json:"self,omitempty"`
}

type PointPrice

type PointPrice struct {
	Key
	Attributes PointPriceAttributes `json:"attributes"`
}

type PointPriceAttributes

type PointPriceAttributes struct {
	// Amount of `urmo` tokens for one point
	Urmo int64 `json:"urmo"`
}

type PointPriceListResponse

type PointPriceListResponse struct {
	Data     []PointPrice    `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*PointPriceListResponse) GetMeta

func (r *PointPriceListResponse) GetMeta(out interface{}) error

func (*PointPriceListResponse) PutMeta

func (r *PointPriceListResponse) PutMeta(v interface{}) (err error)

type PointPriceResponse

type PointPriceResponse struct {
	Data     PointPrice `json:"data"`
	Included Included   `json:"included"`
}

type Relation

type Relation struct {
	Data  *Key   `json:"data,omitempty"`
	Links *Links `json:"links,omitempty"`
}

type RelationCollection

type RelationCollection struct {
	Data  []Key  `json:"data"`
	Links *Links `json:"links,omitempty"`
}

func (RelationCollection) MarshalJSON

func (r RelationCollection) MarshalJSON() ([]byte, error)

type Resource

type Resource interface {
	//GetKey - returns key of the Resource
	GetKey() Key
}

type ResourceType

type ResourceType string
const (
	BALANCE         ResourceType = "balance"
	CLAIM_EVENT     ResourceType = "claim_event"
	CREATE_BALANCE  ResourceType = "create_balance"
	UPDATE_BALANCE  ResourceType = "update_balance"
	EVENT           ResourceType = "event"
	POINT_PRICE     ResourceType = "point_price"
	VERIFY_PASSPORT ResourceType = "verify_passport"
	WITHDRAW        ResourceType = "withdraw"
	WITHDRAWAL      ResourceType = "withdrawal"
)

List of ResourceType

type VerifyPassport

type VerifyPassport struct {
	Key
	Attributes VerifyPassportAttributes `json:"attributes"`
}

type VerifyPassportAttributes

type VerifyPassportAttributes struct {
	// JSON encoded ZK passport verification proof.
	Proof json.RawMessage `json:"proof"`
}

type VerifyPassportListRequest

type VerifyPassportListRequest struct {
	Data     []VerifyPassport `json:"data"`
	Included Included         `json:"included"`
	Links    *Links           `json:"links"`
	Meta     json.RawMessage  `json:"meta,omitempty"`
}

func (*VerifyPassportListRequest) GetMeta

func (r *VerifyPassportListRequest) GetMeta(out interface{}) error

func (*VerifyPassportListRequest) PutMeta

func (r *VerifyPassportListRequest) PutMeta(v interface{}) (err error)

type VerifyPassportRequest

type VerifyPassportRequest struct {
	Data     VerifyPassport `json:"data"`
	Included Included       `json:"included"`
}

type Withdraw

type Withdraw struct {
	Key
	Attributes WithdrawAttributes `json:"attributes"`
}

type WithdrawAttributes

type WithdrawAttributes struct {
	// Rarimo address to withdraw to. Can be any valid address.
	Address string `json:"address"`
	// Amount of points to withdraw
	Amount int64 `json:"amount"`
	// JSON encoded ZK passport verification proof.
	Proof json.RawMessage `json:"proof"`
}

type WithdrawListRequest

type WithdrawListRequest struct {
	Data     []Withdraw      `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*WithdrawListRequest) GetMeta

func (r *WithdrawListRequest) GetMeta(out interface{}) error

func (*WithdrawListRequest) PutMeta

func (r *WithdrawListRequest) PutMeta(v interface{}) (err error)

type WithdrawRequest

type WithdrawRequest struct {
	Data     Withdraw `json:"data"`
	Included Included `json:"included"`
}

type Withdrawal

type Withdrawal struct {
	Key
	Attributes    WithdrawalAttributes     `json:"attributes"`
	Relationships *WithdrawalRelationships `json:"relationships,omitempty"`
}

type WithdrawalAttributes

type WithdrawalAttributes struct {
	// Rarimo address which points were withdrawn to. Can be any valid address.
	Address string `json:"address"`
	// Amount of points withdrawn
	Amount int64 `json:"amount"`
	// Unix timestamp of withdrawal creation
	CreatedAt int32 `json:"created_at"`
}

type WithdrawalListResponse

type WithdrawalListResponse struct {
	Data     []Withdrawal    `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*WithdrawalListResponse) GetMeta

func (r *WithdrawalListResponse) GetMeta(out interface{}) error

func (*WithdrawalListResponse) PutMeta

func (r *WithdrawalListResponse) PutMeta(v interface{}) (err error)

type WithdrawalRelationships

type WithdrawalRelationships struct {
	Balance Relation `json:"balance"`
}

type WithdrawalResponse

type WithdrawalResponse struct {
	Data     Withdrawal `json:"data"`
	Included Included   `json:"included"`
}

Jump to

Keyboard shortcuts

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