httptransport

package
v0.0.0-...-9d843bf Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalLoginResponse

func MarshalLoginResponse(responseData *gateway_s.LoginResponseIDO, w http.ResponseWriter)

func MarshalProfileResponse

func MarshalProfileResponse(responseData *user_s.User, w http.ResponseWriter)

func MarshalRefreshTokenResponse

func MarshalRefreshTokenResponse(accessToken string, accessTokenExpiryDate time.Time, refreshToken string, refreshTokenExpiryDate time.Time, u *user_s.User, w http.ResponseWriter)

func MarshalVerifyResponse

func MarshalVerifyResponse(responseData *gateway_s.VerifyResponseIDO, w http.ResponseWriter)

func UnmarshalProfileUpdateRequest

func UnmarshalProfileUpdateRequest(ctx context.Context, r *http.Request) (*user_s.User, error)

func ValidateForgotPasswordRequest

func ValidateForgotPasswordRequest(dirtyData *ForgotPasswordRequestIDO) error

func ValidateLoginRequest

func ValidateLoginRequest(dirtyData *LoginRequestIDO) error

func ValidatePasswordResetRequest

func ValidatePasswordResetRequest(dirtyData *PasswordResetRequestIDO) error

func ValidateProfileUpdateRequest

func ValidateProfileUpdateRequest(dirtyData *ProfileUpdateRequestIDO) error

func ValidateRefreshTokenRequest

func ValidateRefreshTokenRequest(dirtyData *RefreshTokenRequestIDO) (bool, string)

func ValidateVerifyRequest

func ValidateVerifyRequest(dirtyData *VerifyRequestIDO) error

Types

type ForgotPasswordRequestIDO

type ForgotPasswordRequestIDO struct {
	Email string `json:"email"`
}

func UnmarshalForgotPasswordRequest

func UnmarshalForgotPasswordRequest(ctx context.Context, r *http.Request) (*ForgotPasswordRequestIDO, error)

type GreetingRequest

type GreetingRequest struct {
	Name string `json:"name"`
}

type GreetingResponse

type GreetingResponse struct {
	Message string `json:"message"`
}

type Handler

type Handler struct {
	Logger     *slog.Logger
	Controller gateway_c.GatewayController
}

Handler Creates http request handler

func NewHandler

func NewHandler(loggerp *slog.Logger, c gateway_c.GatewayController) *Handler

NewHandler Constructor

func (*Handler) DisableOTP

func (h *Handler) DisableOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) ForgotPassword

func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request)

func (*Handler) GenerateOTP

func (h *Handler) GenerateOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) GenerateOTPAndQRCodePNGImage

func (h *Handler) GenerateOTPAndQRCodePNGImage(w http.ResponseWriter, r *http.Request)

func (*Handler) Greet

func (h *Handler) Greet(w http.ResponseWriter, r *http.Request)

PostGreet returns the greeting

func (*Handler) HealthCheck

func (h *Handler) HealthCheck(w http.ResponseWriter, r *http.Request)

Returns the status of the system.

func (*Handler) Login

func (h *Handler) Login(w http.ResponseWriter, r *http.Request)

func (*Handler) Logout

func (h *Handler) Logout(w http.ResponseWriter, r *http.Request)

func (*Handler) PasswordReset

func (h *Handler) PasswordReset(w http.ResponseWriter, r *http.Request)

func (*Handler) Profile

func (h *Handler) Profile(w http.ResponseWriter, r *http.Request)

func (*Handler) ProfileChangePassword

func (h *Handler) ProfileChangePassword(w http.ResponseWriter, r *http.Request)

func (*Handler) ProfileUpdate

func (h *Handler) ProfileUpdate(w http.ResponseWriter, r *http.Request)

func (*Handler) RecoveryOTP

func (h *Handler) RecoveryOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) RefreshToken

func (h *Handler) RefreshToken(w http.ResponseWriter, r *http.Request)

func (*Handler) RegisterBusiness

func (h *Handler) RegisterBusiness(w http.ResponseWriter, r *http.Request)

func (*Handler) RegisterCustomer

func (h *Handler) RegisterCustomer(w http.ResponseWriter, r *http.Request)

func (*Handler) ValidateOTP

func (h *Handler) ValidateOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) Verify

func (h *Handler) Verify(w http.ResponseWriter, r *http.Request)

func (*Handler) VerifyOTP

func (h *Handler) VerifyOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) Version

func (h *Handler) Version(w http.ResponseWriter, r *http.Request)

Version returns the server version. Developers note, to see result you can run in your terminal `curl http://localhost:8000/api/v1/version`.

type LoginRequestIDO

type LoginRequestIDO struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type PasswordResetRequestIDO

type PasswordResetRequestIDO struct {
	VerificationCode string `json:"verification_code"`
	Password         string `json:"password"`
	PasswordRepeated string `json:"password_repeated"`
}

func UnmarshalPasswordResetRequest

func UnmarshalPasswordResetRequest(ctx context.Context, r *http.Request) (*PasswordResetRequestIDO, error)

type ProfileUpdateRequestIDO

type ProfileUpdateRequestIDO struct {
	FirstName                 string `bson:"first_name" json:"first_name"`
	LastName                  string `bson:"last_name" json:"last_name"`
	Email                     string `json:"email"`
	Phone                     string `bson:"phone,omitempty" json:"phone,omitempty"`
	Country                   string `bson:"country,omitempty" json:"country,omitempty"`
	Region                    string `bson:"region,omitempty" json:"region,omitempty"`
	City                      string `bson:"city,omitempty" json:"city,omitempty"`
	PostalCode                string `bson:"postal_code,omitempty" json:"postal_code,omitempty"`
	AddressLine1              string `bson:"address_line1,omitempty" json:"address_line1,omitempty"`
	AddressLine2              string `bson:"address_line2,omitempty" json:"address_line2,omitempty"`
	HowDidYouHearAboutUs      int8   `bson:"how_did_you_hear_about_us,omitempty" json:"how_did_you_hear_about_us,omitempty"`
	HowDidYouHearAboutUsOther string `bson:"how_did_you_hear_about_us_other,omitempty" json:"how_did_you_hear_about_us_other,omitempty"`
	AgreePromotionsEmail      bool   `bson:"agree_promotions_email,omitempty" json:"agree_promotions_email,omitempty"`
	HasShippingAddress        bool   `bson:"has_shipping_address" json:"has_shipping_address,omitempty"`
	ShippingName              string `bson:"shipping_name" json:"shipping_name,omitempty"`
	ShippingPhone             string `bson:"shipping_phone" json:"shipping_phone,omitempty"`
	ShippingCountry           string `bson:"shipping_country" json:"shipping_country,omitempty"`
	ShippingRegion            string `bson:"shipping_region" json:"shipping_region,omitempty"`
	ShippingCity              string `bson:"shipping_city" json:"shipping_city,omitempty"`
	ShippingPostalCode        string `bson:"shipping_postal_code" json:"shipping_postal_code,omitempty"`
	ShippingAddressLine1      string `bson:"shipping_address_line1" json:"shipping_address_line1,omitempty"`
	ShippingAddressLine2      string `bson:"shipping_address_line2" json:"shipping_address_line2,omitempty"`
}

type RefreshTokenRequestIDO

type RefreshTokenRequestIDO struct {
	Value string `json:"value"`
}

func UnmarshalRefreshTokenRequest

func UnmarshalRefreshTokenRequest(ctx context.Context, r *http.Request) (*RefreshTokenRequestIDO, error, int)

type RefreshTokenResponseIDO

type RefreshTokenResponseIDO struct {
	Email                  string    `json:"username"`
	AccessToken            string    `json:"access_token"`
	AccessTokenExpiryDate  time.Time `json:"access_token_expiry_date"`
	RefreshToken           string    `json:"refresh_token"`
	RefreshTokenExpiryDate time.Time `json:"refresh_token_expiry_date"`
}

RefreshTokenResponseIDO struct used to represent the system's response when the `login` POST request was a success.

type VerifyRequestIDO

type VerifyRequestIDO struct {
	Code string `json:"code"`
}

func UnmarshalVerifyRequest

func UnmarshalVerifyRequest(ctx context.Context, r *http.Request) (*VerifyRequestIDO, error)