-
Notifications
You must be signed in to change notification settings - Fork 4
/
endpoints.go
76 lines (66 loc) · 2.51 KB
/
endpoints.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
package kanka
import (
"fmt"
"strconv"
"time"
)
type endpoint string
// Available Kanka API Endpoints
const (
// Core Objects
EndpointProfile endpoint = "profile"
EndpointCampaign endpoint = "campaigns"
EndpointCharacter endpoint = "characters"
EndpointLocation endpoint = "locations"
EndpointMapPoint endpoint = "map_points"
EndpointFamily endpoint = "families"
EndpointOrganization endpoint = "organisations"
EndpointOrganizationMember endpoint = "organisation_members"
EndpointItem endpoint = "items"
EndpointNote endpoint = "notes"
EndpointEvent endpoint = "events"
EndpointCalendar endpoint = "calendars"
EndpointRace endpoint = "races"
EndpointQuest endpoint = "quests"
EndpointQuestCharacters endpoint = "quest_characters"
EndpointQuestLocation endpoint = "quest_locations"
EndpointQuestItem endpoint = "quest_items"
EndpointQuestOrganization endpoint = "quest_organisations"
EndpointJournal endpoint = "journals"
EndpointTag endpoint = "tags"
EndpointConversation endpoint = "conversations"
EndpointDiceRoll endpoint = "dice_rolls"
// Entities
EndpointAttribute endpoint = "attributes"
EndpointEntityEvent endpoint = "entity_events"
EndpointEntityFile endpoint = "entity_files"
EndpointEntityInventories endpoint = "inventories"
EndpointEntityInventory endpoint = "inventory"
EndpointEntityNote endpoint = "entity_notes"
EndpointEntityTag endpoint = "entity_tags"
EndpointRelation endpoint = "relations"
endpointEntity endpoint = "entities"
// Search
EndpointSearch endpoint = "search"
)
// append returns an endpoint appended with the provided string.
func (e endpoint) append(s string) endpoint {
return endpoint(string(e) + s)
}
// concat returns an endpoint appropriately concatenated with the provided
// endpoint.
func (e endpoint) concat(end endpoint) endpoint {
return e.append("/" + string(end))
}
// id returns an endpoint appropriately formatted with the provided id.
func (e endpoint) id(id int) (endpoint, error) {
if id < 0 {
return "", fmt.Errorf("provided ID (%d) cannot be negative", id)
}
return e.append("/" + strconv.Itoa(id)), nil
}
// sync returns an endpoint appropriately formatted with the provided lastSync
// time.
func (e endpoint) sync(t time.Time) endpoint {
return e.append("/?lastSync=" + t.Format(time.RFC3339))
}