This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsearch_index.go
67 lines (58 loc) · 1.97 KB
/
search_index.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
package xivapi
import (
"net/url"
"strings"
)
// SearchIndex specifies the index to search in
type SearchIndex string
// The different indexes
const (
IndexAchievement SearchIndex = "achievement"
IndexAction = "action"
IndexBNPCName = "bnpcname"
IndexCompanion = "companion"
IndexENPCResident = "enpcresident"
IndexEmote = "emote"
IndexFate = "fate"
IndexInstanceContent = "instancecontent"
IndexItem = "item"
IndexLeve = "leve"
IndexMount = "mount"
IndexPlaceName = "placename"
IndexQuest = "quest"
IndexRecipe = "recipe"
IndexStatus = "status"
IndexTitle = "title"
IndexWeather = "weather"
IndexBuddyEquip = "buddyequip"
IndexOrchestrion = "orchestrion"
// IndexEnemy is an alias for IndexBNPCName
IndexEnemy = "bnpcname"
// IndexMinion is an alias for IndexCompanion
IndexMinion = "companion"
// IndexNPC is an alias for IndexENPCResident
IndexNPC = "enpcresident"
// IndexChocoboGear is an alias for IndexBuddyEquip
IndexChocoboGear = "buddyequip"
)
// SearchIndexes is the list of indexes to search in
type SearchIndexes []SearchIndex
func (si SearchIndexes) String() string {
indexesMap := make(map[string]struct{})
for _, index := range si {
indexesMap[string(index)] = struct{}{}
}
indexes := make([]string, len(indexesMap))
i := 0
for index := range indexesMap {
indexes[i] = index
i++
}
return strings.Join(indexes, ",")
}
// EncodeValues encodes the list into a custom list of values
// This is a custom Encoder for go-querystring https://godoc.org/github.com/google/go-querystring/query
func (si SearchIndexes) EncodeValues(key string, v *url.Values) error {
v.Set(key, si.String())
return nil
}