service

package
v0.0.0-...-a7d487d Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Channel *amqp.Channel
View Source
var Queues map[string]func(amqp.Delivery) = map[string]func(amqp.Delivery){
	"new_order":              HandleNewOrder,
	"order_ready":            HandleOrderReady,
	"order_dropped":          HandleDriverDropOrder,
	"order_canceled":         HandleCanceledOrder,
	"order_pickuped":         HandleOrderPickuped,
	"reset_password":         HandleResetPassword,
	"order_preparing":        HandleOrderPreparing,
	"order_delivered":        HandleOrderDelivered,
	"driver_accepted_order":  HandleDriverAcceptOrder,
	"order_ready_assigment":  HandleOrderAssignment,
	"merchant_accpted_order": HandleAcceptOrder,
	"verification":           HandleVerification,
}
View Source
var (
	RedisClient *redis.Client
)

Functions

func AsignOrderToDriver

func AsignOrderToDriver(order Order, driver Driver)

func CreateDocument

func CreateDocument(index *meilisearch.Index, changeEvent bson.M)

func DeleteDocument

func DeleteDocument(index *meilisearch.Index, changeEvent bson.M)

func HandleAcceptOrder

func HandleAcceptOrder(data amqp.Delivery)

func HandleCanceledOrder

func HandleCanceledOrder(data amqp.Delivery)

func HandleDriverAcceptOrder

func HandleDriverAcceptOrder(data amqp.Delivery)

func HandleDriverDropOrder

func HandleDriverDropOrder(data amqp.Delivery)

func HandleNewOrder

func HandleNewOrder(data amqp.Delivery)

func HandleOrderAssignment

func HandleOrderAssignment(msg amqp.Delivery)

func HandleOrderDelivered

func HandleOrderDelivered(data amqp.Delivery)

func HandleOrderPickuped

func HandleOrderPickuped(data amqp.Delivery)

func HandleOrderPreparing

func HandleOrderPreparing(data amqp.Delivery)

func HandleOrderReady

func HandleOrderReady(data amqp.Delivery)

func HandleResetPassword

func HandleResetPassword(data amqp.Delivery)

func HandleVerification

func HandleVerification(data amqp.Delivery)

func InitAmqp

func InitAmqp()

func InitRedisClient

func InitRedisClient()

func InitSynchronizer

func InitSynchronizer()

func ProduceMessages

func ProduceMessages(queueName string, body []byte)

func PublishTopic

func PublishTopic(topic string, message interface{})

publish topic to redis channel

func RemoveObjectID

func RemoveObjectID(objectid string) string

func RemoveSensitiveFields

func RemoveSensitiveFields(data bson.M)

func ResetPassword

func ResetPassword(email string)

func SendEmailNotification

func SendEmailNotification(message string, subject string, rec ...string) error

func SendNotifictionSms

func SendNotifictionSms(message string, to string) error

func SendPushNotificationPlatforms

func SendPushNotificationPlatforms(token string, page string, title string, body string) error

func SendWebsocketNotification

func SendWebsocketNotification(event string, body interface{}, rec string, socket notify.Socket) error

func UpdateDocument

func UpdateDocument(index *meilisearch.Index, changeEvent bson.M)

Types

type Customer

type Customer struct {
	Id         string `json:"id,omitempty"`
	Email      string `json:"email"`
	FamilyName string `json:"family_name"`
	GivenName  string `json:"given_name"`
	Address    string `json:"address"`
	Metadata   struct {
		WebhookEndpoint string `json:"webhook_endpoint"`
	} `json:"metadata"`
	Profile string `json:"profile"`
	Device  Device `json:"device"`
	Phone   string `json:"phone"`
}

func GetInformationCustomer

func GetInformationCustomer(id string) Customer

type Device

type Device struct {
	DeviceId string ` json:"device_id"`
	Kind     string ` json:"kind"` // andriod ,ios
}

type Driver

type Driver struct {
	Id        string    `json:"id"`
	GivenName string    `json:"given_name"`
	Age       time.Time `json:"age"`
	Metadata  struct {
		WebhookEndpoint string `json:"webhook_endpoint"`
	} `json:"metadata"`
	Profile  string   `json:"profile"`
	Device   Device   `json:"device"`
	Location Location `json:"location"`
	Status   bool     `json:"status"`
	Vehicle  struct {
		Model   string  `json:"model"`
		Type    string  `json:"type" `
		Payload float64 `json:"payload"`
	} `json:"vehicle"`
	Phone string `json:"phone"`
}

func FindBestDriver

func FindBestDriver(order Order) []Driver

driver availability, proximity to the rider, vehicle type or weight or others, and driver ratings // traffic and estimated time of arrival => mongodb

func GetInformationDriver

func GetInformationDriver(id string) Driver

type Item

type Item struct {
	ItemExternalId string `json:"item_external_id"`
	Quantity       uint   `json:"quantity" `
	Price          uint   `json:"price" `
}

type Location

type Location struct {
	Point       string    `json:"point"`
	Coordinates []float64 `json:"coordinates"`
}

type Merchant

type Merchant struct {
	Id            string   `json:"id"`
	BusinessName  string   `json:"business_name"`
	BusinessPhone string   `json:"business_phone"`
	Location      Location `json:"location"`
	Address       string   `json:"address"`
	Metadata      struct {
		WebhookEndpoint string `json:"webhook_endpoint"`
	} `json:"metadata"`
	Device Device `json:"-" bson:"device"`
	Closed bool   `json:"closed"`
}

func GetInformationMer

func GetInformationMer(id string) Merchant

type Metadata

type Metadata struct {
	CreatedAt time.Time `json:"created_at"`
}

type Order

type Order struct {
	Id                    string    `json:"id,omitempty"`
	OrderValue            uint      `json:"order_value"  `
	Type                  string    `json:"type" `
	Items                 []Item    `json:"items"`
	DropOffPhone          string    `json:"dropoff_phone" `
	DropOffExteranlId     string    `json:"dropoff_external_id" `
	DropOffContactName    string    `json:"dropoff_contact_name" `
	DropOffTimeEstimated  int       `json:"dropoff_time_estimated" `
	DropOffAddress        string    `json:"dropoff_address" `
	DroOffLocation        Location  `json:"dropoff_location" `
	DropOffInstruction    string    `json:"dropoff_instructions" `
	Stage                 string    `json:"stage" `
	ActionIfUndeliverable string    `json:"action_if_undeliverable" `
	PickupAddress         string    `json:"pickup_address" `
	PickUpExternalId      string    `json:"pickup_external_id"`
	PickUpName            string    `json:"pickup_name"`
	PickUpPhone           string    `json:"pickup_phone"`
	PickUpLocation        Location  `json:"pickup_location"`
	PickupTime            time.Time `json:"pickup_time"`
	PickupEstimatedTime   int       `json:"pickup_estimated_time"`
	PickupReferenceTag    string    `json:"pickup_reference_tag" `
	DriverPhone           string    `json:"driver_phone"`
	DriverAllowedVehicles []string  `json:"driver_allowed_vehicles"  `
	DriverExternalId      string    `json:"driver_external_id"`
	Metadata              Metadata  `json:"metadata" `
	CancelReason          string    `json:"cancel_reason"`
	DisplayId             string    `json:"display_id"`
}

Jump to

Keyboard shortcuts

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