surender/prodege-api

Laravel package for Prodege MR API integration

v1.0.3 2025-08-05 06:35 UTC

This package is auto-updated.

Last update: 2025-08-05 06:38:59 UTC


README

A Laravel package for seamless integration with the Prodege MR API, featuring secure request signing, time offset handling, and robust response management โ€” all wrapped in a clean, facade-based interface.

๐Ÿš€ Features

  • โœ… Signed API requests with SHA-256 HMAC
  • ๐Ÿ•’ Time offset handling via /lookup-request-time-offset
  • ๐Ÿงฑ Laravel Facade support (ProdegeApi::post(...))
  • ๐Ÿง  Smart response handling with automatic message normalization
  • ๐Ÿ”ง Null implementation (NullProdegeService) for local/testing environments

๐Ÿ“ฆ Installation

Install via Packagist:

composer require surender/prodege-api

โš™๏ธ Configuration

php artisan vendor:publish --tag=prodege-config

Set up your .env:

 PRODEGE_API_KEY=your_api_key
 PRODEGE_SECRET=your_secret
 PRODEGE_BASE_URL=https://api.prodegemr.com

โœ… Usage

use Surender\ProdegeApi\Facades\ProdegeApi;

$response = ProdegeApi::post('project-create', [
    'project_id' => 1234001,
    'project_type_id' => 1,
    'project_name' => 'Test Project',
    'loi' => 60,
    'country_id' => 1,
    'project_url' => 'http://www.google.com/?tr_id=%transid%',
    'cpi' => 2.25,
    'mobile_optimized' => 'true',
    'sample_size' => 100,
    'expected_ir' => 90
]);

if ($response->isSuccess()) {
    return response()->json([
        'message' => $response->getMessage(),
        'response' => $response->toArray(),
    ]);
}

return response()->json([
    'message' => $response->getMessage(),
    'errors' => $response->getErrorCodes(),
    'response' => $response->toArray(),
], 422);

๐Ÿงฐ Utilities

Generate Signed URL

$url = ProdegeApi::generateSignedUrl('target-endpoint', ['key' => 'value']);

Generate Signed Params

$params = ProdegeApi::generateSignedParams(['key' => 'value']);

๐Ÿงช Testing in Local Environment

Prevent real API calls using the NullProdegeService:

use Surender\ProdegeApi\Contracts\ProdegeApiInterface;
use Surender\ProdegeApi\Services\NullProdegeService;

$this->app->bind(ProdegeApiInterface::class, NullProdegeService::class);

๐Ÿ” ResponseHandler Methods

Method Description

  • isSuccess() Returns true if status_id is 1
  • getMessage() Gets first message (handles string or array)
  • getMessages() Gets all messages as array
  • getErrorCodes() Returns any error codes
  • toArray() Returns the raw API response

๐Ÿ“„ License

  • MIT License. See LICENSE file.

๐Ÿ™Œ Contributing

  • Pull requests and issues are welcome! If you're planning a big change, open an issue first to discuss.

Let me know if you want a sample Laravel controller, targeting payload format, or if you'd like me to generate a GitHub Actions workflow for automatic testing and tag-based version release ๐Ÿš€