forked from broderickhyman/albiondata-client
-
Notifications
You must be signed in to change notification settings - Fork 29
/
operation_auction_get_offers.go
59 lines (46 loc) · 1.44 KB
/
operation_auction_get_offers.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
package client
import (
"encoding/json"
"github.com/ao-data/albiondata-client/lib"
"github.com/ao-data/albiondata-client/log"
)
type operationAuctionGetOffers struct {
Category string `mapstructure:"1"`
SubCategory string `mapstructure:"2"`
Quality string `mapstructure:"3"`
Enchantment uint32 `mapstructure:"4"`
EnchantmentLevel string `mapstructure:"8"`
ItemIds []uint16 `mapstructure:"6"`
MaxResults uint32 `mapstructure:"9"`
IsAscendingOrder bool `mapstructure:"12"`
}
func (op operationAuctionGetOffers) Process(state *albionState) {
log.Debug("Got AuctionGetOffers operation...")
}
type operationAuctionGetOffersResponse struct {
MarketOrders []string `mapstructure:"0"`
}
func (op operationAuctionGetOffersResponse) Process(state *albionState) {
log.Debug("Got response to AuctionGetOffers operation...")
if !state.IsValidLocation() {
return
}
var orders []*lib.MarketOrder
for _, v := range op.MarketOrders {
order := &lib.MarketOrder{}
err := json.Unmarshal([]byte(v), order)
if err != nil {
log.Errorf("Problem converting market order to internal struct: %v", err)
}
order.LocationID = state.LocationId
orders = append(orders, order)
}
if len(orders) < 1 {
return
}
upload := lib.MarketUpload{
Orders: orders,
}
log.Infof("Sending %d market offers to ingest", len(orders))
sendMsgToPublicUploaders(upload, lib.NatsMarketOrdersIngest, state)
}