Skip to content

Commit

Permalink
Initial sportsbook commit
Browse files Browse the repository at this point in the history
  • Loading branch information
will-taylor-willowtree committed Oct 31, 2021
0 parents commit e4e53e3
Show file tree
Hide file tree
Showing 15 changed files with 1,066 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa_personal' <git command>

46 changes: 46 additions & 0 deletions clients/ceaser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package clients

import (
"Sportsbook/dtos"
"encoding/json"
"fmt"
"io"
"net/http"
)

func GetCeaserPromotions() (*dtos.CeasersPromotionResponse, error) {
client := &http.Client{}
req, err := http.NewRequest(
http.MethodGet,
"https://www.williamhill.com/us/va/bet/api/v2/sports/americanfootball/events/schedule",
nil)
if err != nil {
return nil, err
}

q := req.URL.Query()
q.Add("format", "json")
req.URL.RawQuery = q.Encode()

resp, err := client.Do(req)
if err != nil {
fmt.Println("Errored when sending request to the server")
return nil, err
}


defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {

}
}(resp.Body)

target := dtos.CeasersPromotionResponse{}
err = json.NewDecoder(resp.Body).Decode(&target)
if err != nil {
return nil, err
}

return &target, nil
}
46 changes: 46 additions & 0 deletions clients/dk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package clients

import (
"Sportsbook/dtos"
"encoding/json"
"fmt"
"io"
"net/http"
)

func GetDraftKingsPromotions() (*dtos.DraftKingsResponse, error) {
client := &http.Client{}
req, err := http.NewRequest(
http.MethodGet,
"https://sportsbook-us-va.draftkings.com//sites/US-VA-SB/api/v4/eventgroups/88670561",
nil)
if err != nil {
return nil, err
}

q := req.URL.Query()
q.Add("format", "json")
req.URL.RawQuery = q.Encode()

resp, err := client.Do(req)
if err != nil {
fmt.Println("Errored when sending request to the server")
return nil, err
}


defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {

}
}(resp.Body)

target := dtos.DraftKingsResponse{}
err = json.NewDecoder(resp.Body).Decode(&target)
if err != nil {
return nil, err
}

return &target, nil
}
97 changes: 97 additions & 0 deletions dtos/ceaser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package dtos

import "time"

type CeasersPromotionResponse struct {
SportID string `json:"sportId"`
Name string `json:"name"`
EventCount int `json:"eventCount"`
Competitions []struct {
ID string `json:"id"`
Name string `json:"name"`
Events []struct {
Markets []struct {
ID string `json:"id"`
Name string `json:"name"`
TemplateName string `json:"templateName"`
DisplayOrder int `json:"displayOrder"`
Type string `json:"type"`
Display bool `json:"display"`
TradedInPlay bool `json:"tradedInPlay"`
TemplateID string `json:"templateId"`
SpOffered bool `json:"spOffered"`
Active bool `json:"active"`
SportID string `json:"sportId"`
CompetitionID string `json:"competitionId"`
EventID string `json:"eventId"`
KeyMarket bool `json:"keyMarket"`
DisplayName string `json:"displayName"`
CollectionName string `json:"collectionName"`
PrimaryDisplayOrder int `json:"primaryDisplayOrder"`
SecondaryDisplayOrder int `json:"secondaryDisplayOrder"`
Selections []struct {
ID string `json:"id"`
Display bool `json:"display"`
Name string `json:"name"`
SportID string `json:"sportId"`
CompetitionID string `json:"competitionId"`
EventID string `json:"eventId"`
MarketID string `json:"marketId"`
Active bool `json:"active"`
Type string `json:"type"`
Price struct {
F string `json:"f"`
D float64 `json:"d"`
A int `json:"a"`
} `json:"price"`
} `json:"selections"`
SixPackView bool `json:"sixPackView"`
Line float64 `json:"line,omitempty"`
BetLimits struct {
LiabilityLimit int `json:"liabilityLimit"`
MaxMultipleBet int `json:"maxMultipleBet"`
MaxWin int `json:"maxWin"`
MaxBet int `json:"maxBet"`
} `json:"betLimits,omitempty"`
Metadata struct {
Line string `json:"line"`
MarketCategory string `json:"marketCategory"`
MarketCode string `json:"marketCode"`
PricingSource string `json:"pricingSource"`
Period string `json:"period"`
MarketType string `json:"marketType"`
} `json:"metadata,omitempty"`
ByoEligible bool `json:"byoEligible"`
} `json:"markets"`
ID string `json:"id"`
Name string `json:"name"`
StartTime time.Time `json:"startTime"`
Type string `json:"type"`
Display bool `json:"display"`
TradedInPlay bool `json:"tradedInPlay"`
SportID string `json:"sportId"`
CompetitionID string `json:"competitionId"`
CompetitionName string `json:"competitionName"`
Active bool `json:"active"`
Started bool `json:"started"`
MarketCountActivePreMatch int `json:"marketCountActivePreMatch"`
MarketCountActiveInPlay int `json:"marketCountActiveInPlay"`
ByoEligible bool `json:"byoEligible"`
LiveEventData struct {
EventID string `json:"eventId"`
GameTime struct {
Seconds int `json:"seconds"`
Minutes int `json:"minutes"`
} `json:"gameTime"`
Scores []struct {
Team string `json:"team"`
Points int `json:"points"`
} `json:"scores"`
StatsID int `json:"statsId"`
StartTime time.Time `json:"startTime"`
Quarter int `json:"quarter"`
} `json:"liveEventData,omitempty"`
} `json:"events"`
GroupName string `json:"groupName"`
} `json:"competitions"`
}
139 changes: 139 additions & 0 deletions dtos/dk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package dtos

import "time"

type DraftKingsResponse struct {
EventGroup struct {
EventGroupID int `json:"eventGroupId"`
ProviderEventGroupID string `json:"providerEventGroupId"`
ProviderID int `json:"providerId"`
DisplayGroupID int `json:"displayGroupId"`
Name string `json:"name"`
OfferCategories []struct {
OfferCategoryID int `json:"offerCategoryId"`
Name string `json:"name"`
OfferSubcategoryDescriptors []struct {
SubcategoryID int `json:"subcategoryId"`
Name string `json:"name"`
OfferSubcategory struct {
Name string `json:"name"`
SubcategoryID int `json:"subcategoryId"`
ComponentID int `json:"componentId"`
Offers [][]Offers `json:"offers"`
} `json:"offerSubcategory,omitempty"`
} `json:"offerSubcategoryDescriptors,omitempty"`
} `json:"offerCategories"`
Events []struct {
EventID int `json:"eventId"`
DisplayGroupID int `json:"displayGroupId"`
EventGroupID int `json:"eventGroupId"`
EventGroupName string `json:"eventGroupName"`
ProviderEventID string `json:"providerEventId"`
ProviderID int `json:"providerId"`
Name string `json:"name"`
StartDate time.Time `json:"startDate"`
TeamName1 string `json:"teamName1"`
TeamName2 string `json:"teamName2"`
TeamShortName1 string `json:"teamShortName1"`
TeamShortName2 string `json:"teamShortName2"`
EventStatus struct {
State string `json:"state"`
IsClockDisabled bool `json:"isClockDisabled"`
Minute int `json:"minute"`
Second int `json:"second"`
IsClockRunning bool `json:"isClockRunning"`
} `json:"eventStatus"`
EventScorecard struct {
ScorecardComponentID int `json:"scorecardComponentId"`
} `json:"eventScorecard"`
MediaList []struct {
EventID int `json:"eventId"`
MediaProviderName string `json:"mediaProviderName"`
MediaID string `json:"mediaId"`
MediaTypeName string `json:"mediaTypeName"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"mediaList"`
LiveBettingOffered bool `json:"liveBettingOffered"`
LiveBettingEnabled bool `json:"liveBettingEnabled"`
IsSameGameParlayEligible bool `json:"isSameGameParlayEligible,omitempty"`
} `json:"events"`
} `json:"eventGroup"`
Promotions []struct {
PromotionID int `json:"promotionId"`
IsArchived bool `json:"isArchived"`
SortOrder int `json:"sortOrder"`
ShowInCarousel bool `json:"showInCarousel"`
ShowOnPromoPage bool `json:"showOnPromoPage"`
IsFeatured bool `json:"isFeatured"`
TaggedEntityType int `json:"taggedEntityType,omitempty"`
ProviderID int `json:"providerId,omitempty"`
EventGroupID int `json:"eventGroupId,omitempty"`
StartDate time.Time `json:"startDate"`
ProductID int `json:"productId"`
JurisdictionIds []int `json:"jurisdictionIds"`
IsOptedIn bool `json:"isOptedIn"`
PromotionHeadline string `json:"promotionHeadline"`
PromotionDescription string `json:"promotionDescription"`
CtaLink string `json:"ctaLink"`
CtaDeepLink string `json:"ctaDeepLink"`
ExpirationDate time.Time `json:"expirationDate"`
SiteExperience []string `json:"siteExperience"`
ProductName string `json:"productName"`
OptIn bool `json:"optIn"`
IsTargeted bool `json:"isTargeted"`
SortAheadOfTargetedPromos bool `json:"sortAheadOfTargetedPromos"`
IsOfferCardImagePromotion bool `json:"isOfferCardImagePromotion"`
ShouldImageCardAutoRefresh bool `json:"shouldImageCardAutoRefresh"`
IsStraplinePromotion bool `json:"isStraplinePromotion"`
WebStraplineZone string `json:"webStraplineZone,omitempty"`
NativeStraplineZone string `json:"nativeStraplineZone,omitempty"`
WebStraplineImage string `json:"webStraplineImage,omitempty"`
NativeStraplineImage string `json:"nativeStraplineImage,omitempty"`
IsFTDOnlySportsbook bool `json:"isFTDOnlySportsbook"`
IsFTDOnlyCasino bool `json:"isFTDOnlyCasino"`
ExternalCampaignID int `json:"externalCampaignId,omitempty"`
DisplayGroupID int `json:"displayGroupId,omitempty"`
DestinationURL string `json:"destinationUrl,omitempty"`
Deeplink string `json:"deeplink,omitempty"`
PromotionImage string `json:"promotionImage,omitempty"`
PromotionSubHeadline string `json:"promotionSubHeadline,omitempty"`
CtaText string `json:"ctaText,omitempty"`
PromotionTermsModalImage string `json:"promotionTermsModalImage,omitempty"`
Terms string `json:"terms,omitempty"`
PromotionTypeName string `json:"promotionTypeName,omitempty"`
PromotionOfferCardImage string `json:"promotionOfferCardImage,omitempty"`
ImageCardHasTerms bool `json:"imageCardHasTerms,omitempty"`
EventID int `json:"eventId,omitempty"`
} `json:"promotions"`
}

type Offers struct {
ProviderOfferID string `json:"providerOfferId"`
ProviderID int `json:"providerId"`
ProviderEventID string `json:"providerEventId"`
ProviderEventGroupID string `json:"providerEventGroupId"`
Label string `json:"label"`
IsSuspended bool `json:"isSuspended"`
IsOpen bool `json:"isOpen"`
OfferSubcategoryID int `json:"offerSubcategoryId"`
IsSubcategoryFeatured bool `json:"isSubcategoryFeatured"`
BetOfferTypeID int `json:"betOfferTypeId"`
DisplayGroupID int `json:"displayGroupId"`
EventGroupID int `json:"eventGroupId"`
ProviderCriterionID string `json:"providerCriterionId"`
Outcomes []struct {
ProviderOutcomeID string `json:"providerOutcomeId"`
ProviderID int `json:"providerId"`
ProviderOfferID string `json:"providerOfferId"`
Label string `json:"label"`
OddsAmerican string `json:"oddsAmerican"`
OddsDecimal float64 `json:"oddsDecimal"`
OddsDecimalDisplay string `json:"oddsDecimalDisplay"`
OddsFractional string `json:"oddsFractional"`
Line float64 `json:"line"`
Main bool `json:"main"`
} `json:"outcomes"`
OfferUpdateState string `json:"offerUpdateState"`
OfferSequence int `json:"offerSequence"`
Source string `json:"source"`
}
18 changes: 18 additions & 0 deletions dtos/mongoModels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dtos

type MongoPromotionRecords []MongoPromotionRecord

type MongoPromotionRecord struct {
EventName string
Spread []MongoGameLineRecord
Moneyline []MongoGameLineRecord
Totals []MongoGameLineRecord
}

type MongoGameLineRecord struct {
Book string
LineChoice string
Line string
LineOdds string
LineDecimal float64
}
Loading

0 comments on commit e4e53e3

Please sign in to comment.