Skip to content

Instantly share code, notes, and snippets.

@jpospychala
Created February 15, 2016 22:57
Show Gist options
  • Save jpospychala/82cf369be8a97111b5de to your computer and use it in GitHub Desktop.
Save jpospychala/82cf369be8a97111b5de to your computer and use it in GitHub Desktop.
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Valuto API</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"><style>@import url('https://fonts.googleapis.com/css?family=Roboto:400,700|Inconsolata|Raleway:200');.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}.right .hljs-comment{color:#969896}.right .css .hljs-class,.right .css .hljs-id,.right .css .hljs-pseudo,.right .hljs-attribute,.right .hljs-regexp,.right .hljs-tag,.right .hljs-variable,.right .html .hljs-doctype,.right .ruby .hljs-constant,.right .xml .hljs-doctype,.right .xml .hljs-pi,.right .xml .hljs-tag .hljs-title{color:#c66}.right .hljs-built_in,.right .hljs-constant,.right .hljs-literal,.right .hljs-number,.right .hljs-params,.right .hljs-pragma,.right .hljs-preprocessor{color:#de935f}.right .css .hljs-rule .hljs-attribute,.right .ruby .hljs-class .hljs-title{color:#f0c674}.right .hljs-header,.right .hljs-inheritance,.right .hljs-name,.right .hljs-string,.right .hljs-value,.right .ruby .hljs-symbol,.right .xml .hljs-cdata{color:#b5bd68}.right .css .hljs-hexcolor,.right .hljs-title{color:#8abeb7}.right .coffeescript .hljs-title,.right .hljs-function,.right .javascript .hljs-title,.right .perl .hljs-sub,.right .python .hljs-decorator,.right .python .hljs-title,.right .ruby .hljs-function .hljs-title,.right .ruby .hljs-title .hljs-keyword{color:#81a2be}.right .hljs-keyword,.right .javascript .hljs-function{color:#b294bb}.right .hljs{display:block;overflow-x:auto;background:#1d1f21;color:#c5c8c6;padding:.5em;-webkit-text-size-adjust:none}.right .coffeescript .javascript,.right .javascript .xml,.right .tex .hljs-formula,.right .xml .css,.right .xml .hljs-cdata,.right .xml .javascript,.right .xml .vbscript{opacity:.5}body{color:black;background:white;font:400 14px / 1.42 'Roboto',Helvetica,sans-serif}header{border-bottom:1px solid #f2f2f2;margin-bottom:12px}h1,h2,h3,h4,h5{color:black;margin:12px 0}h1 .permalink,h2 .permalink,h3 .permalink,h4 .permalink,h5 .permalink{margin-left:0;opacity:0;transition:opacity .25s ease}h1:hover .permalink,h2:hover .permalink,h3:hover .permalink,h4:hover .permalink,h5:hover .permalink{opacity:1}.triple h1 .permalink,.triple h2 .permalink,.triple h3 .permalink,.triple h4 .permalink,.triple h5 .permalink{opacity:.15}.triple h1:hover .permalink,.triple h2:hover .permalink,.triple h3:hover .permalink,.triple h4:hover .permalink,.triple h5:hover .permalink{opacity:.15}h1{font:200 36px 'Raleway',Helvetica,sans-serif;font-size:36px}h2{font:200 36px 'Raleway',Helvetica,sans-serif;font-size:30px}h3{font-size:100%;text-transform:uppercase}h5{font-size:100%;font-weight:normal}p{margin:0 0 10px}p.choices{line-height:1.6}a{color:#428bca;text-decoration:none}li p{margin:0}hr.split{border:0;height:1px;width:100%;padding-left:6px;margin:12px auto;background-image:linear-gradient(to right, rgba(0,0,0,0) 20%, rgba(0,0,0,0.2) 51.4%, rgba(255,255,255,0.2) 51.4%, rgba(255,255,255,0) 80%)}dl dt{float:left;width:130px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}dl dd{margin-left:150px}blockquote{color:rgba(0,0,0,0.5);font-size:15.5px;padding:10px 20px;margin:12px 0;border-left:5px solid #e8e8e8}blockquote p:last-child{margin-bottom:0}pre{background-color:#f5f5f5;padding:12px;border:1px solid #cfcfcf;border-radius:6px;overflow:auto}pre code{color:black;background-color:transparent;padding:0;border:none}code{color:#444;background-color:#f5f5f5;font:'Inconsolata',monospace;padding:1px 4px;border:1px solid #cfcfcf;border-radius:3px}ul,ol{padding-left:2em}table{border-collapse:collapse;border-spacing:0;margin-bottom:12px}table tr:nth-child(2n){background-color:#fafafa}table th,table td{padding:6px 12px;border:1px solid #e6e6e6}.text-muted{opacity:.5}.note,.warning{padding:.3em 1em;margin:1em 0;border-radius:2px;font-size:90%}.note h1,.warning h1,.note h2,.warning h2,.note h3,.warning h3,.note h4,.warning h4,.note h5,.warning h5,.note h6,.warning h6{font-family:200 36px 'Raleway',Helvetica,sans-serif;font-size:135%;font-weight:500}.note p,.warning p{margin:.5em 0}.note{color:black;background-color:#f0f6fb;border-left:4px solid #428bca}.note h1,.note h2,.note h3,.note h4,.note h5,.note h6{color:#428bca}.warning{color:black;background-color:#fbf1f0;border-left:4px solid #c9302c}.warning h1,.warning h2,.warning h3,.warning h4,.warning h5,.warning h6{color:#c9302c}header{margin-top:24px}nav{position:fixed;top:24px;bottom:0;overflow-y:auto}nav .resource-group{padding:0}nav .resource-group .heading{position:relative}nav .resource-group .heading .chevron{position:absolute;top:12px;right:12px;opacity:.5}nav .resource-group .heading a{display:block;color:black;opacity:.7;border-left:2px solid transparent;margin:0}nav .resource-group .heading a:hover{text-decoration:none;background-color:bad-color;border-left:2px solid black}nav ul{list-style-type:none;padding-left:0}nav ul a{display:block;font-size:13px;color:rgba(0,0,0,0.7);padding:8px 12px;border-top:1px solid #d9d9d9;border-left:2px solid transparent;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nav ul a:hover{text-decoration:none;background-color:bad-color;border-left:2px solid black}nav ul>li{margin:0}nav ul>li:first-child{margin-top:-12px}nav ul>li:last-child{margin-bottom:-12px}nav ul ul a{padding-left:24px}nav ul ul li{margin:0}nav ul ul li:first-child{margin-top:0}nav ul ul li:last-child{margin-bottom:0}nav>div>div>ul>li:first-child>a{border-top:none}.preload *{transition:none !important}.pull-left{float:left}.pull-right{float:right}.badge{display:inline-block;float:right;min-width:10px;min-height:14px;padding:3px 7px;font-size:12px;color:#000;background-color:#f2f2f2;border-radius:10px;margin:-2px 0}.badge.get{color:#70bbe1;background-color:#d9edf7}.badge.head{color:#70bbe1;background-color:#d9edf7}.badge.options{color:#70bbe1;background-color:#d9edf7}.badge.put{color:#f0db70;background-color:#fcf8e3}.badge.patch{color:#f0db70;background-color:#fcf8e3}.badge.post{color:#93cd7c;background-color:#dff0d8}.badge.delete{color:#ce8383;background-color:#f2dede}.collapse-button{float:right}.collapse-button .close{display:none;color:#428bca;cursor:pointer}.collapse-button .open{color:#428bca;cursor:pointer}.collapse-button.show .close{display:inline}.collapse-button.show .open{display:none}.collapse-content{max-height:0;overflow:hidden;transition:max-height .3s ease-in-out}nav{width:220px}.container{max-width:940px;margin-left:auto;margin-right:auto}.container .row .content{margin-left:244px;width:696px}.container .row:after{content:'';display:block;clear:both}.container-fluid nav{width:22%}.container-fluid .row .content{margin-left:24%}.container-fluid.triple nav{width:16.5%;padding-right:1px}.container-fluid.triple .row .content{position:relative;margin-left:16.5%;padding-left:24px}.middle:before,.middle:after{content:'';display:table}.middle:after{clear:both}.middle{box-sizing:border-box;width:51.5%;padding-right:12px}.right{box-sizing:border-box;float:right;width:48.5%;padding-left:12px}.right a{color:#428bca}.right h1,.right h2,.right h3,.right h4,.right h5,.right p,.right div{color:white}.right pre{background-color:#1d1f21;border:1px solid #1d1f21}.right pre code{color:#c5c8c6}.right .description{margin-top:12px}.triple .resource-heading{font-size:125%}.definition{margin-top:12px;margin-bottom:12px}.definition .method{font-weight:bold}.definition .method.get{color:#2e8ab8}.definition .method.head{color:#2e8ab8}.definition .method.options{color:#2e8ab8}.definition .method.post{color:#56b82e}.definition .method.put{color:#b8a22e}.definition .method.patch{color:#b8a22e}.definition .method.delete{color:#b82e2e}.definition .uri{word-break:break-all;word-wrap:break-word}.definition .hostname{opacity:.5}.example-names{background-color:#eee;padding:12px;border-radius:6px}.example-names .tab-button{cursor:pointer;color:black;border:1px solid #ddd;padding:6px;margin-left:12px}.example-names .tab-button.active{background-color:#d5d5d5}.right .example-names{background-color:#444}.right .example-names .tab-button{color:white;border:1px solid #666;border-radius:6px}.right .example-names .tab-button.active{background-color:#5e5e5e}#nav-background{position:fixed;left:0;top:0;bottom:0;width:16.5%;padding-right:14.4px;background-color:#fbfbfb;border-right:1px solid #f0f0f0;z-index:-1}#right-panel-background{position:absolute;right:-12px;top:-12px;bottom:-12px;width:48.6%;background-color:#333;z-index:-1}@media (max-width:1200px){nav{width:198px}.container{max-width:840px}.container .row .content{margin-left:224px;width:606px}}@media (max-width:992px){nav{width:169.4px}.container{max-width:720px}.container .row .content{margin-left:194px;width:526px}}@media (max-width:768px){nav{display:none}.container{width:95%;max-width:none}.container .row .content,.container-fluid .row .content,.container-fluid.triple .row .content{margin-left:auto;margin-right:auto;width:95%}#nav-background{display:none}#right-panel-background{width:48.6%}}.back-to-top{position:fixed;z-index:1;bottom:0;right:24px;padding:4px 8px;color:rgba(0,0,0,0.5);background-color:#f2f2f2;text-decoration:none !important;border-top:1px solid #d9d9d9;border-left:1px solid #d9d9d9;border-right:1px solid #d9d9d9;border-top-left-radius:3px;border-top-right-radius:3px}.resource-group{padding:12px;margin-bottom:12px;background-color:white;border:1px solid #d9d9d9;border-radius:6px}.resource-group h2.group-heading,.resource-group .heading a{padding:12px;margin:-12px -12px 12px -12px;background-color:#f2f2f2;border-bottom:1px solid #d9d9d9;border-top-left-radius:6px;border-top-right-radius:6px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.triple .content .resource-group{padding:0;border:none}.triple .content .resource-group h2.group-heading,.triple .content .resource-group .heading a{margin:0 0 12px 0;border:1px solid #d9d9d9}nav .resource-group .heading a{padding:12px;margin-bottom:0}nav .resource-group .collapse-content{padding:0}.action{margin-bottom:12px;padding:12px 12px 0 12px;overflow:hidden;border:1px solid transparent;border-radius:6px}.action h4.action-heading{padding:12px;margin:-12px -12px 12px -12px;border-bottom:1px solid transparent;border-top-left-radius:6px;border-top-right-radius:6px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.action h4.action-heading .name{float:right;font-weight:normal}.action h4.action-heading .method{padding:6px 12px;margin-right:12px;border-radius:3px}.action h4.action-heading .method.get{color:#fff;background-color:#337ab7}.action h4.action-heading .method.head{color:#fff;background-color:#337ab7}.action h4.action-heading .method.options{color:#fff;background-color:#337ab7}.action h4.action-heading .method.put{color:#fff;background-color:#ed9c28}.action h4.action-heading .method.patch{color:#fff;background-color:#ed9c28}.action h4.action-heading .method.post{color:#fff;background-color:#5cb85c}.action h4.action-heading .method.delete{color:#fff;background-color:#d9534f}.action h4.action-heading code{color:#444;background-color:#f5f5f5;border-color:#cfcfcf;font-weight:normal}.action dl.inner{padding-bottom:2px}.action .title{border-bottom:1px solid white;margin:0 -12px -1px -12px;padding:12px}.action.get{border-color:#bce8f1}.action.get h4.action-heading{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.head{border-color:#bce8f1}.action.head h4.action-heading{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.options{border-color:#bce8f1}.action.options h4.action-heading{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.post{border-color:#d6e9c6}.action.post h4.action-heading{color:#5cb85c;background:#dff0d8;border-bottom-color:#d6e9c6}.action.put{border-color:#faebcc}.action.put h4.action-heading{color:#ed9c28;background:#fcf8e3;border-bottom-color:#faebcc}.action.patch{border-color:#faebcc}.action.patch h4.action-heading{color:#ed9c28;background:#fcf8e3;border-bottom-color:#faebcc}.action.delete{border-color:#ebccd1}.action.delete h4.action-heading{color:#d9534f;background:#f2dede;border-bottom-color:#ebccd1}</style></head><body class="preload"><a href="#top" class="text-muted back-to-top"><i class="fa fa-toggle-up"></i>&nbsp;Back to top</a><div class="container-fluid"><div class="row"><nav><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#top">Overview</a></div><div class="collapse-content"><ul><li><a href="#header-prerequisites">Prerequisites</a></li><li><a href="#header-security">Security</a></li><li><a href="#header-authentication">Authentication</a></li><li><a href="#header-how-to-register-an-integration?">How to register an integration?</a></li><li><a href="#header-exemplary-scenario">Exemplary scenario</a></li><li><a href="#header-conventions">Conventions</a></li><li><a href="#header-versioning">Versioning</a></li><li><a href="#header-requests-and-responses">Requests and responses</a></li><li><a href="#header-deduplication">Deduplication</a></li><li><a href="#header-events">Events</a></li><li><a href="#header-getting-all-events-history-since-ever">Getting all events history since ever</a></li><li><a href="#header-getting-all-events-history-since-particular-moment-in-time">Getting all events history since particular moment in time</a></li><li><a href="#header-wait-5-seconds-for-new-events-that-happened-since-last-check">Wait 5 seconds for new events that happened since last check</a></li><li><a href="#header-onboarding-customers">Onboarding customers</a></li><li><a href="#header-registering-customer-to-valuto">Registering customer to Valuto</a></li><li><a href="#header-adding-broker-to-customer-valuto-account">Adding broker to customer Valuto account</a></li><li><a href="#header-code-samples">Code samples</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#financial">Financial</a></div><div class="collapse-content"><ul><li><a href="#financial-payouts-post"><span class="badge post"><i class="fa fa-plus"></i></span>Prepare payout</a></li><li><a href="#financial-wallet-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>Get customer wallet balance</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#customer">Customer</a></div><div class="collapse-content"><ul></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#events-api">Events API</a></div><div class="collapse-content"><ul><li><a href="#events-api-events-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>Get all events</a></li></ul></div></div><p style="text-align: center; word-wrap: break-word;"><a href="http://api.valuto.com/v1">http://api.valuto.com/v1</a></p></nav><div class="content"><header><h1 id="top">Valuto API</h1></header><p>Valuto is an European multi-currency account for B2B and B2C payments.
It allows to:</p>
<ul>
<li>
<p><em>accept domestic bank transfers</em> in PLN, CZK, USD, EUR, GBP, SEK, NOK, DKK or RONs
using our infrastructure of local bank accounts in corresponding countries,</p>
</li>
<li>
<p><em>send domestic bank transfers</em> in above currencies using the same infrastructure
of local bank accounts,</p>
</li>
<li>
<p><em>exchange currency</em> on our currency exchange marketplace.</p>
</li>
</ul>
<p>Valuto API allows to integrate any system with Valuto account, to enable automatic transaction processing.
Integration is possible after requesting an authorization from any Valuto account
owner. Such approach enables two types of integration:</p>
<ul>
<li>
<p>companies can integrate their own systems with their wallet by themselves,</p>
</li>
<li>
<p>system providers can enable their users to integrate Valuto accounts
with their systems.</p>
</li>
</ul>
<p>Valuto Roadmap for 2016 assumes that all account operations
will be available through API, however initial version of Valuto API allows to:</p>
<ul>
<li>
<p>initiate a bank transfer payment (in any currency),</p>
</li>
<li>
<p>initiate a payment between Valuto users (in any currency),</p>
</li>
<li>
<p>request for authorization from a Valuto account owner.</p>
</li>
</ul>
<h1 id="header-prerequisites">Prerequisites <a class="permalink" href="#header-prerequisites" aria-hidden="true">¶</a></h1>
<h2 id="header-security">Security <a class="permalink" href="#header-security" aria-hidden="true">¶</a></h2>
<p>All network activity with Valuto is sent via HTTPS protocol. HTTPS encrypts the communication and authenticates
the API server. API uses request signing mechanism based on asymmetric cryptography, to authenticate all requests and
avoid exchanging security tokens over the wire.</p>
<h2 id="header-authentication">Authentication <a class="permalink" href="#header-authentication" aria-hidden="true">¶</a></h2>
<p>To make sure that each request to Valuto API is authentic, we use asymmetric cryptography. Each integration has to be
registered in Valuto (this requirement will be lessened in the future). During registration, developer submits
integration public key, and receives <em>broker id</em>.</p>
<p>Developer has to sign all requests with his secret key and provide a signature in header <code>x-valuto-sign</code>.
This gives him a guarantee that no one else can make requests on his behalf, even Valuto itself can not act on behalf of any developer.
Similarly, Valuto can safely assume that as long as a request is identified with <code>x-valuto-sign</code>
that matches that developer public key, it is authorized by the developer.</p>
<p>Actions can be performed on behalf of those Valuto users who have granted access to their accounts to specific integrations
(identified by <em>broker-id</em>). Every integration has its set of permissions required to operate
(e.g. checking balance, initiating a payment). When a user authorizes
integration he acknowledges this set of permissions.</p>
<p>Developer has to pass <em>integration ID</em> in <code>x-valuto-broker-id</code> header in every request.</p>
<p>Following steps are required to sign a request for sending:</p>
<ul>
<li>
<p>Concatenate HTTP request hostname, request path and request body (if exists)</p>
<pre><code>data = hostname + <span class="hljs-string">'\n'</span> + path + <span class="hljs-string">'\n'</span> + <span class="hljs-tag">body</span></code></pre>
</li>
<li>
<p>Use private RSA key to generate base64-encoded signature of concatenated data</p>
<pre><code>signature = privateRSAkey.<span class="hljs-function"><span class="hljs-title">sign</span><span class="hljs-params">(data)</span></span></code></pre>
</li>
<li>
<p>Set signature header:</p>
<pre><code>x-valuto-<span class="hljs-string">sign:</span> <span class="hljs-string">'signature'</span>
x-valuto-broker-<span class="hljs-string">id:</span> <span class="hljs-string">'integrationId'</span></code></pre>
</li>
</ul>
<h2 id="header-how-to-register-an-integration?">How to register an integration? <a class="permalink" href="#header-how-to-register-an-integration?" aria-hidden="true">¶</a></h2>
<p>To use this API you need to:</p>
<ol>
<li>
<p>Generate public/private key pair for integration:</p>
<pre><code>$ openssl genrsa -out private<span class="hljs-class">.key</span> <span class="hljs-number">4096</span>
$ openssl rsa -<span class="hljs-keyword">in</span> private<span class="hljs-class">.key</span> -pubout -out public<span class="hljs-class">.key</span></code></pre>
</li>
<li>
<p>Send <code>public.key</code> to e-mail <a href="mailto:api@valuto.com">api@valuto.com</a>.</p>
</li>
<li>
<p>You will receive <code>x-valuto-broker-id</code> which will enable you to create signature <code>x-valuto-sign</code></p>
</li>
</ol>
<h1 id="header-exemplary-scenario">Exemplary scenario <a class="permalink" href="#header-exemplary-scenario" aria-hidden="true">¶</a></h1>
<p>This scenario describes how the exemplary integration can initiate a payment using Valuto API.
A developer has already registered his integration, submitted his public key, and obtained <em>broker id</em>.
He has already requested access to a specific Valuto user for his integration.</p>
<ol>
<li>
<p>Integration fetches all past events for Valuto. Initially the list is empty.</p>
<pre><code>GET /events
Content-<span class="hljs-string">Type:</span> <span class="hljs-string">'application/json'</span>
x-valuto-<span class="hljs-string">sign:</span> <span class="hljs-string">'dUVsUZdSeEt+PSbqdQYnTAcfgS......gUrXwQIxyaG323GhBeVPo5kMz7cQ=='</span>
x-valuto-broker-<span class="hljs-string">id:</span> <span class="hljs-string">'74738335-02a3-4ece-b23c-8952367b737e'</span>
<span class="hljs-number">200</span> OK
content-<span class="hljs-string">type:</span> <span class="hljs-string">'application/json; charset=utf-8'</span>
content-<span class="hljs-string">length:</span> <span class="hljs-string">'2'</span>
[]</code></pre>
</li>
<li>
<p>Lets assume that an example Valuto user permitted access to his account for this integration. Another events
fetch returns the information about that.</p>
<pre><code>GET /events
Content-<span class="hljs-string">Type:</span> <span class="hljs-string">'application/json'</span>
x-valuto-<span class="hljs-string">sign:</span> <span class="hljs-string">'dUVsUZdSeEt+PSbqdQYnTAcfgS......gUrXwQIxyaG323GhBeVPo5kMz7cQ=='</span>
x-valuto-broker-<span class="hljs-string">id:</span> <span class="hljs-string">'74738335-02a3-4ece-b23c-8952367b737e'</span>
<span class="hljs-number">200</span> OK
content-<span class="hljs-string">type:</span> <span class="hljs-string">'application/json; charset=utf-8'</span>
content-<span class="hljs-string">length:</span> <span class="hljs-string">'143'</span>
[{
<span class="hljs-string">"_id"</span>:<span class="hljs-number">1510</span>,
<span class="hljs-string">"event_name"</span>:<span class="hljs-string">"CUSTOMER_ACCEPTS_BROKER"</span>,
<span class="hljs-string">"ts"</span>:<span class="hljs-string">"2016-02-02T11:15:28.935Z"</span>,
<span class="hljs-string">"email"</span>:<span class="hljs-string">"walutomat3+b2@gmail.com"</span>,
<span class="hljs-string">"valuto_id"</span>:<span class="hljs-string">"WX20000237WX"</span>
}]</code></pre>
</li>
<li>
<p>Integration sends a request to initiate a new payment on behalf of Valuto user:</p>
<pre><code>POST /payout/<span class="hljs-operator"><span class="hljs-keyword">prepare</span>
<span class="hljs-keyword">Content</span>-<span class="hljs-keyword">Type</span>: <span class="hljs-string">'application/json'</span>
x-valuto-<span class="hljs-keyword">sign</span>: <span class="hljs-string">'S1zXk3f9/RgO06E3kzX8hHIUy4q......2Qx18B79IobUzpY+cU6c5g7s5lHuFmm8LMB1tirRw=='</span>
x-valuto-broker-<span class="hljs-keyword">id</span>: <span class="hljs-string">'74738335-02a3-4ece-b23c-8952367b737e'</span>
{
<span class="hljs-string">"request_id"</span>: <span class="hljs-string">"unique-id-123"</span>,
<span class="hljs-string">"valuto_id"</span>: <span class="hljs-string">"WX20000237WX"</span>,
<span class="hljs-string">"payment"</span>: {
<span class="hljs-string">"amount"</span>: <span class="hljs-string">"100.00 PLN"</span>,
<span class="hljs-string">"title"</span>: <span class="hljs-string">"invoice for goods"</span>,
<span class="hljs-string">"recipient"</span>: {
<span class="hljs-string">"type"</span>: <span class="hljs-string">"IBAN"</span>,
<span class="hljs-string">"name"</span>: <span class="hljs-string">"Goods Company"</span>,
<span class="hljs-string">"address"</span>: <span class="hljs-string">"Incredible Shipments Street 1, London"</span>,
<span class="hljs-string">"iban"</span>: <span class="hljs-string">"PL81723116442358135293889265"</span>
}
}
}
<span class="hljs-number">200</span> OK
<span class="hljs-keyword">content</span>-<span class="hljs-keyword">type</span>: <span class="hljs-string">'application/json; charset=utf-8'</span>
<span class="hljs-keyword">content</span>-<span class="hljs-keyword">length</span>: <span class="hljs-string">'45'</span>
{<span class="hljs-string">"id"</span>:<span class="hljs-string">"23c815cd-0a18-432c-ae9c-a21fc47ebe02"</span>}
</span></code></pre>
</li>
<li>
<p>When the payment gets authorized by Valuto user (e.g. by mobile application or through web interface)
the event about it is sent to integration. This way integrating application can handle the progress with payment.</p>
<pre><code><span class="hljs-type">GET</span> /events?last_id=<span class="hljs-number">1510</span>
<span class="hljs-symbol">'Content</span>-<span class="hljs-type">Type</span>': <span class="hljs-symbol">'application</span>/json',
<span class="hljs-symbol">'x</span>-valuto-sign': <span class="hljs-symbol">'dUVsUZdSeEt</span>+<span class="hljs-type">PSbqdQYnTAcfgShHlhn</span>......<span class="hljs-type">UmV8eH6NqfgUrXwQIxyaG323GhBeVPo5kMz7cQ</span>==',
<span class="hljs-symbol">'x</span>-valuto-broker-id': <span class="hljs-symbol">'74738335</span>-<span class="hljs-number">02</span>a3-<span class="hljs-number">4</span>ece-b23c-<span class="hljs-number">8952367</span>b737e'
<span class="hljs-number">200</span> <span class="hljs-type">OK</span>
content-<span class="hljs-class"><span class="hljs-keyword">type</span>:</span> <span class="hljs-symbol">'application</span>/json; charset=utf-<span class="hljs-number">8</span>'
[
{
<span class="hljs-string">"_id"</span>: <span class="hljs-number">1781</span>,
<span class="hljs-string">"event_name"</span>: <span class="hljs-string">"PAYMENT"</span>,
<span class="hljs-string">"event_type"</span>: <span class="hljs-string">"WALLET"</span>,
<span class="hljs-string">"event_transaction_unit_id"</span>: <span class="hljs-string">"d0fa9130-a0fb-4e7b-ae84-d753638225f1"</span>,
<span class="hljs-string">"ts"</span>: <span class="hljs-string">"2016-02-05T10:09:54.348Z"</span>,
<span class="hljs-string">"currency"</span>: <span class="hljs-string">"PLN"</span>,
<span class="hljs-string">"amount"</span>: <span class="hljs-string">"-100.00 PLN"</span>,
<span class="hljs-string">"balance"</span>: <span class="hljs-string">"900.00 PLN"</span>,
<span class="hljs-string">"storno"</span>: <span class="hljs-literal">false</span>,
<span class="hljs-string">"payment_id"</span>: <span class="hljs-string">"23c815cd-0a18-432c-ae9c-a21fc47ebe02"</span>,
<span class="hljs-string">"direction"</span>: <span class="hljs-string">"OUT"</span>,
<span class="hljs-string">"title"</span>: <span class="hljs-string">"invoice for goods"</span>,
<span class="hljs-string">"priority"</span>: <span class="hljs-string">"STANDARD"</span>,
<span class="hljs-string">"valuto_id"</span>: <span class="hljs-string">"WX20000237WX"</span>,
<span class="hljs-string">"destination"</span>: {
<span class="hljs-string">"type"</span>: <span class="hljs-string">"IBAN"</span>,
<span class="hljs-string">"iban"</span>: <span class="hljs-string">"PL81723116442358135293889265"</span>,
<span class="hljs-string">"name"</span>: <span class="hljs-string">"Goods Company"</span>,
<span class="hljs-string">"address"</span>: <span class="hljs-string">"Szyperska 14, Poznan"</span>
}
}
]</code></pre>
</li>
</ol>
<h1 id="header-conventions">Conventions <a class="permalink" href="#header-conventions" aria-hidden="true">¶</a></h1>
<h2 id="header-versioning">Versioning <a class="permalink" href="#header-versioning" aria-hidden="true">¶</a></h2>
<p>This is the version 1.0 of the Valuto API.
Additional fields may appear without bumping version number.</p>
<h2 id="header-requests-and-responses">Requests and responses <a class="permalink" href="#header-requests-and-responses" aria-hidden="true">¶</a></h2>
<p>Every request performed by registered broker needs to have following headers:</p>
<pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">'application/json'</span>
<span class="hljs-attribute">x-valuto-sign</span>: <span class="hljs-string">signature</span>
<span class="hljs-attribute">x-valuto-broker-id</span>: <span class="hljs-string">broker-id</span></code></pre>
<p>To learn how to create signature, see “Authentication section”.
To learn how to obtain your broker-id, see “How to register an integration?”.</p>
<p>All responses from valuto are in JSON format.</p>
<p>Following are descriptions of typical status codes that may be returned:</p>
<table>
<thead>
<tr>
<th>Status code</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>OK</td>
</tr>
<tr>
<td>208</td>
<td>Ignored, Request has already been received</td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized, problem with authorizing requested broker id</td>
</tr>
<tr>
<td>403</td>
<td>Forbidden, broker is not allowed to perform requested operation</td>
</tr>
<tr>
<td>422</td>
<td>Either validation error, different request has been already processed with given unique id, or other problem</td>
</tr>
</tbody>
</table>
<h2 id="header-deduplication">Deduplication <a class="permalink" href="#header-deduplication" aria-hidden="true">¶</a></h2>
<p>Every request sent to the API contains a unique id assigned by broker. Whenever Valuto API
responds with status 200, a request is guaranteed to be processed. Under unusual circumstances, API consumer
might sometimes not be able to receive or read response. Requests with the same id will be processed exactly once.</p>
<p>When another identical request is received, API responds with response code 208, that the request has been deduplicated.
When another request with the same id is received, API responds with error code 422 meaning that id must be unique.</p>
<p>Whenever API consumer has doubts if his request has been sent successfully, he can safely
repeat it until he receives response code 200 or 208.</p>
<h2 id="header-events">Events <a class="permalink" href="#header-events" aria-hidden="true">¶</a></h2>
<p>API consumer is usually only one of many stakeholders in transaction processing, so he’s
frequently interested to be informed timely about any system state changes.
Events API is an answer to that need. It provides both the history of all system changes since any
arbitrary moment, as well as ability to get push-style notifications about current system state changes
in real-time.</p>
<h3 id="header-getting-all-events-history-since-ever">Getting all events history since ever <a class="permalink" href="#header-getting-all-events-history-since-ever" aria-hidden="true">¶</a></h3>
<pre><code><span class="hljs-title">GET</span> /events</code></pre>
<h3 id="header-getting-all-events-history-since-particular-moment-in-time">Getting all events history since particular moment in time <a class="permalink" href="#header-getting-all-events-history-since-particular-moment-in-time" aria-hidden="true">¶</a></h3>
<pre><code><span class="hljs-attribute">GET /events?last_id</span>=<span class="hljs-string">moment_id
</span></code></pre>
<h3 id="header-wait-5-seconds-for-new-events-that-happened-since-last-check">Wait 5 seconds for new events that happened since last check <a class="permalink" href="#header-wait-5-seconds-for-new-events-that-happened-since-last-check" aria-hidden="true">¶</a></h3>
<pre><code>GET /events?last_id=moment_id&amp;<span class="hljs-keyword">timeout</span>=<span class="hljs-number">5000</span></code></pre>
<h1 id="header-onboarding-customers">Onboarding customers <a class="permalink" href="#header-onboarding-customers" aria-hidden="true">¶</a></h1>
<h2 id="header-registering-customer-to-valuto">Registering customer to Valuto <a class="permalink" href="#header-registering-customer-to-valuto" aria-hidden="true">¶</a></h2>
<h2 id="header-adding-broker-to-customer-valuto-account">Adding broker to customer Valuto account <a class="permalink" href="#header-adding-broker-to-customer-valuto-account" aria-hidden="true">¶</a></h2>
<h1 id="header-code-samples">Code samples <a class="permalink" href="#header-code-samples" aria-hidden="true">¶</a></h1>
<p>Example app using <code>x-valuto-broker-id</code> signature in nodejs is <a href="https://github.com/Currency-One/valuto-api-demo">available on GitHub</a></p>
<section id="financial" class="resource-group"><h2 class="group-heading">Financial <a href="#financial" class="permalink">&para;</a></h2><p>Resources related to financial operations.</p>
<div id="financial-payouts" class="resource"><h3 class="resource-heading">Payouts <a href="#financial-payouts" class="permalink">&nbsp;&para;</a></h3><p>Payout is a money transfer going from Valuto customer account to bank account,
another Valuto customer account, or Tax/Social Security authority in Poland (ZUS/US).</p>
<p>Payout flows through following steps:</p>
<ul>
<li>
<p>Preparation - Broker can prepare payout for Valuto customer by filling up the payout data.</p>
</li>
<li>
<p>Authoziation - Customer confirms payout with SMS authorization mechanism.</p>
</li>
<li>
<p>Sending - Valuto sends the payout.</p>
</li>
</ul>
<div id="financial-payouts-post" class="action post"><h4 class="action-heading"><div class="name">Prepare payout</div><a href="#financial-payouts-post" class="method post">POST</a><code class="uri">/payout/prepare</code></h4><p>Adds a payout to customer’s list of pending payouts. Upon success, it returns JSON with created payout id.
This id can be used later to check payout status.</p>
<h4>Example URI</h4><div class="definition"><span class="method post">POST</span>&nbsp;<span class="uri"><span class="hostname">http://api.valuto.com/v1</span>/payout/prepare</span></div><div class="title"><strong>Request&nbsp;&nbsp;<code>Initiate bank payout</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span><br><span class="hljs-attribute">x-valuto-sign</span>: <span class="hljs-string">'RSA signature'</span><br><span class="hljs-attribute">x-valuto-broker-id</span>: <span class="hljs-string">'1234'</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">request_id</span>": <span class="hljs-value"><span class="hljs-string">"0129389123123123123"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">title</span>": <span class="hljs-value"><span class="hljs-string">"payment for dinner"</span></span>,
"<span class="hljs-attribute">amount</span>": <span class="hljs-value"><span class="hljs-string">"1500.00 EUR"</span></span>,
"<span class="hljs-attribute">priority</span>": <span class="hljs-value"><span class="hljs-string">"EXPRESS"</span></span>,
"<span class="hljs-attribute">destination</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"IBAN"</span></span>,
"<span class="hljs-attribute">iban</span>": <span class="hljs-value"><span class="hljs-string">"PL12345678901234567890123456"</span></span>,
"<span class="hljs-attribute">owner_name</span>": <span class="hljs-value"><span class="hljs-string">"Jan Kowalski"</span></span>,
"<span class="hljs-attribute">owner_address</span>": <span class="hljs-value"><span class="hljs-string">"ul. Garbary 1, Poznań 12-234"</span></span>,
"<span class="hljs-attribute">country</span>": <span class="hljs-value"><span class="hljs-string">"PL"</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Request&nbsp;&nbsp;<code>Initiate Valuto payment</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span><br><span class="hljs-attribute">x-valuto-sign</span>: <span class="hljs-string">'RSA signature'</span><br><span class="hljs-attribute">x-valuto-broker-id</span>: <span class="hljs-string">'1234'</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">request_id</span>": <span class="hljs-value"><span class="hljs-string">"0129389123123123123"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">title</span>": <span class="hljs-value"><span class="hljs-string">"payment for dinner"</span></span>,
"<span class="hljs-attribute">amount</span>": <span class="hljs-value"><span class="hljs-string">"1500.00 EUR"</span></span>,
"<span class="hljs-attribute">priority</span>": <span class="hljs-value"><span class="hljs-string">"EXPRESS"</span></span>,
"<span class="hljs-attribute">destination</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"VALUTO"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX999999WX"</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response&nbsp;&nbsp;<code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><div class="description"><p>Payout initiated successfully</p>
</div><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"1234-1234-1234-1234"</span>
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response&nbsp;&nbsp;<code>208</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><div class="description"><p>Payout already processed</p>
</div><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"1234-1234-1234-1234"</span>
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div><div id="financial-wallet" class="resource"><h3 class="resource-heading">Wallet <a href="#financial-wallet" class="permalink">&nbsp;&para;</a></h3><div id="financial-wallet-get" class="action get"><h4 class="action-heading"><div class="name">Get customer wallet balance</div><a href="#financial-wallet-get" class="method get">GET</a><code class="uri">/wallet/balance</code></h4><h4>Example URI</h4><div class="definition"><span class="method get">GET</span>&nbsp;<span class="uri"><span class="hostname">http://api.valuto.com/v1</span>/wallet/balance</span></div><div class="title"><strong>Response&nbsp;&nbsp;<code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">updated_ts</span>": <span class="hljs-value"><span class="hljs-string">"2015-10-28T12:39:15.346Z"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123WX"</span></span>,
"<span class="hljs-attribute">balances</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">currency</span>": <span class="hljs-value"><span class="hljs-string">"PLN"</span></span>,
"<span class="hljs-attribute">amount_available</span>": <span class="hljs-value"><span class="hljs-string">"900.00 PLN"</span></span>,
"<span class="hljs-attribute">amount_blocked</span>": <span class="hljs-value"><span class="hljs-string">"100.00 PLN"</span>
</span>},
{
"<span class="hljs-attribute">currency</span>": <span class="hljs-value"><span class="hljs-string">"EUR"</span></span>,
"<span class="hljs-attribute">amount_available</span>": <span class="hljs-value"><span class="hljs-string">"30.00 EUR"</span></span>,
"<span class="hljs-attribute">amount_blocked</span>": <span class="hljs-value"><span class="hljs-string">"0.00 EUR"</span>
</span>},
{
"<span class="hljs-attribute">currency</span>": <span class="hljs-value"><span class="hljs-string">"USD"</span></span>,
"<span class="hljs-attribute">amount_available</span>": <span class="hljs-value"><span class="hljs-string">"2300.00 EUR"</span></span>,
"<span class="hljs-attribute">amount_blocked</span>": <span class="hljs-value"><span class="hljs-string">"1000.00 EUR"</span>
</span>}
]
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section><section id="customer" class="resource-group"><h2 class="group-heading">Customer <a href="#customer" class="permalink">&para;</a></h2><p>Resources related to customer.</p>
</section><section id="events-api" class="resource-group"><h2 class="group-heading">Events API <a href="#events-api" class="permalink">&para;</a></h2><p>Event-driven API</p>
<div id="events-api-events" class="resource"><h3 class="resource-heading">Events <a href="#events-api-events" class="permalink">&nbsp;&para;</a></h3><div id="events-api-events-get" class="action get"><h4 class="action-heading"><div class="name">Get all events</div><a href="#events-api-events-get" class="method get">GET</a><code class="uri">/events</code></h4><p>Get the list of events. Every event looks something like this</p>
<pre><code>[
{
<span class="hljs-string">"ordinal_number"</span>: «unique_event_id»,
<span class="hljs-string">"event_name"</span>: «PAYLOAD_TYPE»,
<span class="hljs-string">"valuto_id"</span>: <span class="hljs-string">"customer_who_owns_payload"</span>,
<span class="hljs-string">"id"</span>: <span class="hljs-string">"payload_globally_unique_id"</span>,
«payload_<span class="hljs-built_in">type</span>»: «PAYLOAD»
}
]
Event types: PAYOUT, AGREEMENT</code></pre>
<h4>Example URI</h4><div class="definition"><span class="method get">GET</span>&nbsp;<span class="uri"><span class="hostname">http://api.valuto.com/v1</span>/events</span></div><div class="title"><strong>Request&nbsp;&nbsp;<code>Payout update</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">x-valuto-sign</span>: <span class="hljs-string">'RSA signature'</span><br><span class="hljs-attribute">x-valuto-broker-id</span>: <span class="hljs-string">'1234'</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>[
{
"<span class="hljs-attribute">ordinal_number</span>": <span class="hljs-value"><span class="hljs-number">80936</span></span>,
"<span class="hljs-attribute">event_name</span>": <span class="hljs-value"><span class="hljs-string">"AGREEMENT"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"acccompany123:WX123456WX"</span></span>,
"<span class="hljs-attribute">agreement</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"acccompany123:WX123456WX"</span></span>,
"<span class="hljs-attribute">broker_id</span>": <span class="hljs-value"><span class="hljs-string">"acccompany123"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">email</span>": <span class="hljs-value"><span class="hljs-string">"jan@goodscompany.test"</span>
</span>}
</span>},
{
"<span class="hljs-attribute">ordinal_number</span>": <span class="hljs-value"><span class="hljs-number">80937</span></span>,
"<span class="hljs-attribute">event_name</span>": <span class="hljs-value"><span class="hljs-string">"PAYOUT"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"uuid123456"</span></span>,
"<span class="hljs-attribute">payout</span>": <span class="hljs-value">{
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"uuid123456"</span></span>,
"<span class="hljs-attribute">title</span>": <span class="hljs-value"><span class="hljs-string">"payment for dinner"</span></span>,
"<span class="hljs-attribute">amount</span>": <span class="hljs-value"><span class="hljs-string">"1500.00 EUR"</span></span>,
"<span class="hljs-attribute">priority</span>": <span class="hljs-value"><span class="hljs-string">"EXPRESS"</span></span>,
"<span class="hljs-attribute">fee</span>": <span class="hljs-value"><span class="hljs-string">"1.00 EUR"</span></span>,
"<span class="hljs-attribute">status</span>": <span class="hljs-value"><span class="hljs-string">"PENDING"</span></span>,
"<span class="hljs-attribute">destination</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"IBAN"</span></span>,
"<span class="hljs-attribute">iban</span>": <span class="hljs-value"><span class="hljs-string">"PL12345678901234567890123456"</span></span>,
"<span class="hljs-attribute">owner_name</span>": <span class="hljs-value"><span class="hljs-string">"Jan Kowalski"</span></span>,
"<span class="hljs-attribute">owner_address</span>": <span class="hljs-value"><span class="hljs-string">"ul. Garbary 1, Poznań 12-234"</span></span>,
"<span class="hljs-attribute">country</span>": <span class="hljs-value"><span class="hljs-string">"PL"</span>
</span>}
</span>}
</span>}
]</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response&nbsp;&nbsp;<code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>[
{
"<span class="hljs-attribute">ordinal_number</span>": <span class="hljs-value"><span class="hljs-number">80937</span></span>,
"<span class="hljs-attribute">event_name</span>": <span class="hljs-value"><span class="hljs-string">"PAYOUT"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-string">"123456"</span></span>,
"<span class="hljs-attribute">payout</span>": <span class="hljs-value">{
"<span class="hljs-attribute">title</span>": <span class="hljs-value"><span class="hljs-string">"payment for dinner"</span></span>,
"<span class="hljs-attribute">amount</span>": <span class="hljs-value"><span class="hljs-string">"1500.00 EUR"</span></span>,
"<span class="hljs-attribute">priority</span>": <span class="hljs-value"><span class="hljs-string">"EXPRESS"</span></span>,
"<span class="hljs-attribute">fee</span>": <span class="hljs-value"><span class="hljs-string">"1.00 EUR"</span></span>,
"<span class="hljs-attribute">status</span>": <span class="hljs-value"><span class="hljs-string">"PENDING"</span></span>,
"<span class="hljs-attribute">destination</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"IBAN"</span></span>,
"<span class="hljs-attribute">iban</span>": <span class="hljs-value"><span class="hljs-string">"PL12345678901234567890123456"</span></span>,
"<span class="hljs-attribute">owner_name</span>": <span class="hljs-value"><span class="hljs-string">"Jan Kowalski"</span></span>,
"<span class="hljs-attribute">owner_address</span>": <span class="hljs-value"><span class="hljs-string">"ul. Garbary 1, Poznań 12-234"</span></span>,
"<span class="hljs-attribute">country</span>": <span class="hljs-value"><span class="hljs-string">"PL"</span>
</span>}
</span>}
</span>}
]</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Request&nbsp;&nbsp;<code>Customer update</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response&nbsp;&nbsp;<code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>[
{
"<span class="hljs-attribute">ordinal_number</span>": <span class="hljs-value"><span class="hljs-number">80997</span></span>,
"<span class="hljs-attribute">event_name</span>": <span class="hljs-value"><span class="hljs-string">"CUSTOMER"</span></span>,
"<span class="hljs-attribute">valuto_id</span>": <span class="hljs-value"><span class="hljs-string">"WX123456WX"</span></span>,
"<span class="hljs-attribute">phone</span>": <span class="hljs-value"><span class="hljs-string">"123456"</span></span>,
"<span class="hljs-attribute">updated_ts</span>": <span class="hljs-value"><span class="hljs-string">"2015-11-16T13:20:16.000Z"</span>
</span>}
]</code></pre><div style="height: 1px;"></div></div></div></div></div></section></div></div></div><p style="text-align: center;" class="text-muted">Generated by&nbsp;<a href="https://github.com/danielgtaylor/aglio" class="aglio">aglio</a>&nbsp;on 15 Feb 2016</p><script>/* eslint-env browser */
/* eslint quotes: [2, "single"] */
'use strict';
/*
Determine if a string ends with another string.
*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
/*
Get a list of direct child elements by class name.
*/
function childrenByClass(element, name) {
var filtered = [];
for (var i = 0; i < element.children.length; i++) {
var child = element.children[i];
var classNames = child.className.split(' ');
if (classNames.indexOf(name) !== -1) {
filtered.push(child);
}
}
return filtered;
}
/*
Get an array [width, height] of the window.
*/
function getWindowDimensions() {
var w = window,
d = document,
e = d.documentElement,
g = d.body,
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
return [x, y];
}
/*
Collapse or show a request/response example.
*/
function toggleCollapseButton(event) {
var button = event.target.parentNode;
var content = button.parentNode.nextSibling;
var inner = content.children[0];
if (button.className.indexOf('collapse-button') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it
button.className = 'collapse-button';
content.style.maxHeight = '0px';
} else {
// Currently hidden, so let's show it
button.className = 'collapse-button show';
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
function toggleTabButton(event) {
var i, index;
var button = event.target;
// Get index of the current button.
var buttons = childrenByClass(button.parentNode, 'tab-button');
for (i = 0; i < buttons.length; i++) {
if (buttons[i] === button) {
index = i;
button.className = 'tab-button active';
} else {
buttons[i].className = 'tab-button';
}
}
// Hide other tabs and show this one.
var tabs = childrenByClass(button.parentNode.parentNode, 'tab');
for (i = 0; i < tabs.length; i++) {
if (i === index) {
tabs[i].style.display = 'block';
} else {
tabs[i].style.display = 'none';
}
}
}
/*
Collapse or show a navigation menu. It will not be hidden unless it
is currently selected or `force` has been passed.
*/
function toggleCollapseNav(event, force) {
var heading = event.target.parentNode;
var content = heading.nextSibling;
var inner = content.children[0];
if (heading.className.indexOf('heading') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it, but only if this nav item
// is already selected. This prevents newly selected items from
// collapsing in an annoying fashion.
if (force || window.location.hash && endsWith(event.target.href, window.location.hash)) {
content.style.maxHeight = '0px';
}
} else {
// Currently hidden, so let's show it
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
/*
Refresh the page after a live update from the server. This only
works in live preview mode (using the `--server` parameter).
*/
function refresh(body) {
document.querySelector('body').className = 'preload';
document.body.innerHTML = body;
// Re-initialize the page
init();
autoCollapse();
document.querySelector('body').className = '';
}
/*
Determine which navigation items should be auto-collapsed to show as many
as possible on the screen, based on the current window height. This also
collapses them.
*/
function autoCollapse() {
var windowHeight = getWindowDimensions()[1];
var itemsHeight = 64; /* Account for some padding */
var itemsArray = Array.prototype.slice.call(
document.querySelectorAll('nav .resource-group .heading'));
// Get the total height of the navigation items
itemsArray.forEach(function (item) {
itemsHeight += item.parentNode.offsetHeight;
});
// Should we auto-collapse any nav items? Try to find the smallest item
// that can be collapsed to show all items on the screen. If not possible,
// then collapse the largest item and do it again. First, sort the items
// by height from smallest to largest.
var sortedItems = itemsArray.sort(function (a, b) {
return a.parentNode.offsetHeight - b.parentNode.offsetHeight;
});
while (sortedItems.length && itemsHeight > windowHeight) {
for (var i = 0; i < sortedItems.length; i++) {
// Will collapsing this item help?
var itemHeight = sortedItems[i].nextSibling.offsetHeight;
if ((itemsHeight - itemHeight <= windowHeight) || i === sortedItems.length - 1) {
// It will, so let's collapse it, remove its content height from
// our total and then remove it from our list of candidates
// that can be collapsed.
itemsHeight -= itemHeight;
toggleCollapseNav({target: sortedItems[i].children[0]}, true);
sortedItems.splice(i, 1);
break;
}
}
}
}
/*
Initialize the interactive functionality of the page.
*/
function init() {
var i, j;
// Make collapse buttons clickable
var buttons = document.querySelectorAll('.collapse-button');
for (i = 0; i < buttons.length; i++) {
buttons[i].onclick = toggleCollapseButton;
// Show by default? Then toggle now.
if (buttons[i].className.indexOf('show') !== -1) {
toggleCollapseButton({target: buttons[i].children[0]});
}
}
var responseCodes = document.querySelectorAll('.example-names');
for (i = 0; i < responseCodes.length; i++) {
var tabButtons = childrenByClass(responseCodes[i], 'tab-button');
for (j = 0; j < tabButtons.length; j++) {
tabButtons[j].onclick = toggleTabButton;
// Show by default?
if (j === 0) {
toggleTabButton({target: tabButtons[j]});
}
}
}
// Make nav items clickable to collapse/expand their content.
var navItems = document.querySelectorAll('nav .resource-group .heading');
for (i = 0; i < navItems.length; i++) {
navItems[i].onclick = toggleCollapseNav;
// Show all by default
toggleCollapseNav({target: navItems[i].children[0]});
}
}
// Initial call to set up buttons
init();
window.onload = function () {
autoCollapse();
// Remove the `preload` class to enable animations
document.querySelector('body').className = '';
};
</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment