Pavel Sinitsin
cea1f96bb4
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.
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
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),
|
||
}
|
||
}
|