Skip to content

Commit

Permalink
Added examples for Portal API and fixed filters for Portal API
Browse files Browse the repository at this point in the history
  • Loading branch information
codedeviate committed Jul 10, 2024
1 parent b3aad91 commit 75acc49
Show file tree
Hide file tree
Showing 23 changed files with 771 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Writerside/hi.tree
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,21 @@
<toc-element topic="PortalAPI-Reports-Filters.md"/>
<toc-element topic="PortalAPI-Users-Filters.md"/>
</toc-element>
<toc-element topic="PortalAPI-Examples.md"/>
<toc-element topic="PortalAPI-Examples.md">
<toc-element topic="Portal-Example-getArticles.md"/>
<toc-element topic="Portal-Example-getConversationss.md"/>
<toc-element topic="Portal-Example-getCountries.md"/>
<toc-element topic="Portal-Example-getCreditflow.md"/>
<toc-element topic="Portal-Example-getCurrencies.md"/>
<toc-element topic="Portal-Example-getCustomers.md"/>
<toc-element topic="Portal-Example-getInvoices.md"/>
<toc-element topic="Portal-Example-getLanguages.md"/>
<toc-element topic="Portal-Example-getlogos.md"/>
<toc-element topic="Portal-Example-getMerchant.md"/>
<toc-element topic="Portal-Example-getReports.md"/>
<toc-element topic="Portal-Example-getUsers.md"/>
<toc-element topic="Portal-Example-getWhitelists.md"/>
</toc-element>
<toc-element topic="Portal-API-Changelog.md"/>
</toc-element>
<toc-element topic="MyQvickly-API.md"/>
Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Auth-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

<include from="Snippets-AuthAPI.md" element-id="snippet-header" />

The AuthAPI is used to authenticate users for the [Portal API](Portal-API.md).
2 changes: 2 additions & 0 deletions Writerside/topics/Filters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Filters

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

The filter engine for the PortalAPI is powerful and flexible. It allows you to filter the results of a request based on a wide range of criteria.

The way to trigger a filter is to add a query parameter to the URL called `filter`. The value of the `filter` parameter is a name of the filter you want to apply.
Expand Down
2 changes: 2 additions & 0 deletions Writerside/topics/Portal-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

> The PortalAPI is currently an OpenAPI based documentation. Until we have converted it to fit the common documentation format, you can view the converted OpenAPI documentation in this section.
>
> Please note that some information may be missing or incomplete.
> {style="information"}
The portal is a web application that allow merchants to manage their invoices, customers, and products. The API is used to interact with the portal.
Expand Down
46 changes: 46 additions & 0 deletions Writerside/topics/Portal-Example-getArticles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# getArticles

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$articles = $portalAPI->get('articles', params: ['filter' => 'searchArticleNumber', 'articlenr' => 'test']);
if(is_array($articles) && array_key_exists('error', $articles)) {
echo "Code: " . $articles['code'] . "\n";
echo "Error: " . $articles['error'] . "\n";
exit;
}
echo "Found " . count($articles) . " articles\n";
if(count($articles) > 0) {
$oneArticle = array_pop($articles);
$oneArticleId = $oneArticle['mexcParamvaluesetsid'];
$article = $portalAPI->get('articles/' . $oneArticleId);
echo "And the last article is:\n";
echo json_encode($article, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
48 changes: 48 additions & 0 deletions Writerside/topics/Portal-Example-getConversationss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# getConversationss

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$conversations = $portalAPI->get('conversations');
if(is_array($conversations) && array_key_exists('error', $conversations)) {
echo "Code: " . $conversations['code'] . "\n";
echo "Error: " . $conversations['error'] . "\n";
exit;
}
echo "Found " . count($conversations) . " conversations\n";
if(count($conversations) > 0) {
$oneConversation = array_pop($conversations);
$oneConversationId = $oneConversation['mexcParamvaluesetsid'];
$conversation = $portalAPI->get('conversations/' . $oneConversation);
echo "And the last conversation is:\n";
echo json_encode($conversation, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
46 changes: 46 additions & 0 deletions Writerside/topics/Portal-Example-getCountries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# getCountries

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$countries = $portalAPI->get('countries');
if(is_array($countries) && array_key_exists('error', $countries)) {
echo "Code: " . $countries['code'] . "\n";
echo "Error: " . $countries['error'] . "\n";
exit;
}
echo "Found " . count($countries) . " countries\n";
if(count($countries) > 0) {
$oneCountry = array_pop($countries);
echo "And the last country is:\n";
echo json_encode($oneCountry, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
41 changes: 41 additions & 0 deletions Writerside/topics/Portal-Example-getCreditflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# getCreditflow

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$creditflow = $portalAPI->get('creditflow/search/5501011018');
if(is_array($creditflow) && array_key_exists('error', $creditflow)) {
echo "Code: " . $creditflow['code'] . "\n";
echo "Error: " . $creditflow['error'] . "\n";
exit;
}
echo json_encode($creditflow, JSON_PRETTY_PRINT);



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
46 changes: 46 additions & 0 deletions Writerside/topics/Portal-Example-getCurrencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# getCurrencies

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$currencies = $portalAPI->get('currencies');
if(is_array($currencies) && array_key_exists('error', $currencies)) {
echo "Code: " . $currencies['code'] . "\n";
echo "Error: " . $currencies['error'] . "\n";
exit;
}
echo "Found " . count($currencies) . " currencies\n";
if(count($currencies) > 0) {
$oneCurrency = array_pop($currencies);
echo "And the last currency is:\n";
echo json_encode($oneCurrency, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
48 changes: 48 additions & 0 deletions Writerside/topics/Portal-Example-getCustomers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# getCustomers

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$customers = $portalAPI->get('customers', params: ['filter' => 'search', 'search' => 'Testperson']);
if(is_array($customers) && array_key_exists('error', $customers)) {
echo "Code: " . $customers['code'] . "\n";
echo "Error: " . $customers['error'] . "\n";
exit;
}
echo "Found " . count($customers) . " customers\n";
if(count($customers) > 0) {
$oneCustomer = array_pop($customers);
$oneCustomerId = $oneCustomer['mexcParamvaluesetsid'];
$customer = $portalAPI->get('customers/' . $oneCustomerId);
echo "And the last customer is:\n";
echo json_encode($customer, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
48 changes: 48 additions & 0 deletions Writerside/topics/Portal-Example-getInvoices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# getInvoices

<include from="Snippets-PortalAPI.md" element-id="snippet-header" />

Start typing here...

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$invoices = $portalAPI->get('invoices', params: ['filter' => 'search', 'search' => 'Testperson']);
if(is_array($invoices) && array_key_exists('error', $invoices)) {
echo "Code: " . $invoices['code'] . "\n";
echo "Error: " . $invoices['error'] . "\n";
exit;
}
echo "Found " . count($invoices) . " invoices\n";
if(count($invoices) > 0) {
$oneInvoice = array_pop($invoices);
$oneInvoiceId = $oneInvoice['invoiceid_real'];
$invoice = $portalAPI->get('invoices/' . $oneInvoiceId);
echo "And the last invoice is:\n";
echo json_encode($invoice, JSON_PRETTY_PRINT);
}



]]>
</code-block>

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>

</tabs>
Loading

0 comments on commit 75acc49

Please sign in to comment.