{"_id":"58c29e31b5cbed190027a70a","project":"575aeffae12cf20e002f306c","user":"57601a13af3e090e00108059","parentDoc":null,"__v":0,"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":1,"slug":"instalação-da-api-sdks","title":"Instalação da API (SDK's)"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-03-10T12:38:09.009Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":3,"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 Python 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 Python:\n\n## Instalando via <a href=\"https://pypi.python.org/pypi/pip\" target=\"_blank\">Pip</a>\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ pip install gerencianet\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n## Testado com\n\n- Python <code>2.7</code>, <code>3.3</code>, <code>3.4</code> e <code>3.5</code>\n\n## Uso Básico\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# encoding: utf-8\\n\\nfrom gerencianet import Gerencianet\\n\\ncredentials = {\\n    'client_id': 'client_id',\\n    'client_secret': 'client_secret',\\n    'sandbox': True\\n}\\n\\ngn = Gerencianet(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\\nprint gn.create_charge(body=body)\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n## Exemplos\n\nVocê pode executar os exemplos dentro de <code>examples</code> com <code>$ python examples/example.py</code>:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ python examples/create_charge.py\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nLembre-se de definir as credenciais corretas dentro de <code>examples/credentials.py</code> antes de executar.\n\n## Testes\n\nPara executar os testes, basta executar *pytest*:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ py.test\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]","excerpt":"Você está em: *\"Instalação da API (SDK's) > Python\"*","slug":"instalacao-sdk-python","type":"basic","title":"Python"}

Python

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

[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 Python já está preparada para realizar essa autenticação automaticamente.</p>" } [/block] A seguir, confira os procedimentos para instalação da SDK da Gerencianet em Python: ## Instalando via <a href="https://pypi.python.org/pypi/pip" target="_blank">Pip</a> [block:code] { "codes": [ { "code": "$ pip install gerencianet", "language": "python" } ] } [/block] ## Testado com - Python <code>2.7</code>, <code>3.3</code>, <code>3.4</code> e <code>3.5</code> ## Uso Básico [block:code] { "codes": [ { "code": "# encoding: utf-8\n\nfrom gerencianet import Gerencianet\n\ncredentials = {\n 'client_id': 'client_id',\n 'client_secret': 'client_secret',\n 'sandbox': True\n}\n\ngn = Gerencianet(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\nprint gn.create_charge(body=body)", "language": "python" } ] } [/block] ## Exemplos Você pode executar os exemplos dentro de <code>examples</code> com <code>$ python examples/example.py</code>: [block:code] { "codes": [ { "code": "$ python examples/create_charge.py", "language": "python" } ] } [/block] Lembre-se de definir as credenciais corretas dentro de <code>examples/credentials.py</code> antes de executar. ## Testes Para executar os testes, basta executar *pytest*: [block:code] { "codes": [ { "code": "$ py.test", "language": "python" } ] } [/block]