bpiek/api/api.go
Pavel Sinitsin 05b8245f11
Refactor category variables and client authentication.
Renamed category variables to use underscores for better clarity and consistency. Updated client authentication method to accept username and password directly instead of using a Credentials struct.
2024-09-08 19:04:06 +03:00

32 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package api
import (
"gitea.24example.ru/spavelit/bpiek/client"
"gitea.24example.ru/spavelit/bpiek/model"
)
type (
Api struct {
Client *client.Client
}
Credentials struct {
Username string
Password string
}
Method interface {
GetParentCategories() ([]model.Category, error) // Возвращает массив категорий каталога 1-ого уровня.
GetCategories() ([]model.Category, error) // Возвращает массив с категориями
GetTreeCategories() ([]model.TreeCategories, error) // Возвращает дерево категорий
GetProducts() ([]model.Product, error) // Возвращает массив с продукцией
GetProductByArticle(article string) (model.Product, error) // Возвращает товар по артикул
GetRemainsAndPlanresidues() ([]model.ShortProduct, error) // Возвращает массив, в котором содержатся актуальные цены и остатки товаров.
}
)
func NewApi(credentials Credentials) Method {
return &Api{
Client: client.NewClient(credentials.Username, credentials.Password),
}
}