<!DOCTYPE html> <html xmlns='www.w3.org/1999/xhtml'>
<head> <title>Code coverage for Capital one</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src='./assets/0.10.0/application.js' type='text/javascript'></script> <link href='./assets/0.10.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'> <link rel="shortcut icon" type="image/png" href="./assets/0.10.0/favicon_green.png" /> <link rel="icon" type="image/png" href="./assets/0.10.0/favicon.png" /> </head> <body> <div id="loading"> <img src="./assets/0.10.0/loading.gif" alt="loading"/> </div> <div id="wrapper" style="display:none;"> <div class="timestamp">Generated <abbr class="timeago" title="2015-09-08T11:52:50-05:00">2015-09-08T11:52:50-05:00</abbr></div> <ul class="group_tabs"></ul> <div id="content"> <div class="file_list_container" id="AllFiles"> <h2> <span class="group_name">All Files</span> (<span class="covered_percent"><span class="green">99.75%</span></span> covered at <span class="covered_strength"> <span class="green"> 2.38 </span> </span> hits/line) </h2> <a name="AllFiles"></a> <div> <b>12</b> files in total. <b>400</b> relevant lines. <span class="green"><b>399</b> lines covered</span> and <span class="red"><b>1</b> lines missed </span> </div> <table class="file_list"> <thead> <tr> <th>File</th> <th>% covered</th> <th>Lines</th> <th>Relevant Lines</th> <th>Lines covered</th> <th>Lines missed</th> <th>Avg. Hits / Line</th> </tr> </thead> <tbody> <tr> <td class="strong"><a href="#77c7d4e39683102d6491ec29c973adba85ede768" class="src_link" title="lib/capital_one.rb">lib/capital_one.rb</a></td> <td class="green strong">100.0 %</td> <td>58</td> <td>18</td> <td>18</td> <td>0</td> <td>7.9</td> </tr> <tr> <td class="strong"><a href="#be0af5f7989b3dae319257fafb69972f50fba24a" class="src_link" title="lib/capital_one/account.rb">lib/capital_one/account.rb</a></td> <td class="green strong">100.0 %</td> <td>116</td> <td>49</td> <td>49</td> <td>0</td> <td>4.1</td> </tr> <tr> <td class="strong"><a href="#4920a1f33a538c3a8bf319407124a455b7032faf" class="src_link" title="lib/capital_one/atm.rb">lib/capital_one/atm.rb</a></td> <td class="green strong">100.0 %</td> <td>49</td> <td>19</td> <td>19</td> <td>0</td> <td>1.6</td> </tr> <tr> <td class="strong"><a href="#9ef485049d4e970d60afe7fd568ca0bd5871916c" class="src_link" title="lib/capital_one/bill.rb">lib/capital_one/bill.rb</a></td> <td class="green strong">100.0 %</td> <td>124</td> <td>48</td> <td>48</td> <td>0</td> <td>1.6</td> </tr> <tr> <td class="strong"><a href="#4362c7cd9c31d47f07610ce16db68f6968f06830" class="src_link" title="lib/capital_one/branch.rb">lib/capital_one/branch.rb</a></td> <td class="green strong">100.0 %</td> <td>37</td> <td>15</td> <td>15</td> <td>0</td> <td>1.6</td> </tr> <tr> <td class="strong"><a href="#9d6e78f0ca8ae2319eb48d58dc640dd1ee0bc831" class="src_link" title="lib/capital_one/customer.rb">lib/capital_one/customer.rb</a></td> <td class="green strong">100.0 %</td> <td>113</td> <td>40</td> <td>40</td> <td>0</td> <td>2.0</td> </tr> <tr> <td class="strong"><a href="#5bd4b3c628722b3d590fa1752cfd9b8f9777d281" class="src_link" title="lib/capital_one/deposit.rb">lib/capital_one/deposit.rb</a></td> <td class="green strong">100.0 %</td> <td>110</td> <td>42</td> <td>42</td> <td>0</td> <td>2.0</td> </tr> <tr> <td class="strong"><a href="#1099be63a00c4c92c91d7e77e68da8316d834e89" class="src_link" title="lib/capital_one/merchant.rb">lib/capital_one/merchant.rb</a></td> <td class="green strong">97.56 %</td> <td>118</td> <td>41</td> <td>40</td> <td>1</td> <td>1.8</td> </tr> <tr> <td class="strong"><a href="#0d11ac0799ef22a9dd646e1825098d04b4fd2670" class="src_link" title="lib/capital_one/purchase.rb">lib/capital_one/purchase.rb</a></td> <td class="green strong">100.0 %</td> <td>107</td> <td>41</td> <td>41</td> <td>0</td> <td>1.9</td> </tr> <tr> <td class="strong"><a href="#cc3bc6146cda462f16e9bd0945e38539cdbba1ff" class="src_link" title="lib/capital_one/transfer.rb">lib/capital_one/transfer.rb</a></td> <td class="green strong">100.0 %</td> <td>93</td> <td>45</td> <td>45</td> <td>0</td> <td>1.9</td> </tr> <tr> <td class="strong"><a href="#9dc4fd8cd512f510c0b09ef896b92bbbdc0422a0" class="src_link" title="lib/capital_one/version.rb">lib/capital_one/version.rb</a></td> <td class="green strong">100.0 %</td> <td>3</td> <td>2</td> <td>2</td> <td>0</td> <td>1.0</td> </tr> <tr> <td class="strong"><a href="#fc349552d31dbf0f29dbb28e47e604e109a8255e" class="src_link" title="lib/capital_one/withdrawal.rb">lib/capital_one/withdrawal.rb</a></td> <td class="green strong">100.0 %</td> <td>108</td> <td>40</td> <td>40</td> <td>0</td> <td>1.9</td> </tr> </tbody> </table>
</div>
</div> <div id="footer"> Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.10.0 and simplecov-html v0.10.0<br/> using RSpec </div> <div class="source_files"> <div class="source_table" id="77c7d4e39683102d6491ec29c973adba85ede768"> <div class="header"> <h3>lib/capital_one.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>18</b> relevant lines. <span class="green"><b>18</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="never" data-hits="" data-linenumber="1"> <code class="ruby">=begin</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="3"> <code class="ruby">==Capital One API Gem</code> </li> <li class="never" data-hits="" data-linenumber="4"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> This is a gem to wrap the Capital One public API.</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"> Visit api.reimaginebanking.com for more details.</code> </li> <li class="never" data-hits="" data-linenumber="7"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="8"> <code class="ruby">=end</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="10"> <span class="hits">1</span> <code class="ruby">module Config</code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> class << self</code> </li> <li class="covered" data-hits="1" data-linenumber="12"> <span class="hits">1</span> <code class="ruby"> attr_accessor :apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="14"> <span class="hits">1</span> <code class="ruby"> def baseUrl</code> </li> <li class="covered" data-hits="126" data-linenumber="15"> <span class="hits">126</span> <code class="ruby"> @baseUrl = 'http://api.nessiebanking.com:80'</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby">end</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="20"> <span class="hits">1</span> <code class="ruby">require 'net/http'</code> </li> <li class="covered" data-hits="1" data-linenumber="21"> <span class="hits">1</span> <code class="ruby">require 'json'</code> </li> <li class="covered" data-hits="1" data-linenumber="22"> <span class="hits">1</span> <code class="ruby">require 'uri'</code> </li> <li class="never" data-hits="" data-linenumber="23"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="24"> <span class="hits">1</span> <code class="ruby">require 'capital_one/account'</code> </li> <li class="covered" data-hits="1" data-linenumber="25"> <span class="hits">1</span> <code class="ruby">require 'capital_one/atm'</code> </li> <li class="covered" data-hits="1" data-linenumber="26"> <span class="hits">1</span> <code class="ruby">require 'capital_one/bill'</code> </li> <li class="covered" data-hits="1" data-linenumber="27"> <span class="hits">1</span> <code class="ruby">require 'capital_one/branch'</code> </li> <li class="covered" data-hits="1" data-linenumber="28"> <span class="hits">1</span> <code class="ruby">require 'capital_one/customer'</code> </li> <li class="covered" data-hits="1" data-linenumber="29"> <span class="hits">1</span> <code class="ruby">require 'capital_one/deposit'</code> </li> <li class="covered" data-hits="1" data-linenumber="30"> <span class="hits">1</span> <code class="ruby">require 'capital_one/merchant'</code> </li> <li class="covered" data-hits="1" data-linenumber="31"> <span class="hits">1</span> <code class="ruby">require 'capital_one/purchase'</code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby">require 'capital_one/transfer'</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby">require 'capital_one/withdrawal'</code> </li> <li class="never" data-hits="" data-linenumber="34"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="35"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby">=begin </code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby">==Important Info</code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby">Depending on the access level/type of API key supplied, some of</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby">these methods will return 403 error codes(forbidden). Enterprise level</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby">API keys have access to any/all of the GET requests, but nothing else. </code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby">Customer level API keys have access to GET, POST, PUT, and DELETE, but only</code> </li> <li class="never" data-hits="" data-linenumber="44"> <code class="ruby">for valid accounts which are associated with the customer API key. </code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby">Additionally, some of the GET requests will change in functionality depending on the</code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby">type of key used. For example, the getAll method in the Customer class returns all customers if</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby">the enterprise API key is used. If the customer API key is used, it will only return the customers that</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby">the key is associated with.</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby">For the purposes of this gem, any ID parameters Strings that are 24 hex characters long. Below is an example:</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby">5326c07ba520d1066c9ac52b</code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="54"> <code class="ruby">You can see the API that this gem wraps at api.reimaginebanking.com</code> </li> <li class="never" data-hits="" data-linenumber="55"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="56"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="57"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="58"> <code class="ruby">=end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="be0af5f7989b3dae319257fafb69972f50fba24a"> <div class="header"> <h3>lib/capital_one/account.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>49</b> relevant lines. <span class="green"><b>49</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Account</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="32" data-linenumber="4"> <span class="hits">32</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="37" data-linenumber="12"> <span class="hits">37</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"> #= getAll</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> # Returns an array of hashes getting all the customers.</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Each index in the array is the hash of an individual customer. </code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="20"> <span class="hits">1</span> <code class="ruby"> def self.getAll</code> </li> <li class="covered" data-hits="27" data-linenumber="21"> <span class="hits">27</span> <code class="ruby"> url = "#{self.urlWithEntity}?&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="27" data-linenumber="22"> <span class="hits">27</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="27" data-linenumber="23"> <span class="hits">27</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> #== getAllByType</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> # Gets all accounts of a given type.</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> #= Parameters: type</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Accepts a string of the account type. 3 possbilities: Credit Card, Savings, Checking.</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> # Returns an array of hashes with the accounts.</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby"> def self.getAllByType(type)</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}?type=#{type}&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> #== getOne</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"> # Returns the account specified by its account ID.</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> #= Parameters: AccountId</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"> # Accepts a string of the account ID. </code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"> # Returns a hash with the account info.</code> </li> <li class="covered" data-hits="1" data-linenumber="44"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="45"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="46"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="47"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> #== getAllByCustomerId</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # Returns all accounts associated with a given customer ID as an array of hashes. </code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"> #= Parameters: CustomerId</code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"> # Accepts a string of the customer ID</code> </li> <li class="never" data-hits="" data-linenumber="54"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="55"> <span class="hits">1</span> <code class="ruby"> def self.getAllByCustomerId(customerId)</code> </li> <li class="covered" data-hits="2" data-linenumber="56"> <span class="hits">2</span> <code class="ruby"> url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="57"> <span class="hits">2</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="2" data-linenumber="58"> <span class="hits">2</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="59"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="60"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="61"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> #==updateAccount</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # Updates an account's nickname.</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> #= Parameters: AccountID, AccountHash</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # Returns the http response code.</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="69"> <span class="hits">1</span> <code class="ruby"> def self.updateAccount(accountId, account)</code> </li> <li class="covered" data-hits="1" data-linenumber="70"> <span class="hits">1</span> <code class="ruby"> accountToUpdate = account.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="71"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="72"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="73"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="74"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="75"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="76"> <span class="hits">1</span> <code class="ruby"> request.body = accountToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="77"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="78"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="79"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="80"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="81"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="82"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="83"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="84"> <code class="ruby"> #== createAccount</code> </li> <li class="never" data-hits="" data-linenumber="85"> <code class="ruby"> # Creates a new account</code> </li> <li class="never" data-hits="" data-linenumber="86"> <code class="ruby"> # Parameters: CustomerID, accountHash</code> </li> <li class="never" data-hits="" data-linenumber="87"> <code class="ruby"> # Returns the http response code. </code> </li> <li class="never" data-hits="" data-linenumber="88"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="89"> <span class="hits">1</span> <code class="ruby"> def self.createAccount(custID, account)</code> </li> <li class="covered" data-hits="1" data-linenumber="90"> <span class="hits">1</span> <code class="ruby"> accountToCreate = account.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="91"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="92"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="93"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="94"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="95"> <span class="hits">1</span> <code class="ruby"> request.body = accountToCreate</code> </li> <li class="covered" data-hits="1" data-linenumber="96"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="97"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="100"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="101"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="102"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="103"> <code class="ruby"> #== deleteAccount</code> </li> <li class="never" data-hits="" data-linenumber="104"> <code class="ruby"> # delete a given account by accountId.</code> </li> <li class="never" data-hits="" data-linenumber="105"> <code class="ruby"> # Parameters: AccountId.</code> </li> <li class="never" data-hits="" data-linenumber="106"> <code class="ruby"> # Returns the http response code. </code> </li> <li class="never" data-hits="" data-linenumber="107"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="108"> <span class="hits">1</span> <code class="ruby"> def self.deleteAccount(accountId)</code> </li> <li class="covered" data-hits="1" data-linenumber="109"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="110"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="111"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="112"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="113"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="114"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="115"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="116"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="4920a1f33a538c3a8bf319407124a455b7032faf"> <div class="header"> <h3>lib/capital_one/atm.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>19</b> relevant lines. <span class="green"><b>19</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Atm</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="5" data-linenumber="4"> <span class="hits">5</span> <code class="ruby"> return Config.baseUrl + "/atms"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="1" data-linenumber="8"> <span class="hits">1</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="5" data-linenumber="12"> <span class="hits">5</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAll</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Returns all ATMs as an array of hashes.</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="20"> <span class="hits">1</span> <code class="ruby"> def self.getAll</code> </li> <li class="covered" data-hits="2" data-linenumber="21"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="22"> <span class="hits">2</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="2" data-linenumber="23"> <span class="hits">2</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> #==getAllByLocation</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> # Get all ATMs withing a certain radius of a geocoordinate</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> #= Paremeters: latitude, longitude, radius</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Accepts lat, lng, and rad as floats</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> # Returns an array of hashes within the radius of the geocoordinate. Each hash has an ATM.</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby"> def self.getAllByLocation(lat, lng, rad)</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> # Gets one ATM for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"> # Parameters: AtmId</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> # Returns the ATM that has the given ID. </code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="43"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="44"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="45"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="46"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby">end</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"></code> </li> </ol> </pre>
</div>
<div class="source_table" id="9ef485049d4e970d60afe7fd568ca0bd5871916c"> <div class="header"> <h3>lib/capital_one/bill.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>48</b> relevant lines. <span class="green"><b>48</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Bill</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.accountBaseUrl</code> </li> <li class="covered" data-hits="5" data-linenumber="4"> <span class="hits">5</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.customerBaseUrl</code> </li> <li class="covered" data-hits="2" data-linenumber="8"> <span class="hits">2</span> <code class="ruby"> return Config.baseUrl + "/customers"</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="3" data-linenumber="12"> <span class="hits">3</span> <code class="ruby"> return Config.baseUrl + "/bills"</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="15"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="1" data-linenumber="16"> <span class="hits">1</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="19"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="11" data-linenumber="20"> <span class="hits">11</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="21"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="22"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="23"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"> #==getAllByAccountId</code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> # Get all bills for a specific account</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> # Parameters: accountId</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> # Returns an array of hashes containing the bills. </code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="30"> <span class="hits">1</span> <code class="ruby"> def self.getAllByAccountId(accountId)</code> </li> <li class="covered" data-hits="2" data-linenumber="31"> <span class="hits">2</span> <code class="ruby"> url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="32"> <span class="hits">2</span> <code class="ruby"> response = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="2" data-linenumber="33"> <span class="hits">2</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="34"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="35"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> #==getAllByCustomerId</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> # Get all bills for a specific customer</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"> # Parameters: customerId</code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> # Returns the customer as a hash array.</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="41"> <span class="hits">1</span> <code class="ruby"> def self.getAllByCustomerId(customerId)</code> </li> <li class="covered" data-hits="1" data-linenumber="42"> <span class="hits">1</span> <code class="ruby"> url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="43"> <span class="hits">1</span> <code class="ruby"> response = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="44"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> # Gets one bill for a specific billId</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> # Parameters: billId</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> # Returns a hash with the bill data</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="52"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="53"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="54"> <span class="hits">1</span> <code class="ruby"> response = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="55"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="56"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="57"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="58"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="59"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="60"> <code class="ruby"> #==updateBill</code> </li> <li class="never" data-hits="" data-linenumber="61"> <code class="ruby"> # Updates an account's information by id with given json data. </code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"> # Parameters: BillId, BillJson</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> # Json format is as follows: </code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # "status": "",</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> # "payee": "",</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # "nickname": "",</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> # "payment_date": "",</code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"> # "recurring_date": 0,</code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> # "payment_amount": 0</code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"> # Returns http response code. </code> </li> <li class="never" data-hits="" data-linenumber="73"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="74"> <span class="hits">1</span> <code class="ruby"> def self.updateBill(billId, bill)</code> </li> <li class="covered" data-hits="1" data-linenumber="75"> <span class="hits">1</span> <code class="ruby"> billToUpdate = bill.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="76"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="77"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="78"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="79"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="80"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="81"> <span class="hits">1</span> <code class="ruby"> request.body = billToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="82"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="83"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="84"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="85"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="86"> <code class="ruby"> #==createBill</code> </li> <li class="never" data-hits="" data-linenumber="87"> <code class="ruby"> # create a new bill on an associated account ID</code> </li> <li class="never" data-hits="" data-linenumber="88"> <code class="ruby"> # Parameters: AccountId, BillJson</code> </li> <li class="never" data-hits="" data-linenumber="89"> <code class="ruby"> # Json is as follows:</code> </li> <li class="never" data-hits="" data-linenumber="90"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="91"> <code class="ruby"> # "status": "",</code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> # "payee": "",</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"> # "nickname": "",</code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"> # "payment_date": "",</code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # "recurring_date": 0,</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"> # "payment_amount": 0</code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> # Returns http response code. </code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="100"> <span class="hits">1</span> <code class="ruby"> def self.createBill(accountId, bill)</code> </li> <li class="covered" data-hits="2" data-linenumber="101"> <span class="hits">2</span> <code class="ruby"> url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="102"> <span class="hits">2</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="2" data-linenumber="103"> <span class="hits">2</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="2" data-linenumber="104"> <span class="hits">2</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})</code> </li> <li class="covered" data-hits="2" data-linenumber="105"> <span class="hits">2</span> <code class="ruby"> request.body = bill.to_json</code> </li> <li class="covered" data-hits="2" data-linenumber="106"> <span class="hits">2</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="2" data-linenumber="107"> <span class="hits">2</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="108"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="109"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="110"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="111"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="112"> <code class="ruby"> #==deleteBill</code> </li> <li class="never" data-hits="" data-linenumber="113"> <code class="ruby"> # delete a bill by its id</code> </li> <li class="never" data-hits="" data-linenumber="114"> <code class="ruby"> # Parameters: BillId</code> </li> <li class="never" data-hits="" data-linenumber="115"> <code class="ruby"> # Returns http response code</code> </li> <li class="covered" data-hits="1" data-linenumber="116"> <span class="hits">1</span> <code class="ruby"> def self.deleteBill(billId)</code> </li> <li class="covered" data-hits="1" data-linenumber="117"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="118"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="119"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="120"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="121"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="122"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="123"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="124"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="4362c7cd9c31d47f07610ce16db68f6968f06830"> <div class="header"> <h3>lib/capital_one/branch.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>15</b> relevant lines. <span class="green"><b>15</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Branch</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="1" data-linenumber="4"> <span class="hits">1</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl + "/branches"</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="4" data-linenumber="12"> <span class="hits">4</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAll</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Gets all branches</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"> # Returns an array of Hashes with the branch data</code> </li> <li class="never" data-hits="" data-linenumber="20"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="21"> <span class="hits">1</span> <code class="ruby"> def self.getAll</code> </li> <li class="covered" data-hits="2" data-linenumber="22"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="23"> <span class="hits">2</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="2" data-linenumber="24"> <span class="hits">2</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> # Gets one branch for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> #= Parameters: AtmId</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> # Returns a hash with the ATM data</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body) </code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="9d6e78f0ca8ae2319eb48d58dc640dd1ee0bc831"> <div class="header"> <h3>lib/capital_one/customer.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>40</b> relevant lines. <span class="green"><b>40</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Customer</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="10" data-linenumber="4"> <span class="hits">10</span> <code class="ruby"> return Config.baseUrl + "/customers"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.urlWithAcctEntity</code> </li> <li class="covered" data-hits="2" data-linenumber="8"> <span class="hits">2</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="1" data-linenumber="12"> <span class="hits">1</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="15"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="12" data-linenumber="16"> <span class="hits">12</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="20"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="21"> <code class="ruby"> #== getAll</code> </li> <li class="never" data-hits="" data-linenumber="22"> <code class="ruby"> # Gets all customers the API key has acccess to.</code> </li> <li class="never" data-hits="" data-linenumber="23"> <code class="ruby"> # Returns an array of hashes.</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="25"> <span class="hits">1</span> <code class="ruby"> def self.getAll</code> </li> <li class="covered" data-hits="6" data-linenumber="26"> <span class="hits">6</span> <code class="ruby"> url = "#{self.urlWithEntity}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="6" data-linenumber="27"> <span class="hits">6</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="6" data-linenumber="28"> <span class="hits">6</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="covered" data-hits="6" data-linenumber="29"> <span class="hits">6</span> <code class="ruby"> return data</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="32"> <code class="ruby"> #== getOne</code> </li> <li class="never" data-hits="" data-linenumber="33"> <code class="ruby"> # Gets the specified customer's information.</code> </li> <li class="never" data-hits="" data-linenumber="34"> <code class="ruby"> #= Parameters: CustomerId</code> </li> <li class="never" data-hits="" data-linenumber="35"> <code class="ruby"> # Returns a Hash with the customer data</code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="37"> <span class="hits">1</span> <code class="ruby"> def self.getOne(custId)</code> </li> <li class="covered" data-hits="1" data-linenumber="38"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{custId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="39"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="40"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"> #== getOneByAccountId</code> </li> <li class="never" data-hits="" data-linenumber="44"> <code class="ruby"> # Get the customer for the given account.</code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> #= Parameters: AccountId</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"> # Returns a hash with the specified customer data.</code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="48"> <span class="hits">1</span> <code class="ruby"> def self.getOneByAccountId(accID)</code> </li> <li class="covered" data-hits="1" data-linenumber="49"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithAcctEntity}/#{accID}/customer?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="50"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="51"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="54"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="55"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="56"> <code class="ruby"> #==createCustomer</code> </li> <li class="never" data-hits="" data-linenumber="57"> <code class="ruby"> # Creates a new customer with the given json data</code> </li> <li class="never" data-hits="" data-linenumber="58"> <code class="ruby"> #= Parameters: CustomerHash</code> </li> <li class="never" data-hits="" data-linenumber="59"> <code class="ruby"> # JSON is as follows: </code> </li> <li class="never" data-hits="" data-linenumber="60"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="61"> <code class="ruby"> # "first_name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"> # "last_name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> # "address": {</code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> # "street_number": "string",</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # "street_name": "",</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> # "city": "",</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # "state": "",</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> # "zip": "" </code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="73"> <span class="hits">1</span> <code class="ruby"> def self.createCustomer(customer)</code> </li> <li class="covered" data-hits="1" data-linenumber="74"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="75"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="76"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="77"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="78"> <span class="hits">1</span> <code class="ruby"> request.body = customer.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="79"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="80"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="81"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="82"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="83"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="84"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="85"> <code class="ruby"> </code> </li> <li class="never" data-hits="" data-linenumber="86"> <code class="ruby"> #== updateCustomer</code> </li> <li class="never" data-hits="" data-linenumber="87"> <code class="ruby"> # Updates a customer by id with given json data. </code> </li> <li class="never" data-hits="" data-linenumber="88"> <code class="ruby"> #= Parameters: CustomerId, CustomerHash.</code> </li> <li class="never" data-hits="" data-linenumber="89"> <code class="ruby"> # Json is as follows: </code> </li> <li class="never" data-hits="" data-linenumber="90"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="91"> <code class="ruby"> # "address": {</code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> # "street_number": "",</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"> # "street_name": "",</code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"> # "city": "",</code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # "state": "",</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"> # "zip": ""</code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"> # Returns http response code. </code> </li> <li class="never" data-hits="" data-linenumber="100"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="101"> <span class="hits">1</span> <code class="ruby"> def self.updateCustomer(custID, customer)</code> </li> <li class="covered" data-hits="1" data-linenumber="102"> <span class="hits">1</span> <code class="ruby"> customerToUpdate = customer.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="103"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{custID}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="104"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="105"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="106"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="107"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="108"> <span class="hits">1</span> <code class="ruby"> request.body = customerToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="109"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="110"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="111"> <code class="ruby"> end </code> </li> <li class="never" data-hits="" data-linenumber="112"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="113"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="5bd4b3c628722b3d590fa1752cfd9b8f9777d281"> <div class="header"> <h3>lib/capital_one/deposit.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>42</b> relevant lines. <span class="green"><b>42</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Deposit</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="7" data-linenumber="4"> <span class="hits">7</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="12" data-linenumber="12"> <span class="hits">12</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAllByAccountId</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Get all deposits for a specific account</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"> #= Parameters: AccountID</code> </li> <li class="never" data-hits="" data-linenumber="20"> <code class="ruby"> # Returns an array of hashes containing the deposits for that account.</code> </li> <li class="never" data-hits="" data-linenumber="21"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="22"> <span class="hits">1</span> <code class="ruby"> def self.getAllByAccountId(accID)</code> </li> <li class="covered" data-hits="4" data-linenumber="23"> <span class="hits">4</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accID}/deposits?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="4" data-linenumber="24"> <span class="hits">4</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="4" data-linenumber="25"> <span class="hits">4</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="covered" data-hits="4" data-linenumber="26"> <span class="hits">4</span> <code class="ruby"> return data</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"> # Returns a deposit for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="32"> <code class="ruby"> #= Parameters: DepositId</code> </li> <li class="never" data-hits="" data-linenumber="33"> <code class="ruby"> # Returns a hash with the deposit data</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="36"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="37"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"> #==createDeposit</code> </li> <li class="never" data-hits="" data-linenumber="44"> <code class="ruby"> # Creates a new deposit.</code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> # Parameters: toAccountId, DepositHash</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"> # DepositHash is formatted as follows: </code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> # "transaction_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"> # "description": "string"</code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="54"> <code class="ruby"> # Returns http response code. </code> </li> <li class="never" data-hits="" data-linenumber="55"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="56"> <span class="hits">1</span> <code class="ruby"> def self.createDeposit(toAcc, deposit)</code> </li> <li class="covered" data-hits="2" data-linenumber="57"> <span class="hits">2</span> <code class="ruby"> depositToCreate = deposit.to_json</code> </li> <li class="covered" data-hits="2" data-linenumber="58"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{toAcc}/deposits?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="59"> <span class="hits">2</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="2" data-linenumber="60"> <span class="hits">2</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="2" data-linenumber="61"> <span class="hits">2</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})</code> </li> <li class="covered" data-hits="2" data-linenumber="62"> <span class="hits">2</span> <code class="ruby"> request.body = depositToCreate</code> </li> <li class="covered" data-hits="2" data-linenumber="63"> <span class="hits">2</span> <code class="ruby"> resp = http.request(request)</code> </li> <li class="covered" data-hits="2" data-linenumber="64"> <span class="hits">2</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> #==updateDeposit</code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # Updates an existing deposit</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"> #= Parameters: DepositId, DepositHash</code> </li> <li class="never" data-hits="" data-linenumber="73"> <code class="ruby"> # DepositHash is formatted as follows: </code> </li> <li class="never" data-hits="" data-linenumber="74"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="75"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="76"> <code class="ruby"> # "transaction_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="77"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="78"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="79"> <code class="ruby"> # "description": "string"</code> </li> <li class="never" data-hits="" data-linenumber="80"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="81"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="82"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="83"> <span class="hits">1</span> <code class="ruby"> def self.updateDeposit(id, deposit)</code> </li> <li class="covered" data-hits="1" data-linenumber="84"> <span class="hits">1</span> <code class="ruby"> depositToUpdate = deposit.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="85"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="86"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="87"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="88"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="89"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="90"> <span class="hits">1</span> <code class="ruby"> request.body = depositToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="91"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="92"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> #==deleteDeposit</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> # Deletes an existing deposit</code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"> #= Parameters: DepositId</code> </li> <li class="never" data-hits="" data-linenumber="100"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="101"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="102"> <span class="hits">1</span> <code class="ruby"> def self.deleteDeposit(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="103"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="104"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="105"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="106"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="107"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="108"> <span class="hits">1</span> <code class="ruby"> resp = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="109"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="110"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="1099be63a00c4c92c91d7e77e68da8316d834e89"> <div class="header"> <h3>lib/capital_one/merchant.rb</h3> <h4><span class="green">97.56 %</span> covered</h4> <div> <b>41</b> relevant lines. <span class="green"><b>40</b> lines covered</span> and <span class="red"><b>1</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Merchant</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="9" data-linenumber="4"> <span class="hits">9</span> <code class="ruby"> return Config.baseUrl + "/merchants"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="missed" data-hits="0" data-linenumber="8"> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="10" data-linenumber="12"> <span class="hits">10</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAll</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Returns all Merchants as an array of hashes</code> </li> <li class="covered" data-hits="1" data-linenumber="19"> <span class="hits">1</span> <code class="ruby"> def self.getAll</code> </li> <li class="covered" data-hits="5" data-linenumber="20"> <span class="hits">5</span> <code class="ruby"> url = "#{self.urlWithEntity}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="5" data-linenumber="21"> <span class="hits">5</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="5" data-linenumber="22"> <span class="hits">5</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="covered" data-hits="5" data-linenumber="23"> <span class="hits">5</span> <code class="ruby"> return data</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> #==getAllByLocation</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> # Returns all Merchants within a given location range</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> #= Parameters: Latitude, Longitude, Radius</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Accepts lat, lng, and rad as floats</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> # Returns an array of hashes</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby"> def self.getAllByLocation(lat, lng, rad)</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="covered" data-hits="1" data-linenumber="36"> <span class="hits">1</span> <code class="ruby"> return data</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"> # Returns a single merchant for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> #= Parameters: MerchantId</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"> # Returns a hash</code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="44"> <span class="hits">1</span> <code class="ruby"> def self.getOne(merchId)</code> </li> <li class="covered" data-hits="1" data-linenumber="45"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="46"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="47"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="covered" data-hits="1" data-linenumber="48"> <span class="hits">1</span> <code class="ruby"> return data</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"> #==updateMerchant</code> </li> <li class="never" data-hits="" data-linenumber="54"> <code class="ruby"> # Updates an existing Merchant</code> </li> <li class="never" data-hits="" data-linenumber="55"> <code class="ruby"> #= Parameters: MerchantId, MerchantHash</code> </li> <li class="never" data-hits="" data-linenumber="56"> <code class="ruby"> # MerchantHash format is as follows: </code> </li> <li class="never" data-hits="" data-linenumber="57"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="58"> <code class="ruby"> # "name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="59"> <code class="ruby"> # "address": {</code> </li> <li class="never" data-hits="" data-linenumber="60"> <code class="ruby"> # "street_number": "string",</code> </li> <li class="never" data-hits="" data-linenumber="61"> <code class="ruby"> # "street_name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"> # "city": "string",</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> # "state": "string",</code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> # "zip": "string",</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # },</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> # "geocode": {</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # "lat": 0,</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> # "lng": 0,</code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="73"> <span class="hits">1</span> <code class="ruby"> def self.updateMerchant(merchId, merchant)</code> </li> <li class="covered" data-hits="1" data-linenumber="74"> <span class="hits">1</span> <code class="ruby"> merchantToUpdate = merchant.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="75"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="76"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="77"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="78"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="79"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="80"> <span class="hits">1</span> <code class="ruby"> request.body = merchantToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="81"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="82"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="83"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="84"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="85"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="86"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="87"> <code class="ruby"> #==createMerchant</code> </li> <li class="never" data-hits="" data-linenumber="88"> <code class="ruby"> # Creates a new Merchant</code> </li> <li class="never" data-hits="" data-linenumber="89"> <code class="ruby"> #= Parameters: MerchantHash</code> </li> <li class="never" data-hits="" data-linenumber="90"> <code class="ruby"> # MerchantHash format is as follows: </code> </li> <li class="never" data-hits="" data-linenumber="91"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> # "name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"> # "address": {</code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"> # "street_number": "string",</code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # "street_name": "string",</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"> # "city": "string",</code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> # "state": "string",</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> # "zip": "string",</code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"> # },</code> </li> <li class="never" data-hits="" data-linenumber="100"> <code class="ruby"> # "geocode": {</code> </li> <li class="never" data-hits="" data-linenumber="101"> <code class="ruby"> # "lat": 0,</code> </li> <li class="never" data-hits="" data-linenumber="102"> <code class="ruby"> # "lng": 0,</code> </li> <li class="never" data-hits="" data-linenumber="103"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="104"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="105"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="106"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="107"> <span class="hits">1</span> <code class="ruby"> def self.createMerchant(merchant)</code> </li> <li class="covered" data-hits="1" data-linenumber="108"> <span class="hits">1</span> <code class="ruby"> merchantToCreate = merchant.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="109"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="110"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="111"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="112"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="113"> <span class="hits">1</span> <code class="ruby"> request.body = merchantToCreate</code> </li> <li class="covered" data-hits="1" data-linenumber="114"> <span class="hits">1</span> <code class="ruby"> resp = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="115"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="116"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="117"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="118"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="0d11ac0799ef22a9dd646e1825098d04b4fd2670"> <div class="header"> <h3>lib/capital_one/purchase.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>41</b> relevant lines. <span class="green"><b>41</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Purchase</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="7" data-linenumber="4"> <span class="hits">7</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="12" data-linenumber="12"> <span class="hits">12</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAll</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Returns all purchases for a given account</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"> #= Parameters: AccountId</code> </li> <li class="never" data-hits="" data-linenumber="20"> <code class="ruby"> # Returns an array of hashes</code> </li> <li class="never" data-hits="" data-linenumber="21"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="22"> <span class="hits">1</span> <code class="ruby"> def self.getAllByAccountId(accId)</code> </li> <li class="covered" data-hits="4" data-linenumber="23"> <span class="hits">4</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accId}/purchases?&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="4" data-linenumber="24"> <span class="hits">4</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="4" data-linenumber="25"> <span class="hits">4</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Returns a purchase for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> #= Parameters: PurchaseId</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"> # Returns a hash</code> </li> <li class="never" data-hits="" data-linenumber="32"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/purchases/#{id}?&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="36"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"> #==createPurchase</code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> # Creates a new purchase for a given account</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"> #= Parameters: AccountId, PurchaseHash</code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"> # PurchaseHash is formatted as follows:</code> </li> <li class="never" data-hits="" data-linenumber="44"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> # "merchant_id": "string",</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> # "purchase_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> # "description": "string"</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"> # Returns http response code</code> </li> <li class="covered" data-hits="1" data-linenumber="53"> <span class="hits">1</span> <code class="ruby"> def self.createPurchase(accId, purchase)</code> </li> <li class="covered" data-hits="2" data-linenumber="54"> <span class="hits">2</span> <code class="ruby"> purchaseToCreate = purchase.to_json</code> </li> <li class="covered" data-hits="2" data-linenumber="55"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accId}/purchases?&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="56"> <span class="hits">2</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="2" data-linenumber="57"> <span class="hits">2</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="2" data-linenumber="58"> <span class="hits">2</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="2" data-linenumber="59"> <span class="hits">2</span> <code class="ruby"> request.body = purchaseToCreate</code> </li> <li class="covered" data-hits="2" data-linenumber="60"> <span class="hits">2</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="2" data-linenumber="61"> <span class="hits">2</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> #==updatePurchase</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # Updates an existing purchase</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> #= Parameters: PurchaseId, PurchaseHash</code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"> # PurchaseHash is formatted as follows:</code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # "merchant_id": "string",</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="73"> <code class="ruby"> # "purchase_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="74"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="75"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="76"> <code class="ruby"> # "description": "string"</code> </li> <li class="never" data-hits="" data-linenumber="77"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="78"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="79"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="80"> <span class="hits">1</span> <code class="ruby"> def self.updatePurchase(id, purchase)</code> </li> <li class="covered" data-hits="1" data-linenumber="81"> <span class="hits">1</span> <code class="ruby"> purchaseToUpdate = purchase.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="82"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/purchases/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="83"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="84"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="85"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="86"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="87"> <span class="hits">1</span> <code class="ruby"> request.body = purchaseToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="88"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="89"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="90"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="91"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"> #==deletePurchase</code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # Deletes a purchase for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"> #= Parameters: PurchaseId</code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="99"> <span class="hits">1</span> <code class="ruby"> def self.deletePurchase(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="100"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/purchases/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="101"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="102"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="103"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="104"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="105"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="106"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="107"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="cc3bc6146cda462f16e9bd0945e38539cdbba1ff"> <div class="header"> <h3>lib/capital_one/transfer.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>45</b> relevant lines. <span class="green"><b>45</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Transfer</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="8" data-linenumber="4"> <span class="hits">8</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="13" data-linenumber="12"> <span class="hits">13</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"> #= getAll</code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> # Returns an array of hashes getting all the transfers for an account.</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Each index in the array is the hash of an individual transfer.</code> </li> <li class="covered" data-hits="1" data-linenumber="19"> <span class="hits">1</span> <code class="ruby"> def self.getAll(accId)</code> </li> <li class="covered" data-hits="4" data-linenumber="20"> <span class="hits">4</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accId}/transfers?&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="4" data-linenumber="21"> <span class="hits">4</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="4" data-linenumber="22"> <span class="hits">4</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="23"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="24"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="25"> <code class="ruby"> #== getAllByType</code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> # Gets all transfers of a given type and account.</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"> #= Parameters:</code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> # Accepts a string of the transfer type. 2 possbilities: payer or payee</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Returns an array of hashes with the transfers.</code> </li> <li class="covered" data-hits="1" data-linenumber="30"> <span class="hits">1</span> <code class="ruby"> def self.getAllByType(accId, type)</code> </li> <li class="covered" data-hits="1" data-linenumber="31"> <span class="hits">1</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accId}/transfers?type=#{type}&key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="32"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="34"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="35"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="36"> <code class="ruby"> #== getOne</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> # Returns the transfer specified by its transfer ID.</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"> #= Parameters:</code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> # Accepts a string of the transfer ID. </code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"> # Returns a hash with the transfer info.</code> </li> <li class="covered" data-hits="1" data-linenumber="41"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="42"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="43"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="44"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> #== createAccount</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> # Creates a new transfer</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> # Parameters: AccountID, TransferHash</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # Returns the http response code. </code> </li> <li class="covered" data-hits="1" data-linenumber="52"> <span class="hits">1</span> <code class="ruby"> def self.createTransfer(accId, transfer)</code> </li> <li class="covered" data-hits="2" data-linenumber="53"> <span class="hits">2</span> <code class="ruby"> transferToCreate = transfer.to_json</code> </li> <li class="covered" data-hits="2" data-linenumber="54"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accId}/transfers?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="55"> <span class="hits">2</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="2" data-linenumber="56"> <span class="hits">2</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="2" data-linenumber="57"> <span class="hits">2</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="2" data-linenumber="58"> <span class="hits">2</span> <code class="ruby"> request.body = transferToCreate</code> </li> <li class="covered" data-hits="2" data-linenumber="59"> <span class="hits">2</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="2" data-linenumber="60"> <span class="hits">2</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="61"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="62"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"> #==updateAccount</code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # Updates a transfer's info.</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"> # Parameters: TransferId, TransferHash</code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> # Returns the http response code.</code> </li> <li class="covered" data-hits="1" data-linenumber="68"> <span class="hits">1</span> <code class="ruby"> def self.updateTransfer(id, transfer)</code> </li> <li class="covered" data-hits="1" data-linenumber="69"> <span class="hits">1</span> <code class="ruby"> transferToUpdate = transfer.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="70"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="71"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="72"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="73"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="74"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="75"> <span class="hits">1</span> <code class="ruby"> request.body = transferToUpdate</code> </li> <li class="covered" data-hits="1" data-linenumber="76"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="77"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="78"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="79"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="80"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="81"> <code class="ruby"> #== deleteAccount</code> </li> <li class="never" data-hits="" data-linenumber="82"> <code class="ruby"> # delete a given transfer by TransferId.</code> </li> <li class="never" data-hits="" data-linenumber="83"> <code class="ruby"> # Parameters: TransferId.</code> </li> <li class="never" data-hits="" data-linenumber="84"> <code class="ruby"> # Returns the http response code. </code> </li> <li class="covered" data-hits="1" data-linenumber="85"> <span class="hits">1</span> <code class="ruby"> def self.deleteTransfer(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="86"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="87"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="88"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="89"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="90"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="91"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="9dc4fd8cd512f510c0b09ef896b92bbbdc0422a0"> <div class="header"> <h3>lib/capital_one/version.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>2</b> relevant lines. <span class="green"><b>2</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">module CapitalOne</code> </li> <li class="covered" data-hits="1" data-linenumber="2"> <span class="hits">1</span> <code class="ruby"> VERSION = "0.1.0"</code> </li> <li class="never" data-hits="" data-linenumber="3"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
<div class="source_table" id="fc349552d31dbf0f29dbb28e47e604e109a8255e"> <div class="header"> <h3>lib/capital_one/withdrawal.rb</h3> <h4><span class="green">100.0 %</span> covered</h4> <div> <b>40</b> relevant lines. <span class="green"><b>40</b> lines covered</span> and <span class="red"><b>0</b> lines missed.</span> </div> </div> <pre> <ol> <li class="covered" data-hits="1" data-linenumber="1"> <span class="hits">1</span> <code class="ruby">class Withdrawal</code> </li> <li class="never" data-hits="" data-linenumber="2"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="3"> <span class="hits">1</span> <code class="ruby"> def self.urlWithEntity</code> </li> <li class="covered" data-hits="7" data-linenumber="4"> <span class="hits">7</span> <code class="ruby"> return Config.baseUrl + "/accounts"</code> </li> <li class="never" data-hits="" data-linenumber="5"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="6"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="7"> <span class="hits">1</span> <code class="ruby"> def self.url</code> </li> <li class="covered" data-hits="4" data-linenumber="8"> <span class="hits">4</span> <code class="ruby"> return Config.baseUrl</code> </li> <li class="never" data-hits="" data-linenumber="9"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="10"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="11"> <span class="hits">1</span> <code class="ruby"> def self.apiKey</code> </li> <li class="covered" data-hits="12" data-linenumber="12"> <span class="hits">12</span> <code class="ruby"> return Config.apiKey</code> </li> <li class="never" data-hits="" data-linenumber="13"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="14"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="15"> <code class="ruby"> # *** GET ***</code> </li> <li class="never" data-hits="" data-linenumber="16"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="17"> <code class="ruby"> #==getAllByAccountId</code> </li> <li class="never" data-hits="" data-linenumber="18"> <code class="ruby"> # Get all withdrawals for a specific account</code> </li> <li class="never" data-hits="" data-linenumber="19"> <code class="ruby"> #= Parameters: AccountID</code> </li> <li class="never" data-hits="" data-linenumber="20"> <code class="ruby"> # Returns an array of hashes containing the withdrawals for that account.</code> </li> <li class="never" data-hits="" data-linenumber="21"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="22"> <span class="hits">1</span> <code class="ruby"> def self.getAllByAccountId(accID)</code> </li> <li class="covered" data-hits="4" data-linenumber="23"> <span class="hits">4</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{accID}/withdrawals?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="4" data-linenumber="24"> <span class="hits">4</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="4" data-linenumber="25"> <span class="hits">4</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="26"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="27"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="28"> <code class="ruby"> #==getOne</code> </li> <li class="never" data-hits="" data-linenumber="29"> <code class="ruby"> # Get a single withdrawal for a given ID</code> </li> <li class="never" data-hits="" data-linenumber="30"> <code class="ruby"> #= Parameters: WithdrawalId</code> </li> <li class="never" data-hits="" data-linenumber="31"> <code class="ruby"> # Returns a hash</code> </li> <li class="never" data-hits="" data-linenumber="32"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="33"> <span class="hits">1</span> <code class="ruby"> def self.getOne(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="34"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/withdrawals/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="35"> <span class="hits">1</span> <code class="ruby"> resp = Net::HTTP.get_response(URI.parse(url))</code> </li> <li class="covered" data-hits="1" data-linenumber="36"> <span class="hits">1</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="37"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="38"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="39"> <code class="ruby"> # *** POST ***</code> </li> <li class="never" data-hits="" data-linenumber="40"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="41"> <code class="ruby"> #==createWithdrawal</code> </li> <li class="never" data-hits="" data-linenumber="42"> <code class="ruby"> # Creates a new withdrawal</code> </li> <li class="never" data-hits="" data-linenumber="43"> <code class="ruby"> #= Parameters: toAccountId, WithdrawalHash</code> </li> <li class="never" data-hits="" data-linenumber="44"> <code class="ruby"> # WithdrawalHash formatted as follows: </code> </li> <li class="never" data-hits="" data-linenumber="45"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="46"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="47"> <code class="ruby"> # "transaction_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="48"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="49"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="50"> <code class="ruby"> # "desciption": "string"</code> </li> <li class="never" data-hits="" data-linenumber="51"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="52"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="53"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="54"> <span class="hits">1</span> <code class="ruby"> def self.createWithdrawal(toAcc, withdrawal)</code> </li> <li class="covered" data-hits="2" data-linenumber="55"> <span class="hits">2</span> <code class="ruby"> withdrawalToCreate = withdrawal.to_json</code> </li> <li class="covered" data-hits="2" data-linenumber="56"> <span class="hits">2</span> <code class="ruby"> url = "#{self.urlWithEntity}/#{toAcc}/withdrawals?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="2" data-linenumber="57"> <span class="hits">2</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="2" data-linenumber="58"> <span class="hits">2</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="2" data-linenumber="59"> <span class="hits">2</span> <code class="ruby"> request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})</code> </li> <li class="covered" data-hits="2" data-linenumber="60"> <span class="hits">2</span> <code class="ruby"> request.body = withdrawalToCreate</code> </li> <li class="covered" data-hits="2" data-linenumber="61"> <span class="hits">2</span> <code class="ruby"> resp = http.request(request)</code> </li> <li class="covered" data-hits="2" data-linenumber="62"> <span class="hits">2</span> <code class="ruby"> data = JSON.parse(resp.body)</code> </li> <li class="never" data-hits="" data-linenumber="63"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="64"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="65"> <code class="ruby"> # *** PUT ***</code> </li> <li class="never" data-hits="" data-linenumber="66"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="67"> <code class="ruby"> #==updateWithdrawal</code> </li> <li class="never" data-hits="" data-linenumber="68"> <code class="ruby"> # Updates an existing withdrawal</code> </li> <li class="never" data-hits="" data-linenumber="69"> <code class="ruby"> #= Parameters: WithdrawalId, WithdrawalHash</code> </li> <li class="never" data-hits="" data-linenumber="70"> <code class="ruby"> # WithdrawalHash formatted as follows: </code> </li> <li class="never" data-hits="" data-linenumber="71"> <code class="ruby"> # {</code> </li> <li class="never" data-hits="" data-linenumber="72"> <code class="ruby"> # "medium": "balance",</code> </li> <li class="never" data-hits="" data-linenumber="73"> <code class="ruby"> # "transaction_date": "string",</code> </li> <li class="never" data-hits="" data-linenumber="74"> <code class="ruby"> # "status": "pending",</code> </li> <li class="never" data-hits="" data-linenumber="75"> <code class="ruby"> # "amount": 0,</code> </li> <li class="never" data-hits="" data-linenumber="76"> <code class="ruby"> # "desciption": "string"</code> </li> <li class="never" data-hits="" data-linenumber="77"> <code class="ruby"> # }</code> </li> <li class="never" data-hits="" data-linenumber="78"> <code class="ruby"> # Returns http response code</code> </li> <li class="never" data-hits="" data-linenumber="79"> <code class="ruby"></code> </li> <li class="covered" data-hits="1" data-linenumber="80"> <span class="hits">1</span> <code class="ruby"> def self.updateWithdrawal(id, withdrawal)</code> </li> <li class="covered" data-hits="1" data-linenumber="81"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/withdrawals/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="82"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="83"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="84"> <span class="hits">1</span> <code class="ruby"> key = "?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="85"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})</code> </li> <li class="covered" data-hits="1" data-linenumber="86"> <span class="hits">1</span> <code class="ruby"> request.body = withdrawal.to_json</code> </li> <li class="covered" data-hits="1" data-linenumber="87"> <span class="hits">1</span> <code class="ruby"> response = http.request(request)</code> </li> <li class="covered" data-hits="1" data-linenumber="88"> <span class="hits">1</span> <code class="ruby"> return JSON.parse(response.body)</code> </li> <li class="never" data-hits="" data-linenumber="89"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="90"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="91"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="92"> <code class="ruby"> # *** DELETE ***</code> </li> <li class="never" data-hits="" data-linenumber="93"> <code class="ruby"></code> </li> <li class="never" data-hits="" data-linenumber="94"> <code class="ruby"> #==deleteWithdrawal</code> </li> <li class="never" data-hits="" data-linenumber="95"> <code class="ruby"> # Deletes a specified withdrawal from a specified account.</code> </li> <li class="never" data-hits="" data-linenumber="96"> <code class="ruby"> # Parameters: WithdrawalID</code> </li> <li class="never" data-hits="" data-linenumber="97"> <code class="ruby"> # Returns http response code.</code> </li> <li class="never" data-hits="" data-linenumber="98"> <code class="ruby"> #= Note: This does not actually delete the withdrawal from the database, it only sets its status to 'cancelled'</code> </li> <li class="never" data-hits="" data-linenumber="99"> <code class="ruby"> </code> </li> <li class="covered" data-hits="1" data-linenumber="100"> <span class="hits">1</span> <code class="ruby"> def self.deleteWithdrawal(id)</code> </li> <li class="covered" data-hits="1" data-linenumber="101"> <span class="hits">1</span> <code class="ruby"> url = "#{self.url}/withdrawals/#{id}?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="102"> <span class="hits">1</span> <code class="ruby"> uri = URI.parse(url)</code> </li> <li class="covered" data-hits="1" data-linenumber="103"> <span class="hits">1</span> <code class="ruby"> http = Net::HTTP.new(uri.host, uri.port)</code> </li> <li class="covered" data-hits="1" data-linenumber="104"> <span class="hits">1</span> <code class="ruby"> key="?key=#{self.apiKey}"</code> </li> <li class="covered" data-hits="1" data-linenumber="105"> <span class="hits">1</span> <code class="ruby"> request = Net::HTTP::Delete.new(uri.path+key)</code> </li> <li class="covered" data-hits="1" data-linenumber="106"> <span class="hits">1</span> <code class="ruby"> resp = http.request(request)</code> </li> <li class="never" data-hits="" data-linenumber="107"> <code class="ruby"> end</code> </li> <li class="never" data-hits="" data-linenumber="108"> <code class="ruby">end</code> </li> </ol> </pre>
</div>
</div> </div> </body>
</html>