shared

package module
v0.0.0-...-086f00d Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	LpaStatusProcessing = LpaStatus("processing")
	LpaStatusRegistered = LpaStatus("registered")
)
View Source
const (
	AttorneyStatusActive      = AttorneyStatus("active")
	AttorneyStatusReplacement = AttorneyStatus("replacement")
	AttorneyStatusRemoved     = AttorneyStatus("removed")
)

Variables

This section is empty.

Functions

func GetEventHeader

func GetEventHeader(headerName string, event events.APIGatewayProxyRequest) []string

Types

type Address

type Address struct {
	Line1    string `json:"line1" dynamodbav:""`
	Line2    string `json:"line2" dynamodbav:""`
	Line3    string `json:"line3" dynamodbav:""`
	Town     string `json:"town" dynamodbav:""`
	Postcode string `json:"postcode" dynamodbav:""`
	Country  string `json:"country" dynamodbav:""`
}

type Attorney

type Attorney struct {
	Person
	Status AttorneyStatus `json:"status" dynamodbav:""`
}

type AttorneyStatus

type AttorneyStatus string

func (AttorneyStatus) IsValid

func (a AttorneyStatus) IsValid() bool

type Change

type Change struct {
	Key string      `json:"key"`
	Old interface{} `json:"old"`
	New interface{} `json:"new"`
}

type Client

type Client interface {
	Put(ctx context.Context, data Lpa) error
	Get(ctx context.Context, uid string) (Lpa, error)
}

type Date

type Date struct {
	time.Time
	IsMalformed bool
}

func (*Date) UnmarshalJSON

func (m *Date) UnmarshalJSON(data []byte) error

type Donor

type Donor struct {
	Person
	OtherNamesKnownBy string `json:"otherNamesKnownBy" dynamodbav:""`
}

type DynamoDBClient

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

func NewDynamoDB

func NewDynamoDB(tableName string) DynamoDBClient

func (DynamoDBClient) Get

func (c DynamoDBClient) Get(ctx context.Context, uid string) (Lpa, error)

func (DynamoDBClient) Put

func (c DynamoDBClient) Put(ctx context.Context, data Lpa) error

type FieldError

type FieldError struct {
	Source string `json:"source"`
	Detail string `json:"detail"`
}

type JWTVerifier

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

func NewJWTVerifier

func NewJWTVerifier() JWTVerifier

func (JWTVerifier) VerifyHeader

func (v JWTVerifier) VerifyHeader(event events.APIGatewayProxyRequest) bool

verify JWT from event header returns true if verified, false otherwise

func (JWTVerifier) VerifyToken

func (v JWTVerifier) VerifyToken(tokenStr string) error

tokenStr is the JWT token, minus any "Bearer: " prefix

type LogEvent

type LogEvent struct {
	ServiceName string    `json:"service_name"`
	Timestamp   time.Time `json:"timestamp"`
	Status      int       `json:"status"`
	Problem     Problem   `json:"problem"`
	ErrorString string    `json:"error_string,omitempty"`
}

type Lpa

type Lpa struct {
	LpaInit
	Uid              string    `json:"uid" dynamodbav:""`
	Status           LpaStatus `json:"status" dynamodbav:""`
	RegistrationDate time.Time `json:"registrationDate" dynamodbav:""`
	UpdatedAt        time.Time `json:"updatedAt" dynamodbav:""`
}

type LpaInit

type LpaInit struct {
	Donor     Donor      `json:"donor" dynamodbav:""`
	Attorneys []Attorney `json:"attorneys" dynamodbav:""`
}

type LpaStatus

type LpaStatus string

type Person

type Person struct {
	FirstNames  string  `json:"firstNames" dynamodbav:""`
	Surname     string  `json:"surname" dynamodbav:""`
	DateOfBirth Date    `json:"dateOfBirth" dynamodbav:""`
	Email       string  `json:"email" dynamodbav:""`
	Address     Address `json:"address" dynamodbav:""`
}

type Problem

type Problem struct {
	StatusCode int          `json:"-"`
	Code       string       `json:"code"`
	Detail     string       `json:"detail"`
	Errors     []FieldError `json:"errors,omitempty"`
}
var ProblemInternalServerError Problem = Problem{
	StatusCode: 500,
	Code:       "INTERNAL_SERVER_ERROR",
	Detail:     "Internal server error",
}
var ProblemInvalidRequest Problem = Problem{
	StatusCode: 400,
	Code:       "INVALID_REQUEST",
	Detail:     "Invalid request",
}
var ProblemUnauthorisedRequest Problem = Problem{
	StatusCode: 401,
	Code:       "UNAUTHORISED",
	Detail:     "Invalid JWT",
}

func (Problem) Respond

func (problem Problem) Respond() (events.APIGatewayProxyResponse, error)

type Update

type Update struct {
	Type    string   `json:"type"`
	Changes []Change `json:"changes"`
}

Jump to

Keyboard shortcuts

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