Added more API examples

This commit is contained in:
Eduard Urbach 2018-03-28 01:59:14 +02:00
parent c5de0c6d6f
commit bf6a28faca
9 changed files with 69 additions and 43 deletions

View File

@ -1,13 +1,14 @@
component API(types []string)
h1 API
.api-docs-page
h1 API
table
//- thead
//- tr
//- th Table
tbody
each typeName in types
tr
td= typeName
td
a(href="/api/" + strings.ToLower(typeName) + "/")= "/api/" + strings.ToLower(typeName) + "/"
table
//- thead
//- tr
//- th Table
tbody
each typeName in types
tr
td= typeName
td
a(href="/api/" + strings.ToLower(typeName) + "/")= "/api/" + strings.ToLower(typeName) + "/"

View File

@ -1,17 +1,17 @@
component APIDocs(t reflect.Type, examples []string, fields []*utils.APIField)
.api-docs-page
h1= "API: " + t.Name()
h1= t.Name()
h2 Examples
if len(examples) == 0
p.no-data No examples have been added to this type yet.
p.no-data No examples available yet.
else
.buttons
each example in examples
a.button(href="https://notify.moe" + example, target="_blank")
a.button(href=example, target="_blank")
Icon("external-link")
span= example
span= strings.TrimPrefix(example, "/api")
h2 Fields

View File

@ -1,6 +1,7 @@
.api-docs-page
h1,
h2
h2,
p
text-align left
table

View File

@ -24,7 +24,7 @@ component AllNotifications(notifications []*arn.Notification)
a(href=notification.User().Link())= notification.User().Nick
component Notification(notification *arn.Notification)
a.notification(href=notification.Link, target="_blank", data-seen=notification.Seen)
a.notification(href=notification.Link, target="_blank", data-seen=notification.Seen, data-id=notification.ID)
.notification-icon
img.lazy(data-src=notification.Icon, alt=notification.Title)

View File

@ -32,7 +32,7 @@ func BuyItem(ctx *aero.Context) string {
return ctx.Error(http.StatusBadRequest, "Invalid item quantity", err)
}
item, err := arn.GetItem(itemID)
item, err := arn.GetShopItem(itemID)
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching item data", err)

View File

@ -19,7 +19,7 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
}
items, err := arn.AllItems()
items, err := arn.AllShopItems()
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching shop item data", err)

View File

@ -29,7 +29,7 @@ func main() {
user, err := arn.GetUserByNick(nick)
arn.PanicOnError(err)
item, err := arn.GetItem(itemID)
item, err := arn.GetShopItem(itemID)
arn.PanicOnError(err)
if item == nil {

View File

@ -2,8 +2,8 @@ package main
import "github.com/animenotifier/arn"
var items = []*arn.Item{
&arn.Item{
var items = []*arn.ShopItem{
&arn.ShopItem{
ID: "pro-account-3",
Name: "PRO Account (1 season)",
Price: 900,
@ -20,11 +20,11 @@ Includes:
* Access to the VIP channel on Discord
* Early access to new features`,
Icon: "star",
Rarity: arn.ItemRaritySuperior,
Rarity: arn.ShopItemRaritySuperior,
Order: 1,
Consumable: true,
},
&arn.Item{
&arn.ShopItem{
ID: "pro-account-6",
Name: "PRO Account (2 seasons)",
Price: 1600,
@ -41,11 +41,11 @@ Includes:
* Access to the VIP channel on Discord
* Early access to new features`,
Icon: "star",
Rarity: arn.ItemRarityRare,
Rarity: arn.ShopItemRarityRare,
Order: 2,
Consumable: true,
},
&arn.Item{
&arn.ShopItem{
ID: "pro-account-12",
Name: "PRO Account (4 seasons)",
Price: 3000,
@ -62,11 +62,11 @@ Includes:
* Access to the VIP channel on Discord
* Early access to new features`,
Icon: "star",
Rarity: arn.ItemRarityUnique,
Rarity: arn.ShopItemRarityUnique,
Order: 3,
Consumable: true,
},
&arn.Item{
&arn.ShopItem{
ID: "pro-account-24",
Name: "PRO Account (8 seasons)",
Price: 5900,
@ -83,7 +83,7 @@ Includes:
* Access to the VIP channel on Discord
* Early access to new features`,
Icon: "star",
Rarity: arn.ItemRarityLegendary,
Rarity: arn.ShopItemRarityLegendary,
Order: 4,
Consumable: true,
},

View File

@ -104,19 +104,19 @@ var routeTests = map[string][]string{
// Pages
"/anime/:id": []string{
"/anime/1",
"/anime/323",
},
"/anime/:id/characters": []string{
"/anime/1/characters",
"/anime/323/characters",
},
"/anime/:id/episodes": []string{
"/anime/1/episodes",
"/anime/323/episodes",
},
"/anime/:id/tracks": []string{
"/anime/1/tracks",
"/anime/323/tracks",
},
"/thread/:id": []string{
@ -201,7 +201,7 @@ var routeTests = map[string][]string{
// API
"/api/anime/:id": []string{
"/api/anime/1",
"/api/anime/323",
},
"/api/thread/:id": []string{
@ -252,14 +252,14 @@ var routeTests = map[string][]string{
"/api/userfollows/4J6qpK1ve",
},
"/api/anilisttoanime/:id": []string{
"/api/anilisttoanime/527",
},
"/api/animecharacters/:id": []string{
"/api/animecharacters/323",
},
"/api/animerelations/:id": []string{
"/api/animerelations/323",
},
"/api/animeepisodes/:id": []string{
"/api/animeepisodes/323",
},
@ -272,12 +272,36 @@ var routeTests = map[string][]string{
"/api/character/6556",
},
"/api/pushsubscriptions/:id": []string{
"/api/pushsubscriptions/4J6qpK1ve",
"/api/company/:id": []string{
"/api/company/xCAUr7UkRaz",
},
"/api/myanimelisttoanime/:id": []string{
"/api/myanimelisttoanime/527",
"/api/draftindex/:id": []string{
"/api/draftindex/4J6qpK1ve",
},
"/api/inventory/:id": []string{
"/api/inventory/4J6qpK1ve",
},
"/api/shopitem/:id": []string{
"/api/shopitem/pro-account-3",
},
"/api/notification/:id": []string{
"/api/notification/u2WHJpkigm",
},
"/api/quote/:id": []string{
"/api/quote/GXp675zmR",
},
"/api/usernotifications/:id": []string{
"/api/usernotifications/4J6qpK1ve",
},
"/api/pushsubscriptions/:id": []string{
"/api/pushsubscriptions/4J6qpK1ve",
},
// Images