Skip to content

Commit

Permalink
Merge pull request #4 from BlockIo/get-address-example
Browse files Browse the repository at this point in the history
New examples added
  • Loading branch information
doersf authored Sep 3, 2020
2 parents 888acb4 + 7d65520 commit 283c481
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/get_address/get_address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"fmt"
"github.com/joho/godotenv"
"github.com/go-resty/resty/v2"
"os"
)

func main(){
godotenv.Load(".env")
apiKey := os.Getenv("API_KEY")
restClient := resty.New()

rawGetAddressRes, _ := restClient.R().
Get("https://block.io/api/v2/get_new_address?api_key=" + apiKey)

fmt.Println("get_new_address response:")
fmt.Print(rawGetAddressRes)
}
8 changes: 8 additions & 0 deletions examples/get_address/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module block-io/block_io-go/examples/get_address

go 1.12

require (
github.com/go-resty/resty/v2 v2.3.0
github.com/joho/godotenv v1.3.0
)
10 changes: 10 additions & 0 deletions examples/get_address/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
21 changes: 21 additions & 0 deletions examples/get_balance/get_balance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"fmt"
"github.com/go-resty/resty/v2"
"github.com/joho/godotenv"
"os"
)

func main(){
godotenv.Load(".env")
apiKey := os.Getenv("API_KEY")
address := os.Getenv("ADDRESS")
restClient := resty.New()

rawGetAddressBalanceRes, _ := restClient.R().
Get("https://block.io/api/v2/get_address_balance?api_key=" + apiKey + "&address=" + address)

fmt.Println("get_address_balance response:")
fmt.Print(rawGetAddressBalanceRes)
}
8 changes: 8 additions & 0 deletions examples/get_balance/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module block-io/block_io-go/examples/get_balance

go 1.12

require (
github.com/go-resty/resty/v2 v2.3.0
github.com/joho/godotenv v1.3.0
)
10 changes: 10 additions & 0 deletions examples/get_balance/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

0 comments on commit 283c481

Please sign in to comment.