extension

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is used to construct an Extension object

func (*Builder) Build

func (builder *Builder) Build() (Extension, error)

Build constructs the Extension

func (*Builder) WithContent

func (builder *Builder) WithContent(content interface{}) *Builder

WithContent attaches data to the Extension. The content must implement JSON serialization

func (*Builder) WithType

func (builder *Builder) WithType(extensionType string) *Builder

WithType sets the extension type string

type Extension

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

Extension is a generic type of extension that can be used where a more specialised Extension type is not available

Example
content := "SOME CONTENT"
extType := "SOME_TYPE"
extension, err := (&Builder{}).WithContent(content).WithType(extType).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := extension.MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"type":"SOME_TYPE","content":"SOME CONTENT"}

func (Extension) MarshalJSON

func (extension Extension) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type LocationConstraintExtension

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

LocationConstraintExtension is an extension representing a geographic constraint

Example
extension, err := (&LocationConstraintExtensionBuilder{}).
	WithLatitude(51.511831).
	WithLongitude(-0.081446).
	WithRadius(0.001).
	WithMaxUncertainty(0.001).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := extension.MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"type":"LOCATION_CONSTRAINT","content":{"expected_device_location":{"latitude":51.511831,"longitude":-0.081446,"radius":0.001,"max_uncertainty_radius":0.001}}}

func (LocationConstraintExtension) MarshalJSON

func (extension LocationConstraintExtension) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type LocationConstraintExtensionBuilder

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

LocationConstraintExtensionBuilder is used to construct a LocationConstraintExtension

func (*LocationConstraintExtensionBuilder) Build

Build constructs a LocationConstraintExtension from the builder

func (*LocationConstraintExtensionBuilder) WithLatitude

WithLatitude sets the latitude of the location constraint

func (*LocationConstraintExtensionBuilder) WithLongitude

WithLongitude sets the longitude of the location constraint

func (*LocationConstraintExtensionBuilder) WithMaxUncertainty

func (builder *LocationConstraintExtensionBuilder) WithMaxUncertainty(uncertainty float64) *LocationConstraintExtensionBuilder

WithMaxUncertainty sets the max uncertainty allowed by the location constraint extension

func (*LocationConstraintExtensionBuilder) WithRadius

WithRadius sets the radius within which the location constraint will be satisfied

type ThirdPartyAttributeExtension

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

ThirdPartyAttributeExtension is an extension representing the issuance of a third party attribute

Example
attributeDefinition := attribute.NewAttributeDefinition("some_value")

datetime, err := time.Parse("2006-01-02T15:04:05.000Z", "2019-10-30T12:10:09.458Z")
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

extension, err := (&ThirdPartyAttributeExtensionBuilder{}).
	WithExpiryDate(&datetime).
	WithDefinition(attributeDefinition).
	Build()

if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := extension.MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"type":"THIRD_PARTY_ATTRIBUTE","content":{"expiry_date":"2019-10-30T12:10:09.458Z","definitions":[{"name":"some_value"}]}}

func (ThirdPartyAttributeExtension) MarshalJSON

func (extension ThirdPartyAttributeExtension) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type ThirdPartyAttributeExtensionBuilder

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

ThirdPartyAttributeExtensionBuilder is used to construct a ThirdPartyAttributeExtension

func (*ThirdPartyAttributeExtensionBuilder) Build

Build creates a ThirdPartyAttributeExtension using the supplied values

func (*ThirdPartyAttributeExtensionBuilder) WithDefinition

WithDefinition adds an attribute.AttributeDefinition to the list of definitions

func (*ThirdPartyAttributeExtensionBuilder) WithDefinitions

WithDefinitions sets the array of attribute.AttributeDefinition on the extension

func (*ThirdPartyAttributeExtensionBuilder) WithExpiryDate

WithExpiryDate sets the expiry date of the extension as a UTC timestamp

type TransactionalFlowExtension

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

TransactionalFlowExtension represents a type of extension in a dynamic share

Example
content := "SOME CONTENT"

extension, err := (&TransactionalFlowExtensionBuilder{}).
	WithContent(content).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := json.Marshal(extension)
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"type":"TRANSACTIONAL_FLOW","content":"SOME CONTENT"}

func (TransactionalFlowExtension) MarshalJSON

func (extension TransactionalFlowExtension) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type TransactionalFlowExtensionBuilder

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

TransactionalFlowExtensionBuilder constructs a TransactionalFlowExtension

func (*TransactionalFlowExtensionBuilder) Build

Build constructs a TransactionalFlowExtension

func (*TransactionalFlowExtensionBuilder) WithContent

func (builder *TransactionalFlowExtensionBuilder) WithContent(content interface{}) *TransactionalFlowExtensionBuilder

WithContent sets the payload data for a TransactionalFlowExtension. The content must implement JSON serialization

Jump to

Keyboard shortcuts

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