Skip to content

Latest commit

 

History

History
280 lines (208 loc) · 11.4 KB

README.en.md

File metadata and controls

280 lines (208 loc) · 11.4 KB

Contributors Forks Stargazers Issues MIT License LinkedIn


İstanbul Web Tasarım

Paraşüt API Laravel Package

Laravel Packagist Downloads (custom server) Tests

Paraşüt V4 API package for Laravel.
Documentation »

Demo · Bugs · Issues

Laravel Paraşüt API

This project is a package created for Laravel that allows you to easily connect with the Paraşüt V4 API. Once you enter your Paraşüt API details into the .env file, you can easily run any function you want anywhere without repeatedly dealing with Auth processes.

Türkçe dökümanı okuman için lütfen README.md dosyasına gidin.

Why is it needed?

There are almost no fast and simple Paraşüt API packages written for Laravel. We needed a clean package that automatically handles OAuth2 processes, retrieves a new token if the previous one has expired, and allows you to simply write the operation you need in the Controller.

Please report any bugs and issues through the Issues section.

(Back to top)

Starting

Be sure to contact Paraşüt and obtain the necessary information. This applies to both trial and regular accounts.

Adding to your project

Open the terminal in your Laravel project and run the following command;

composer require theposeidonas/laravel-parasut-api

If needed, run the following command to share the config file;

php artisan vendor:publish --tag=parasut-config --force

If you are using an older version of Laravel or have Auto-Discovery disabled, add the following code to the 'aliases' section of the config/app.php file to use it everywhere;

'Parasut' => Theposeidonas\LaravelParasutApi\Facades\Parasut::class,

Configuration

After adding it to your project, you need to add and adjust the following lines in the .env file:

PARASUT_USERNAME="demo@parasut.com"  // Username
PARASUT_PASSWORD="XXXXXXXXX"  // Password
PARASUT_COMPANY_ID="123123" // Company ID
PARASUT_CLIENT_ID="XXXXXXXXXXXXXXXXX" // Paraşüt Client ID
PARASUT_CLIENT_SECRET="XXXXXXXXXXXXXXXXX" // Paraşüt Client Secret
PARASUT_REDIRECT_URI="urn:ietf:wg:oauth:2.0:oob" // Paraşüt Redirect URI, değiştirmenize gerek yok 

(Back to top)

Usage

You need to include the package in the Controller you will use:

use Theposeidonas\LaravelParasutApi\Facades\Parasut;

Models

After completing all the settings and configurations, you can call certain classes in the Controller you will use. These classes are as follows:

/* Sales */
Parasut::Bill();            // Sales Invoice            https://apidocs.parasut.com/#tag/SalesInvoices
Parasut::Customer();        // Customer                 https://apidocs.parasut.com/#tag/Contacts
        
/* Expenses */      
Parasut::Receipt();         // Receipt - Invoice        https://apidocs.parasut.com/#tag/PurchaseBills
Parasut::Bank();            // Bank Expenses            https://apidocs.parasut.com/#tag/BankFees
Parasut::Salary();          // Salary Expenses          https://apidocs.parasut.com/#tag/Salaries
Parasut::Tax();             // Tax Expenses             https://apidocs.parasut.com/#tag/Taxes
Parasut::Supplier();        // Supplier                 https://apidocs.parasut.com/#tag/Contacts
Parasut::Employee();        // Employee                 https://apidocs.parasut.com/#tag/Employees
    
/* Invoicing */ 
Parasut::Inbox();           // E-Invoice Inbox          https://apidocs.parasut.com/#tag/EInvoiceInboxes
Parasut::EArchive();        // E-Archive                https://apidocs.parasut.com/#tag/EArchives
Parasut::EBill();           // E-Invoice                https://apidocs.parasut.com/#tag/EInvoices
Parasut::ESmm();            // E-SMM                    https://apidocs.parasut.com/#tag/ESmms
    
/* Cash */ 
Parasut::Account();         // Cash and Bank            https://apidocs.parasut.com/#tag/Accounts
Parasut::Transaction();     // Transaction              https://apidocs.parasut.com/#tag/Transactions
    
/* Stock */  
Parasut::Product();         // Product                  https://apidocs.parasut.com/#tag/Products
Parasut::Warehouse();       // Warehouse                https://apidocs.parasut.com/#tag/Warehouses
Parasut::Waybill();         // Waybill                  https://apidocs.parasut.com/#tag/ShipmentDocuments
Parasut::StockMovement();   // Stock Movement           https://apidocs.parasut.com/#tag/StockMovements

/* Settings */
Parasut::Category();        // Category                 https://apidocs.parasut.com/#tag/ItemCategories
Parasut::Tag();             // Tag                      https://apidocs.parasut.com/#tag/Tags

/* Other */
Parasut::ApiHome();         // Api Home                 https://apidocs.parasut.com/#tag/ApiHome
Parasut::TrackableJob();    // Trackable Job            https://apidocs.parasut.com/#tag/TrackableJobs
Parasut::Webhook();         // Webhooks                 https://apidocs.parasut.com/#tag/Webhooks

Apart from these, to check the stock level of products, you need to use Parasut::Product()->inventory($id);

Methods

When using the classes within Paraşüt, you can utilize the functions listed on the https://apidocs.parasut.com page.

For example:
To use the customer index function: Parasut::Customer()->index();
To use the customer create function: Parasut::Customer()->create($data);
To use the customer show function: Parasut::Customer()->show($id);
To use the customer edit function: Parasut::Customer()->edit($id, $data);

All functions shown in the documentation are available.

Data Structure

When sending data for a create function within a class, you must send the data as described on https://apidocs.parasut.com. If you don't provide the necessary parameters, you will receive an error.

Additionally, you must send the data as an Array, not as JSON. The package will convert the data to JSON and send it automatically.

Example of creating a Customer:

$customer = [
            'data'=>[
                'type'=>'contacts',
                'attributes'=>[
                    'email'=>'demo@parasut.com',
                    'name'=>'İsim Soyisim',
                    'contact_type'=>'person',
                    'tax_number'=>'11111111111',
                    'account_type'=>'customer'
                ]
            ]
        ];
$response = Parasut::Customer()->create($customer);

If your operations are successful, you will receive an Array like this:

Array
(
    [success] => true // If the operation is successful, true
    [error] => false // If the operation fails, true
    [body] => stdClass Object // Response as described in the Paraşüt documentation -> as stdClass Object
    [status] => 200 // Response Status
)
Query Parameters ()

Filtering and sending query parameters were included in version v1.2.0-beta. You can now send the Query Parameters mentioned in the documentation, which are appended to the end of the URL. The parameters are optional but may vary depending on the endpoint you are using and will be validated. You cannot send parameters that are not required.

WARNING: Before version v1.2.0, the parameter code with vkn in the Inbox was changed. So if you are using it in your project like Parasut::Inbox->index($vkn), you need to send it as an array as shown below.

$parameters = [
    'filter' => [
        'vkn' => 1234567890 // Only integer accepted.
    ],
    // Not required
    'page' => [ 
        'number' => 1,
        'size'=> 15
    ]
];

Parasut::Inbox->index($parameters);

Example of Parameter Submission:

$parameters = [
            'filter' => [
                'name' => 'isim',
                'currency' => 'TRY',
                'bank_name' => 'Banka ismi',
                'bank_branch' => 'Banka Şubesi',
                'account_type' => 'Hesap Tipi',
                'iban' => 'TR00 0000 0000 0000 0000 0000 00'
            ],
            'sort' => 'balance',
            'page' => [
                'number' => 1,
                'size' => 15
            ]
        ];
$response = Parasut::Account()->index($id, $parameters);

(Back to top)

TODO

You can report missing parts and errors in the Issues section.

  • Functions have been included
  • Other missing parts have been added (Others)
  • Staging functions have been removed
  • Extra filters for functions will be added (Query Parameters)

Licensing

This project is distributed under the MIT License. For more information, please refer to the 'LICENSE' file.

(Back to top)

Contact

Baran Arda - @theposeidonas - baran@webremium.com

Proje Linki: https://github.com/theposeidonas/laravel-parasut-api

(Back to top)