code reorg to leverage methods instead of function

moved all metadata.go function calls into method calls for the Halo
struct.  This will make it easier to encapsulate baseurl, apikey, blah
blah, and also makes the code a little bit more readable.  Stats.go and
profile.go are to follow.

Still need to implement http.Client interface and look over the code in
go-halo5-api.go.  Most likely needs to break out and be cleaned up
This commit is contained in:
Derek McQuay 2016-05-10 21:30:18 -07:00
parent b558a172fd
commit 1c339ec1a0
6 changed files with 373 additions and 258 deletions

View File

@ -16,13 +16,36 @@ func checkErr(err error) {
} }
} }
func metadataRequest(baseurl, title, datatype, id string) []byte { func (h *Halo) metadataRequest(datatype, id string) ([]byte, error) {
url, err := url.Parse(fmt.Sprintf("%s/metadata/%s/metadata/%s/%s", baseurl, title, datatype, id)) url, err := url.Parse(fmt.Sprintf("%s/metadata/%s/metadata/%s/%s", h.baseurl, h.title, datatype, id))
checkErr(err) if err != nil {
return nil, err
}
q := url.Query() q := url.Query()
url.RawQuery = q.Encode() url.RawQuery = q.Encode()
response := sendRequest(url.String()) response := h.sendRequest(url.String())
return response return response, nil
}
func (h *Halo) sendRequest(url string) []byte {
request, err := http.NewRequest("GET", url, nil)
checkErr(err)
request.Header.Set("Ocp-Apim-Subscription-Key", h.apikey)
response, err := http.DefaultClient.Do(request)
checkErr(err)
defer response.Body.Close()
// Return the URL of the image for SpartanImage and EmblemImage
if url != response.Request.URL.String() {
return []byte(response.Request.URL.String())
}
// If its not SpartanImage or EmblemImage return the body
contents, err := ioutil.ReadAll(response.Body)
checkErr(err)
return contents
} }
func sendRequest(url string) []byte { func sendRequest(url string) []byte {

16
halo/halo.go Normal file
View File

@ -0,0 +1,16 @@
package halo
type Halo struct {
baseurl string
title string
apikey string
}
func NewHalo(baseurl, title, apikey string) *Halo {
h := &Halo{
baseurl: baseurl,
title: title,
apikey: apikey,
}
return h
}

View File

@ -1,183 +1,268 @@
package halo package halo
import "encoding/json" import (
"encoding/json"
"fmt"
"log"
)
// This one works! func (h *Halo) CampaignMissions() CampaignMissionsStruct {
type CampaignMissionsStruct []struct {
MissionNumber json.Number `json:"missionNumber"`
Name string `json:"name"`
Description string `json:"description"`
ImageURL string `json:"imageUrl"`
Type string `json:"type"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
// This one works!
type CommendationsStruct []struct {
Type string `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
IconImageURL string `json:"iconImageUrl"`
Levels []struct {
Reward struct {
Xp int `json:"xp"`
RequisitionPacks []struct {
Name string `json:"name"`
Description string `json:"description"`
LargeImageURL string `json:"largeImageUrl"`
IsStack bool `json:"isStack"`
IsFeatured bool `json:"isFeatured"`
IsNew bool `json:"isNew"`
CreditPrice int `json:"creditPrice"`
IsPurchasableWithCredits bool `json:"isPurchasableWithCredits"`
IsPurchasableFromMarketplace bool `json:"isPurchasableFromMarketplace"`
XboxMarketplaceProductID interface{} `json:"xboxMarketplaceProductId"`
XboxMarketplaceProductURL interface{} `json:"xboxMarketplaceProductUrl"`
MerchandisingOrder int `json:"merchandisingOrder"`
Flair interface{} `json:"flair"`
StackedRequisitionPacks []interface{} `json:"stackedRequisitionPacks"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"requisitionPacks"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"reward"`
Threshold int `json:"threshold"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"levels"`
RequiredLevels []interface{} `json:"requiredLevels"`
Reward interface{} `json:"reward"`
Category struct {
Name string `json:"name"`
IconImageURL string `json:"iconImageUrl"`
Order int `json:"order"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"category"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
// This one works!
type CsrDesignationsStruct []struct {
Name string `json:"name"`
BannerImageURL string `json:"bannerImageUrl"`
Tiers []struct {
IconImageURL string `json:"iconImageUrl"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"tiers"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
type EnemiesStruct []struct {
Faction string `json:"faction"`
Name string `json:"name"`
Description interface{} `json:"description"`
LargeIconImageURL string `json:"largeIconImageUrl"`
SmallIconImageURL string `json:"smallIconImageUrl"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
type VehiclesStruct []struct {
Name string `json:"name"`
Description string `json:"description"`
LargeIconImageURL string `json:"largeIconImageUrl"`
SmallIconImageURL string `json:"smallIconImageUrl"`
IsUsableByPlayer bool `json:"isUsableByPlayer"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
func CampaignMissions(baseurl, title string) CampaignMissionsStruct {
var j CampaignMissionsStruct var j CampaignMissionsStruct
err := json.Unmarshal(metadataRequest(baseurl, title, "campaign-missions", ""), &j) jsonObject, err := h.metadataRequest("campaign-missions", "")
checkErr(err) if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j return j
} }
func Commendations(baseurl, title string) CommendationsStruct { func (h *Halo) Commendations() CommendationsStruct {
var j CommendationsStruct var j CommendationsStruct
err := json.Unmarshal(metadataRequest(baseurl, title, "commendations", ""), &j) jsonObject, err := h.metadataRequest("commendations", "")
checkErr(err) if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j return j
} }
func CsrDesignations(baseurl, title string) CsrDesignationsStruct { func (h *Halo) CsrDesignations() CsrDesignationsStruct {
var j CsrDesignationsStruct var j CsrDesignationsStruct
err := json.Unmarshal(metadataRequest(baseurl, title, "csr-designations", ""), &j) jsonObject, err := h.metadataRequest("csr-designations", "")
checkErr(err) if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j return j
} }
func Enemies(baseurl, title string) []byte { func (h *Halo) Enemies() EnemiesStruct {
return metadataRequest(baseurl, title, "enemies", "") var j EnemiesStruct
jsonObject, err := h.metadataRequest("enemies", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func FlexibleStats(baseurl, title string) []byte { func (h *Halo) FlexibleStats() FlexibleStatsStruct {
return metadataRequest(baseurl, title, "flexible-stats", "") var j FlexibleStatsStruct
jsonObject, err := h.metadataRequest("flexible-stats", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
fmt.Println("hjere")
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func GameBaseVariants(baseurl, title string) []byte { func (h *Halo) GameBaseVariants() GameBaseVariantsStruct {
return metadataRequest(baseurl, title, "game-base-variants", "") var j GameBaseVariantsStruct
jsonObject, err := h.metadataRequest("game-base-variants", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func GameVariants(baseurl, title, id string) []byte { func (h *Halo) GameVariants(id string) GameVariantsStruct {
return metadataRequest(baseurl, title, "game-variants", id) var j GameVariantsStruct
jsonObject, err := h.metadataRequest("game-variants", id)
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Impulses(baseurl, title string) []byte { func (h *Halo) Impulses() ImpulsesStruct {
return metadataRequest(baseurl, title, "impulses", "") var j ImpulsesStruct
jsonObject, err := h.metadataRequest("impulses", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func MapVariants(baseurl, title, id string) []byte { func (h *Halo) MapVariants(id string) MapVariantsStruct {
return metadataRequest(baseurl, title, "map-variants", id) var j MapVariantsStruct
jsonObject, err := h.metadataRequest("map-variants", id)
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Maps(baseurl, title string) []byte { func (h *Halo) Maps() MapsStruct {
return metadataRequest(baseurl, title, "maps", "") var j MapsStruct
jsonObject, err := h.metadataRequest("maps", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Medals(baseurl, title string) []byte { func (h *Halo) Medals() MedalsStruct {
return metadataRequest(baseurl, title, "medals", "") var j MedalsStruct
jsonObject, err := h.metadataRequest("medals", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Playlists(baseurl, title string) []byte { func (h *Halo) Playlists() PlaylistsStruct {
return metadataRequest(baseurl, title, "playlists", "") var j PlaylistsStruct
jsonObject, err := h.metadataRequest("playlists", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func RequisitionPacks(baseurl, title, id string) []byte { func (h *Halo) RequisitionPacks(id string) RequisitionPacksStruct {
return metadataRequest(baseurl, title, "requisition-packs", id) var j RequisitionPacksStruct
jsonObject, err := h.metadataRequest("requisitions-packs", id)
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Requisitions(baseurl, title, id string) []byte { func (h *Halo) Requisitions(id string) RequisitionsStruct {
return metadataRequest(baseurl, title, "requisitions", id) var j RequisitionsStruct
jsonObject, err := h.metadataRequest("requisitions", id)
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Seasons(baseurl, title string) []byte { func (h *Halo) Seasons() SeasonsStruct {
return metadataRequest(baseurl, title, "seasons", "") var j SeasonsStruct
jsonObject, err := h.metadataRequest("seasons", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Skulls(baseurl, title string) []byte { func (h *Halo) Skulls() SkullsStruct {
return metadataRequest(baseurl, title, "skulls", "") var j SkullsStruct
jsonObject, err := h.metadataRequest("skulls", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func SpartanRanks(baseurl, title string) []byte { func (h *Halo) SpartanRanks() SpartanRanksStruct {
return metadataRequest(baseurl, title, "spartan-ranks", "") var j SpartanRanksStruct
jsonObject, err := h.metadataRequest("spartan-ranks", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func TeamColors(baseurl, title string) []byte { func (h *Halo) TeamColors() TeamColorsStruct {
return metadataRequest(baseurl, title, "team-colors", "") var j TeamColorsStruct
jsonObject, err := h.metadataRequest("team-colors", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Vehicles(baseurl, title string) []byte { func (h *Halo) Vehicles() VehiclesStruct {
return metadataRequest(baseurl, title, "vehicles", "") var j VehiclesStruct
jsonObject, err := h.metadataRequest("vehicles", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }
func Weapons(baseurl, title string) []byte { func (h *Halo) Weapons() WeaponsStruct {
return metadataRequest(baseurl, title, "weapons", "") var j WeaponsStruct
jsonObject, err := h.metadataRequest("weapons", "")
if err != nil {
log.Fatal("MetadataRequest Failed: ", err)
}
err = json.Unmarshal(jsonObject, &j)
if err != nil {
log.Fatal("Failure to unmarshal json: ", err)
}
return j
} }

View File

@ -3,123 +3,8 @@ package halo
import ( import (
"fmt" "fmt"
"net/url" "net/url"
"time"
) )
// Stats Structs
type EventsForMatchStruct struct {
GameEvents []struct {
EventName string `json:"EventName"`
RoundIndex int `json:"RoundIndex"`
TimeSinceStart string `json:"TimeSinceStart"`
} `json:"GameEvents"`
IsCompleteSetOfEvents bool `json:"IsCompleteSetOfEvents"`
Links struct {
StatsMatchDetails struct {
AcknowledgementTypeID int `json:"AcknowledgementTypeId"`
AuthenticationLifetimeExtensionSupported bool `json:"AuthenticationLifetimeExtensionSupported"`
AuthorityID string `json:"AuthorityId"`
Path string `json:"Path"`
QueryString interface{} `json:"QueryString"`
RetryPolicyID string `json:"RetryPolicyId"`
TopicName string `json:"TopicName"`
} `json:"StatsMatchDetails"`
UgcFilmManifest struct {
AcknowledgementTypeID int `json:"AcknowledgementTypeId"`
AuthenticationLifetimeExtensionSupported bool `json:"AuthenticationLifetimeExtensionSupported"`
AuthorityID string `json:"AuthorityId"`
Path string `json:"Path"`
QueryString string `json:"QueryString"`
RetryPolicyID string `json:"RetryPolicyId"`
TopicName string `json:"TopicName"`
} `json:"UgcFilmManifest"`
} `json:"Links"`
}
type MatchesForPlayerStruct struct {
Start int `json:"Start"`
Count int `json:"Count"`
ResultCount int `json:"ResultCount"`
Results []struct {
Links struct {
StatsMatchDetails struct {
AuthorityID string `json:"AuthorityId"`
Path string `json:"Path"`
QueryString interface{} `json:"QueryString"`
RetryPolicyID string `json:"RetryPolicyId"`
TopicName string `json:"TopicName"`
AcknowledgementTypeID int `json:"AcknowledgementTypeId"`
AuthenticationLifetimeExtensionSupported bool `json:"AuthenticationLifetimeExtensionSupported"`
} `json:"StatsMatchDetails"`
UgcFilmManifest struct {
AuthorityID string `json:"AuthorityId"`
Path string `json:"Path"`
QueryString string `json:"QueryString"`
RetryPolicyID string `json:"RetryPolicyId"`
TopicName string `json:"TopicName"`
AcknowledgementTypeID int `json:"AcknowledgementTypeId"`
AuthenticationLifetimeExtensionSupported bool `json:"AuthenticationLifetimeExtensionSupported"`
} `json:"UgcFilmManifest"`
} `json:"Links"`
ID struct {
MatchID string `json:"MatchId"`
GameMode int `json:"GameMode"`
} `json:"Id"`
HopperID string `json:"HopperId"`
MapID string `json:"MapId"`
MapVariant struct {
ResourceType int `json:"ResourceType"`
ResourceID string `json:"ResourceId"`
OwnerType int `json:"OwnerType"`
Owner string `json:"Owner"`
} `json:"MapVariant"`
GameBaseVariantID string `json:"GameBaseVariantId"`
GameVariant struct {
ResourceType int `json:"ResourceType"`
ResourceID string `json:"ResourceId"`
OwnerType int `json:"OwnerType"`
Owner string `json:"Owner"`
} `json:"GameVariant"`
MatchDuration string `json:"MatchDuration"`
MatchCompletedDate struct {
ISO8601Date time.Time `json:"ISO8601Date"`
} `json:"MatchCompletedDate"`
Teams []struct {
ID int `json:"Id"`
Score int `json:"Score"`
Rank int `json:"Rank"`
} `json:"Teams"`
Players []struct {
Player struct {
Gamertag string `json:"Gamertag"`
Xuid interface{} `json:"Xuid"`
} `json:"Player"`
TeamID int `json:"TeamId"`
Rank int `json:"Rank"`
Result int `json:"Result"`
TotalKills int `json:"TotalKills"`
TotalDeaths int `json:"TotalDeaths"`
TotalAssists int `json:"TotalAssists"`
PreMatchRatings interface{} `json:"PreMatchRatings"`
PostMatchRatings interface{} `json:"PostMatchRatings"`
} `json:"Players"`
IsTeamGame bool `json:"IsTeamGame"`
SeasonID interface{} `json:"SeasonId"`
MatchCompletedDateFidelity int `json:"MatchCompletedDateFidelity"`
} `json:"Results"`
Links struct {
Self struct {
AuthorityID string `json:"AuthorityId"`
Path string `json:"Path"`
QueryString string `json:"QueryString"`
RetryPolicyID string `json:"RetryPolicyId"`
TopicName string `json:"TopicName"`
AcknowledgementTypeID int `json:"AcknowledgementTypeId"`
AuthenticationLifetimeExtensionSupported bool `json:"AuthenticationLifetimeExtensionSupported"`
} `json:"Self"`
} `json:"Links"`
}
func EventsForMatch(baseurl, title, matchid string) []byte { func EventsForMatch(baseurl, title, matchid string) []byte {
verifyValidID(matchid, "Match ID") verifyValidID(matchid, "Match ID")
url, err := url.Parse(fmt.Sprintf("%s/stats/%s/matches/%s/events", baseurl, title, matchid)) url, err := url.Parse(fmt.Sprintf("%s/stats/%s/matches/%s/events", baseurl, title, matchid))

View File

@ -1,4 +1,76 @@
package halo
import "encoding/json"
type CampaignMissionsStruct []struct {
MissionNumber json.Number `json:"missionNumber"`
Name string `json:"name"`
Description string `json:"description"`
ImageURL string `json:"imageUrl"`
Type string `json:"type"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
// This one works!
type CommendationsStruct []struct {
Type string `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
IconImageURL string `json:"iconImageUrl"`
Levels []struct {
Reward struct {
Xp int `json:"xp"`
RequisitionPacks []struct {
Name string `json:"name"`
Description string `json:"description"`
LargeImageURL string `json:"largeImageUrl"`
IsStack bool `json:"isStack"`
IsFeatured bool `json:"isFeatured"`
IsNew bool `json:"isNew"`
CreditPrice int `json:"creditPrice"`
IsPurchasableWithCredits bool `json:"isPurchasableWithCredits"`
IsPurchasableFromMarketplace bool `json:"isPurchasableFromMarketplace"`
XboxMarketplaceProductID interface{} `json:"xboxMarketplaceProductId"`
XboxMarketplaceProductURL interface{} `json:"xboxMarketplaceProductUrl"`
MerchandisingOrder int `json:"merchandisingOrder"`
Flair interface{} `json:"flair"`
StackedRequisitionPacks []interface{} `json:"stackedRequisitionPacks"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"requisitionPacks"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"reward"`
Threshold int `json:"threshold"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"levels"`
RequiredLevels []interface{} `json:"requiredLevels"`
Reward interface{} `json:"reward"`
Category struct {
Name string `json:"name"`
IconImageURL string `json:"iconImageUrl"`
Order int `json:"order"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"category"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
// This one works!
type CsrDesignationsStruct []struct {
Name string `json:"name"`
BannerImageURL string `json:"bannerImageUrl"`
Tiers []struct {
IconImageURL string `json:"iconImageUrl"`
ID string `json:"id"`
ContentID string `json:"contentId"`
} `json:"tiers"`
ID string `json:"id"`
ContentID string `json:"contentId"`
}
type CarnageReportArenaStruct struct { type CarnageReportArenaStruct struct {
GameBaseVariantID string `json:"GameBaseVariantId"` GameBaseVariantID string `json:"GameBaseVariantId"`
@ -615,7 +687,7 @@ type EventsForMatchStruct struct {
} `json:"Links"` } `json:"Links"`
} }
type FlexibleStatsStruct struct { type FlexibleStatsStruct []struct {
ContentID string `json:"contentId"` ContentID string `json:"contentId"`
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
@ -1722,5 +1794,3 @@ type WeaponsStruct []struct {
SmallIconImageURL string `json:"smallIconImageUrl"` SmallIconImageURL string `json:"smallIconImageUrl"`
Type string `json:"type"` Type string `json:"type"`
} }

36
main.go
View File

@ -1,5 +1,12 @@
package main package main
import (
"fmt"
"os"
"github.com/tbenz9/go-halo5-api/halo"
)
var baseurl string = "https://www.haloapi.com" var baseurl string = "https://www.haloapi.com"
var title string = "h5" var title string = "h5"
@ -18,7 +25,36 @@ var sampleRequisitionPacksID string = "d10141cb-68a5-4c6b-af38-4e4935f973f7"
var sampleRequisitionID string = "e4f549b2-90af-4dab-b2bc-11a46ea44103" var sampleRequisitionID string = "e4f549b2-90af-4dab-b2bc-11a46ea44103"
var samplePlayers string = "motta13,smoke721" var samplePlayers string = "motta13,smoke721"
func getAPIKey() string {
apikey := os.Getenv("HALO_API_KEY")
if len(apikey) != 32 {
fmt.Println("Invalid API Key")
}
return apikey
}
func main() { func main() {
h := halo.NewHalo(baseurl, title, getAPIKey())
//fmt.Println(h.Enemies())
//fmt.Println(h.FlexibleStats())
//fmt.Println(h.GameBaseVariants())
//fmt.Println(h.Impulses())
//fmt.Println(h.Maps())
//fmt.Println(h.Medals())
//fmt.Println(h.Playlists())
//fmt.Println(h.Seasons())
//fmt.Println(h.Skulls())
//fmt.Println(h.SpartanRanks())
//time.Sleep(time.Second * 10)
//fmt.Println(h.TeamColors())
//fmt.Println(h.Vehicles())
//fmt.Println(h.Weapons())
//fmt.Println(h.GameVariants(sampleGameVariantID))
//fmt.Println(h.MapVariants(sampleMapVariantsID))
//fmt.Println(h.Requisitions(sampleRequisitionID))
fmt.Println(h.RequisitionPacks(sampleRequisitionPacksID))
// Uncomment any of the below for sample output. // Uncomment any of the below for sample output.
// Metadata // Metadata