承接 iamfredric/fortnox 相关项目开发

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

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

iamfredric/fortnox

Composer 安装命令:

composer require iamfredric/fortnox

包简介

Fortnox api integration

README 文档

README

This package is a wrapper for the Fortnox API.

Requirements

php ^8.0 Fortnox developer account https://developer.fortnox.se/

Installation

composer reqiure "iamfredric/fortnox"

Configuration

\Iamfredric\Fortnox\Fortnox::setClientCredentials(
    clientId: 'your-app-client-id',
    clientSecret: 'your-app-client-secret',
    redirectUrl: 'http://your-app-url/fortnox/callback',
    scope: 'your scopes separated by spaces' 
);

Authenticate user

// Redirect user to Fortnox for authentication
$url = \Iamfredric\Fortnox\Fortnox::authUrl();

// In your response handler, when fortnox redirects user back to your app,
$response = \Iamfredric\Fortnox\Fortnox::verifyAuthCode($_GET['code']);
$response['access_token'];
$response['refresh_token'];
$response['scope'];
$response['expires_in'];
$response['token_type'];

Working with resources

Before you can use the resources, you need to authenticate the user.

// You need to pass an object that implements \Iamfredric\Fortnox\Contracts\Authenticatable
// to the authenticateAs method. This object will be used to get the access token and refresh 
// your access token when it expires.
\Iamfredric\Fortnox\Fortnox::authenticateAs(new class implements \Iamfredric\Fortnox\Contracts\Authenticatable {
    public function getFortnoxAccessToken(): string
    {
        return 'your-access-token';
    }
 
    public function getFortnoxRefreshToken(): string
    {
        return 'your-refresh-token'; 
    }

    public function getFortnoxExpiresAt(): DateTime
    {
        return new DateTime('Expiration date for token');
    }

    public function onFortnoxUpdate($data): void
    {
        // Update your database with the new access token and refresh token
    }
});
Get all customers
use \Iamfredric\Fortnox\Resources\Customer;

$customers = Customer::all()

foreach ($customers as $customer) {
    /**  @var $customer Customer */
}
Get a customer
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);
Create a customer
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::create([
    'Name' => 'Acme INC'
]);
Update a customer
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);
// Or
$customer = new Customer([
    "CustomerNumber" => "1",
])

$customer->update([
    'Name' => 'Acme INC'; 
])
// Or
$customer->Name = 'Acme INC';
$customer->save();
Delete a customer
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);

$customer->delete();

Extending current package

class Order extends \Iamfredric\Fortnox\Resources\Resource
{
    protected function getIdKey(): string
    {
        return 'DocumentNumber';
    }
}

Order::all();
$order = Order::find(1);
$order->update([]);
$order->save();
$order->delete();

Testing

composer run test
composer run analyze
composer run sniff

Contributing

Contributing

Contributions are welcome.

Procedure

Before filing an issue:

  • Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
  • Check to make sure your feature suggestion isn't already present within the project.
  • Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
  • Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

  • Check the codebase to ensure that your feature doesn't already exist.
  • Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

Requirements

If the project maintainer has any additional requirements, you will find them listed here.

  • PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.

  • Add tests! - Your patch won't be accepted if it doesn't have tests.

  • Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Happy coding!

License

The MIT License (MIT).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iamfredric/fortnox 适用场景与选型建议

iamfredric/fortnox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 iamfredric/fortnox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 iamfredric/fortnox 我们能提供哪些服务?
定制开发 / 二次开发

基于 iamfredric/fortnox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-29