Looking to hire Laravel developers? Try LaraJobs

pennylane-laravel maintained by ashraam

Description
Pennylane API wrapper for Laravel
Last update
2021/09/01 14:09 (dev-master)
License
Downloads
288

Comments
comments powered by Disqus

Pennylane API wrapper for Laravel

Latest Version on Packagist

Please read the official API documentation to know what are the required fields for each endpoint.


Installation

You can install the package via composer:

composer require ashraam/pennylane-laravel

Then add the Pennylance API KEY in the .env file.

PENNYLANE_API_KEY=my_api_key

Usage

List all customers

$customers = PennylaneLaravel::customers()->list();

Get a customer by it's ID

$customer = PennylaneLaravel::customers()->get(999);

Create a new customer

$customer = PennylaneLaravel::customers()->create([
    'source_id' => (string) 1,
    'customer_type' => 'individual',
    'first_name' => 'John',
    'last_name' => 'Doe',
    'gender' => 'mister',
    'address' => "Street",
    'postal_code' => 'zip code',
    'city' => 'City',
    'country_alpha2' => 'FR',
    'emails' => ['john.doe@gmail.com'],
    'phone' => '+33625478510'
]);

Update a customer

$customer = PennylaneLaravel::customers()->update(1, [
    'delivery_address' => 'Delivery address',
    'delivery_postal_code' => 'Delivery zip code',
    'delivery_city' => 'Delivery city',
    'delivery_country_alpha2' => 'FR'
]);

List all products

$products = PennylaneLaravel::products()->list();

Get a product by it's ID

$product = PennylaneLaravel::products()->get(1);

Create a new product

$product = PennylaneLaravel::products()->create([
    'source_id' => (string) 1,
    'label' => 'Product 1',
    'unit' => 'piece',
    'price_before_tax' => 10,
    'price' => 12,
    'vat_rate' => 'FR_200',
    'currency' => 'EUR',
    'reference' => 'ref-001'
]);

Update a product

$product = PennylaneLaravel::products()->update(1, [
    'description' => 'Updated description'
]);

List all invoices

$invoices = PennylaneLaravel::invoices()->list();

// Invoices can be filtered
$invoices = PennylaneLaravel::invoices()->list([
    [
        'field' => 'customer_id',
        'operator' => 'eq',
        'value' => (string) 1
    ],
    [
        'field' => 'status',
        'operator' => 'eq',
        'value' => 'draft_status'
    ]
]);

Get an invoice by it's ID

$invoice = PennylaneLaravel::invoices()->get('RNT9MXHXAD');

Create an invoice

Second and third default value is set to false

$invoice = PennylaneLaravel::invoices()->create([
    'date' => today()->format('Y-m-d'),
    'deadline' => today()->addDays(15)->format('Y-m-d'),
    'draft' => false,
    'customer' => [
        'source_id' => (string) 1
    ],
    'line_items' => [
        [
            'label' => "My special item",
            'quantity' => 3,
            'product' => [
                'source_id' => (string) 1
            ]
        ],
        [
            'label' => "Remise",
            'quantity' => 1,
            'currency_amount' => -10,
            'unit' => 'piece',
            'vat_rate' => 'FR_200'
        ]
    ]
], $create_customers = false, $create_products = false);

Import an invoice

Third default value is set to false

$invoice = PennylaneLaravel::invoices()->import([
    'date' => today()->format('Y-m-d'),
    'deadline' => today()->addDays(15)->format('Y-m-d'),
    'invoice_number' => 'F-874',
    'currency' => 'EUR',
    'customer' => [
        'source_id' => (string) 1
    ],
    'line_items' => [
        [
            'label' => "My special item",
            'quantity' => 3,
            'product' => [
                'source_id' => (string) 1
            ]
        ],
        [
            'label' => "Remise",
            'quantity' => 1,
            'currency_amount' => -10,
            'unit' => 'piece',
            'vat_rate' => 'FR_200'
        ]
    ]
], $file_url, $create_customer = false);

List all estimates

$estimates = PennylaneLaravel::estimates()->list();

Get an estimate by it's ID

$estimate = PennylaneLaravel::estimates()->get('VVAWLPY8QB');

Create a new estimate

$estimate = PennylaneLaravel::estimates()->create([
    'date' => today()->format('Y-m-d'),
    'deadline' => today()->addDays(15)->format('Y-m-d'),
    'customer' => [
        'source_id' => (string) 1
    ],
    'line_items' => [
        [
            'label' => "My special item",
            'quantity' => 3,
            'product' => [
                'source_id' => (string) 1
            ]
        ],
        [
            'label' => "Random line",
            'quantity' => 1,
            'currency_amount' => 17.85,
            'unit' => 'piece',
            'vat_rate' => 'FR_200'
        ]
    ]
]);

Get an enum

The second parameter default value is en

$values = PennylaneLaravel::enums()->get('unit', 'fr');

Changelog

Please see CHANGELOG for more information what has changed recently.


Contributing

Please see CONTRIBUTING for details.


Security

If you discover any security related issues, please email romain.bertolucci@gmail.com instead of using the issue tracker.


Credits


License

The MIT License (MIT). Please see License File for more information.