-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from dwarvesf/feat/bot-statuses
feat: bot statuses
- Loading branch information
Showing
10 changed files
with
132 additions
and
4 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,51 @@ | ||
package icy | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/dwarvesf/fortress-discord/pkg/model" | ||
) | ||
|
||
type Icy struct { | ||
baseURL string | ||
httpClient *http.Client | ||
} | ||
|
||
func New(baseURL string) IcyAdapter { | ||
return &Icy{ | ||
baseURL: baseURL, | ||
httpClient: &http.Client{}, | ||
} | ||
} | ||
|
||
func (i *Icy) GetBTCTreasury() (*model.IcyWeb3BigIntResponse, error) { | ||
resp, err := i.httpClient.Get(fmt.Sprintf("%s/api/v1/oracle/treasury-btc", i.baseURL)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
var result model.IcyWeb3BigIntResponse | ||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &result, nil | ||
} | ||
|
||
func (i *Icy) GetIcyRate() (*model.IcyWeb3BigIntResponse, error) { | ||
resp, err := i.httpClient.Get(fmt.Sprintf("%s/api/v1/oracle/icy-btc-ratio", i.baseURL)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
var result model.IcyWeb3BigIntResponse | ||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &result, 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,8 @@ | ||
package icy | ||
|
||
import "github.com/dwarvesf/fortress-discord/pkg/model" | ||
|
||
type IcyAdapter interface { | ||
GetBTCTreasury() (*model.IcyWeb3BigIntResponse, error) | ||
GetIcyRate() (*model.IcyWeb3BigIntResponse, error) | ||
} |
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
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
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