定制 juanparati/podium 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

juanparati/podium

Composer 安装命令:

composer require juanparati/podium

包简介

A modern PHP library for Podium compatible with Laravel

README 文档

README

A modern Podio API client compatible with Laravel.

Installation

composer require juanparati/podium

Laravel setup

This library can is compatible with Laravel. The following command will deploy the configuration file:

artisan vendor:publish --provider="Juanparati\Podium\Providers\PodiumProvider"

How to use it?

Client instance and authentication

$client = new \Juanparati\Podium\Podium(
        session: '12346',
        clientId: 'myClientId',
        clientSecret: 'myClientSecret'
);

$client->authenticate(
    new \Juanparati\Podium\Auths\AppAuth(
        appId: '987654',      
        appToken: 'myAppToken'
    )
);

Request a single item

$item = (new \Juanparati\Podium\Requests\ItemRequest($client))->get(itemId: 11111111);

Request all the items of an App

$models = (new \Juanparati\Podium\Requests\ItemRequest($client))->filter(appId: 987654);

or alternatively with custom options:

$models =  (new \Juanparati\Podium\Models\ItemFilterModel([], $client))           
        ->setSortBy('last_edit_on')
        ->setSortDesc(true)
        ->setLimit(5);

Read all the items. Note that items() method is a generator, and it will automatically request the additional pages.

$itemNum = 0;

foreach ($models->items() as $item) {
    print_r($item->originalValues())
    
    // The setLimit options indicate the limit of items per page to the request,
    // but the generator will automatically request the next page.
    // In order to limit the number of results we should manually limit the results.
    if ($itemNum === 10)
        break;
        
    $itemNum++;   
}

Reading item values.

This library provides to ways to read the values of the items.

  1. Obtain the original values using the originalValues method:
$item->originalValues();
  1. Obtain the simplified values using the decodeValue method:
$item->decodeValue();

Both values will transverse all the values tree, however you can reference to an specific value.

// Accessing to the fields
$item->fields->decodeValue();

or

// Accessing to specific values
$item->fields->title;
$item->fields->{'my-custom-field'};

Saving items

⚠️ Note: Saving items is still an experimental feature. Use this feature at your own risk.

It's possible to save/update items.

// Accessing to specific values
$item->fields->title = "My new title";
$item->save(silent: false, hook: true); // Will perform silent update calling the bounded hooks 

Inserting new items

⚠️ Note: Saving items is still an experimental feature. Use this feature at your own risk.

$attr = [
    'title' => 'My new title'
    'revenue' => ['currency' => 'DKK', 'value' => 123.34];
];

(new \Juanparati\Podium\Requests\ItemRequest($client))->create(
    appId: 987654,
    attr: $attr,
    silent: false,
    hook: false
);

Using different field keys

It's possible to retrieve the field keys using the following formats:

  • external_id (Default).
  • external_id in snake case format.
  • field_id.

For example sometime is very suitable to retrieve the field keys in snake case so it's easiest to manipulate.

$item = (new \Juanparati\Podium\Requests\ItemRequest($client))->get(itemId: 11111111);
echo $item->fields->{'my-long-named-field'};

$item->setOptions([
    \Juanparati\Podium\Models\ItemFieldModel::class => [
        \Juanparati\Podium\Models\ItemFieldModel::OPTION_KEY_AS => \Juanparati\Podium\Models\ItemFieldModel::KEY_AS_SNAKECASE,
    ]
);

echo $item->fields->my_long_named_field;

$item->setOptions([
    \Juanparati\Podium\Models\ItemFieldModel::class => [
        \Juanparati\Podium\Models\ItemFieldModel::OPTION_KEY_AS => \Juanparati\Podium\Models\ItemFieldModel::KEY_AS_FIELD_ID,
    ]
);

echo $item->fields->{'12345567'};

Transforming date and datetime to different time zones and formats

$item = (new \Juanparati\Podium\Requests\ItemRequest($client))->get(itemId: 11111111);

$item->setOptions([
    \Juanparati\Podium\Models\ItemFieldModel::class => [
        \Juanparati\Podium\Models\ItemFields\DateItemField::class => [
            \Juanparati\Podium\Models\ItemFields\DateItemField::OPTION_TIMEZONE => 'Europe/Copenhagen',
            \Juanparati\Podium\Models\ItemFields\DateItemField::OPTION_FORMAT => \Juanparati\Podium\Models\ItemFields\DateItemField::FORMAT_TIMESTAMP
        ]
    ]
);

juanparati/podium 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-02