{"_id":"5a0ad3621f94d60024ffe261","project":"575aeffae12cf20e002f306c","version":{"_id":"575aeffae12cf20e002f306f","project":"575aeffae12cf20e002f306c","__v":30,"createdAt":"2016-06-10T16:51:06.080Z","releaseDate":"2016-06-10T16:51:06.080Z","categories":["575aeffae12cf20e002f3070","575af039a083950e004487f7","575af5c7ba4ed70e000ca288","57602fe5b82256240055c657","57602ff6c811102000cef302","576030909b1a9a220067ca40","57604518b82256240055c722","5761a63d207db7170022fc14","5761b9a2b65324200072d79e","576832939f0bf4190014ffdf","576832c09f0bf4190014ffe1","576832cba151c10e004316f0","576832d5bb15f40e00a288ec","576832e107b1f30e0039c645","577680bf3cee3a0e00a000bc","577ff3b1ff48990e000c6806","5783f78c5cbce30e0074e2b7","5783f86292edb92200e6101c","5783f86dbfbba719003f0d8b","5783f8755cbce30e0074e2b8","5783f8b65cbce30e0074e2b9","5783f8bf5cbce30e0074e2ba","5783f8d8ce802f0e0087d574","578529f887c9280e0090394b","57852aeb87c9280e0090394d","57866e72b2f4060e00fa39ca","57ab6d5c39c2fd1900191879","57f39451ab0ee12000bef915","582499a0d90fa027009b259e","58c29df1258e5a1900b60478"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"2016","version_clean":"1.0.0","version":"1"},"category":{"_id":"58c29df1258e5a1900b60478","project":"575aeffae12cf20e002f306c","version":"575aeffae12cf20e002f306f","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-03-10T12:37:05.075Z","from_sync":false,"order":2,"slug":"instalação-da-api-sdks","title":"Instalação da API (SDK's)"},"user":"57601a13af3e090e00108059","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-11-14T11:28:34.714Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"[block:html]\n{\n  \"html\": \"<p>Nossa API é <a href=\\\"https://en.wikipedia.org/wiki/Representational_state_transfer\\\" target=\\\"_blank\\\" title=\\\"Link Externo\\\">RESTful</a> e responde em <a href=\\\"http://www.json.org/\\\" target=\\\"_blank\\\" title=\\\"Link Externo\\\">JSON</a>. A Gerencianet utiliza <a href=\\\"http://oauth.net/\\\" target=\\\"_blank\\\" title=\\\"Link Externo\\\">OAuth</a> para fornecer acesso autorizado à <abbr title=\\\"Application Programming Interface\\\">API</abbr>. Nossa SDK de Go já está preparada para realizar essa autenticação automaticamente.</p>\"\n}\n[/block]\nA seguir, confira os procedimentos para instalação da SDK da Gerencianet em Go:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet\",\n      \"language\": \"go\"\n    }\n  ]\n}\n[/block]\n# Testado com\n\n- <code>Go 1.8</code>\n\n\n# Uso básico\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import (\\n    \\\"github.com/gerencianet/gn-api-sdk-go/gerencianet\\\"\\n)\\n\\ncredentials := map[string]interface{} {\\n    \\\"client_id\\\": \\\"client_id\\\",\\n    \\\"client_secret\\\": \\\"client_secret\\\",\\n    \\\"sandbox\\\": true,\\n    \\\"timeout\\\": 10,\\n}\\n\\ngn := gerencianet.NewGerencianet(credentials)\\n\\nbody = {\\n    \\\"items\\\": [{\\n        \\\"name\\\": \\\"Product 1\\\",\\n        \\\"value\\\": 1000,\\n        \\\"amount\\\": 2,\\n    }],\\n    \\\"shippings\\\": [{\\n        \\\"name\\\": \\\"Default Shipping Cost\\\",\\n        \\\"value\\\": 100,\\n    }]\\n}\\n\\nres, err := gn.CreateCharge(body)\",\n      \"language\": \"go\"\n    }\n  ]\n}\n[/block]\n<br>\n\n# Exemplos\n\nVocê pode rodar os exemplos dentro de <code>_examples</code> com <code>$ go run example.go</code>:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ go run charge/create_charge.go\",\n      \"language\": \"go\"\n    }\n  ]\n}\n[/block]\nBasta lembrar de definir as credenciais corretas dentro de <code>_examples/configs.go</code> antes de serem executadas.\n\n# Testes\n\nPara executar os testes, basta executar:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ go test\",\n      \"language\": \"go\"\n    }\n  ]\n}\n[/block]","excerpt":"Você está em: *\"Instalação da API (SDK's) > Go\"*","slug":"instalacao-sdk-go","type":"basic","title":"Go"}

Go

Você está em: *"Instalação da API (SDK's) > Go"*

[block:html] { "html": "<p>Nossa API é <a href=\"https://en.wikipedia.org/wiki/Representational_state_transfer\" target=\"_blank\" title=\"Link Externo\">RESTful</a> e responde em <a href=\"http://www.json.org/\" target=\"_blank\" title=\"Link Externo\">JSON</a>. A Gerencianet utiliza <a href=\"http://oauth.net/\" target=\"_blank\" title=\"Link Externo\">OAuth</a> para fornecer acesso autorizado à <abbr title=\"Application Programming Interface\">API</abbr>. Nossa SDK de Go já está preparada para realizar essa autenticação automaticamente.</p>" } [/block] A seguir, confira os procedimentos para instalação da SDK da Gerencianet em Go: [block:code] { "codes": [ { "code": "$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet", "language": "go" } ] } [/block] # Testado com - <code>Go 1.8</code> # Uso básico [block:code] { "codes": [ { "code": "import (\n \"github.com/gerencianet/gn-api-sdk-go/gerencianet\"\n)\n\ncredentials := map[string]interface{} {\n \"client_id\": \"client_id\",\n \"client_secret\": \"client_secret\",\n \"sandbox\": true,\n \"timeout\": 10,\n}\n\ngn := gerencianet.NewGerencianet(credentials)\n\nbody = {\n \"items\": [{\n \"name\": \"Product 1\",\n \"value\": 1000,\n \"amount\": 2,\n }],\n \"shippings\": [{\n \"name\": \"Default Shipping Cost\",\n \"value\": 100,\n }]\n}\n\nres, err := gn.CreateCharge(body)", "language": "go" } ] } [/block] <br> # Exemplos Você pode rodar os exemplos dentro de <code>_examples</code> com <code>$ go run example.go</code>: [block:code] { "codes": [ { "code": "$ go run charge/create_charge.go", "language": "go" } ] } [/block] Basta lembrar de definir as credenciais corretas dentro de <code>_examples/configs.go</code> antes de serem executadas. # Testes Para executar os testes, basta executar: [block:code] { "codes": [ { "code": "$ go test", "language": "go" } ] } [/block]