Skip to content

bitebait/dolarpy-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dolarpy-go

Go Package to easily consume the Dolarpy API.

https://github.com/melizeche/dolarPy - by melizeche

Install

go get github.com/bitebait/dolarpy-go

Usage Example

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)
    }
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

This project is licensed under the terms of the MIT License - see the LICENSE file for details