Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bitebait committed Sep 25, 2023
1 parent ffca19d commit 3ff8dec
Showing 1 changed file with 53 additions and 18 deletions.
71 changes: 53 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,64 @@ go get github.com/bitebait/dolarpy-go
package main

import (
"encoding/json"
"fmt"
"encoding/json"
"fmt"

"github.com/bitebait/dolarpy-go"
"github.com/bitebait/dolarpy-go"
)

func main() {
dolarpy.All() // returns all providers data
dolarpy.Providers() // returns providers names
dolarpy.Reference() // returns reference value from 'bcp'
dolarpy.Purchase("cambioschaco") // returns purchase value from 'cambioschaco' (default: 'bcp)
dolarpy.Sale("cambioschaco") // returns sale value from 'cambioschaco' (default: 'bcp)

// JSON Example
j, _ := json.Marshal(dolarpy.All())
fmt.Println(string(j))

// For Loop Example
data := dolarpy.All()
for key, value := range data {
fmt.Printf("Provider: %s - [Purchase: %.2f Sale: %.2f]\n", key, value["compra"], value["venta"])
}
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
Expand Down

0 comments on commit 3ff8dec

Please sign in to comment.