bpiek/api/api.go
Pavel Sinitsin cea1f96bb4
Refactor credential handling and improve parsing logic
Deleted client/credential.go and moved the Credentials struct to the api package for better modularity. Enhanced type safety in api by checking type assertions and added detailed comments in model structs.
2024-09-08 13:50:05 +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),
}
}