functional simple api

This commit is contained in:
2024-08-23 16:39:20 -05:00
parent f9354196dd
commit ae4f12c159
18 changed files with 234 additions and 216 deletions

View File

@@ -1,4 +1,4 @@
package model
package m
type KeypadSize struct {
AttrsPerKey int `json:"attrs_per_key"`

View File

@@ -1,4 +1,4 @@
package model
package m
type NKodePolicy struct {
MaxNkodeLen int `json:"max_nkode_len"`

View File

@@ -1,6 +1,8 @@
package model
package m
import "github.com/google/uuid"
import (
"github.com/google/uuid"
)
type SetNKodeResp struct {
UserInterface []int `json:"user_interface"`
@@ -12,52 +14,62 @@ type NewCustomerPost struct {
}
type GenerateSignupInterfacePost struct {
CustomerId uuid.UUID `json:"customer_id"`
CustomerId CustomerId `json:"customer_id"`
}
type SetNKodePost struct {
Username string `json:"username"`
CustomerId uuid.UUID `json:"customer_id"`
KeySelection []int `json:"key_selection"`
SessionId uuid.UUID `json:"session_id"`
Username Username `json:"username"`
CustomerId CustomerId `json:"customer_id"`
KeySelection KeySelection `json:"key_selection"`
SessionId SessionId `json:"session_id"`
}
type ConfirmNKodePost struct {
CustomerId uuid.UUID `json:"customer_id"`
KeySelection []int `json:"key_selection"`
SessionId uuid.UUID `json:"session_id"`
CustomerId CustomerId `json:"customer_id"`
KeySelection KeySelection `json:"key_selection"`
SessionId SessionId `json:"session_id"`
}
type GetLoginInterfacePost struct {
Username string `json:"username"`
CustomerId uuid.UUID `json:"customer_id"`
Username Username `json:"username"`
CustomerId CustomerId `json:"customer_id"`
}
type LoginPost struct {
CustomerId uuid.UUID `json:"customer_id"`
Username string `json:"username"`
KeySelection []int `json:"key_selection"`
CustomerId CustomerId `json:"customer_id"`
Username Username `json:"username"`
KeySelection KeySelection `json:"key_selection"`
}
type RenewAttributesPost struct {
CustomerId uuid.UUID `json:"customer_id"`
CustomerId CustomerId `json:"customer_id"`
}
type CreateNewCustomerResp struct {
CustomerId uuid.UUID `json:"customer_id"`
CustomerId CustomerId `json:"customer_id"`
}
type GenerateSignupInterfaceResp struct {
SessionId uuid.UUID `json:"session_id"`
UserInterface []int `json:"user_interface"`
SessionId SessionId `json:"session_id"`
UserInterface IdxInterface `json:"user_interface"`
}
type GetLoginInterfaceResp struct {
UserInterface []int `json:"user_interface"`
UserInterface IdxInterface `json:"user_interface"`
}
type KeySelection []int
type CustomerId uuid.UUID
type SessionId uuid.UUID
type Username string
type UserInterface []int
type IdxInterface []int
type NKodeAPIInterface interface {
CreateNewCustomer(KeypadSize, NKodePolicy) (*CustomerId, error)
GenerateSignupInterface(CustomerId) (*GenerateSignupInterfaceResp, error)
SetNKode(Username, CustomerId, SessionId, KeySelection) (IdxInterface, error)
ConfirmNKode(CustomerId, SessionId, KeySelection) error
GetLoginInterface(username Username, customerId CustomerId) (IdxInterface, error)
Login(customerId CustomerId, username Username, keySelection KeySelection) error
RenewAttributes(customerId CustomerId) error
}