Add documentation to the helpers module.

This commit is contained in:
Spencer Ofwiti
2021-05-11 14:34:23 +03:00
parent c9f73899c3
commit e0c045cdfa
37 changed files with 1403 additions and 585 deletions

View File

@@ -60,7 +60,20 @@
<code>src/app/_helpers/mock-backend.ts</code>
</p>
<p class="comment">
<h3>Description</h3>
</p>
<p class="comment">
<p>Intercepts HTTP requests and handles some specified requests internally.
Provides a backend that can handle requests for certain data items.</p>
</p>
<p class="comment">
<h3>Example</h3>
</p>
<div class="io-description">
</div>
<section>
<h3 id="index">Index</h3>
@@ -118,14 +131,16 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="240"
class="link-to-prism">src/app/_helpers/mock-backend.ts:240</a></div>
<div class="io-line">Defined in <a href="" data-line="268"
class="link-to-prism">src/app/_helpers/mock-backend.ts:268</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Intercepts HTTP requests.</p>
</div>
<div class="io-description">
<b>Parameters :</b>
@@ -135,6 +150,7 @@
<td>Name</td>
<td>Type</td>
<td>Optional</td>
<td>Description</td>
</tr>
</thead>
<tbody>
@@ -149,6 +165,12 @@
</td>
<td>
<ul>
<li>An outgoing HTTP request with an optional typed body.</li>
</ul>
</td>
</tr>
<tr>
<td>next</td>
@@ -161,6 +183,12 @@
</td>
<td>
<ul>
<li>The next HTTP handler or the outgoing request dispatcher.</li>
</ul>
</td>
</tr>
</tbody>
</table>
@@ -172,7 +200,8 @@
</div>
<div class="io-description">
<p>The response from the resolved request.</p>
</div>
</td>
</tr>
@@ -186,10 +215,18 @@
<div class="tab-pane fade tab-source-code" id="c-source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from &#x27;@angular/common/http&#x27;;
import {Injectable} from &#x27;@angular/core&#x27;;
// Third party imports
import {Observable, of, throwError} from &#x27;rxjs&#x27;;
import {delay, dematerialize, materialize, mergeMap} from &#x27;rxjs/operators&#x27;;
// Application imports
import {Action, AreaName, AreaType, Category, Token} from &#x27;@app/_models&#x27;;
/** A mock of the curated account types. */
const accountTypes: Array&lt;string&gt; &#x3D; [&#x27;user&#x27;, &#x27;cashier&#x27;, &#x27;vendor&#x27;, &#x27;tokenagent&#x27;, &#x27;group&#x27;];
/** A mock of actions made by the admin staff. */
const actions: Array&lt;Action&gt; &#x3D; [
{ id: 1, user: &#x27;Tom&#x27;, role: &#x27;enroller&#x27;, action: &#x27;Disburse RSV 100&#x27;, approval: false },
{ id: 2, user: &#x27;Christine&#x27;, role: &#x27;admin&#x27;, action: &#x27;Change user phone number&#x27;, approval: true },
@@ -199,38 +236,93 @@ const actions: Array&lt;Action&gt; &#x3D; [
{ id: 6, user: &#x27;Patience&#x27;, role: &#x27;enroller&#x27;, action: &#x27;Change user information&#x27;, approval: false }
];
const tokens: Array&lt;Token&gt; &#x3D; [
/** A mock of curated area names. */
const areaNames: Array&lt;AreaName&gt; &#x3D; [
{
name: &#x27;Giftable Reserve&#x27;, symbol: &#x27;GRZ&#x27;, address: &#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;, supply: &#x27;1000000001000000000000000000&#x27;,
decimals: &#x27;18&#x27;, reserves: {}
name: &#x27;Mukuru Nairobi&#x27;,
locations: [&#x27;kayaba&#x27;, &#x27;kayba&#x27;, &#x27;kambi&#x27;, &#x27;mukuru&#x27;, &#x27;masai&#x27;, &#x27;hazina&#x27;, &#x27;south&#x27;, &#x27;tetra&#x27;, &#x27;tetrapak&#x27;, &#x27;ruben&#x27;, &#x27;rueben&#x27;, &#x27;kingston&#x27;,
&#x27;korokocho&#x27;, &#x27;kingstone&#x27;, &#x27;kamongo&#x27;, &#x27;lungalunga&#x27;, &#x27;sinai&#x27;, &#x27;sigei&#x27;, &#x27;lungu&#x27;, &#x27;lunga lunga&#x27;, &#x27;owino road&#x27;, &#x27;seigei&#x27;]
},
{
name: &#x27;Demo Token&#x27;, symbol: &#x27;DEMO&#x27;, address: &#x27;0xc80D6aFF8194114c52AEcD84c9f15fd5c8abb187&#x27;, supply: &#x27;99999999999999998976&#x27;,
decimals: &#x27;18&#x27;, reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;99999999999999998976&#x27;}},
reserveRatio: &#x27;1000000&#x27;, owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
name: &#x27;Kinango Kwale&#x27;,
locations: [&#x27;amani&#x27;, &#x27;bofu&#x27;, &#x27;chibuga&#x27;, &#x27;chikomani&#x27;, &#x27;chilongoni&#x27;, &#x27;chigojoni&#x27;, &#x27;chinguluni&#x27;, &#x27;chigato&#x27;, &#x27;chigale&#x27;, &#x27;chikole&#x27;,
&#x27;chilongoni&#x27;, &#x27;chilumani&#x27;, &#x27;chigojoni&#x27;, &#x27;chikomani&#x27;, &#x27;chizini&#x27;, &#x27;chikomeni&#x27;, &#x27;chidzuvini&#x27;, &#x27;chidzivuni&#x27;, &#x27;chikuyu&#x27;, &#x27;chizingo&#x27;,
&#x27;doti&#x27;, &#x27;dzugwe&#x27;, &#x27;dzivani&#x27;, &#x27;dzovuni&#x27;, &#x27;hanje&#x27;, &#x27;kasemeni&#x27;, &#x27;katundani&#x27;, &#x27;kibandaogo&#x27;, &#x27;kibandaongo&#x27;, &#x27;kwale&#x27;, &#x27;kinango&#x27;,
&#x27;kidzuvini&#x27;, &#x27;kalalani&#x27;, &#x27;kafuduni&#x27;, &#x27;kaloleni&#x27;, &#x27;kilibole&#x27;, &#x27;lutsangani&#x27;, &#x27;peku&#x27;, &#x27;gona&#x27;, &#x27;guro&#x27;, &#x27;gandini&#x27;, &#x27;mkanyeni&#x27;, &#x27;myenzeni&#x27;,
&#x27;miyenzeni&#x27;, &#x27;miatsiani&#x27;, &#x27;mienzeni&#x27;, &#x27;mnyenzeni&#x27;, &#x27;minyenzeni&#x27;, &#x27;miyani&#x27;, &#x27;mioleni&#x27;, &#x27;makuluni&#x27;, &#x27;mariakani&#x27;, &#x27;makobeni&#x27;, &#x27;madewani&#x27;,
&#x27;mwangaraba&#x27;, &#x27;mwashanga&#x27;, &#x27;miloeni&#x27;, &#x27;mabesheni&#x27;, &#x27;mazeras&#x27;, &#x27;mazera&#x27;, &#x27;mlola&#x27;, &#x27;muugano&#x27;, &#x27;mulunguni&#x27;, &#x27;mabesheni&#x27;, &#x27;miatsani&#x27;,
&#x27;miatsiani&#x27;, &#x27;mwache&#x27;, &#x27;mwangani&#x27;, &#x27;mwehavikonje&#x27;, &#x27;miguneni&#x27;, &#x27;nzora&#x27;, &#x27;nzovuni&#x27;, &#x27;vikinduni&#x27;, &#x27;vikolani&#x27;, &#x27;vitangani&#x27;, &#x27;viogato&#x27;,
&#x27;vyogato&#x27;, &#x27;vistangani&#x27;, &#x27;yapha&#x27;, &#x27;yava&#x27;, &#x27;yowani&#x27;, &#x27;ziwani&#x27;, &#x27;majengo&#x27;, &#x27;matuga&#x27;, &#x27;vigungani&#x27;, &#x27;vidziweni&#x27;, &#x27;vinyunduni&#x27;, &#x27;ukunda&#x27;,
&#x27;kokotoni&#x27;, &#x27;mikindani&#x27;]
},
{
name: &#x27;Foo Token&#x27;, symbol: &#x27;FOO&#x27;, address: &#x27;0x9ceD86089f7aBB5A97B40eb0E7521e7aa308d354&#x27;, supply: &#x27;1000000000000000001014&#x27;,
decimals: &#x27;18&#x27;, reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;1000000000000000001014&#x27;}},
reserveRatio: &#x27;1000000&#x27;, owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
name: &#x27;Misc Nairobi&#x27;,
locations: [&#x27;nairobi&#x27;, &#x27;west&#x27;, &#x27;lindi&#x27;, &#x27;kibera&#x27;, &#x27;kibira&#x27;, &#x27;kibra&#x27;, &#x27;makina&#x27;, &#x27;soweto&#x27;, &#x27;olympic&#x27;, &#x27;kangemi&#x27;, &#x27;ruiru&#x27;, &#x27;congo&#x27;,
&#x27;kawangware&#x27;, &#x27;kwangware&#x27;, &#x27;donholm&#x27;, &#x27;dagoreti&#x27;, &#x27;dandora&#x27;, &#x27;kabete&#x27;, &#x27;sinai&#x27;, &#x27;donhom&#x27;, &#x27;donholm&#x27;, &#x27;huruma&#x27;, &#x27;kitengela&#x27;,
&#x27;makadara&#x27;, &#x27;,mlolongo&#x27;, &#x27;kenyatta&#x27;, &#x27;mlolongo&#x27;, &#x27;tassia&#x27;, &#x27;tasia&#x27;, &#x27;gatina&#x27;, &#x27;56&#x27;, &#x27;industrial&#x27;, &#x27;kariobangi&#x27;, &#x27;kasarani&#x27;, &#x27;kayole&#x27;,
&#x27;mathare&#x27;, &#x27;pipe&#x27;, &#x27;juja&#x27;, &#x27;uchumi&#x27;, &#x27;jogoo&#x27;, &#x27;umoja&#x27;, &#x27;thika&#x27;, &#x27;kikuyu&#x27;, &#x27;stadium&#x27;, &#x27;buru buru&#x27;, &#x27;ngong&#x27;, &#x27;starehe&#x27;, &#x27;mwiki&#x27;,
&#x27;fuata&#x27;, &#x27;kware&#x27;, &#x27;kabiro&#x27;, &#x27;embakassi&#x27;, &#x27;embakasi&#x27;, &#x27;kmoja&#x27;, &#x27;east&#x27;, &#x27;githurai&#x27;, &#x27;landi&#x27;, &#x27;langata&#x27;, &#x27;limuru&#x27;, &#x27;mathere&#x27;,
&#x27;dagoretti&#x27;, &#x27;kirembe&#x27;, &#x27;muugano&#x27;, &#x27;mwiki&#x27;, &#x27;toi market&#x27;]
},
{
name: &#x27;testb&#x27;, symbol: &#x27;tstb&#x27;, address: &#x27;0xC63cFA91A3BFf41cE31Ff436f67D3ACBC977DB95&#x27;, supply: &#x27;99000&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;99000&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
name: &#x27;Misc Mombasa&#x27;,
locations: [&#x27;mombasa&#x27;, &#x27;likoni&#x27;, &#x27;bangla&#x27;, &#x27;bangladesh&#x27;, &#x27;kizingo&#x27;, &#x27;old town&#x27;, &#x27;makupa&#x27;, &#x27;mvita&#x27;, &#x27;ngombeni&#x27;, &#x27;ngómbeni&#x27;, &#x27;ombeni&#x27;,
&#x27;magongo&#x27;, &#x27;miritini&#x27;, &#x27;changamwe&#x27;, &#x27;jomvu&#x27;, &#x27;ohuru&#x27;, &#x27;tudor&#x27;, &#x27;diani&#x27;]
},
{
name: &#x27;testa&#x27;, symbol: &#x27;tsta&#x27;, address: &#x27;0x8fA4101ef19D0a078239d035659e92b278bD083C&#x27;, supply: &#x27;9981&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;9981&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
name: &#x27;Kisauni&#x27;,
locations: [&#x27;bamburi&#x27;, &#x27;kisauni&#x27;, &#x27;mworoni&#x27;, &#x27;nyali&#x27;, &#x27;shanzu&#x27;, &#x27;bombolulu&#x27;, &#x27;mtopanga&#x27;, &#x27;mjambere&#x27;, &#x27;majaoni&#x27;, &#x27;manyani&#x27;, &#x27;magogoni&#x27;,
&#x27;junda&#x27;, &#x27;mwakirunge&#x27;, &#x27;mshomoroni&#x27;]
},
{
name: &#x27;testc&#x27;, symbol: &#x27;tstc&#x27;, address: &#x27;0x4A6fA6bc3BfE4C9661bC692D9798425350C9e3D4&#x27;, supply: &#x27;100990&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;100990&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
name: &#x27;Kilifi&#x27;,
locations: [&#x27;kilfi&#x27;, &#x27;kilifi&#x27;, &#x27;mtwapa&#x27;, &#x27;takaungu&#x27;, &#x27;makongeni&#x27;, &#x27;mnarani&#x27;, &#x27;mnarani&#x27;, &#x27;office&#x27;, &#x27;g.e&#x27;, &#x27;ge&#x27;, &#x27;raibai&#x27;, &#x27;ribe&#x27;]
},
{
name: &#x27;Kakuma&#x27;,
locations: [&#x27;kakuma&#x27;]
},
{
name: &#x27;Kitui&#x27;,
locations: [&#x27;kitui&#x27;, &#x27;mwingi&#x27;]
},
{
name: &#x27;Nyanza&#x27;,
locations: [&#x27;busia&#x27;, &#x27;nyalgunga&#x27;, &#x27;mbita&#x27;, &#x27;siaya&#x27;, &#x27;kisumu&#x27;, &#x27;nyalenda&#x27;, &#x27;hawinga&#x27;, &#x27;rangala&#x27;, &#x27;uyoma&#x27;, &#x27;mumias&#x27;, &#x27;homabay&#x27;, &#x27;homaboy&#x27;,
&#x27;migori&#x27;, &#x27;kusumu&#x27;]
},
{
name: &#x27;Misc Rural Counties&#x27;,
locations: [&#x27;makueni&#x27;, &#x27;meru&#x27;, &#x27;kisii&#x27;, &#x27;bomet&#x27;, &#x27;machakos&#x27;, &#x27;bungoma&#x27;, &#x27;eldoret&#x27;, &#x27;kakamega&#x27;, &#x27;kericho&#x27;, &#x27;kajiado&#x27;, &#x27;nandi&#x27;, &#x27;nyeri&#x27;,
&#x27;wote&#x27;, &#x27;kiambu&#x27;, &#x27;mwea&#x27;, &#x27;nakuru&#x27;, &#x27;narok&#x27;]
},
{
name: &#x27;other&#x27;,
locations: [&#x27;other&#x27;, &#x27;none&#x27;, &#x27;unknown&#x27;]
}
];
/** A mock of curated area types. */
const areaTypes: Array&lt;AreaType&gt; &#x3D; [
{
name: &#x27;urban&#x27;,
area: [&#x27;urban&#x27;, &#x27;nairobi&#x27;, &#x27;mombasa&#x27;]
},
{
name: &#x27;rural&#x27;,
area: [&#x27;rural&#x27;, &#x27;kakuma&#x27;, &#x27;kwale&#x27;, &#x27;kinango&#x27;, &#x27;kitui&#x27;, &#x27;nyanza&#x27;]
},
{
name: &#x27;periurban&#x27;,
area: [&#x27;kilifi&#x27;, &#x27;periurban&#x27;]
},
{
name: &#x27;other&#x27;,
area: [&#x27;other&#x27;]
}
];
/** A mock of the user&#x27;s business categories */
const categories: Array&lt;Category&gt; &#x3D; [
{
name: &#x27;system&#x27;,
@@ -333,96 +425,60 @@ const categories: Array&lt;Category&gt; &#x3D; [
}
];
const areaNames: Array&lt;AreaName&gt; &#x3D; [
{
name: &#x27;Mukuru Nairobi&#x27;,
locations: [&#x27;kayaba&#x27;, &#x27;kayba&#x27;, &#x27;kambi&#x27;, &#x27;mukuru&#x27;, &#x27;masai&#x27;, &#x27;hazina&#x27;, &#x27;south&#x27;, &#x27;tetra&#x27;, &#x27;tetrapak&#x27;, &#x27;ruben&#x27;, &#x27;rueben&#x27;, &#x27;kingston&#x27;,
&#x27;korokocho&#x27;, &#x27;kingstone&#x27;, &#x27;kamongo&#x27;, &#x27;lungalunga&#x27;, &#x27;sinai&#x27;, &#x27;sigei&#x27;, &#x27;lungu&#x27;, &#x27;lunga lunga&#x27;, &#x27;owino road&#x27;, &#x27;seigei&#x27;]
},
{
name: &#x27;Kinango Kwale&#x27;,
locations: [&#x27;amani&#x27;, &#x27;bofu&#x27;, &#x27;chibuga&#x27;, &#x27;chikomani&#x27;, &#x27;chilongoni&#x27;, &#x27;chigojoni&#x27;, &#x27;chinguluni&#x27;, &#x27;chigato&#x27;, &#x27;chigale&#x27;, &#x27;chikole&#x27;,
&#x27;chilongoni&#x27;, &#x27;chilumani&#x27;, &#x27;chigojoni&#x27;, &#x27;chikomani&#x27;, &#x27;chizini&#x27;, &#x27;chikomeni&#x27;, &#x27;chidzuvini&#x27;, &#x27;chidzivuni&#x27;, &#x27;chikuyu&#x27;, &#x27;chizingo&#x27;,
&#x27;doti&#x27;, &#x27;dzugwe&#x27;, &#x27;dzivani&#x27;, &#x27;dzovuni&#x27;, &#x27;hanje&#x27;, &#x27;kasemeni&#x27;, &#x27;katundani&#x27;, &#x27;kibandaogo&#x27;, &#x27;kibandaongo&#x27;, &#x27;kwale&#x27;, &#x27;kinango&#x27;,
&#x27;kidzuvini&#x27;, &#x27;kalalani&#x27;, &#x27;kafuduni&#x27;, &#x27;kaloleni&#x27;, &#x27;kilibole&#x27;, &#x27;lutsangani&#x27;, &#x27;peku&#x27;, &#x27;gona&#x27;, &#x27;guro&#x27;, &#x27;gandini&#x27;, &#x27;mkanyeni&#x27;, &#x27;myenzeni&#x27;,
&#x27;miyenzeni&#x27;, &#x27;miatsiani&#x27;, &#x27;mienzeni&#x27;, &#x27;mnyenzeni&#x27;, &#x27;minyenzeni&#x27;, &#x27;miyani&#x27;, &#x27;mioleni&#x27;, &#x27;makuluni&#x27;, &#x27;mariakani&#x27;, &#x27;makobeni&#x27;, &#x27;madewani&#x27;,
&#x27;mwangaraba&#x27;, &#x27;mwashanga&#x27;, &#x27;miloeni&#x27;, &#x27;mabesheni&#x27;, &#x27;mazeras&#x27;, &#x27;mazera&#x27;, &#x27;mlola&#x27;, &#x27;muugano&#x27;, &#x27;mulunguni&#x27;, &#x27;mabesheni&#x27;, &#x27;miatsani&#x27;,
&#x27;miatsiani&#x27;, &#x27;mwache&#x27;, &#x27;mwangani&#x27;, &#x27;mwehavikonje&#x27;, &#x27;miguneni&#x27;, &#x27;nzora&#x27;, &#x27;nzovuni&#x27;, &#x27;vikinduni&#x27;, &#x27;vikolani&#x27;, &#x27;vitangani&#x27;, &#x27;viogato&#x27;,
&#x27;vyogato&#x27;, &#x27;vistangani&#x27;, &#x27;yapha&#x27;, &#x27;yava&#x27;, &#x27;yowani&#x27;, &#x27;ziwani&#x27;, &#x27;majengo&#x27;, &#x27;matuga&#x27;, &#x27;vigungani&#x27;, &#x27;vidziweni&#x27;, &#x27;vinyunduni&#x27;, &#x27;ukunda&#x27;,
&#x27;kokotoni&#x27;, &#x27;mikindani&#x27;]
},
{
name: &#x27;Misc Nairobi&#x27;,
locations: [&#x27;nairobi&#x27;, &#x27;west&#x27;, &#x27;lindi&#x27;, &#x27;kibera&#x27;, &#x27;kibira&#x27;, &#x27;kibra&#x27;, &#x27;makina&#x27;, &#x27;soweto&#x27;, &#x27;olympic&#x27;, &#x27;kangemi&#x27;, &#x27;ruiru&#x27;, &#x27;congo&#x27;,
&#x27;kawangware&#x27;, &#x27;kwangware&#x27;, &#x27;donholm&#x27;, &#x27;dagoreti&#x27;, &#x27;dandora&#x27;, &#x27;kabete&#x27;, &#x27;sinai&#x27;, &#x27;donhom&#x27;, &#x27;donholm&#x27;, &#x27;huruma&#x27;, &#x27;kitengela&#x27;,
&#x27;makadara&#x27;, &#x27;,mlolongo&#x27;, &#x27;kenyatta&#x27;, &#x27;mlolongo&#x27;, &#x27;tassia&#x27;, &#x27;tasia&#x27;, &#x27;gatina&#x27;, &#x27;56&#x27;, &#x27;industrial&#x27;, &#x27;kariobangi&#x27;, &#x27;kasarani&#x27;, &#x27;kayole&#x27;,
&#x27;mathare&#x27;, &#x27;pipe&#x27;, &#x27;juja&#x27;, &#x27;uchumi&#x27;, &#x27;jogoo&#x27;, &#x27;umoja&#x27;, &#x27;thika&#x27;, &#x27;kikuyu&#x27;, &#x27;stadium&#x27;, &#x27;buru buru&#x27;, &#x27;ngong&#x27;, &#x27;starehe&#x27;, &#x27;mwiki&#x27;,
&#x27;fuata&#x27;, &#x27;kware&#x27;, &#x27;kabiro&#x27;, &#x27;embakassi&#x27;, &#x27;embakasi&#x27;, &#x27;kmoja&#x27;, &#x27;east&#x27;, &#x27;githurai&#x27;, &#x27;landi&#x27;, &#x27;langata&#x27;, &#x27;limuru&#x27;, &#x27;mathere&#x27;,
&#x27;dagoretti&#x27;, &#x27;kirembe&#x27;, &#x27;muugano&#x27;, &#x27;mwiki&#x27;, &#x27;toi market&#x27;]
},
{
name: &#x27;Misc Mombasa&#x27;,
locations: [&#x27;mombasa&#x27;, &#x27;likoni&#x27;, &#x27;bangla&#x27;, &#x27;bangladesh&#x27;, &#x27;kizingo&#x27;, &#x27;old town&#x27;, &#x27;makupa&#x27;, &#x27;mvita&#x27;, &#x27;ngombeni&#x27;, &#x27;ngómbeni&#x27;, &#x27;ombeni&#x27;,
&#x27;magongo&#x27;, &#x27;miritini&#x27;, &#x27;changamwe&#x27;, &#x27;jomvu&#x27;, &#x27;ohuru&#x27;, &#x27;tudor&#x27;, &#x27;diani&#x27;]
},
{
name: &#x27;Kisauni&#x27;,
locations: [&#x27;bamburi&#x27;, &#x27;kisauni&#x27;, &#x27;mworoni&#x27;, &#x27;nyali&#x27;, &#x27;shanzu&#x27;, &#x27;bombolulu&#x27;, &#x27;mtopanga&#x27;, &#x27;mjambere&#x27;, &#x27;majaoni&#x27;, &#x27;manyani&#x27;, &#x27;magogoni&#x27;,
&#x27;junda&#x27;, &#x27;mwakirunge&#x27;, &#x27;mshomoroni&#x27;]
},
{
name: &#x27;Kilifi&#x27;,
locations: [&#x27;kilfi&#x27;, &#x27;kilifi&#x27;, &#x27;mtwapa&#x27;, &#x27;takaungu&#x27;, &#x27;makongeni&#x27;, &#x27;mnarani&#x27;, &#x27;mnarani&#x27;, &#x27;office&#x27;, &#x27;g.e&#x27;, &#x27;ge&#x27;, &#x27;raibai&#x27;, &#x27;ribe&#x27;]
},
{
name: &#x27;Kakuma&#x27;,
locations: [&#x27;kakuma&#x27;]
},
{
name: &#x27;Kitui&#x27;,
locations: [&#x27;kitui&#x27;, &#x27;mwingi&#x27;]
},
{
name: &#x27;Nyanza&#x27;,
locations: [&#x27;busia&#x27;, &#x27;nyalgunga&#x27;, &#x27;mbita&#x27;, &#x27;siaya&#x27;, &#x27;kisumu&#x27;, &#x27;nyalenda&#x27;, &#x27;hawinga&#x27;, &#x27;rangala&#x27;, &#x27;uyoma&#x27;, &#x27;mumias&#x27;, &#x27;homabay&#x27;, &#x27;homaboy&#x27;,
&#x27;migori&#x27;, &#x27;kusumu&#x27;]
},
{
name: &#x27;Misc Rural Counties&#x27;,
locations: [&#x27;makueni&#x27;, &#x27;meru&#x27;, &#x27;kisii&#x27;, &#x27;bomet&#x27;, &#x27;machakos&#x27;, &#x27;bungoma&#x27;, &#x27;eldoret&#x27;, &#x27;kakamega&#x27;, &#x27;kericho&#x27;, &#x27;kajiado&#x27;, &#x27;nandi&#x27;, &#x27;nyeri&#x27;,
&#x27;wote&#x27;, &#x27;kiambu&#x27;, &#x27;mwea&#x27;, &#x27;nakuru&#x27;, &#x27;narok&#x27;]
},
{
name: &#x27;other&#x27;,
locations: [&#x27;other&#x27;, &#x27;none&#x27;, &#x27;unknown&#x27;]
}
];
const areaTypes: Array&lt;AreaType&gt; &#x3D; [
{
name: &#x27;urban&#x27;,
area: [&#x27;urban&#x27;, &#x27;nairobi&#x27;, &#x27;mombasa&#x27;]
},
{
name: &#x27;rural&#x27;,
area: [&#x27;rural&#x27;, &#x27;kakuma&#x27;, &#x27;kwale&#x27;, &#x27;kinango&#x27;, &#x27;kitui&#x27;, &#x27;nyanza&#x27;]
},
{
name: &#x27;periurban&#x27;,
area: [&#x27;kilifi&#x27;, &#x27;periurban&#x27;]
},
{
name: &#x27;other&#x27;,
area: [&#x27;other&#x27;]
}
];
const accountTypes: Array&lt;string&gt; &#x3D; [&#x27;user&#x27;, &#x27;cashier&#x27;, &#x27;vendor&#x27;, &#x27;tokenagent&#x27;, &#x27;group&#x27;];
const transactionTypes: Array&lt;string&gt; &#x3D; [&#x27;transactions&#x27;, &#x27;conversions&#x27;, &#x27;disbursements&#x27;, &#x27;rewards&#x27;, &#x27;reclamation&#x27;];
/** A mock of curated genders */
const genders: Array&lt;string&gt; &#x3D; [&#x27;male&#x27;, &#x27;female&#x27;, &#x27;other&#x27;];
/** A mock of the tokens in the system. */
const tokens: Array&lt;Token&gt; &#x3D; [
{
name: &#x27;Giftable Reserve&#x27;, symbol: &#x27;GRZ&#x27;, address: &#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;, supply: &#x27;1000000001000000000000000000&#x27;,
decimals: &#x27;18&#x27;, reserves: {}
},
{
name: &#x27;Demo Token&#x27;, symbol: &#x27;DEMO&#x27;, address: &#x27;0xc80D6aFF8194114c52AEcD84c9f15fd5c8abb187&#x27;, supply: &#x27;99999999999999998976&#x27;,
decimals: &#x27;18&#x27;, reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;99999999999999998976&#x27;}},
reserveRatio: &#x27;1000000&#x27;, owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
},
{
name: &#x27;Foo Token&#x27;, symbol: &#x27;FOO&#x27;, address: &#x27;0x9ceD86089f7aBB5A97B40eb0E7521e7aa308d354&#x27;, supply: &#x27;1000000000000000001014&#x27;,
decimals: &#x27;18&#x27;, reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;1000000000000000001014&#x27;}},
reserveRatio: &#x27;1000000&#x27;, owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
},
{
name: &#x27;testb&#x27;, symbol: &#x27;tstb&#x27;, address: &#x27;0xC63cFA91A3BFf41cE31Ff436f67D3ACBC977DB95&#x27;, supply: &#x27;99000&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;99000&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
},
{
name: &#x27;testa&#x27;, symbol: &#x27;tsta&#x27;, address: &#x27;0x8fA4101ef19D0a078239d035659e92b278bD083C&#x27;, supply: &#x27;9981&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;9981&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
},
{
name: &#x27;testc&#x27;, symbol: &#x27;tstc&#x27;, address: &#x27;0x4A6fA6bc3BfE4C9661bC692D9798425350C9e3D4&#x27;, supply: &#x27;100990&#x27;, decimals: &#x27;18&#x27;,
reserves: {&#x27;0xa686005CE37Dce7738436256982C3903f2E4ea8E&#x27;: {weight: &#x27;1000000&#x27;, balance: &#x27;100990&#x27;}}, reserveRatio: &#x27;1000000&#x27;,
owner: &#x27;0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a&#x27;
}
];
/** A mock of curated transaction types. */
const transactionTypes: Array&lt;string&gt; &#x3D; [&#x27;transactions&#x27;, &#x27;conversions&#x27;, &#x27;disbursements&#x27;, &#x27;rewards&#x27;, &#x27;reclamation&#x27;];
/**
* Intercepts HTTP requests and handles some specified requests internally.
* Provides a backend that can handle requests for certain data items.
*
* @implements HttpInterceptor
*/
@Injectable()
export class MockBackendInterceptor implements HttpInterceptor {
/**
* Intercepts HTTP requests.
*
* @param request - An outgoing HTTP request with an optional typed body.
* @param next - The next HTTP handler or the outgoing request dispatcher.
* @returns The response from the resolved request.
*/
intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
const { url, method, headers, body } &#x3D; request;
@@ -434,22 +490,17 @@ export class MockBackendInterceptor implements HttpInterceptor {
.pipe(delay(500))
.pipe(dematerialize());
/** Forward requests from select routes to their internal handlers. */
function handleRoute(): Observable&lt;any&gt; {
switch (true) {
case url.endsWith(&#x27;/accounttypes&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getAccountTypes();
case url.endsWith(&#x27;/actions&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getActions();
case url.match(/\/actions\/\d+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getActionById();
case url.match(/\/actions\/\d+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;POST&#x27;:
return approveAction();
case url.endsWith(&#x27;/tokens&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTokens();
case url.match(/\/tokens\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTokenBySymbol();
case url.endsWith(&#x27;/categories&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getCategories();
case url.match(/\/categories\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getCategoryByProduct();
case url.endsWith(&#x27;/areanames&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getAreaNames();
case url.match(/\/areanames\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
@@ -458,12 +509,18 @@ export class MockBackendInterceptor implements HttpInterceptor {
return getAreaTypes();
case url.match(/\/areatypes\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getAreaTypeByArea();
case url.endsWith(&#x27;/accounttypes&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getAccountTypes();
case url.endsWith(&#x27;/transactiontypes&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTransactionTypes();
case url.endsWith(&#x27;/categories&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getCategories();
case url.match(/\/categories\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getCategoryByProduct();
case url.endsWith(&#x27;/genders&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getGenders();
case url.endsWith(&#x27;/tokens&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTokens();
case url.match(/\/tokens\/\w+$/) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTokenBySymbol();
case url.endsWith(&#x27;/transactiontypes&#x27;) &amp;&amp; method &#x3D;&#x3D;&#x3D; &#x27;GET&#x27;:
return getTransactionTypes();
default:
// pass through any requests not handled above
return next.handle(request);
@@ -472,15 +529,6 @@ export class MockBackendInterceptor implements HttpInterceptor {
// route functions
function getActions(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(actions);
}
function getActionById(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedAction: Action &#x3D; actions.find(action &#x3D;&gt; action.id &#x3D;&#x3D;&#x3D; idFromUrl());
return ok(queriedAction);
}
function approveAction(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedAction: Action &#x3D; actions.find(action &#x3D;&gt; action.id &#x3D;&#x3D;&#x3D; idFromUrl());
queriedAction.approval &#x3D; body.approval;
@@ -488,23 +536,17 @@ export class MockBackendInterceptor implements HttpInterceptor {
return ok(message);
}
function getTokens(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(tokens);
function getAccountTypes(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(accountTypes);
}
function getTokenBySymbol(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedToken: Token &#x3D; tokens.find(token &#x3D;&gt; token.symbol &#x3D;&#x3D;&#x3D; stringFromUrl());
return ok(queriedToken);
function getActions(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(actions);
}
function getCategories(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const categoryList: Array&lt;string&gt; &#x3D; categories.map(category &#x3D;&gt; category.name);
return ok(categoryList);
}
function getCategoryByProduct(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedCategory: Category &#x3D; categories.find(category &#x3D;&gt; category.products.includes(stringFromUrl()));
return ok(queriedCategory.name);
function getActionById(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedAction: Action &#x3D; actions.find(action &#x3D;&gt; action.id &#x3D;&#x3D;&#x3D; idFromUrl());
return ok(queriedAction);
}
function getAreaNames(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
@@ -527,24 +569,35 @@ export class MockBackendInterceptor implements HttpInterceptor {
return ok(queriedAreaType.name);
}
function getAccountTypes(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(accountTypes);
function getCategories(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const categoryList: Array&lt;string&gt; &#x3D; categories.map(category &#x3D;&gt; category.name);
return ok(categoryList);
}
function getTransactionTypes(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(transactionTypes);
function getCategoryByProduct(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedCategory: Category &#x3D; categories.find(category &#x3D;&gt; category.products.includes(stringFromUrl()));
return ok(queriedCategory.name);
}
function getGenders(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(genders);
}
// helper functions
function ok(responseBody: any): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return of(new HttpResponse({ status: 200, body: responseBody }));
function getTokens(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(tokens);
}
function getTokenBySymbol(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
const queriedToken: Token &#x3D; tokens.find(token &#x3D;&gt; token.symbol &#x3D;&#x3D;&#x3D; stringFromUrl());
return ok(queriedToken);
}
function getTransactionTypes(): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return ok(transactionTypes);
}
// helper functions
function error(message): Observable&lt;any&gt; {
return throwError({ status: 400, error: { message } });
}
@@ -554,6 +607,10 @@ export class MockBackendInterceptor implements HttpInterceptor {
return parseInt(urlParts[urlParts.length - 1], 10);
}
function ok(responseBody: any): Observable&lt;HttpResponse&lt;any&gt;&gt; {
return of(new HttpResponse({ status: 200, body: responseBody }));
}
function stringFromUrl(): string {
const urlParts: Array&lt;string&gt; &#x3D; url.split(&#x27;/&#x27;);
return urlParts[urlParts.length - 1];
@@ -561,6 +618,11 @@ export class MockBackendInterceptor implements HttpInterceptor {
}
}
/**
* Exports the MockBackendInterceptor as an Angular provider.
*
* @exports
*/
export const MockBackendProvider &#x3D; {
provide: HTTP_INTERCEPTORS,
useClass: MockBackendInterceptor,