2017 © Pedro Peláez
 

library speakout-api-client

image

skiftet/speakout-api-client

  • Monday, October 2, 2017
  • by JoelESvensson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Installation

Run composer require skiftet/speakout-api-client in your project root to install the package., (*1)

Usage

NOTE: The api currently only works with an in-development version of the Speakout api that isn't released yet

use Skiftet\Speakout\Api\Client as Speakout;

$speakout = new Speakout([
    'endpoint' => '', // Set this to the url of a running Speakout deployment. E.g. 'http://localhost:3000'
    'user'     => '', // The username of a Speakout user
    'password' => '', // The correponding password
]);

/**
 * This will load request an array with all campaigns
 */
$campaigns = $speakout->campaigns()->all();

/**
 * This will request an array with all campaigns, sorted by action count
 */
$campaigns = $speakout->campaigns()->orderBy('actions')->get();

/**
 * You can also do nested queries for deeper filters. The example below will only
 * take actions since the 1st of March 2017 into account.
 */
$campaigns = $speakout->campaigns()->orderBy('actions')->has('actions', function (Query $query) {
    return $query->since('2017-03-01'); // this can also be an instance of \DateTime
})->get();

TODO

  • Implement creating new actions
  • Hydrated models
  • Decide whether to use active record or data mapper pattern for models
  • Lazy loading model relationships

The Versions