lukapeharda/pushlapgrowth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lukapeharda/pushlapgrowth

最新稳定版本:1.1.0

Composer 安装命令:

composer require lukapeharda/pushlapgrowth

包简介

A PHP client for the PushLapGrowth API

README 文档

README

A PHP client for the PushLapGrowth API.

Installation

Install via Composer:

composer require lukapeharda/pushlapgrowth

Requirements

  • PHP 7.4 or higher
  • Guzzle HTTP Client

Usage (Standard PHP)

You can use the client in any PHP application by instantiating the Client class with your API Token.

use PushLapGrowth\Client;
use PushLapGrowth\DTO\CreateSaleData;
use PushLapGrowth\DTO\UpdateSaleData;
use PushLapGrowth\DTO\CreateReferralData;
use PushLapGrowth\Exceptions\ValidationException;

// Initialize Client
$client = new Client('YOUR_API_TOKEN');

try {
    // 0. Create a Referral
    $referralData = new CreateReferralData(
        'John Doe',
        'john@example.com',
        'ext_123', // referredUserExternalId
        'aff_abc'  // affiliateId (optional)
        // ... options: affiliateEmail, promoCode, plan, status
    );
    $client->createReferral($referralData);

    // 1. Create a Sale
    $data = new CreateSaleData(
        100.0,          // totalEarned
        'ref_123',      // referralId (optional)
        'user@example.com' // email (optional)
    );
    $response = $client->createSale($data);
    print_r($response);

    // 2. Update a Sale (using Internal ID)
    $updateData = new UpdateSaleData(
        $response['id'], // saleId
        'New Name',      // name
        null,            // email
        150.0            // totalEarned
    );
    $client->updateSale($updateData);

    // 3. Update a Sale (using External ID)
    // Useful if you only store your own system's IDs
    $externalUpdateData = new UpdateSaleData(
        null, // ID looked up automatically
        null,
        null,
        250.0
    );
    $client->updateSaleUsingExternalId('my_external_id_123', $externalUpdateData);

    // 4. Delete a Sale
    $client->deleteSale($response['id']);

    // 5. Delete a Sale (using External ID)
    $client->deleteSaleUsingExternalId('my_external_id_123');

} catch (ValidationException $e) {
    // Handle Validation Errors (422)
    print_r($e->getErrors());
} catch (\Exception $e) {
    // Handle other errors
    echo $e->getMessage();
}

Usage (Laravel)

This package includes a Service Provider and Facade-like behavior for Laravel 5.6+ and above.

1. Configuration

Publish the configuration file (optional):

php artisan vendor:publish --provider="PushLapGrowth\PushLapGrowthServiceProvider" --tag="config"

Add your API Token to .env:

PUSHLAPGROWTH_API_TOKEN=your_token_here

2. Dependency Injection

You can type-hint the Client class in your Controllers, Jobs, or Services.

use PushLapGrowth\Client;
use PushLapGrowth\DTO\CreateSaleData;

class SaleController extends Controller
{
    public function store(Client $client)
    {
        $data = new CreateSaleData(50.0, 'ref_abc');
        $client->createSale($data);

        return response()->json(['status' => 'success']);
    }
}

Error Handling

The client throws specific exceptions for different error scenarios:

  • PushLapGrowth\Exceptions\ValidationException: Thrown on 422 Unprocessable Entity. Use getErrors() to see details.
  • PushLapGrowth\Exceptions\NotFoundException: Thrown on 404 Not Found.
  • PushLapGrowth\Exceptions\ApiException: Thrown on other API errors (500, 400, etc.).

All exceptions extend PushLapGrowth\Exceptions\PushLapGrowthException.

Testing

Run the test suite:

vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固