-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package model | ||
|
||
type LeagueResponse struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Type string `json:"type"` | ||
Logo string `json:"logo"` | ||
} | ||
|
||
type CountryResponse struct { | ||
Name string `json:"name"` | ||
Code string `json:"code"` | ||
Flag string `json:"flag"` | ||
} | ||
|
||
type SeassonResponse struct { | ||
Year int `json:"year"` | ||
Start string `json:"start"` | ||
End string `json:"end"` | ||
Current bool `json:"current"` | ||
} | ||
|
||
type CoverageResponse struct { | ||
Standings bool `json:"standings"` | ||
Players bool `json:"players"` | ||
TopScorers bool `json:"top_scorers"` | ||
TopAssists bool `json:"top_assists"` | ||
TopCards bool `json:"top_cards"` | ||
Injuries bool `json:"injuries"` | ||
Predictions bool `json:"predictions"` | ||
Odds bool `json:"odds"` | ||
} | ||
|
||
type FixturesResponse struct { | ||
Events bool `json:"events"` | ||
Lineups bool `json:"lineups"` | ||
StatisticsFixtures bool `json:"statistics_fixtures"` | ||
StatisticsPlayers bool `json:"statistics_players"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package telco | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"errors" | ||
"io" | ||
"net/http" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
type Telco struct { | ||
} | ||
|
||
func NewTelco() *Telco { | ||
return &Telco{} | ||
} | ||
|
||
type ITelco interface { | ||
} | ||
|
||
func (p *Telco) Token() ([]byte, error) { | ||
dataJson, err := json.Marshal(p) | ||
if err != nil { | ||
return nil, errors.New(err.Error()) | ||
} | ||
|
||
req, err := http.NewRequest(http.MethodPost, "", bytes.NewBuffer(dataJson)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
now := time.Now() | ||
timeStamp := strconv.Itoa(int(now.Unix())) | ||
|
||
req.Header.Add("Accept-Charset", "utf-8") | ||
req.Header.Add("X-Api-Key", "") | ||
req.Header.Add("X-Signature", "") | ||
req.Header.Add("X-Trxtime", timeStamp) | ||
|
||
tr := &http.Transport{ | ||
MaxIdleConns: 40, | ||
IdleConnTimeout: 60 * time.Second, | ||
DisableCompression: true, | ||
} | ||
|
||
client := &http.Client{ | ||
Timeout: 60 * time.Second, | ||
Transport: tr, | ||
} | ||
|
||
resp, err := client.Do(req) | ||
if err != nil { | ||
return nil, errors.New(err.Error()) | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return nil, errors.New(err.Error()) | ||
} | ||
|
||
return body, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package utils | ||
|
||
import ( | ||
"log" | ||
"os" | ||
) | ||
|
||
func GetEnv(key string) string { | ||
value := os.Getenv(key) | ||
if len(value) == 0 { | ||
log.Panicf("Error %v", key) | ||
} | ||
return value | ||
} |