recsys/common

Core components for the Recsys PHP payment processing library

1.0.2 2019-01-09 02:15 UTC

This package is auto-updated.

Last update: 2022-06-09 16:12:44 UTC


README

Core components for the Recsys PHP processing library

Build Status

Recsys is a framework agnostic, multi-gateway recsys processing library for PHP.This package implements common classes required by Recsys.

Installing

$ composer require recsys/common -vvv

Usage

Build your own gateway

<?php
namespace Recsys;

use Recsys\Common\AbstractGateway;

class TestGateway extends AbstractGateway
{
    // Report multi-items
    public function reportItems(array $parameters)
    {
        ...
    }
    
    // Report one item
    public function reportItem(array $parameter)
    {
        ...
    }
    
    // Remove multi-items
    public function removeItems(array $itemIds)
    {
        ...
    }
    
    // Remove one item
    public function removeItem($itemId)
    {
        ...
    }
    
    // Search multi-items
    public function findItems(array $itemIds)
    {
        ...
    }
    
    // Search one item
    public function findItem($itemId)
    {
        ...
    }
    
    // Report user multi-actions
    public function reportActions(array $parameters)
    {
        ...
    }
    
    // Report user one action
    public function reportAction($parameter)
    {
        ...
    }
    
    // Get a recommend result
    public function recommend(array $parameters)
    {
        ...
    }  
}

Build your own request

<?php

namespace Recsys;

use Recsys\Common\Message\AbstractRequest;

class TestRequest extends AbstractRequest
{
    // Handle your data and return them
    public function getData()
    {
        ...
    }
    
    // Make a http request to remote api, return a response implements \Recsys\Common\Message\ResponseInterface
    public function sendData($data)
    {
        ...    
        
        return new TestResponse($this, $data);
    }
}

Build your own response

<?php
namespace Recsys;

use Recsys\Common\Message\AbstractResponse;

class TestResponse extends AbstractResponse
{
    public function isSuccessful()
    {
        ...
    }
}

Use TestGateway

<?php

use Recsys\Recsys;
use Recsys\TestGateway;

$gateway = Recsys::create(TestGateway::class);

...

$response = $gateway->recommend($options);

if ($response->isSuccessful()) {
    print_r($response);
} else {
    ...
}

License

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