-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshops.go
More file actions
177 lines (155 loc) · 6.23 KB
/
shops.go
File metadata and controls
177 lines (155 loc) · 6.23 KB
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
package rlapi
import "context"
type ShopID int
// Shop represents a shop in the game
type Shop struct {
ID ShopID `json:"ID"`
Type string `json:"Type"`
StartDate int64 `json:"StartDate"`
EndDate *int64 `json:"EndDate"`
LogoURL *string `json:"LogoURL"`
Name *string `json:"Name"`
Title *string `json:"Title"`
}
// ShopCatalogue represents the catalogue for a given shop
type ShopCatalogue struct {
ShopID ShopID `json:"ShopID"`
ShopItems []ShopItem `json:"ShopItems"`
}
// ShopItem represents an item available for purchase in a shop
type ShopItem struct {
ShopItemID int `json:"ShopItemID"`
StartDate int64 `json:"StartDate"`
EndDate *int64 `json:"EndDate"`
MaxQuantityPerPlayer *int `json:"MaxQuantityPerPlayer"`
ImageURL *string `json:"ImageURL"`
DeliverableProducts []DeliverableProduct `json:"DeliverableProducts"`
DeliverableCurrencies []DeliverableCurrency `json:"DeliverableCurrencies"`
Costs []ShopItemCost `json:"Costs"`
ShopItemLocations []int `json:"ShopItemLocations"`
Title *string `json:"Title"`
Description *string `json:"Description"`
FeaturedCollections []interface{} `json:"FeaturedCollections"`
Attributes []ProductAttribute `json:"Attributes"`
Disclaimer *string `json:"Disclaimer"`
PurchasedQuantity int `json:"PurchasedQuantity"`
Purchasable bool `json:"Purchasable"`
MaxQuantityPerDay *int `json:"MaxQuantityPerDay"`
DailyPurchasedQuantity *int `json:"DailyPurchasedQuantity"`
}
// DeliverableProduct represents a product that can be delivered from a shop purchase
type DeliverableProduct struct {
Count int `json:"Count"`
Product Product `json:"Product"`
SortID *int `json:"SortID"`
IsOwned *bool `json:"IsOwned,omitempty"`
}
// DeliverableCurrency represents currency that can be delivered from a shop purchase
type DeliverableCurrency struct {
ID int `json:"ID"`
Amount int `json:"Amount"`
}
// Product represents a game product/item
type Product struct {
ProductID int `json:"ProductID"`
InstanceID *string `json:"InstanceID"`
Attributes []ProductAttribute `json:"Attributes"`
SeriesID int `json:"SeriesID"`
AddedTimestamp *int64 `json:"AddedTimestamp"`
UpdatedTimestamp *int64 `json:"UpdatedTimestamp"`
}
// ProductAttribute represents an attribute of a product
type ProductAttribute struct {
Key string `json:"Key"`
Value interface{} `json:"Value"`
}
// ShopItemCost represents the cost of a shop item
type ShopItemCost struct {
ResetTime *int64 `json:"ResetTime"`
ShopItemCostID int `json:"ShopItemCostID"`
Discount *interface{} `json:"Discount"`
BulkDiscounts *interface{} `json:"BulkDiscounts"`
StartDate int64 `json:"StartDate"`
EndDate *int64 `json:"EndDate"`
Price []CurrencyPrice `json:"Price"`
SortID int `json:"SortID"`
DisplayTypeID int `json:"DisplayTypeID"`
ShopScaledCost interface{} `json:"ShopScaledCost"`
}
// CurrencyPrice represents a price in the specified currency
type CurrencyPrice struct {
ID int `json:"ID"`
Amount int `json:"Amount"`
}
type GetStandardShopsResponse struct {
Shops []Shop `json:"Shops"`
}
type GetShopCatalogueRequest struct {
ShopIDs []ShopID `json:"ShopIDs"`
}
type GetShopCatalogueResponse struct {
Catalogues []ShopCatalogue `json:"Catalogues"`
}
type GetPlayerWalletRequest struct {
PlayerID PlayerID `json:"PlayerID"`
}
type GetPlayerWalletResponse struct {
Currencies []struct {
ID int `json:"ID"`
Amount int `json:"Amount"`
ExpirationTime *string `json:"ExpirationTime"`
UpdatedTimestamp int64 `json:"UpdatedTimestamp"`
IsTradable bool `json:"IsTradable"`
TradeHold *string `json:"TradeHold"`
} `json:"Currencies"`
}
type GetShopNotificationsResponse struct {
ShopNotifications []struct {
ShopNotificationID int `json:"ShopNotificationID"`
ShopItemCostID int `json:"ShopItemCostID"`
StartTime int64 `json:"StartTime"`
EndTime int64 `json:"EndTime"`
ImageURL *string `json:"ImageURL"`
Title string `json:"Title"`
DeliverableProducts []DeliverableProduct `json:"DeliverableProducts"`
} `json:"ShopNotifications"`
}
// GetStandardShops retrieves the list of available shops.
func (p *PsyNetRPC) GetStandardShops(ctx context.Context) (*GetStandardShopsResponse, error) {
var result GetStandardShopsResponse
err := p.sendRequestSync(ctx, "Shops/GetStandardShops v1", map[string]interface{}{}, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetShopCatalogue retrieves detailed information about items available in specified shops.
func (p *PsyNetRPC) GetShopCatalogue(ctx context.Context, shopIDs []ShopID) (*GetShopCatalogueResponse, error) {
request := GetShopCatalogueRequest{
ShopIDs: shopIDs,
}
var result GetShopCatalogueResponse
err := p.sendRequestSync(ctx, "Shops/GetShopCatalogue v2", request, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetPlayerWallet retrieves the authenticated player's wallet information.
func (p *PsyNetRPC) GetPlayerWallet(ctx context.Context) (*GetPlayerWalletResponse, error) {
var result GetPlayerWalletResponse
err := p.sendRequestSync(ctx, "Shops/GetPlayerWallet v1", GetPlayerWalletRequest{PlayerID: p.localPlayerID}, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetShopNotifications retrieves current shop notifications.
func (p *PsyNetRPC) GetShopNotifications(ctx context.Context) (*GetShopNotificationsResponse, error) {
var result GetShopNotificationsResponse
err := p.sendRequestSync(ctx, "Shops/GetShopNotifications v1", emptyRequest{}, &result)
if err != nil {
return nil, err
}
return &result, nil
}