2017 © Pedro Peláez
 

library service-layer

B!Q Common service layer

image

bootiq/service-layer

B!Q Common service layer

  • Friday, May 18, 2018
  • by bootiq
  • Repository
  • 1 Watchers
  • 1 Stars
  • 429 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 148 % Grown

The README.md

BootIq - Service Layer

BOOT!Q Logo, (*1)

pipeline status coverage report, (*2)

Service Layer vendor, for SOA communication (REST/SOAP)., (*3)

Installation

For installation of Boot!Q Service Layer, use composer:, (*4)

composer require bootiq/service-layer

Adapters

BootIq\ServiceLayer\Adapter\GuzzleAdapter

Default adapter is GuzzleAdapter, primary for REST communication., (*5)

Configuration

  • dependencies
    • client - GuzzleHttp\ClientInterface - client for calling requests.
    • responseFactory - BootIq\ServiceLayer\Response\ResponseFactoryInterface - response factory for creating specific response.
    • urn - URN of API (for example: https://api.bootiq.io).
  • timeout - request timeout provided by setTimeout method (default: 10s).
  • cache - if you want cache responses, provide your cache service (PSR-16).
  • logger - if you want log what is going on in adapter, provide your logger service (PSR-3).

Own adapter

To create your own adapter, you have to implement BootIq\ServiceLayer\Adapter\AdapterInterface., (*6)

Enum

Library provides enums: * BootIq\ServiceLayer\Enum\HttpCode - List of all HTTP codes according to http://www.restapitutorial.com/httpstatuscodes.html. * BootIq\ServiceLayer\Enum\HttpMethod - List of all available HTTP methods according to http://www.restapitutorial.com/lessons/httpmethods.html., (*7)

Exception

We provide base exception for working with our service layer (BootIq\ServiceLayer\Exception\ServiceLayerException)., (*8)

Requests

Every request which can be called by adapter must implement BootIq\ServiceLayer\Request\RequestInterface., (*9)

In BootIq\ServiceLayer\Request namespace are abstract classes for various http methods, for more simple integration with our service layer., (*10)

For example:, (*11)

<?php

namespace BootIq\CmsApiVendor\Request\Page;

use BootIq\ServiceLayer\Request\GetMethod;

class GetPageRequest extends GetMethod
{

    /**
     * @var int
     */
    private $pageId;

    /**
     * GetPageRequest constructor.
     * @param int $pageId
     */
    public function __construct(int $pageId)
    {
        $this->pageId = $pageId;
    }

    /**
     * @return string
     */
    public function getEndpoint(): string
    {
        return 'page/' . $this->pageId;
    }
}

Response

Every response returned by adapter must implement BootIq\ServiceLayer\Response\ResponseInterface., (*12)

We provide default response object BootIq\ServiceLayer\Response\Response and default response factory BootIq\ServiceLayer\Response\ResponseFactory for faster implementation., (*13)

The Versions