go-faker/types/types.go

120 lines
4 KiB
Go
Raw Permalink Normal View History

package types
import "time"
type GenerateRequest struct {
Seed string `json:"seed"`
Count int `json:"count"`
Type DataType `json:"type"`
Fields []string `json:"fields"`
}
type GenerateResponse struct {
Data []map[string]any `json:"data"`
Meta ResponseMeta `json:"meta"`
Format string `json:"format"`
}
type ResponseMeta struct {
Count int `json:"count"`
Seed string `json:"seed"`
GeneratedAt string `json:"generated_at"`
}
type DataType string
const (
TypePerson DataType = "person"
TypeAddress DataType = "address"
TypeProduct DataType = "product"
TypeAnalytics DataType = "analytics"
)
var ValidFields = map[DataType][]string{
TypePerson: {
"first_name", "last_name", "full_name",
"phone", "email", "gender", "age",
"language", "city", "region", "nationality",
"occupation", "company", "blood_type",
"date_of_birth", "username", "password",
},
TypeAddress: {
"street", "city", "region", "sub_city",
"postal_code", "zone", "woreda", "kebele",
"house_number", "latitude", "longitude",
},
TypeProduct: {
"name", "category", "price", "sku",
"brand", "description", "weight", "stock",
"expiry_date", "manufactured_date",
},
TypeAnalytics: {
"user_id", "event", "timestamp", "amount",
"currency", "session_id", "page_url",
"ip_address", "device_type", "browser",
"os", "country", "referrer",
},
}
type Person struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
FullName string `json:"full_name,omitempty"`
Phone string `json:"phone,omitempty"`
Email string `json:"email,omitempty"`
Gender string `json:"gender,omitempty"`
Age int `json:"age,omitempty"`
Language string `json:"language,omitempty"`
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
Nationality string `json:"nationality,omitempty"`
Occupation string `json:"occupation,omitempty"`
Company string `json:"company,omitempty"`
BloodType string `json:"blood_type,omitempty"`
DateOfBirth string `json:"date_of_birth,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
type Address struct {
Street string `json:"street,omitempty"`
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
SubCity string `json:"sub_city,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
Zone string `json:"zone,omitempty"`
Woreda string `json:"woreda,omitempty"`
Kebele string `json:"kebele,omitempty"`
HouseNumber string `json:"house_number,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
}
type Product struct {
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
Price float64 `json:"price,omitempty"`
SKU string `json:"sku,omitempty"`
Brand string `json:"brand,omitempty"`
Description string `json:"description,omitempty"`
Weight float64 `json:"weight,omitempty"`
Stock int `json:"stock,omitempty"`
ExpiryDate string `json:"expiry_date,omitempty"`
ManufacturedDate string `json:"manufactured_date,omitempty"`
}
type Analytics struct {
UserID string `json:"user_id,omitempty"`
Event string `json:"event,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Amount float64 `json:"amount,omitempty"`
Currency string `json:"currency,omitempty"`
SessionID string `json:"session_id,omitempty"`
PageURL string `json:"page_url,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
DeviceType string `json:"device_type,omitempty"`
Browser string `json:"browser,omitempty"`
OS string `json:"os,omitempty"`
Country string `json:"country,omitempty"`
Referrer string `json:"referrer,omitempty"`
}