From 654a82cd11714775a7286d4613fa8d0489511ad1 Mon Sep 17 00:00:00 2001 From: Riandy Rahman Nugraha Date: Fri, 3 Dec 2021 20:24:52 +0300 Subject: [PATCH] fix: update zatca-sdk-go to latest update, update sample usage code in README.md --- README.md | 14 +++++++------- examples/qrcode_generator/.gitignore | 1 + examples/qrcode_generator/go.mod | 2 +- examples/qrcode_generator/go.sum | 2 ++ examples/qrcode_generator/main.go | 22 +++++++--------------- 5 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 examples/qrcode_generator/.gitignore diff --git a/README.md b/README.md index ae2767c..1cb49d4 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,12 @@ import ( func main() { // encode data using TLV method to get code hash - hash, err := qrCode.EncodeTLV(qrcode.Data{ - SellerName: "Bobs Records", - SellerTaxNumber: "310122393500003", - Timestamp: time.Date(2022, 04, 25, 15, 30, 00, 00, time.UTC), - InvoiceTotal: 1000, - TotalVAT: 150, + hash, err := qrcode.EncodeTLV(qrcode.Data{ + SellerName: "Bobs Records", + SellerTaxNumber: "310122393500003", + Timestamp: time.Date(2022, 04, 25, 15, 30, 00, 00, time.UTC), + InvoiceTotal: 1000, + TotalVAT: 150, }) if err != nil { log.Fatalf("unable to encode TLV due: %v", err) @@ -41,7 +41,7 @@ func main() { fmt.Println("hash data:", hash) // decode hash using TLV method to get data - data, err := qrcode.DecodeTLV("AR3Yp9mE2KzZiNin2YfYsdmKINin2YTYudix2KjZigIPMzEwMTIyMzkzNTAwMDAzAxQyMDIyLTA0LTI1VDE1OjMwOjAwWgQHMTAwMC4wMAUGMTUwLjAw") + data, err := qrcode.DecodeTLV(hash) if err != nil { log.Fatalf("unable to decode TLV due: %v", err) } diff --git a/examples/qrcode_generator/.gitignore b/examples/qrcode_generator/.gitignore new file mode 100644 index 0000000..3a46856 --- /dev/null +++ b/examples/qrcode_generator/.gitignore @@ -0,0 +1 @@ +qr.png \ No newline at end of file diff --git a/examples/qrcode_generator/go.mod b/examples/qrcode_generator/go.mod index 6ad8e7f..e4824ea 100644 --- a/examples/qrcode_generator/go.mod +++ b/examples/qrcode_generator/go.mod @@ -3,6 +3,6 @@ module qrcode_generator go 1.16 require ( - github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211202074435-18341e584c9c // indirect + github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211203170357-4c1189a98eb1 // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect ) diff --git a/examples/qrcode_generator/go.sum b/examples/qrcode_generator/go.sum index 66ada78..dde9d46 100644 --- a/examples/qrcode_generator/go.sum +++ b/examples/qrcode_generator/go.sum @@ -2,5 +2,7 @@ github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211202071118-b3ec4cfc3c60 h1:bXw3 github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211202071118-b3ec4cfc3c60/go.mod h1:Pwl7G1DblSnj27OT7dMMuV20HegghOqdznkq8PoQLms= github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211202074435-18341e584c9c h1:VxrAZ7sHbprf2tNa5uZqAXSuCXZfQLBCKK19OH5z8nk= github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211202074435-18341e584c9c/go.mod h1:Pwl7G1DblSnj27OT7dMMuV20HegghOqdznkq8PoQLms= +github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211203170357-4c1189a98eb1 h1:MqeFlLI5spRRm+3aYMb7JOOP8O0kywCvl7ni+6rB2L4= +github.com/Haraj-backend/zatca-sdk-go v0.0.0-20211203170357-4c1189a98eb1/go.mod h1:Pwl7G1DblSnj27OT7dMMuV20HegghOqdznkq8PoQLms= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= diff --git a/examples/qrcode_generator/main.go b/examples/qrcode_generator/main.go index 848fdb9..74dabda 100644 --- a/examples/qrcode_generator/main.go +++ b/examples/qrcode_generator/main.go @@ -9,24 +9,16 @@ import ( ) func main() { - input := qrcode.QRCodeData{ - SellerName: "Bobs Records", - SellerTRN: "310122393500003", - Timestamp: time.Date(2022, 04, 25, 15, 30, 00, 00, time.UTC), - InvoiceTotal: 1000, - TotalVAT: 150, - } - - qrCode, err := qrcode.NewQRCode(input) - if err != nil { - log.Fatalf("unable to initialize new qrcode due: %v", err) - } - - hash, err := qrCode.EncodeTLV() + hash, err := qrcode.EncodeTLV(qrcode.Data{ + SellerName: "Bobs Records", + SellerTaxNumber: "310122393500003", + Timestamp: time.Date(2022, 04, 25, 15, 30, 00, 00, time.UTC), + InvoiceTotal: 1000, + TotalVAT: 150, + }) if err != nil { log.Fatalf("unable to encode TLV due: %v", err) } - err = goqrcode.WriteFile(hash, goqrcode.Medium, 256, "qr.png") if err != nil { log.Fatalf("unable to encode TLV due: %v", err)