added json keys to structs
This commit is contained in:
		| @@ -0,0 +1,26 @@ | ||||
| package backend | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| const endpoint = "https://diyhrt.market/api/listings" | ||||
|  | ||||
| func GetListings() []Listing { | ||||
| 	apiKey := os.Getenv("API_KEY") | ||||
| 	fmt.Println(apiKey) | ||||
|  | ||||
| 	// why put api key in url parameter | ||||
| 	req, err := http.NewRequest("GET", endpoint+"?api_token="+apiKey, nil) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		fmt.Print(err.Error()) | ||||
| 		return []Listing{} | ||||
| 	} | ||||
|  | ||||
| 	fmt.Println(req.Body.Read()) | ||||
|  | ||||
| 	return []Listing{} | ||||
| } | ||||
|   | ||||
| @@ -1,41 +1,41 @@ | ||||
| package backend | ||||
|  | ||||
| type ActiveIngredient struct { | ||||
| 	Name        string | ||||
| 	Ester       string | ||||
| 	DisplayName string | ||||
| 	Name        string `json:"name"` | ||||
| 	Ester       string `json:"ester"` | ||||
| 	DisplayName string `json:"display_name"` | ||||
| } | ||||
|  | ||||
| type Product struct { | ||||
| 	Id               int | ||||
| 	Name             string | ||||
| 	Image            string | ||||
| 	ActiveIngredient ActiveIngredient | ||||
| 	Id               int              `json:"id"` | ||||
| 	Name             string           `json:"name"` | ||||
| 	Image            string           `json:"image"` | ||||
| 	ActiveIngredient ActiveIngredient `json:"active_ingredient"` | ||||
| } | ||||
|  | ||||
| type Store struct { | ||||
| 	Id                 int | ||||
| 	Name               string | ||||
| 	Url                string | ||||
| 	Description        string | ||||
| 	ShipsFromCountry   string | ||||
| 	ShipsToCountry     string | ||||
| 	ServiceStatus      string | ||||
| 	ServiceStatusNotes string | ||||
| 	PaymentMethods     string | ||||
| 	CategoryName       string | ||||
| 	Id                 int    `json:"id"` | ||||
| 	Name               string `json:"name"` | ||||
| 	Url                string `json:"url"` | ||||
| 	Description        string `json:"description"` | ||||
| 	ShipsFromCountry   string `json:"ships_from_country"` | ||||
| 	ShipsToCountry     string `json:"ships_to_country"` | ||||
| 	ServiceStatus      string `json:"service_status"` | ||||
| 	ServiceStatusNotes string `json:"service_status_notes"` | ||||
| 	PaymentMethods     string `json:"payment_methods"` | ||||
| 	CategoryName       string `json:"category_name"` | ||||
| } | ||||
|  | ||||
| type Listing struct { | ||||
| 	Id             int | ||||
| 	ProductName    string | ||||
| 	StoreName      string | ||||
| 	Price          string | ||||
| 	PriceCurrency  string | ||||
| 	State          string | ||||
| 	InStock        bool | ||||
| 	Url            string | ||||
| 	PricingPerUnit string | ||||
| 	Product        Product | ||||
| 	Store          Store | ||||
| 	Id             int     `json:"id"` | ||||
| 	ProductName    string  `json:"product_name"` | ||||
| 	StoreName      string  `json:"store_name"` | ||||
| 	Price          string  `json:"price"` | ||||
| 	PriceCurrency  string  `json:"price_currency"` | ||||
| 	State          string  `json:"state"` | ||||
| 	InStock        bool    `json:"in_stock"` | ||||
| 	Url            string  `json:"url"` | ||||
| 	PricingPerUnit string  `json:"pricing_per_unit"` | ||||
| 	Product        Product `json:"product"` | ||||
| 	Store          Store   `json:"store"` | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user