From 27d56526689d8a251f2cea9d1473f1a473b203b9 Mon Sep 17 00:00:00 2001 From: Wasiq Nazir Date: Fri, 4 Sep 2020 02:49:45 +0500 Subject: [PATCH 1/2] get new address example added --- examples/get_address/get_address.go | 20 ++++++++++++++++++++ examples/get_address/go.mod | 8 ++++++++ examples/get_address/go.sum | 10 ++++++++++ go.sum | 3 +++ 4 files changed, 41 insertions(+) create mode 100644 examples/get_address/get_address.go create mode 100644 examples/get_address/go.mod create mode 100644 examples/get_address/go.sum diff --git a/examples/get_address/get_address.go b/examples/get_address/get_address.go new file mode 100644 index 0000000..050fccc --- /dev/null +++ b/examples/get_address/get_address.go @@ -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) +} diff --git a/examples/get_address/go.mod b/examples/get_address/go.mod new file mode 100644 index 0000000..5958878 --- /dev/null +++ b/examples/get_address/go.mod @@ -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 +) diff --git a/examples/get_address/go.sum b/examples/get_address/go.sum new file mode 100644 index 0000000..6f208c0 --- /dev/null +++ b/examples/get_address/go.sum @@ -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= diff --git a/go.sum b/go.sum index a5b4311..1c9bf2a 100644 --- a/go.sum +++ b/go.sum @@ -10,11 +10,14 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= From 7d65520529744fd179b42b2f695657681475b88f Mon Sep 17 00:00:00 2001 From: Wasiq Nazir Date: Fri, 4 Sep 2020 02:56:20 +0500 Subject: [PATCH 2/2] get address balance example added --- examples/get_balance/get_balance.go | 21 +++++++++++++++++++++ examples/get_balance/go.mod | 8 ++++++++ examples/get_balance/go.sum | 10 ++++++++++ go.sum | 3 --- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 examples/get_balance/get_balance.go create mode 100644 examples/get_balance/go.mod create mode 100644 examples/get_balance/go.sum diff --git a/examples/get_balance/get_balance.go b/examples/get_balance/get_balance.go new file mode 100644 index 0000000..a0d862d --- /dev/null +++ b/examples/get_balance/get_balance.go @@ -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) +} diff --git a/examples/get_balance/go.mod b/examples/get_balance/go.mod new file mode 100644 index 0000000..1e1a0c0 --- /dev/null +++ b/examples/get_balance/go.mod @@ -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 +) diff --git a/examples/get_balance/go.sum b/examples/get_balance/go.sum new file mode 100644 index 0000000..6f208c0 --- /dev/null +++ b/examples/get_balance/go.sum @@ -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= diff --git a/go.sum b/go.sum index 1c9bf2a..a5b4311 100644 --- a/go.sum +++ b/go.sum @@ -10,14 +10,11 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=