simaland

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type Category

type Category struct {
	ID                      int64   `json:"id,omitempty"`
	Sid                     int64   `json:"sid,omitempty"`
	Name                    string  `json:"name,omitempty"`
	Anchor                  string  `json:"anchor,omitempty"`
	Priority                int64   `json:"priority,omitempty"`
	PriorityHome            int64   `json:"priority_home,omitempty"`
	PriorityMenu            int64   `json:"priority_menu,omitempty"`
	IsHiddenInMenu          int64   `json:"is_hidden_in_menu,omitempty"`
	Path                    string  `json:"path,omitempty"`
	Level                   int64   `json:"level,omitempty"`
	Type                    int64   `json:"type,omitempty"`
	IsAdult                 int64   `json:"is_adult,omitempty"`
	HasLocoSlider           bool    `json:"has_loco_slider,omitempty"`
	HasDesign               bool    `json:"has_design,omitempty"`
	HasAsMainDesign         bool    `json:"has_as_main_design,omitempty"`
	IsItemDescriptionHidden bool    `json:"is_item_description_hidden,omitempty"`
	IsForMobileApp          bool    `json:"is_for_mobile_app,omitempty"`
	CategoryGroupID         *int64  `json:"category_group_id,omitempty"`
	HasDesktopDesign        bool    `json:"has_desktop_design,omitempty"`
	HasMobileDesign         bool    `json:"has_mobile_design,omitempty"`
	H1                      string  `json:"h1,omitempty"`
	IsComparable            bool    `json:"is_comparable,omitempty"`
	Photo                   *string `json:"photo,omitempty"`
	Icon                    string  `json:"icon,omitempty"`
	IsLeaf                  int64   `json:"is_leaf,omitempty"`
	FullSlug                string  `json:"full_slug,omitempty"`
	AsideCategoriesIDS      []int64 `json:"aside_categories_ids,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Options) (*Client, error)

func (*Client) CheckoutByProducts added in v0.1.2

func (c *Client) CheckoutByProducts(email, phone, name string, cart map[int64]int) (*Order, error)

CheckuotByProducts - создание заказа без использования корзины

func (*Client) Do

func (c *Client) Do(method, path string, body, data any, modificators ...RequestModificator) error

func (*Client) FindSettlement added in v0.1.2

func (c *Client) FindSettlement(name string) (ListResponse[Settlement], error)

FindSettlement - Поиск поселения для получения списка доставки

func (*Client) GetAuthor

func (c *Client) GetAuthor(id int) (*Author, error)

GetAuthor - Возвращает одного автора

func (*Client) GetItem

func (c *Client) GetItem(id int) (*Item, error)

GetItem - Получает товар из Simaland

func (*Client) GetOrder added in v0.1.3

func (c *Client) GetOrder(id int64) (*Order, error)

GetOrder - Получение заказа по его идентификатору

func (*Client) ListAuthors

func (c *Client) ListAuthors(page, count int) ([]Author, error)

Authors - Возвращает список авторов

page [int] - номер страницы count [int] - кол-во элементов (enum: )

func (*Client) ListCategory

func (c *Client) ListCategory(page int, count int) (*ListResponse[Category], error)

func (*Client) ListDeliveryAddress

func (c *Client) ListDeliveryAddress(settlement int64, page, count int) (ListResponse[DeliveryPoint], error)

func (*Client) ListItems

func (c *Client) ListItems(page int, count int, category int) (*ListResponse[Item], error)

ListItems - Производит листинг товаров

type DeliveryPoint added in v0.1.2

type DeliveryPoint struct {
	ID           int64  `json:"id"`
	SettlementID int64  `json:"settlement_id"`
	Address      string `json:"address"`
}

type Error

type Error struct {
	Msg  string
	Data map[string]interface{}
}

func (*Error) Error

func (e *Error) Error() string

type Item

type Item struct {
	ID  int64 `json:"id,omitempty"`
	Sid int64 `json:"sid,omitempty"`

	Name       string `json:"name,omitempty"`
	CategoryID int64  `json:"category_id,omitempty"`

	Price           int64 `json:"price,omitempty"`
	PriceMax        int64 `json:"price_max,omitempty"`
	RetailPrice     int64 `json:"retail_price,omitempty"`
	DiscountPercent int64 `json:"discountPercent,omitempty"`

	Photos []struct {
		URLPart string `json:"url_part,omitempty"`
		Version int    `json:"version,omitempty"`
	} `json:"photos,omitempty"`

	Description string `json:"description,omitempty"`
}
type Link struct {
	Href string `json:"href,omitempty"`
}
type Links struct {
	Self Link `json:"self,omitempty"`
	Next Link `json:"next,omitempty"`
	Last Link `json:"last,omitempty"`
}

type ListResponse

type ListResponse[T any] struct {
	Items []T   `json:"items,omitempty"`
	Links Links `json:"_links,omitempty"`
	Meta  Meta  `json:"_meta,omitempty"`
}

type Logger

type Logger interface {
	Logf(format string, args ...any)
}

type Meta

type Meta struct {
	TotalCount  int64 `json:"totalCount,omitempty"`
	PageCount   int64 `json:"pageCount,omitempty"`
	CurrentPage int64 `json:"currentPage,omitempty"`
	PerPage     int64 `json:"perPage,omitempty"`
}

type Options

type Options func(*Client) (*Client, error)

func WithApiKey

func WithApiKey(key string) Options

WithAPIKey - Добавляет ключ API к HTTP запросу

func WithClient

func WithClient(cl *http.Client) Options

WithClient - Настраивает ваш http клиент для обработки запросов

func WithJWT

func WithJWT(login, password string) Options

WithJWT - Добавляет к запросу заголовок для авторизации по JWT токену

func WithLogger

func WithLogger(log Logger) Options

WithLogger - Добавляет логгер с клиенту

type Order added in v0.1.3

type Order struct {
	ID            int64       `json:"id"`
	UserID        int64       `json:"user_id"`
	ManagerID     int64       `json:"manager_id"`
	PaymentID     interface{} `json:"payment_id"`
	PaymentTypeID int64       `json:"payment_type_id"`

	Subtotal int64 `json:"subtotal"`
	Discount int64 `json:"discount"`
	Total    int64 `json:"total"`

	PaymentURL string `json:"payment_form,omitempty"`

	Comment                       string `json:"comment,omitempty"`
	ContactPerson                 string `json:"contact_person,omitempty"`
	IsUseDigitalSignature         bool   `json:"is_use_digital_signature,omitempty"`
	ManagerAction                 int64  `json:"manager_action,omitempty"`
	PersonType                    int64  `json:"person_type,omitempty"`
	IsTemperatureLimitsAgreed     bool   `json:"is_temperature_limits_agreed,omitempty"`
	IsOffice                      bool   `json:"is_office,omitempty"`
	HasItemWithByThePieceAddition bool   `json:"has_item_with_by_the_piece_addition,omitempty"`
	Email                         string `json:"email,omitempty"`
	CartCreatedAt                 string `json:"cart_created_at,omitempty"`
	ItemsCount                    int64  `json:"items_count,omitempty"`
	UnitCount                     int64  `json:"unit_count,omitempty"`
	GoogleCid                     string `json:"google_cid,omitempty"`
	AssemblyCost                  int64  `json:"assembly_cost,omitempty"`
	StatusID                      int64  `json:"status_id,omitempty"`
	NotificationTypeID            int64  `json:"notification_type_id,omitempty"`
	IsRemote                      bool   `json:"is_remote,omitempty"`
	IsSmallWholesale              bool   `json:"is_small_wholesale,omitempty"`
	ManagerComment                string `json:"manager_comment,omitempty"`
	IsReorderDenied               bool   `json:"is_reorder_denied,omitempty"`
	HasJewelry                    bool   `json:"has_jewelry,omitempty"`
	CreatedAt                     string `json:"created_at,omitempty"`
	UpdatedAt                     string `json:"updated_at,omitempty"`
	IsEnqueued                    bool   `json:"is_enqueued,omitempty"`
	DoneInfo                      string `json:"done_info,omitempty"`
}

type RequestModificator

type RequestModificator func(*http.Request)

func SetCount

func SetCount(count int) RequestModificator

SetCount устанавливает кол-во товаров на странице ENUM: 10, 20, 50, 100 defaultValue: 50

func SetHeader

func SetHeader(key, val string) RequestModificator

func SetPage

func SetPage(page int) RequestModificator

SetPage Устанавливает номер выводимой страницы

func SetQuery

func SetQuery(key, val string) RequestModificator

type Settlement added in v0.1.2

type Settlement struct {
	ID      int64  `json:"id"`
	Name    string `json:"name"`
	Region  string `json:"region"`
	Country string `json:"country"`
	Type    string `json:"type"`
	KladrID string `json:"kladr_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL