-
Notifications
You must be signed in to change notification settings - Fork 1
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 #2 from CudoVentures/Change-APR-Calc
Update APR calculations
- Loading branch information
Showing
9 changed files
with
155 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ | |
# Go workspace file | ||
go.work | ||
|
||
cmd/stats-service/stats-service | ||
cmd/stats-service/stats-service | ||
|
||
/stats-service |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package distribution | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"net/http" | ||
) | ||
|
||
type client struct { | ||
Url string | ||
} | ||
|
||
func NewRestClient(url string) *client { | ||
return &client{Url: url} | ||
} | ||
|
||
func (c client) GetParams(ctx context.Context) (ParametersResponse, error) { | ||
respStr, err := c.get(ctx, "/distribution/parameters") | ||
if err != nil { | ||
return ParametersResponse{}, err | ||
} | ||
|
||
var res parametersResult | ||
if err := json.Unmarshal([]byte(respStr), &res); err != nil { | ||
return ParametersResponse{}, err | ||
} | ||
|
||
return res.Result, nil | ||
} | ||
|
||
func (c client) get(ctx context.Context, uri string) (string, error) { | ||
getReq, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s%s", c.Url, uri), nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
resp, err := http.DefaultClient.Do(getReq) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
defer resp.Body.Close() | ||
body, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(body), nil | ||
} | ||
|
||
type parametersResult struct { | ||
Result ParametersResponse `json:"result"` | ||
} | ||
|
||
type ParametersResponse struct { | ||
CommunityTax string `json:"community_tax"` | ||
} |
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