Documentation
¶
Index ¶
- type AnalyticObject
- type Characteristic
- type Client
- type ExecutedModule
- type MeasureType
- type Nomenclature
- type NomenclatureItem
- type Order
- type OrderProduct
- type OrderStatus
- type OrderStatusType
- type Price
- type Product
- type ProductItem
- type ReceiptConfirm
- type ReceiptDiscount
- type ReceiptItems
- type ReceiptRefund
- type ReceiptResult
- type RefundItem
- type RefundItemResult
- type RefundResult
- type SmartBonus
- func (s *SmartBonus) ChangeOrderStatus(statusBody StatusBody) error
- func (s *SmartBonus) ConfigOrder(orderUrl, statusUrl, token string, ...) error
- func (s *SmartBonus) ConfirmReceipt(receipt ReceiptConfirm) (*ReceiptResult, error)
- func (s *SmartBonus) DeleteReceipts(receipts []string) error
- func (s *SmartBonus) DiscountReceipt(receipt ReceiptDiscount) (*ReceiptResult, error)
- func (s *SmartBonus) GetClient(userId string) (*Client, error)
- func (s *SmartBonus) RefundReceipt(receipt ReceiptRefund) (*RefundResult, error)
- func (s *SmartBonus) SyncNomenclatures(nomes []Product) error
- func (s *SmartBonus) SyncNomenclaturesV2(nomes []Nomenclature) error
- func (s *SmartBonus) SyncReceipts(receipts []ReceiptConfirm) error
- func (s *SmartBonus) SyncTags(tags []Tag) error
- type StatusBody
- type Store
- type Tag
- type TextLang
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalyticObject ¶
type AnalyticObject struct {
ExecutedModules []ExecutedModule `json:"executed_modules"`
}
List of executed modules
type Characteristic ¶
type Client ¶
type Client struct {
Phone string `json:"phone"` // phone number of client (unique)
Balance float64 `json:"balance"` // amount of bonuses in smartbonus account
Name string `json:"name"` // client name (optional)
}
Client instance is smartbonus app user
type ExecutedModule ¶
type ExecutedModule struct {
Id string `json:"id"` // identifier of smartbonus module
Type string `json:"type"` // type of object: subscriber_module|discount_module|coupon_module
Accrued float64 `json:"accrued_bonus"` // amount of accrued bonuses
Immediate float64 `json:"immediate_bonus"` // amount of immediate discount
Withdrawn float64 `json:"withdrawn_bonus"` // amount of withdrawn bonuses
ModuleType string `json:"module_type"` // type of smartbonus module
Name string `json:"name"` // title of module
}
Smartbonus modules that accrued/withdrawn bonuses or added discount
type MeasureType ¶
type MeasureType string
const ( PIECE MeasureType = "piece" KILOGRAM MeasureType = "kilogram" GRAM MeasureType = "gram" )
type Nomenclature ¶
type Nomenclature struct {
Id string `json:"id"` // unique identifier of product in your db
Name string `json:"name"` // title of product
Description string `json:"description,omitempty"` // description of product (optional)
Image string `json:"photo_url,omitempty"` // image of product, if you have more than one image join them by comma (optional)
IsDeleted bool `json:"is_deleted,omitempty"` // send true if you deleted that product (optional)
CategoryId string `json:"category,omitempty"` // unique identifier of category in your db (optional)
Barcode string `json:"barcode,omitempty"` // barcode of your product (optional)
Price float64 `json:"price,omitempty"` // price of your product (optional)
IsCategory bool `json:"is_category,omitempty"` // send true if current instance is category or false if it's product (optional)
Tags []string `json:"tags,omitempty"` // list of tag identifiers (optional)
CanBuy bool `json:"can_buy,omitempty"` // send true if this product can be buyed in smartbonus app (optional)
IsHidden *bool `json:"is_hidden,omitempty"` // send false if you want to show this product in smartbonus app catalog for clients (optional)
IsWeight bool `json:"is_weight"` // send true if nomenclature item is weight product.
Multiplier float64 `json:"multiplier"` // send 0.01 price at 0.1 kg & 0.001 at 1 kg
Quantity float64 `json:"quantity"` // product quantity
OldPrice float64 `json:"old_price"` // previous price that identify discount of product.
Priority int64 `json:"priority"` // priority in apps
Articul string `json:"articul"` // articul of product
}
Nomenclature instance has to be sync to smartbonus after it created, changed or deleted. If you cannot trigger nomenclature events, send it by some interval: once a day for example.
type NomenclatureItem ¶
type NomenclatureItem struct {
Id string `json:"nomenclature_id"` // your product identifier
Quantity float64 `json:"amount"` // quantity or product
Price float64 `json:"unit_price"` // price of product
MasterID string `json:"master_id"`
PosterID string `json:"poster_id"` // the nomenlautre is related to the store, not to the customer
}
type Order ¶
type Order struct {
Store // your StoreId token that configured
Id string `json:"remote_id"` // unique identifier of order in smartbonus
Code string `json:"code"` // number of order for client
UserId string `json:"user_id"` // client identifier that has to be used to sync receipt
Phone string `json:"phone"` // phone number of client
UserName string `json:"user_name"` // name of client
Amount float64 `json:"amount"` // amount for pay
Currency string `json:"currency"` // ISO 4217: UAH, USD, EUR
Date int64 `json:"date_unix"` // date of order
IsPaid bool `json:"is_paid"` // order paid online by client
ProductsAmount float64 `json:"products_amount"` // amount of products
DeliveryCost float64 `json:"delivery_cost"` // cost of delivery
Discount float64 `json:"discount"` // amount of discount
Products []OrderProduct `json:"products"`
Statuses []OrderStatus `json:"statuses"`
Comment string `json:"comment"` // client comment
DeliveryType string `json:"delivery"` // type of delivery
DeliveryAddress string `json:"deliveryAddress"`
DeliveryTime string `json:"deliveryTime"`
}
Order instance - send new order that created in smartbonus to your api after webhook is configured:
type OrderProduct ¶
type OrderProduct struct {
Id string `json:"id"` // your nomenclature identifier
Price float64 `json:"amount"` // price of product
Quantity float64 `json:"quantity"` // quantity of product
}
OrderProduct instance - element of products in Order:
type OrderStatus ¶
type OrderStatus struct {
Date int64 `json:"date_unix"` // date of status creation
Status OrderStatusType `json:"status"`
}
OrderStatus instance - element of statuses in Order:
type OrderStatusType ¶
type OrderStatusType int
List of order statuses
const ( NEW OrderStatusType = iota PAYMENT_PENDING PAYMENT_CANCELED PROCESSING AWAITING_SHIPMENT AWAITING_PICKUP COMPLETED CANCELED REFUNDED AWAITING_WEB_PAYMENT WEB_PAYMENT_SUCCESSFUL AWAITING_FOR_COLLECT COLLECTING TRANSFERRED_FOR_DELIVERY DELIVERING CANCEL_REQUEST AWAITING_POST_PAYMENT )
func (OrderStatusType) Get ¶
func (s OrderStatusType) Get(status string) (OrderStatusType, error)
func (OrderStatusType) String ¶
func (a OrderStatusType) String() string
type Price ¶
type Price struct {
Value float64 `json:"value"`
StoreID string `json:"store_id,omitempty"`
OldPrice float64 `json:"old_price,omitempty"`
Measure MeasureType `json:"measure"`
Quantity float64 `json:"quantity,omitempty"`
}
type Product ¶
type Product struct {
ProductItem
Modifiers []ProductItem `json:"modifiers"`
}
type ProductItem ¶
type ProductItem struct {
ID string `json:"id"`
Titles TextLang `json:"titles"`
Descriptions TextLang `json:"descriptions"`
Images []string `json:"images"`
Categories []string `json:"categories"`
Priority int64 `json:"priority"`
Barcode string `json:"barcode"`
IsHidden bool `json:"is_hidden"`
CanBuy bool `json:"can_buy"`
Prices []Price `json:"prices"`
Characteristics []Characteristic `json:"characteristics"`
Brand string `json:"brand"`
}
type ReceiptConfirm ¶
type ReceiptConfirm struct {
Store
UserId string `json:"user_id"` // Phone or sanned key from smartbonus app
Date int64 `json:"date,omitempty"` // Date of receipt (optional)
Discount float64 `json:"discount"` // Amount of discount that received from DiscountReceipt method.
Items []NomenclatureItem `json:"list"` // List of products
Id string `json:"remote_id"` // Unique receipt identifier
Change float64 `json:"accrued,omitempty"` // Rest of money that will accrue to smartbonus account
Additional map[string]interface{} `json:"additional"`
}
Body for receipt confirmation
type ReceiptDiscount ¶
type ReceiptDiscount struct {
Store
UserId string `json:"user_id"` // Phone or sanned key from smartbonus app
Date int64 `json:"date,omitempty"` // Date of receipt (optional)
Withdrawn float64 `json:"withdrawn,omitempty"` // Amount of money that cashier want to withdraw from client account (optional)
Items []NomenclatureItem `json:"receipt"` // products of receipt
Additional map[string]interface{} `json:"additional"`
}
Body for receipt discount method
type ReceiptItems ¶
type ReceiptItems struct {
Id string `json:"id"` // your product identifier
Accrued float64 `json:"accrued"` // amount of accrued bonuses
Withdrawn float64 `json:"withdrawn"` // amount of withdrawn bonuses
Immediate float64 `json:"immediate"` // amount of immediate discount
Quantity float64 `json:"amount"` // quantity of product
Price float64 `json:"unit_price"` // price of product
}
Item of receipt response
type ReceiptRefund ¶
type ReceiptRefund struct {
Store
Id string `json:"refund_id"` // identifier of your refund receipt
ReceiptId string `json:"remote_id"` // identifier of your sell receipt
Items []RefundItem `json:"list"` // list of refund products
}
Receipt refund request body
type ReceiptResult ¶
type ReceiptResult struct {
Discount float64 `json:"discount"` // amount of discount: withdrawn + immediate
Info string `json:"info"` // description of modules
Accrued float64 `json:"user_add_bonus"` // amount of accrued bonuses
Withdrawn float64 `json:"withdrawn"` // amount of withdrawn bonuses
Immediate float64 `json:"immediate"` // amount of immediate discount
UserName string `json:"user_name"` // client name
Items []ReceiptItems `json:"nomenclatures"` // list of products
AnalyticObjects AnalyticObject `json:"analytics_object"` // details of smartbonus modules
}
Receipt response of discount and confirm methods
type RefundItem ¶
type RefundItem struct {
Id string `json:"nomenclature_id"` // your product identifier
Quantity float64 `json:"amount"` // quantity of product
}
Item of receipt refund request
type RefundItemResult ¶
type RefundItemResult struct {
Id string `json:"id"` // your product identifier
Immediate float64 `json:"immediate"` // amount of immediate discount
Withdrawn float64 `json:"withdrawn"` // amount of withdrawn bonuses
Accrued float64 `json:"accrued"` // amount of accrued bonuses
}
Item response of refund receipt request rest = price * quantity - withdrawn - immediate
type SmartBonus ¶
type SmartBonus struct {
Store
}
Object implement all features
func NewSmartBonus ¶
func NewSmartBonus(storeId, sbRoute, customerId string) *SmartBonus
Create new instance of SmartBonus object On testing set to env variable with name SB_ROUTE Ask smartbonus team for your sbRoute
func (*SmartBonus) ChangeOrderStatus ¶
func (s *SmartBonus) ChangeOrderStatus(statusBody StatusBody) error
func (*SmartBonus) ConfigOrder ¶
func (s *SmartBonus) ConfigOrder(orderUrl, statusUrl, token string, syncNomenclatureFull, syncNomenclatureByCustomer bool) error
func (*SmartBonus) ConfirmReceipt ¶
func (s *SmartBonus) ConfirmReceipt(receipt ReceiptConfirm) (*ReceiptResult, error)
func (*SmartBonus) DeleteReceipts ¶
func (s *SmartBonus) DeleteReceipts(receipts []string) error
func (*SmartBonus) DiscountReceipt ¶
func (s *SmartBonus) DiscountReceipt(receipt ReceiptDiscount) (*ReceiptResult, error)
func (*SmartBonus) RefundReceipt ¶
func (s *SmartBonus) RefundReceipt(receipt ReceiptRefund) (*RefundResult, error)
func (*SmartBonus) SyncNomenclatures ¶
func (s *SmartBonus) SyncNomenclatures(nomes []Product) error
func (*SmartBonus) SyncNomenclaturesV2 ¶
func (s *SmartBonus) SyncNomenclaturesV2(nomes []Nomenclature) error
func (*SmartBonus) SyncReceipts ¶
func (s *SmartBonus) SyncReceipts(receipts []ReceiptConfirm) error
func (*SmartBonus) SyncTags ¶
func (s *SmartBonus) SyncTags(tags []Tag) error
type StatusBody ¶
type StatusBody struct {
Store
OrderId string `json:"order_id"` // identifier of order in smartbonus
Status OrderStatusType `json:"status"` // one of OrderStatuses
}
Body of status: