-
Notifications
You must be signed in to change notification settings - Fork 0
/
9ecd728d.c175ba02.js
1 lines (1 loc) · 7.9 KB
/
9ecd728d.c175ba02.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[92],{192: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),i=(n(0),n(250)),o=n(257),c=n(258),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:"/documentation/docs/Instalacao/python",sidebar_label:"Python",sidebar:"someSidebar",previous:{title:"NodeJS",permalink:"/documentation/docs/Instalacao/node"},next:{title:"Java",permalink:"/documentation/docs/Instalacao/java"}},p=[{value:'Installing via <a href="https://pypi.org/project/pip/">PIP</a>',id:"installing-via-pip",children:[]},{value:"Tested with",id:"tested-with",children:[]},{value:"Basic use",id:"basic-use",children:[]},{value:"Exemplos",id:"exemplos",children:[]},{value:"Tests",id:"tests",children:[]}],u={rightToc:p};function b(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},u,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h1",{className:"titulo"},"Python"),Object(i.b)("div",{className:"subtitulo"},Object(i.b)("p",null,"Our API is ",Object(i.b)("a",{href:"https://en.wikipedia.org/wiki/Representational_state_transfer"},"RESTful"),"\nand responds in ",Object(i.b)("a",{href:"https://www.json.org/json-en.html"},"JSON"),". Gerencianet uses ",Object(i.b)("a",{href:"https://oauth.net/"},"OAuth")," to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically."),Object(i.b)("p",null,"Below, check out the procedures for installing the Gerencianet SDK in ",Object(i.b)("a",{href:"https://github.com/gerencianet/gn-api-sdk-python",target:"_blank",title:"Link Externo"},"Python"),":"),Object(i.b)("h2",{id:"installing-via-pip"},"Installing via ",Object(i.b)("a",{href:"https://pypi.org/project/pip/"},"PIP")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),"$ pip install gerencianet\n")),Object(i.b)("h2",{id:"tested-with"},"Tested with"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"Python ",Object(i.b)("inlineCode",{parentName:"li"},"2.7"),", ",Object(i.b)("inlineCode",{parentName:"li"},"3.3")," ,",Object(i.b)("inlineCode",{parentName:"li"},"3.4")," e ",Object(i.b)("inlineCode",{parentName:"li"},"3.5")," ")),Object(i.b)("h2",{id:"basic-use"},"Basic use"),Object(i.b)(o.a,{defaultValue:"py",values:[{label:"Python",value:"py"}],mdxType:"Tabs"},Object(i.b)(c.a,{value:"py",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.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(i.b)("h2",{id:"exemplos"},"Exemplos"),Object(i.b)("p",null,"You can run the examples inside ",Object(i.b)("inlineCode",{parentName:"p"},"examples")," with ",Object(i.b)("inlineCode",{parentName:"p"},"$ python examples/example.py"),":"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),"$ python examples/create_charge.py\n")),Object(i.b)("h2",{id:"tests"},"Tests"),Object(i.b)("p",null,"Remember to set the correct credentials inside ",Object(i.b)("inlineCode",{parentName:"p"},"examples/credentials.py")," before ",Object(i.b)("inlineCode",{parentName:"p"},"run"),"."),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),"$ py.test\n"))))}b.isMDXComponent=!0},250: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 i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(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 c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(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={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[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):c(c({},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,i=e.originalType,o=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=p(n),d=a,m=u["".concat(o,".").concat(d)]||u[d]||b[d]||i;return n?r.a.createElement(m,c(c({ref:t},s),{},{components:n})):r.a.createElement(m,c({ref:t},s))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=d;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var s=2;s<i;s++)o[s]=n[s];return r.a.createElement.apply(null,o)}return r.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},254: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}},255:function(e,t,n){"use strict";var a=n(0);const r=Object(a.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});t.a=r},256:function(e,t,n){"use strict";var a=n(0),r=n(255);t.a=function(){return Object(a.useContext)(r.a)}},257:function(e,t,n){"use strict";var a=n(0),r=n.n(a),i=n(256),o=n(254),c=n(92),l=n.n(c);const s=37,p=39;t.a=function(e){const{block:t,children:n,defaultValue:c,values:u,groupId:b}=e,{tabGroupChoices:d,setTabGroupChoices:m}=Object(i.a)(),[f,h]=Object(a.useState)(c);if(null!=b){const e=d[b];null!=e&&e!==f&&u.some(t=>t.value===e)&&h(e)}const O=e=>{h(e),null!=b&&m(b,e)},y=[];return r.a.createElement("div",null,r.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(o.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(o.a)("tabs__item",l.a.tabItem,{"tabs__item--active":f===e}),key:e,ref:e=>y.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)}})(y,e.target,e),onFocus:()=>O(e),onClick:()=>O(e)},t))),r.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(n).filter(e=>e.props.value===f)[0]))}},258: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)}}}]);