Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
pull_request:
push:
branches:
- master
- 'codex/**'

jobs:
source-compatibility:
name: Source compatibility (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '5.4'
- '7.4'
- '8.4'
- '8.5'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: none

- name: Lint source files
run: find src -name '*.php' -print0 | xargs -0 -n 1 php -l

tests:
name: Tests (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.4'
- '8.5'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring
coverage: none

- name: Validate Composer configuration
run: composer validate --strict --no-check-lock

- name: Install dependencies
run: composer update --no-interaction --prefer-dist --no-progress

- name: Run test suite
run: composer test
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"name" : "oneall/php-sdk",
"description" : "PHP SDK for the OneAll API.",
"license" : "GPL-2.0-or-later",
"require" : {
"php": ">=5.4"
},
"require-dev" : {
"phpunit/phpunit": "@stable",
"phpunit/phpunit": "^9.6",
"phpmd/phpmd" : "~2.6"
},
"scripts" : {
"test": "phpunit"
},
"autoload" : {
"psr-4": {
"Oneall\\": "src/"
Expand Down
29 changes: 14 additions & 15 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="unit">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
10 changes: 10 additions & 0 deletions src/Api/Apis/Analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Oneall\Api\Apis;

/**
* Backwards-compatible alias for the sharing analytics API.
*/
class Analytics extends SharingAnalytics
{
}
2 changes: 1 addition & 1 deletion src/Api/Apis/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null)
public function getAll($pagination = null)
{
if (!$pagination)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Apis/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null)
public function getAll($pagination = null)
{
if (!$pagination)
{
Expand Down Expand Up @@ -147,7 +147,7 @@ public function synchronize($identityToken, $updateUserData = true, $forceTokenU
*
* @return \Oneall\Client\Response
*/
public function getContacts($identityToken, Pagination $pagination = null, $disable_cache = false)
public function getContacts($identityToken, $pagination = null, $disable_cache = false)
{
if (!$pagination)
{
Expand Down
10 changes: 8 additions & 2 deletions src/Api/Apis/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Oneall\Api\Apis\Provider\Steam;
use Oneall\Api\Apis\Provider\Twitter;
use Oneall\Api\Apis\Provider\Youtube;
use Oneall\Api\Pagination;
use Oneall\Client\ClientInterface;
use Oneall\Exception\ProviderApiNotFound;

Expand Down Expand Up @@ -79,9 +80,14 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll()
public function getAll($pagination = null)
{
return $this->getClient()->get('/providers.json');
if (!$pagination)
{
$pagination = new Pagination();
}

return $this->getClient()->get('/providers.json?' . $pagination->build());
}

/**
Expand Down
73 changes: 73 additions & 0 deletions src/Api/Apis/Provider/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
namespace Oneall\Api\Apis\Provider;

use Oneall\Api\AbstractApi;
use Oneall\Api\Pagination;
use Oneall\Exception\BadMethodCallException;

/**
* Class Facebook
Expand All @@ -43,6 +45,77 @@ public function getName()
return 'facebook';
}

/**
* @param string $identityToken
* @param Pagination|null $pagination
*
* @return \Oneall\Client\Response
*/
public function getPosts($identityToken, $pagination = null)
{
if (!$pagination)
{
$pagination = new Pagination();
}

return $this->getClient()->get('/identities/' . $identityToken . '/facebook/posts.json?' . $pagination->build());
}

/**
* @param Pagination|null $pagination
*
* @return \Oneall\Client\Response
*/
public function getPages($pagination = null)
{
if (!$pagination)
{
$pagination = new Pagination();
}

return $this->getClient()->get('/providers/facebook/pages.json?' . $pagination->build());
}

/**
* @param string $pageToken
* @param string|null $text
* @param array $link
* @param string|null $picture
*
* @return \Oneall\Client\Response
*/
public function publish($pageToken, $text = null, array $link = [], $picture = null)
{
if (empty($text) && empty($link) && empty($picture))
{
throw new BadMethodCallException('No data to publish.');
}

$data = [
'request' => [
'page_message' => [
'parts' => [
'text' => ['body' => $text],
'picture' => [],
'link' => [],
]
]
]
];

if (!empty($picture))
{
$data['request']['page_message']['parts']['picture'] = ['url' => $picture];
}

if (!empty($link))
{
$data['request']['page_message']['parts']['link'] = $link;
}

return $this->getClient()->post('/providers/facebook/pages/' . $pageToken . '/publish.json', $data);
}

// ****************
// Pull API
// ****************
Expand Down
10 changes: 10 additions & 0 deletions src/Api/Apis/Provider/Steam.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public function getName()
return 'steam';
}

/**
* @param string $identityToken
*
* @return \Oneall\Client\Response
*/
public function getGames($identityToken)
{
return $this->getClient()->get('/identities/' . $identityToken . '/steam/games.json');
}

/**
* Steam \ List Games
*
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Apis/Provider/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function pullTweets($identityToken, $num_tweets = 50, $after_tweet_id = '
*
* @return \Oneall\Client\Response
*/
public function pushTweet($identityToken, $message, array $picturesIds = [], string $location = null)
public function pushTweet($identityToken, $message, array $picturesIds = [], $location = null)
{
$data = [
"request" => [
Expand Down
10 changes: 10 additions & 0 deletions src/Api/Apis/Provider/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public function getName()
return 'youtube';
}

/**
* @param string $identityToken
*
* @return \Oneall\Client\Response
*/
public function getVideos($identityToken)
{
return $this->getClient()->get('/identities/' . $identityToken . '/youtube/videos.json');
}

/**
* Youtube \ List Videos
*
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Apis/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null)
public function getAll($pagination = null)
{
if (!$pagination)
{
Expand All @@ -75,7 +75,7 @@ public function getAll(Pagination $pagination = null)
*
* @return \Oneall\Client\Response
*/
public function getPageByToken($sharing_page_token, Pagination $pagination = null)
public function getPageByToken($sharing_page_token, $pagination = null)
{
if (!$pagination)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public function getPageByUrl($url)
*
* @return \Oneall\Client\Response
*/
public function getMessages(Pagination $pagination = null)
public function getMessages($pagination = null)
{
if (!$pagination)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Apis/SharingAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null, $identityToken = null, $userToken = null)
public function getAll($pagination = null, $identityToken = null, $userToken = null)
{
$query = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Api/Apis/ShortUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(\Oneall\Api\Pagination $pagination = null)
public function getAll($pagination = null)
{
if (!$pagination)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Apis/Sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getName()
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null)
public function getAll($pagination = null)
{
if (!$pagination)
{
Expand Down
12 changes: 11 additions & 1 deletion src/Api/Apis/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,23 @@ public function createUser(
*/
public function updateUser(
$userToken,
array $identity = [],
$identity = [],
$externalId = null,
$login = null,
$password = null,
$mode = self::MODE_UPDATE_REPLACE
)
{
if (!is_array($identity))
{
$arguments = func_get_args();
$externalId = isset($arguments[1]) ? $arguments[1] : null;
$login = isset($arguments[2]) ? $arguments[2] : null;
$password = isset($arguments[3]) ? $arguments[3] : null;
$identity = (isset($arguments[4]) && is_array($arguments[4])) ? $arguments[4] : [];
$mode = isset($arguments[5]) ? $arguments[5] : self::MODE_UPDATE_REPLACE;
}

if (empty($externalId) && empty($login) && empty($password) && empty($identity))
{
return null;
Expand Down
Loading