承接 lacodix/sevdesk-saloon 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lacodix/sevdesk-saloon

最新稳定版本:v0.13.1

Composer 安装命令:

composer require lacodix/sevdesk-saloon

包简介

A PHP package for consuming the SevDesk API based on Saloon

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Documentation

** WORK IN PROGRESS _ DOCUMENTATION NOT READY **

You can find the entire documentation for this package on our documentation site.

This package helps you to consume the Sevdesk API with your PHP projects. The package is based on Saloon https://api.sevdesk.de/

Installation

composer require lacodix/sevdesk-saloon

Quickstart

Create an API Connector first. You have to provide some configuration data, to get the sevdesk api working. There are several settings that you'd have to set in all requests otherwise, like default tax rates and your api user id.

use Lacodix\SevdeskSaloon\SevdeskSaloon;

$sevdeskSaloon = new SevdeskSaloon(
    $api_token, // Your API Token - get it in your Sevdesk account
    [
        'sevUserId'   => 12345678,     // the Sevdesk Uer ID - needed to create invoices
        'taxRate'     => 19,
        'taxText'     => 'MwSt 19%',   // only in version 1.0
        'taxType'     => 'default',    // only in version 1.0
        'taxRule'     => 1,            // only in version 2.0
        'currency'    => 'EUR',
        'invoiceType' => 'RE',
    ]
);

Get Your API User Id

Unfortunately Sevdesk doesn't show up the user ids on the UI. So you have to consume the API without configuration for the first time. You can just run the following code (you need a valid token).

    $sevdeskSaloon = new SevdeskSaloon($api_token);
    $sevdeskSaloon->sevUser()->get();

this will return an array of all sevUsers in your account. Take the ID and save it in your configuration.

[
    [
      "id" => "1234567",
      "objectName" => "SevUser",
      "additionalInformation" => null,
      "create" => ...,
      ...
    ]
]

Consuming the Api

With the connector you can just consume all existing API resources

    $sevdeskSaloon->contact()->get();
    $sevdeskSaloon->contact()->create($contactType, $contactData);
    
    $sevdeskSaloon->invoice()->get();
    $sevdeskSaloon->invoice()->create($sevContactId, $items, $data);
    $sevdeskSaloon->invoice()->sendViaEmail($invoiceId, $data);

Mock API Calls in your tests

Since this package is based on Saloon, you can just use the MockClient to mock all requests in your tests.

See Saloon Documentation for more information.

Contributing

Please run the following commands and solve potential problems before committing and think about adding tests for new functionality.

composer rector:test
composer insights
composer csfixer:test
composer phpstan:test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

With the first usage of Sevdesk API we used the package laravel-sevdesk-api created by Martin. Nevertheless we had some issues, for example when downloading invoices as PDF, which Martin solved via a direkt print out of the pdf, while we wanted to save the PDF on our side. Finally the testability with mocking the default Guzzle Client is a impertinence, why we decided to make our own package based on Saloon and with no dependency on Laravel, so you can also use it in other composer based PHP Projects. Some few parts are still based on Martins package like the Countries-Enum.

License

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

统计信息

  • 总下载量: 357
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-13