larowka/kudago-api

PHP Wrapper for KudaGo API

v0.4.1 2021-11-26 21:20 UTC

This package is auto-updated.

Last update: 2024-11-27 03:43:21 UTC


README

PHP wrapper for KudaGo API base on Guzzle Http Client

Requirements

  • PHP 7.3 or later

Installation

Via Composer:

$ composer require larowka/kudago-api

or you can update your composer.json file:

{
    "require": {
      "larowka/kudago-api": "0.2.*"
    }
}

Laravel

Lumen

Usage examples

Create API Wrapper instance

use Larowka\KudaGo\Api;

$kudago = new Api();

Traits

Some entities have common traits for sorting, details, filter by time or coordinates, and paginator. Use IDE annotations or official documentation for allowed arguments.

$events = $kudago->events();

// Sorting
$events->orderBy('id', '-publication_date') // Order by id ASC and by publication_date DESC
        ->get();

// Details
$events->expand('images', 'dates') // Get detailed information of images and dates in result
        ->get();

// Filter by time
$events->before('2022', '!Y')    // Get results between 2021-10-12 and 2022 year
        ->after('2021-10-12', 'Y-m-d')
        ->get();

// Filter by coordinates
$events->inRadius(59.9, 30.3, 10000) // Include only events in radius 10000 meters around point [latitude, longitude]
        ->get();

// Paginator
$events->page(3) // Page number
        ->pageSize(35) // Items on page
        ->get();
        
// Concrete object
$events->find(161043); // find by event ID

API Endpoints

Object categories (doc)
$categories = $kudago->categories();

$eventCategories = $categories->events()->get();
$placeCategories = $categories->places()->get();
Locations (doc)

traits: Sort

$locations = $kudago->locations();

$cities = $locations->orderBy('timezone')->get();
$city = $locations->find('spb');
Search (doc)

traits: Paginator, Details, CoordsFilter

$kudago->search()
        ->query('art') // Query string
        ->type('event') // Include only specific type: news, event, place, list
        ->expand('place', 'dates')
        ->get();
Events (doc)

traits: Paginator, Sort, Details, TimeFilter, CoordsFilter

$kudago->events()
        ->after('2021-10-11')
        ->orderBy('-publication_date')
        ->page(5)
        ->pageSize(50)
        ->get();
Events of the day (doc)
$kudago->eventsOfTheDay()->get();
News (doc)
$kudago->news()->get();
Lists (doc)

traits: Paginator, Sort, Details

$kudago->lists()->get();
Places (doc)

traits: Paginator, Sort, Details, TimeFilter, CoordsFilter

$kudago->places()
        ->ids(157,33338) // Include only specific places by placeID
        ->get();
Movies (doc)

traits: Paginator, Sort, Details, TimeFilter

$kudago->movies()->get();
Showings (doc)

traits: Paginator, Sort, Details, TimeFilter

$kudago->showings()
        ->inPlace(19757) // Include only showings in specific place
        ->get();
Movie Showings (doc)

traits: Paginator, Sort, Details, TimeFilter

$kudago->movieShowings(3315)
        ->inPlace(19757) // Include only showings in specific place
        ->get();
Agents (doc)
$kudago->agents()->get();
Agent Roles (doc)
$kudago->agentRoles()->get();