fetchdocs / fetchdocs-api-php
A PHP wrapper for using the fetchdocs API
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 155
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/fetchdocs/fetchdocs-api-php
Requires
- php: >=7.0.0
- ext-json: *
- ext-openssl: *
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-10-25 03:30:59 UTC
README
##Overview
fetchdocs.io - Fetch API can be used for the API-Based integration of document fetching as well as for the UI Plug&Play Integration.
All Access to the APIs are restricted by an API Key. Request your access on https://www.fetchdocs.io by submitting the contact form.
##Fetchdocs PHP SDK Client
The fetch php sdk client enables you to work with fetchdocs API you can check API documentation following this link
##Installation
- Run
composer require fetchdocs/fetchdocs-api-php. - Include
require_once '/path/to/your-project/vendor/autoload.php';to your index file
Examples
####1.Get Document
require '../vendor/autoload.php'; //Client using stage server $clientStage = \Fetchdocs\SDKClient\Client::make('Your API KEY', 'Your Hash Key', true); //Create Environment $environment = $clientStage->createEnvironment([ 'name' => 'Environment Name', 'default_environment' => true, 'push_notification_url' => 'Your Push Notification Url', 'push_input_request_url' => 'Your Push Input Request Url' ]); //Create a customer $customer = $clientStage->createCustomer([ 'environment_prim_uid' => $environment->prim_uid ]); //Supplier $supplier = getSupplierByName($clientStage, 'Test Portal'); //Create Customer Supplier $customerSupplier = $clientStage->createCustomerSupplier([ 'customer_prim_uid' => $customer->prim_uid, 'supplier_prim_uid' => $supplier->prim_uid, 'active' => true, 'username' => 'Customer Supplier Username', 'password' => 'PASSWORD' ], 'Your Encryption Key'); //Push document to document queue $doc = $clientStage->testQueueDocument([ 'prim_uid' => $customer->prim_uid, 'customer_supplier_uid' => $customerSupplier->customer_supplier_prim_uid ]); //Get Documents $documents = $clientStage->getDocumentsQueue([ 'environment_prim_uid' => $environment->prim_uid ]); while ($documents->count <= 0) { $documents = $clientStage->getDocumentsQueue([ 'environment_prim_uid' => $environment->data->prim_uid ]); } //Get document $document = $clientStage->getDocument([ 'prim_uid' => $documents->documents[0]->prim_uid, 'customer_secret' => $customer->customer_secret ]);
##SDK API
- Please check API documentation for more information about request parameters and expected response following this link
- Please note that each client method returns a
STD Objectmapping the API response #####1. Use Production Server
$client = \Fetchdocs\SDKClient\Client::make('Your API Key', 'Your Hash Key');
#####2. Use Stage Server
$client = \Fetchdocs\SDKClient\Client::make('Your Stage API Key', 'Your Stage Hash Key', true);
#####3. List Environments
$client->environments();
[
{
"prim_uid": "10361",
"name": "Default",
"push_document_url": "",
"push_notification_url": "https://push.domain.tld/notifications/",
"push_input_request_url": "https://push.domain.tld/input_request/",
"ui_redirect_url": "",
"default_environment": true
},
{
"prim_uid": "10362",
"name": "Env",
"push_document_url": "",
"push_notification_url": "https://push.domain.tld/notifications/",
"push_input_request_url": "https://push.domain.tld/input_request/",
"ui_redirect_url": "",
"default_environment": false
}
]
#####4.List Timezones
$client->timezones();
[
"Africa/Abidjan",
"Africa/Accra"
]
#####5.Date Formats
$client->dateFormats();
[
"d.m.Y",
"m/d/Y",
"d/m/Y"
]
#####6.Create Environment
$client->createEnvironment([ 'name' => 'Environment Name', 'default_environment' => true, 'push_notification_url' => 'https://push.domain.tld/notifications/', 'push_input_request_url' => 'https://push.domain.tld/input_request/' ]);
{
"prim_uid": 10432
}
#####7.Update Environment
$client->updateEnvironment([ 'prim_uid' => $environment->prim_uid, 'name' => 'New Name' ])
{
"success": true
}
#####8.Delete Environment
$client->deleteEnvironment([ 'prim_uid' => $environment->prim_uid, ])
{
"success": true
}
#####9.List Customers Accounts
$client->listCustomerAccounts([ 'environment_prim_uid' => 10361 ])
[
{
"prim_uid": 1,
"language": "en",
"timezone": "Europe/Berlin",
"date_format": "m/d/Y",
"environment": 144
}
]
#####10.Create Customer
$client->createCustomer([ 'environment_prim_uid' => $environment->prim_uid ]);
{
"prim_uid": 6684,
"customer_secret": "b3cjpcy8",
"access_token": "o1zhz0yzrbx3i5v65j20a751rrg6tyji"
}
#####11.Update Customer
$client->updateCustomer([ 'prim_uid' => '10500', 'customer_secret' => 'Customer Secret', 'language' => 'de' ])
{
"success": true
}
#####12.Delete Customer
$client->deleteCustomer([ 'prim_uid' => '10500', 'customer_secret' => 'Customer Secret', ])
{
"success": true
}
#####12.Deactivate Customer
$client->deactivateCustomer([ 'prim_uid' => '10500', 'customer_secret' => 'Customer Secret', ])
{
"success": true
}
#####12.Activate Customer
$client->activateCustomer([ 'prim_uid' => '10500', 'customer_secret' => 'Customer Secret', ])
{
"success": true
}
#####13.Get Customer Account Overview
$client->->getCustomerAccountOverview([ 'prim_uid' => '10500', ])
{
"customer_data": {
"prim_uid": 1,
"language": "en",
"timezone": "Europe/Berlin",
"date_format": "m/d/Y"
},
"customer_suppliers": [
{
"prim_uid": 307,
"name": "1&1.de"
}
]
}
#####14.Get Customer Session
$client->getCustomerSession([ 'prim_uid' => $customer->prim_uid, 'customer_secret' => $customer->customer_secret ])
{
"prim_uid": 6690,
"access_token": "Access Token"
}
#####15.Destroy Customer Session
$client->destroyCustomerSession([ 'access_token => "Access Token" ])
{
"success": true
}
#####16.List Suppliers
$client->->listSuppliers()
[
{
"prim_uid": 2568,
"name": "1&1 - Versatel (Business-Kunden)",
"created": "2018-02-12 12:52:38",
"supplier_login_url": "https://online-rechnung.versatel.de/tb/telcobill.faces",
"supplier_logo_url": "https://portal-ui-images.s3.eu-central-1.amazonaws.com/logo/120x120/25206.jpg",
"document_type": "invoice",
"quick_feedback_supported": false
}
]
#####17.Create Customer Supplier
$client->createCustomerSupplier([ 'customer_prim_uid' => 10050, 'supplier_prim_uid' => 2568, 'active' => true, 'username' => 'CustomerSupplier', 'password' => 'PASSWORD' ], 'Encryption-Key');
{
"success": true,
"customer_supplier_prim_uid": 13
}
If quick_feedback parameter is set as true
{
"success": true,
"quick_feedback_started": true,
"feedback_process_uid": 12
}
#####18.Delete Customer Supplier
$client->deleteCustomerSupplier([ 'prim_uid' => '15000' ])
{
"success": true
}
#####19.List Customer Suppliers
$client->listCustomerSuppliers([ 'prim_uid' => '10500' //customer uid ])
[
{
"prim_uid": 2355,
"supplier_name": "1&1.de",
"supplier_prim_uid": 307,
"supplier_logo": "",
"supplier_logo_url": "",
"active": true,
"input_request_prim_uid": 585,
"download_start_date": "2013-07-18",
"last_started": "2013-07-18 08:17:13",
"next_planned_run": "2013-07-18 10:00:00",
"last_status_key": "PENDING",
"username": "admin",
"document_type": "invoice"
}
]
#####20.Update Customer Supplier
$client->updateCustomerSupplier([ 'customer_prim_uid' => 10050, 'supplier_prim_uid' => 2568, 'active' => true, 'username' => 'CustomerSupplier', 'password' => 'PASSWORD' ], 'Encryption-Key');
{
"success": true
}
#####21.Get Supplier Fields
$client->getSuppliersFields([ 'prim_uid' => '2568' ])
[
{
"field_key": "USERNAME",
"label": "Username",
"help_text": "Here can be any string that can be shown as a help text for the field",
"mandatory": true,
"type": "text",
"dependency": ""
},
{
"field_key": "PASSWORD",
"label": "Password",
"help_text": "Here can be any string that can be shown as a help text for the field",
"mandatory": true,
"type": "password",
"dependency": "USERNAME"
},
{
"field_key": "LANG",
"label": "Language",
"help_text": "",
"mandatory": false,
"type": "dropdown",
"dependency": "",
"options": "{\"de_de\":\"Deutsch\",\"en_us\":\"English\"}"
}
]
#####22.Get Document Queue
$client->getDocumentQueue([ 'environment_prim_uid' => '15' ]);
{
"count": 100,
"total": 2345,
"documents": [
{
"prim_uid": 173,
"customer_prim_uid": 1,
"customer_supplier_prim_uid": 13,
"supplier_prim_uid": 307,
"filename": "receipt-1708171523.pdf",
"file_size": 136.75, // File size is always in KB
"file_content_checksum": "", // md5 hash of file content (raw content, not base64 encoded content)
"document_type": "invoice" // currently "invoice" and "bank_statement" are supported
}
]
}
#####23.Get Document
$client->getDocument([ 'prim_uid' => '102', 'customer_secret' => 'Customer Secret' ]);
{
"prim_uid": 102,
"customer_prim_uid": 1,
"customer_supplier_prim_uid": 13,
"supplier_prim_uid": 307,
"filename": "receipt-1708171523.pdf",
"file_size": "136.75",
"file_content_checksum": "",
"file_content": "",
"document_type": "invoice"
}
#####24. Remove Document From Queue
$client->removeDocumentFromQueue([ 'prim_uid' => $document->prim_uid, 'customer_secret' => $customer->customer_secret ]);
{
"success": true
}