-
Notifications
You must be signed in to change notification settings - Fork 0
/
9ecd728d.fc5b485d.js
1 lines (1 loc) · 7.82 KB
/
9ecd728d.fc5b485d.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[81],{181:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return l})),n.d(t,"metadata",(function(){return s})),n.d(t,"rightToc",(function(){return p})),n.d(t,"default",(function(){return b}));var a=n(2),r=n(6),o=(n(0),n(229)),c=n(236),i=n(237),l={id:"python",title:"Python",hide_title:!0,sidebar_label:"Python"},s={id:"Instalacao/python",isDocsHomePage:!1,title:"Python",description:"Python",source:"@site/docs\\Instalacao\\Python.md",permalink:"/docs/Instalacao/python",sidebar_label:"Python",sidebar:"someSidebar",previous:{title:"NodeJS",permalink:"/docs/Instalacao/node"},next:{title:"Java",permalink:"/docs/Instalacao/java"}},p=[{value:'Instalando via <a href="https://pypi.org/project/pip/">PIP</a>',id:"instalando-via-pip",children:[]},{value:"Testado com",id:"testado-com",children:[]},{value:"Uso B\xe1sico",id:"uso-b\xe1sico",children:[]},{value:"Exemplos",id:"exemplos",children:[]},{value:"Testes",id:"testes",children:[]}],u={rightToc:p};function b(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},u,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h1",{className:"titulo"},"Python"),Object(o.b)("div",{className:"subtitulo"},Object(o.b)("p",null,"Nossa API \xe9 ",Object(o.b)("a",{href:"https://en.wikipedia.org/wiki/Representational_state_transfer"},"RESTful"),"\ne responde em ",Object(o.b)("a",{href:"https://www.json.org/json-en.html"},"JSON"),". A Gerencianet utiliza ",Object(o.b)("a",{href:"https://oauth.net/"},"OAuth")," para fornecer acesso autorizado \xe0 API.\nNossa SDK de Python j\xe1 est\xe1 preparada para realizar essa autentica\xe7\xe3o automaticamente."),Object(o.b)("p",null,"A seguir, confira os procedimentos para instala\xe7\xe3o da SDK da Gerencianet em Python:"),Object(o.b)("h2",{id:"instalando-via-pip"},"Instalando via ",Object(o.b)("a",{href:"https://pypi.org/project/pip/"},"PIP")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"$ pip install gerencianet\n")),Object(o.b)("h2",{id:"testado-com"},"Testado com"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"Python ",Object(o.b)("inlineCode",{parentName:"li"},"2.7"),", ",Object(o.b)("inlineCode",{parentName:"li"},"3.3")," ,",Object(o.b)("inlineCode",{parentName:"li"},"3.4")," e ",Object(o.b)("inlineCode",{parentName:"li"},"3.5")," ")),Object(o.b)("h2",{id:"uso-b\xe1sico"},"Uso B\xe1sico"),Object(o.b)(c.a,{defaultValue:"py",values:[{label:"Python",value:"py"}],mdxType:"Tabs"},Object(o.b)(i.a,{value:"py",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"# 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")))),Object(o.b)("h2",{id:"exemplos"},"Exemplos"),Object(o.b)("p",null,"Voc\xea pode executar os exemplos dentro de ",Object(o.b)("inlineCode",{parentName:"p"},"examples")," com ",Object(o.b)("inlineCode",{parentName:"p"},"$ python examples/example.py"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"$ python examples/create_charge.py\n")),Object(o.b)("h2",{id:"testes"},"Testes"),Object(o.b)("p",null,"Lembre-se de definir as credenciais corretas dentro de ",Object(o.b)("inlineCode",{parentName:"p"},"examples/credentials.py")," antes de ",Object(o.b)("inlineCode",{parentName:"p"},"executar"),"."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"$ py.test\n"))))}b.isMDXComponent=!0},229:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},o=Object.keys(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),p=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=p(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},d=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,c=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=p(n),d=a,m=u["".concat(c,".").concat(d)]||u[d]||b[d]||o;return n?r.a.createElement(m,i(i({ref:t},s),{},{components:n})):r.a.createElement(m,i({ref:t},s))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,c=new Array(o);c[0]=d;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:a,c[1]=i;for(var s=2;s<o;s++)c[s]=n[s];return r.a.createElement.apply(null,c)}return r.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},233:function(e,t,n){"use strict";function a(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=a(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}t.a=function(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=a(e))&&(r&&(r+=" "),r+=t);return r}},234:function(e,t,n){"use strict";var a=n(0);const r=Object(a.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});t.a=r},235:function(e,t,n){"use strict";var a=n(0),r=n(234);t.a=function(){return Object(a.useContext)(r.a)}},236:function(e,t,n){"use strict";var a=n(0),r=n.n(a),o=n(235),c=n(233),i=n(92),l=n.n(i);const s=37,p=39;t.a=function(e){const{block:t,children:n,defaultValue:i,values:u,groupId:b}=e,{tabGroupChoices:d,setTabGroupChoices:m}=Object(o.a)(),[f,O]=Object(a.useState)(i);if(null!=b){const e=d[b];null!=e&&e!==f&&u.some(t=>t.value===e)&&O(e)}const y=e=>{O(e),null!=b&&m(b,e)},h=[];return r.a.createElement("div",null,r.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(c.a)("tabs",{"tabs--block":t})},u.map(({value:e,label:t})=>r.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":f===e,className:Object(c.a)("tabs__item",l.a.tabItem,{"tabs__item--active":f===e}),key:e,ref:e=>h.push(e),onKeyDown:e=>((e,t,n)=>{switch(n.keyCode){case p:((e,t)=>{const n=e.indexOf(t)+1;e[n]?e[n].focus():e[0].focus()})(e,t);break;case s:((e,t)=>{const n=e.indexOf(t)-1;e[n]?e[n].focus():e[e.length-1].focus()})(e,t)}})(h,e.target,e),onFocus:()=>y(e),onClick:()=>y(e)},t))),r.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(n).filter(e=>e.props.value===f)[0]))}},237:function(e,t,n){"use strict";var a=n(0),r=n.n(a);t.a=function(e){return r.a.createElement("div",null,e.children)}}}]);