entity

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Scheme is entity scheme.
	Scheme = prefix

	// ErrMultiplePaymentMethodsSet is a sentinel error when multiple payment methods are set in a single payment detail.
	ErrMultiplePaymentMethodsSet = errors.Error("multiple payment methods are set")

	// ErrNoPaymentMethodSet is a sentinel error when no payment method is set in a single payment detail.
	ErrNoPaymentMethodSet = errors.Error("no payment method is set")

	// ErrEntityInvalidData sentinel error when data unmarshal is failed.
	ErrEntityInvalidData = errors.Error("invalid entity data")
)
View Source
const (
	// BootstrappedEntityService maps to the service for entities
	BootstrappedEntityService string = "BootstrappedEntityService"
)

Variables

This section is empty.

Functions

func CreateValidator

func CreateValidator(factory identity.Factory) documents.ValidatorGroup

CreateValidator returns a validator group that should be run before creating the entity and persisting it to DB

func UpdateValidator

func UpdateValidator(factory identity.Factory, anchorSrv anchors.Service) documents.ValidatorGroup

UpdateValidator returns a validator group that should be run before updating the entity

Types

type Address added in v1.0.0

type Address struct {
	IsMain        bool   `json:"is_main"`
	IsRemitTo     bool   `json:"is_remit_to"`
	IsShipTo      bool   `json:"is_ship_to"`
	IsPayTo       bool   `json:"is_pay_to"`
	Label         string `json:"label"`
	Zip           string `json:"zip"`
	State         string `json:"state"`
	Country       string `json:"country"`
	AddressLine1  string `json:"address_line_1"`
	AddressLine2  string `json:"address_line_2"`
	ContactPerson string `json:"contact_person"`
}

Address holds the address details of the entity.

type BankPaymentMethod added in v1.0.0

type BankPaymentMethod struct {
	Identifier        byteutils.HexBytes `json:"identifier" swaggertype:"primitive,string"`
	Address           Address            `json:"address"`
	HolderName        string             `json:"holder_name"`
	BankKey           string             `json:"bank_key"`
	BankAccountNumber string             `json:"bank_account_number"`
	SupportedCurrency string             `json:"supported_currency"`
}

BankPaymentMethod holds the bank details of the entity.

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap sets the required storage and registers

type Contact added in v1.0.0

type Contact struct {
	Name  string `json:"name"`
	Title string `json:"title"`
	Email string `json:"email"`
	Phone string `json:"phone"`
	Fax   string `json:"fax"`
}

Contact holds the entity contact details.

type CryptoPaymentMethod added in v1.0.0

type CryptoPaymentMethod struct {
	Identifier        byteutils.HexBytes `json:"identifier" swaggertype:"primitive,string"`
	To                string             `json:"to"`
	ChainURI          string             `json:"chain_uri"`
	SupportedCurrency string             `json:"supported_currency"`
}

CryptoPaymentMethod holds the crypto details of the entity.

type Data added in v1.0.0

type Data struct {
	Identity       *identity.DID   `json:"identity" swaggertype:"primitive,string"`
	LegalName      string          `json:"legal_name"`
	Addresses      []Address       `json:"addresses"`
	PaymentDetails []PaymentDetail `json:"payment_details"`
	Contacts       []Contact       `json:"contacts"`
}

Data represents the entity data.

type Entity

type Entity struct {
	*documents.CoreDocument

	Data Data
}

Entity implements the documents.Model keeps track of entity related fields and state

func (*Entity) AddAttributes added in v1.0.0

func (e *Entity) AddAttributes(ca documents.CollaboratorsAccess, prepareNewVersion bool, attrs ...documents.Attribute) error

AddAttributes adds attributes to the Entity model.

func (*Entity) AddNFT

func (e *Entity) AddNFT(grantReadAccess bool, registry common.Address, tokenID []byte) error

AddNFT adds NFT to the Entity.

func (*Entity) CalculateDocumentRoot

func (e *Entity) CalculateDocumentRoot() ([]byte, error)

CalculateDocumentRoot calculates the document root

func (*Entity) CalculateSigningRoot

func (e *Entity) CalculateSigningRoot() ([]byte, error)

CalculateSigningRoot calculates the signing root of the document.

func (*Entity) CollaboratorCanUpdate

func (e *Entity) CollaboratorCanUpdate(updated documents.Model, collaborator identity.DID) error

CollaboratorCanUpdate checks if the collaborator can update the document.

func (*Entity) CreateNFTProofs

func (e *Entity) CreateNFTProofs(
	account identity.DID,
	registry common.Address,
	tokenID []byte,
	nftUniqueProof, readAccessProof bool) (prf *documents.DocumentProof, err error)

CreateNFTProofs creates proofs specific to NFT minting.

func (*Entity) CreateProofs

func (e *Entity) CreateProofs(fields []string) (prf *documents.DocumentProof, err error)

CreateProofs generates proofs for given fields.

func (*Entity) DeleteAttribute added in v1.0.0

func (e *Entity) DeleteAttribute(key documents.AttrKey, prepareNewVersion bool) error

DeleteAttribute deletes the attribute from the model.

func (*Entity) DeriveFromClonePayload added in v1.2.0

func (e *Entity) DeriveFromClonePayload(_ context.Context, m documents.Model) error

DeriveFromClonePayload unpacks the entity data from the Payload This method clones the transition rules and roles from a template document.

func (*Entity) DeriveFromCreatePayload added in v1.0.0

func (e *Entity) DeriveFromCreatePayload(_ context.Context, payload documents.CreatePayload) error

DeriveFromCreatePayload unpacks the entity data from the Payload.

func (*Entity) DeriveFromUpdatePayload added in v1.0.0

func (e *Entity) DeriveFromUpdatePayload(_ context.Context, payload documents.UpdatePayload) (documents.Model, error)

DeriveFromUpdatePayload unpacks the update payload and prepares a new version.

func (*Entity) DocumentType

func (*Entity) DocumentType() string

DocumentType returns the entity document type.

func (*Entity) FromJSON

func (e *Entity) FromJSON(jsonData []byte) error

FromJSON unmarshals the json bytes into Entity

func (*Entity) GetData added in v1.0.0

func (e *Entity) GetData() interface{}

GetData returns entity data

func (*Entity) JSON

func (e *Entity) JSON() ([]byte, error)

JSON marshals Entity into a json bytes

func (*Entity) PackCoreDocument

func (e *Entity) PackCoreDocument() (cd coredocumentpb.CoreDocument, err error)

PackCoreDocument packs the Entity into a CoreDocument.

func (*Entity) Patch added in v1.0.0

func (e *Entity) Patch(payload documents.UpdatePayload) error

Patch merges payload data into model

func (*Entity) Scheme added in v1.0.0

func (e *Entity) Scheme() string

Scheme returns the entity scheme.

func (*Entity) Type

func (e *Entity) Type() reflect.Type

Type gives the Entity type

func (*Entity) UnpackCoreDocument

func (e *Entity) UnpackCoreDocument(cd coredocumentpb.CoreDocument) error

UnpackCoreDocument unpacks the core document into Entity.

type OtherPaymentMethod added in v1.0.0

type OtherPaymentMethod struct {
	Identifier        byteutils.HexBytes `json:"identifier" swaggertype:"primitive,string"`
	Type              string             `json:"type"`
	PayTo             string             `json:"pay_to"`
	SupportedCurrency string             `json:"supported_currency"`
}

OtherPaymentMethod represents any other payment methods entity accepts.

type PaymentDetail added in v1.0.0

type PaymentDetail struct {
	Predefined          bool                 `json:"predefined"`
	BankPaymentMethod   *BankPaymentMethod   `json:"bank_payment_method,omitempty"`
	CryptoPaymentMethod *CryptoPaymentMethod `json:"crypto_payment_method,omitempty"`
	OtherPaymentMethod  *OtherPaymentMethod  `json:"other_payment_method,omitempty"`
}

PaymentDetail contains the payments receiving details of the entity. Note: only one of the payment methods has to be set for a given payment detail.

type Service

type Service interface {
	documents.Service

	// GetEntityByRelationship returns the entity model from database or requests from granter
	GetEntityByRelationship(ctx context.Context, relationshipIdentifier []byte) (documents.Model, error)
}

Service defines specific functions for entity

func DefaultService

func DefaultService(
	srv documents.Service,
	repo documents.Repository,
	queueSrv queue.TaskQueuer,
	jobManager jobs.Manager,
	factory identity.Factory,
	erService entityrelationship.Service,
	anchorSrv anchors.Service,
	processor documents.DocumentRequestProcessor,
	receivedEntityValidator func() documents.ValidatorGroup,
) Service

DefaultService returns the default implementation of the service.

Jump to

Keyboard shortcuts

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