-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
8480039
commit 8e31b83
Showing
5 changed files
with
73 additions
and
20 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,28 @@ | ||
package goingecko | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/JulianToledano/goingecko/assetPlatforms" | ||
"net/url" | ||
) | ||
|
||
func (c *Client) AssetPlatforms(filter string) (*assetPlatforms.AssetPlatforms, error) { | ||
params := url.Values{} | ||
|
||
if filter != "" { | ||
params.Add("filter", filter) | ||
} | ||
|
||
rUrl := fmt.Sprintf("%s?%s", assetPlatformsURL, params.Encode()) | ||
resp, err := c.MakeReq(rUrl) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var data *assetPlatforms.AssetPlatforms | ||
err = json.Unmarshal(resp, &data) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return data, 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,11 @@ | ||
package assetPlatforms | ||
|
||
type AssetPlatforms []Asset | ||
|
||
type Asset struct { | ||
ID string `json:"id"` | ||
ChainIdentifier int64 `json:"chain_identifier"` | ||
Name string `json:"name"` | ||
ShortName string `json:"shortName"` | ||
NativeCoinId string `json:"native_coin_id"` | ||
} |
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,19 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/JulianToledano/goingecko" | ||
"testing" | ||
) | ||
|
||
func TestAssetPlatforms(t *testing.T) { | ||
|
||
cgClient := goingecko.NewClient(nil) | ||
|
||
assetData, err := cgClient.AssetPlatforms("") | ||
if assetData == nil { | ||
t.Errorf("Error") | ||
} | ||
if err != nil { | ||
t.Errorf("Error: %s", err) | ||
} | ||
} |