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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
package object // import "github.com/SevereCloud/vksdk/v2/object"
import (
"bytes"
"encoding/json"
"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
Title string `json:"title"` // Currency Title
}
// 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 when the item has been created in Unixtime.
Date int `json:"date,omitempty"`
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"`
IsMainVariant BaseBoolInt `json:"is_main_variant"`
AlbumsIDs []int `json:"albums_ids"`
Photos []PhotosPhoto `json:"photos"`
Likes BaseLikesInfo `json:"likes"`
Reposts BaseRepostsInfo `json:"reposts"`
ViewsCount int `json:"views_count,omitempty"`
URL string `json:"url"` // URL to item
ButtonTitle string `json:"button_title"`
ExternalID string `json:"external_id"`
Dimensions MarketDimensions `json:"dimensions"`
Weight int `json:"weight"`
VariantsGroupingID int `json:"variants_grouping_id"`
PropertyValues []MarketMarketItemProperty `json:"property_values"`
CartQuantity int `json:"cart_quantity"`
SKU string `json:"sku"`
}
// UnmarshalJSON MarketMarketItem.
//
// BUG(VK): https://github.com/SevereCloud/vksdk/issues/147
func (market *MarketMarketItem) UnmarshalJSON(data []byte) error {
if bytes.Equal(data, []byte("false")) {
return nil
}
type renamedMarketMarketItem MarketMarketItem
var r renamedMarketMarketItem
err := json.Unmarshal(data, &r)
if err != nil {
return err
}
*market = MarketMarketItem(r)
return nil
}
// MarketMarketItemProperty struct.
type MarketMarketItemProperty struct {
VariantID int `json:"variant_id"`
VariantName string `json:"variant_name"`
PropertyName string `json:"property_name"`
}
// MarketDimensions struct.
type MarketDimensions struct {
Width int `json:"width"`
Height int `json:"height"`
Length int `json:"length"`
}
// 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
OldAmountText string `json:"old_amount_text"`
}
// UnmarshalJSON MarketPrice.
//
// BUG(VK): unavailable product, in fave.get return [].
func (m *MarketPrice) UnmarshalJSON(data []byte) error {
if bytes.Equal(data, []byte("[]")) {
return nil
}
type renamedMarketPrice MarketPrice
var r renamedMarketPrice
err := json.Unmarshal(data, &r)
if err != nil {
return err
}
*m = MarketPrice(r)
return nil
}
// 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 MarketOrderStatus `json:"status"`
ItemsCount int `json:"items_count"`
TotalPrice MarketPrice `json:"total_price"`
DisplayOrderID string `json:"display_order_id"`
Comment string `json:"comment"`
PreviewOrderItems []MarketOrderItem `json:"preview_order_items"`
PriceDetails []MarketPriceDetail `json:"price_details"`
Delivery MarketOrderDelivery `json:"delivery"`
Recipient MarketOrderRecipient `json:"recipient"`
}
// MarketOrderDelivery struct.
type MarketOrderDelivery struct {
TrackNumber string `json:"track_number"`
TrackLink string `json:"track_link"`
Address string `json:"address"`
Type string `json:"type"`
DeliveryPoint MarketDeliveryPoint `json:"delivery_point,omitempty"`
}
// MarketDeliveryPoint struct.
type MarketDeliveryPoint struct {
ID int `json:"id"`
ExternalID string `json:"external_id"`
OutpostOnly BaseBoolInt `json:"outpost_only"`
CashOnly BaseBoolInt `json:"cash_only"`
Address MarketDeliveryPointAddress `json:"address"`
DisplayTitle string `json:"display_title"`
ServiceID int `json:"service_id"`
}
// MarketDeliveryPointAddress struct.
type MarketDeliveryPointAddress struct {
ID int `json:"id"`
Address string `json:"address"`
CityID int `json:"city_id"`
CountryID int `json:"country_id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Phone string `json:"phone"`
Title string `json:"title"`
WorkInfoStatus string `json:"work_info_status"`
}
// MarketOrderRecipient struct.
type MarketOrderRecipient struct {
Name string `json:"name"`
Phone string `json:"phone"`
DisplayText string `json:"display_text"`
}
// 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 BaseBoolInt `json:"is_accent,omitempty"`
}
|