summaryrefslogtreecommitdiffstats
path: root/schema.go
diff options
context:
space:
mode:
Diffstat (limited to 'schema.go')
-rw-r--r--schema.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/schema.go b/schema.go
new file mode 100644
index 0000000..ec3dfee
--- /dev/null
+++ b/schema.go
@@ -0,0 +1,39 @@
+package exchange
+
+import (
+ "fmt"
+
+ "github.com/shopspring/decimal"
+)
+
+type response[T any] struct {
+ Data T
+ Status status
+}
+
+type status struct {
+ Error string `json:"error_message"`
+}
+
+type apiError struct {
+ Status status
+}
+
+func (e apiError) Error() string {
+ return fmt.Sprintf("currency exchange api error: %v", e.Status.Error)
+}
+
+type priceConversionQuery struct {
+ Amount uint `url:"amount"`
+ From string `url:"symbol"`
+ To string `url:"convert"`
+}
+
+type priceConversion struct {
+ Id uint
+ Quote map[string]price
+}
+
+type price struct {
+ Price decimal.Decimal
+}