Refactor Query to be Dynamic for each chains
uwezukwechibuzor opened this issue · 1 comments
uwezukwechibuzor commented
Refactor Query to be Dynamic for each chains
uwezukwechibuzor commented
func FetchOrders(address string) (*fixstruct.OrderResponse, error) {
// Read API_URL from .env file
ordersURL := os.Getenv("ORDERS_URL")
if ordersURL == "" {
return nil, errors.New("ORDERS_URL not found in .env file")
}
url := fmt.Sprintf("%s/%s", ordersURL, address)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var orders fixstruct.OrderResponse
err = json.Unmarshal(body, &orders)
if err != nil {
return nil, err
}
return &orders, nil
}
func FetchAllOrders() (*fixstruct.OrderResponse, error) {
// Read API_URL from .env file
ordersURL := os.Getenv("ORDERS_URL")
if ordersURL == "" {
return nil, errors.New("ORDERS_URL not found in .env file")
}
resp, err := http.Get(ordersURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var orders fixstruct.OrderResponse
err = json.Unmarshal(body, &orders)
if err != nil {
return nil, err
}
return &orders, nil
}
This and other FIX message types are to be refactored to include its chainID