firelike / litres-api

Zend Framework module to consume LitRes APIs


LitRes API Client

Build Status License

Introduction

Zend Framework module to consume LitRes API

Installation

Install the module using Composer into your application's vendor directory. Add the following line to your composer.json.

{
    "require": {
        "firelike/litres-api": "^1.0"
    }
}

Configuration

Enable the module in your application.config.php file.

return array(
    'modules' => array(
        'Firelike\LitRes'
    )
);

Copy and paste the litres.local.php.dist file to your config/autoload folder and customize it with your credentials and other configuration settings. Make sure to remove .dist from your file.Your litres.local.php might look something like the following:

<?php
return [
    'litres_service' => [
        'log'=>[
            'enable'=>false,
            'message_formats'=>[
                '{method} {uri} HTTP/{version} {req_body}',
                'RESPONSE: {code} - {res_body}',
            ],
            'logger'=>[
                 'stream' => 'php://output',
            ]
        ]
    ]
];

Usage

Calling from your code:

        use Firelike\LitRes\Request\AbstractRequest;
        use Firelike\LitRes\Request\Browser as BrowserRequest;
        use Firelike\LitRes\Service\LitResService;


        $request = new BrowserRequest();
        $request->setSearch('King')
            ->setLang('en')
            ->setLimit(25);

        $service = new LitResService();
        $result = $service->browser($request);

        $numberOfRecords = $result->toArray()['results'];
        var_dump($numberOfRecords);

        $records= $result->toArray()['fb2-book'];
        var_dump($records);

Using the console:

php public/index.php litres browser --search=King -v

Implemented Service Methods:

  • browser
  • genres
  • persons

Links

BSD 3-Clause License

Copyright (c) 2016, Flexi Network, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
php composer.phar require "firelike/litres-api"

Require

  • php: ^5.6 || ^7.0
  • zendframework/zend-mvc-console: ^1.1
  • guzzlehttp/guzzle-services: ^1.0
  • zendframework/zend-log: ^2.9

Require Dev

  • phpunit/phpunit: ^5.7