Go Package to easily consume the Dolarpy API.
https://github.com/melizeche/dolarPy - by melizeche
go get github.com/bitebait/dolarpy-go
package main
import (
"encoding/json"
"fmt"
"github.com/bitebait/dolarpy-go"
)
func main() {
allData, err := dolarpy.All()
if err != nil {
fmt.Printf("Failed to get all providers data: %v\n", err)
return
}
fmt.Println(allData)
providers, err := dolarpy.Providers()
if err != nil {
fmt.Printf("Failed to get providers names: %v\n", err)
return
}
fmt.Println(providers)
reference, err := dolarpy.Reference()
if err != nil {
fmt.Printf("Failed to get reference value: %v\n", err)
return
}
fmt.Println(reference)
purchase, err := dolarpy.Purchase("cambioschaco")
if err != nil {
fmt.Printf("Failed to get purchase value from 'cambioschaco': %v\n", err)
return
}
fmt.Println(purchase)
sale, err := dolarpy.Sale("cambioschaco")
if err != nil {
fmt.Printf("Failed to get sale value from 'cambioschaco': %v\n", err)
return
}
fmt.Println(sale)
data, err := dolarpy.All()
if err != nil {
fmt.Printf("Failed to get all providers data: %v\n", err)
return
}
j, _ := json.Marshal(data)
fmt.Println(string(j))
for provider, values := range data {
purchase := values["compra"]
sale := values["venta"]
fmt.Printf("Provider: %s - [Purchase: %.2f Sale: %.2f]\n", provider, purchase, sale)
}
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
This project is licensed under the terms of the MIT License - see the LICENSE file for details