Skip to content

Commit

Permalink
change namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
amalfra committed Jul 25, 2021
1 parent 727e38e commit 5da5ba7
Show file tree
Hide file tree
Showing 26 changed files with 174 additions and 196 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ vendor
test.php
*~
phpunit.xml
*.cache
*.bak
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can load the wrapper classes using namespace as:
```php
require __DIR__ . '/vendor/autoload.php';

use \SupportBee\SupportBee;
use \Amalfra\SupportBee\Client as SupportBee;
```

Now create a new object
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
}
],
"autoload": {
"psr-0": {
"SupportBee": "src/"
"psr-4": {
"Amalfra\\SupportBee\\": "src/"
}
}
}
45 changes: 16 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="supportbee Test Suite">
<directory>./tests/SupportBee/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>

<filter>
<whitelist>
<directory suffix=".php">./src/SupportBee/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/SupportBee/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Supportbee Test Suite">
<directory>./tests/SupportBee/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
</phpunit>
9 changes: 4 additions & 5 deletions src/SupportBee/API/Agents.php → src/API/Agents.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Agents
*
* @package SupportBee\API\Agents
* @package Amalfra\SupportBee\API
*/
class Agents extends API {
class Agents extends HTTP {

public static function agents($options = array()) {
self::validate($options, array(
Expand Down
9 changes: 4 additions & 5 deletions src/SupportBee/API/Comments.php → src/API/Comments.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Comments
*
* @package SupportBee\API\Comments
* @package Amalfra\SupportBee\API
*/
class Comments extends API {
class Comments extends HTTP {

public static function comments($id = 0) {
return self::process_request('tickets/'.$id.'/comments');
Expand Down
9 changes: 4 additions & 5 deletions src/SupportBee/API/Emails.php → src/API/Emails.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Emails
*
* @package SupportBee\API\Emails
* @package Amalfra\SupportBee\API
*/
class Emails extends API {
class Emails extends HTTP {

public static function emails() {
return self::process_request('emails');
Expand Down
9 changes: 4 additions & 5 deletions src/SupportBee/API/Groups.php → src/API/Groups.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Groups
*
* @package SupportBee\API\Groups
* @package Amalfra\SupportBee\API
*/
class Groups extends API {
class Groups extends HTTP {

public static function groups($options = array()) {
self::validate($options, array(
Expand Down
17 changes: 17 additions & 0 deletions src/API/Labels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Amalfra\SupportBee\API;

use Amalfra\SupportBee\HTTP;

/**
* Class Labels
*
* @package Amalfra\SupportBee\API
*/
class Labels extends HTTP {

public static function labels() {
return self::process_request('labels');
}
}
9 changes: 4 additions & 5 deletions src/SupportBee/API/Replies.php → src/API/Replies.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Replies
*
* @package SupportBee\API\Replies
* @package Amalfra\SupportBee\API
*/
class Replies extends API {
class Replies extends HTTP {

public static function replies($id = 0) {
return self::process_request('tickets/'.$id.'/replies');
Expand Down
9 changes: 4 additions & 5 deletions src/SupportBee/API/Reports.php → src/API/Reports.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;

/**
* Class Reports
*
* @package SupportBee\API\Reports
* @package Amalfra\SupportBee\API
*/
class Reports extends API {
class Reports extends HTTP {

public static function avg_first_response_time_report($options = array()) {
self::validate($options, array(
Expand Down
17 changes: 17 additions & 0 deletions src/API/Snippets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Amalfra\SupportBee\API;

use Amalfra\SupportBee\HTTP;

/**
* Class Snippets
*
* @package Amalfra\SupportBee\API
*/
class Snippets extends HTTP {

public static function snippets() {
return self::process_request('snippets');
}
}
9 changes: 4 additions & 5 deletions src/SupportBee/API/Tickets.php → src/API/Tickets.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php

namespace SupportBee\API;
namespace Amalfra\SupportBee\API;

use SupportBee\SupportBee as SupportBee;
use SupportBee\API as API;
use Amalfra\SupportBee\HTTP;
use \InvalidArgumentException;

/**
* Class Tickets
*
* @package SupportBee\API\Tickets
* @package Amalfra\SupportBee\API;
*/
class Tickets extends API {
class Tickets extends HTTP {

public static function tickets($options = array()) {
self::validate($options, array(
Expand Down
17 changes: 17 additions & 0 deletions src/API/WebHooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Amalfra\SupportBee\API;

use Amalfra\SupportBee\HTTP;

/**
* Class WebHooks
*
* @package Amalfra\SupportBee\API
*/
class WebHooks extends HTTP {

public static function webhooks() {
return self::process_request('web_hooks');
}
}
33 changes: 16 additions & 17 deletions src/SupportBee/SupportBee.php → src/Client.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<?php

namespace SupportBee;

use SupportBee\Exceptions\ConfigException as ConfigException;
use SupportBee\API\Tickets as Tickets;
use SupportBee\API\Replies as Replies;
use SupportBee\API\Comments as Comments;
use SupportBee\API\Agents as Agents;
use SupportBee\API\Labels as Labels;
use SupportBee\API\Groups as Groups;
use SupportBee\API\Snippets as Snippets;
use SupportBee\API\WebHooks as WebHooks;
use SupportBee\API\Reports as Reports;
use SupportBee\API\Emails as Emails;
namespace Amalfra\SupportBee;

use Amalfra\SupportBee\Exceptions\ConfigException;
use Amalfra\SupportBee\API\Tickets;
use Amalfra\SupportBee\API\Replies;
use Amalfra\SupportBee\API\Comments;
use Amalfra\SupportBee\API\Agents;
use Amalfra\SupportBee\API\Labels;
use Amalfra\SupportBee\API\Groups;
use Amalfra\SupportBee\API\Snippets;
use Amalfra\SupportBee\API\WebHooks;
use Amalfra\SupportBee\API\Reports;
use Amalfra\SupportBee\API\Emails;

/**
* Class SupportBee
* Class Client
*
* @package SupportBee
* @package Amalfra\SupportBee
*/
class SupportBee {
const VERSION = '1.0.0';
class Client {
const BASE = 'https://COMPANY.supportbee.com/';

public static $base_url = null;
Expand Down
14 changes: 14 additions & 0 deletions src/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Amalfra\SupportBee\Exceptions;

use \Exception;

/**
* Class ConfigException
*
* @package Amalfra\SupportBee\Exceptions
*/
class ConfigException extends Exception {

}
14 changes: 14 additions & 0 deletions src/Exceptions/HTTPException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Amalfra\SupportBee\Exceptions;

use \Exception;

/**
* Class HTTPException
*
* @package Amalfra\SupportBee\Exceptions
*/
class HTTPException extends Exception {

}
18 changes: 9 additions & 9 deletions src/SupportBee/API.php → src/HTTP.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

namespace SupportBee;
namespace Amalfra\SupportBee;

use \InvalidArgumentException;
use \Requests;
use SupportBee\Exceptions\HTTPException as HTTPException;
use Exceptions\HTTPException as HTTPException;

/**
* Class API
* Class HTTP
*
* @package SupportBee\API
* @package Amalfra\SupportBee
*/
class API {
class HTTP {

protected static $http_error_msgs = array(
401 => 'There was an error authenticating with the token.',
Expand Down Expand Up @@ -43,17 +43,17 @@ protected static function tfTostring(&$value, &$key) {

protected static function inject(&$options) {
$options = array_merge($options, array(
'auth_token' => SupportBee::$auth_token
'auth_token' => Client::$auth_token
));
}

private static function request($path, $options, $method = 'GET') {
if (strtoupper($method) == 'GET')
return Requests::get(SupportBee::$base_url.$path.'?'.http_build_query($options), SupportBee::$headers, $options);
return Requests::get(Client::$base_url.$path.'?'.http_build_query($options), Client::$headers, $options);
else if (strtoupper($method) == 'POST')
return Requests::post(SupportBee::$base_url.$path, SupportBee::$headers, json_encode($options));
return Requests::post(Client::$base_url.$path, Client::$headers, json_encode($options));
else if (strtoupper($method) == 'DELETE')
return Requests::delete(SupportBee::$base_url.$path.'?'.http_build_query($options), SupportBee::$headers, $options);
return Requests::delete(Client::$base_url.$path.'?'.http_build_query($options), Client::$headers, $options);
else
throw new Exception('Unknown HTTP request method');
}
Expand Down
Loading

0 comments on commit 5da5ba7

Please sign in to comment.