/
market.go
136 lines (121 loc) · 4.92 KB
/
market.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package object // import "github.com/SevereCloud/vksdk/object"
import (
"fmt"
)
// Information whether the MarketMarketItem is available.
const (
MarketItemAvailable = iota
MarketItemRemoved
MarketItemUnavailable
)
// MarketCurrency struct.
type MarketCurrency struct {
ID int `json:"id"` // Currency ID
Name string `json:"name"` // Currency sign
}
// MarketMarketAlbum struct.
type MarketMarketAlbum struct {
Count int `json:"count"` // Items number
ID int `json:"id"` // Market album ID
OwnerID int `json:"owner_id"` // Market album owner's ID
Photo PhotosPhoto `json:"photo"`
Title string `json:"title"` // Market album title
UpdatedTime int `json:"updated_time"` // Date when album has been updated last time in Unixtime
}
// ToAttachment return attachment format.
func (marketAlbum MarketMarketAlbum) ToAttachment() string {
return fmt.Sprintf("market_album%d_%d", marketAlbum.OwnerID, marketAlbum.ID)
}
// MarketMarketCategory struct.
type MarketMarketCategory struct {
ID int `json:"id"` // Category ID
Name string `json:"name"` // Category name
Section MarketSection `json:"section"`
}
// MarketMarketItem struct.
type MarketMarketItem struct {
AccessKey string `json:"access_key"` // Access key for the market item
Availability int `json:"availability"` // Information whether the item is available
Category MarketMarketCategory `json:"category"`
Date int `json:"date"` // Date when the item has been created in Unixtime
Description string `json:"description"` // Item description
ID int `json:"id"` // Item ID
OwnerID int `json:"owner_id"` // Item owner's ID
Price MarketPrice `json:"price"`
ThumbPhoto string `json:"thumb_photo"` // URL of the preview image
Title string `json:"title"` // Item title
CanComment BaseBoolInt `json:"can_comment"`
CanRepost BaseBoolInt `json:"can_repost"`
IsFavorite BaseBoolInt `json:"is_favorite"`
AlbumsIDs []int `json:"albums_ids"`
Photos []PhotosPhoto `json:"photos"`
Likes BaseLikesInfo `json:"likes"`
Reposts BaseRepostsInfo `json:"reposts"`
ViewsCount int `json:"views_count"`
URL string `json:"url"` // URL to item
ButtonTitle string `json:"button_title"`
ExternalID string `json:"external_id"`
}
// ToAttachment return attachment format.
func (market MarketMarketItem) ToAttachment() string {
return fmt.Sprintf("market%d_%d", market.OwnerID, market.ID)
}
// MarketPrice struct.
type MarketPrice struct {
Amount string `json:"amount"` // Amount
Currency MarketCurrency `json:"currency"`
DiscountRate int `json:"discount_rate"`
OldAmount string `json:"old_amount"`
Text string `json:"text"` // Text
}
// MarketSection struct.
type MarketSection struct {
ID int `json:"id"` // Section ID
Name string `json:"name"` // Section name
}
// MarketOrderStatus order status.
type MarketOrderStatus int
// Possible values.
const (
MarketOrderNew MarketOrderStatus = iota
MarketOrderPending
MarketOrderProcessing
MarketOrderShipped
MarketOrderComplete
MarketOrderCanceled
MarketOrderRefund
)
// MarketOrder struct.
type MarketOrder struct {
ID int `json:"id"`
GroupID int `json:"group_id"`
UserID int `json:"user_id"`
Date int `json:"date"`
Status int `json:"status"` // TODO: v2 MarketOrderStatus
ItemsCount int `json:"items_count"`
TotalPrice MarketPrice `json:"total_price"`
DisplayOrderID string `json:"display_order_id"`
TrackNumber string `json:"track_number"`
TrackLink string `json:"track_link"`
Comment string `json:"comment"`
Address string `json:"address"`
PreviewOrderItems []MarketOrderItem `json:"preview_order_items"`
PriceDetails []MarketPriceDetail `json:"price_details"`
}
// MarketOrderItem struct.
type MarketOrderItem struct {
OwnerID int `json:"owner_id"`
ItemID int `json:"item_id"`
Price MarketPrice `json:"price"`
Quantity int `json:"quantity"`
Item MarketMarketItem `json:"item"`
Title string `json:"title"`
Photo PhotosPhoto `json:"photo"`
Variants []string `json:"variants"`
}
// MarketPriceDetail struct.
type MarketPriceDetail struct {
Title string `json:"title"`
Price MarketPrice `json:"price"`
IsAccent bool `json:"is_accent,omitempty"`
}