Skip to content

Commit

Permalink
Merge pull request #32 from upwork/v1.4.0
Browse files Browse the repository at this point in the history
V1.4.0
  • Loading branch information
mnovozhylov committed Sep 18, 2020
2 parents a36e863 + acc8f50 commit b673581
Show file tree
Hide file tree
Showing 48 changed files with 157 additions and 217 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: php

php:
- "5.6"
- "7.3"
- "7.4"
- hhvm

before_script:
Expand All @@ -10,9 +11,10 @@ before_script:
matrix:
allow_failures:
- php: hhvm
- "5.6"
fast_finish: true

script: ./vendor/phpunit/phpunit/phpunit.php --stderr
script: ./vendor/phpunit/phpunit/phpunit --stderr

notifications:
email:
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History

## 1.4.0
* Send Message to a Batch of Rooms API
* Workdiary::get was replaced with Workdiary::getByCompany (breaking!)
* Milestones::delete was replaced with Milestones::deleteMilestone (breaking!)
* Migrate tests
* Bug fixes
* Stop supporting some Reports API according to announce from Thursday, 2018-06-28

## 1.3.3
* Add Room Messages API

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "upwork/php-upwork",
"description": "PHP bindings for Upwork API",
"version": "v1.3.3",
"version": "v1.4.0",
"type": "library",
"keywords": ["upwork", "php", "api"],
"homepage": "http://www.upwork.com",
"time": "2020-05-08",
"time": "2020-09-09",
"license": "Apache-2.0",
"authors": [
{
Expand All @@ -32,7 +32,7 @@
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/phpunit": "^9",
"phpunit/php-invoker": "*"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Upwork/API/Routers/Hr/Milestones.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function approve($milestoneId, $params)
* @param integer $milestoneId Milestone ID
* @return object
*/
public function delete($milestoneId)
public function deleteMilestone($milestoneId)
{
ApiDebug::p(__FUNCTION__);

Expand Down
18 changes: 18 additions & 0 deletions src/Upwork/API/Routers/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@ public function sendMessageToRoom($company, $roomId, $params = array())
return $response;
}

/**
* Send a message to a batch of rooms
*
* @param string $company Company ID
* @param array $params List of parameters
* @access public
* @return object
*/
public function sendMessageToRooms($company, $params = array())
{
ApiDebug::p(__FUNCTION__);

$response = $this->_client->post('/messages/v3/' . $company . '/stories/batch', $params);
ApiDebug::p('received data', $response);

return $response;
}

/**
* Update a room settings
*
Expand Down
17 changes: 0 additions & 17 deletions src/Upwork/API/Routers/Reports/Finance/Accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@ public function __construct(ApiClient $client)
parent::$_epoint = self::ENTRY_POINT;
}

/**
* Generate Financial Reports for an owned Account
*
* @param integer $freelancerReference Freelancer reference
* @param array $params Parameters
* @return object
*/
public function getOwned($freelancerReference, $params)
{
ApiDebug::p(__FUNCTION__);

$report = $this->_client->get('/finreports/v2/financial_account_owner/' . $freelancerReference, $params);
ApiDebug::p('found report info', $report);

return $report;
}

/**
* Generate Financial Reports for a Specific Account
*
Expand Down
34 changes: 0 additions & 34 deletions src/Upwork/API/Routers/Reports/Finance/Billings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params)
return $report;
}

/**
* Generate Billing Reports for a Specific Freelancer's Team
*
* @param integer $freelancerTeamReference Freelancer team reference
* @param array $params Parameters
* @return object
*/
public function getByFreelancersTeam($freelancerTeamReference, $params)
{
ApiDebug::p(__FUNCTION__);

$report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/billings', $params);
ApiDebug::p('found report info', $report);

return $report;
}

/**
* Generate Billing Reports for a Specific Freelancer's Company
*
* @param integer $freelancerCompanyReference Freelancer company reference
* @param array $params Parameters
* @return object
*/
public function getByFreelancersCompany($freelancerCompanyReference, $params)
{
ApiDebug::p(__FUNCTION__);

$report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/billings', $params);
ApiDebug::p('found report info', $report);

return $report;
}

/**
* Generate Billing Reports for a Specific Buyer's Team
*
Expand Down
34 changes: 0 additions & 34 deletions src/Upwork/API/Routers/Reports/Finance/Earnings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params)
return $report;
}

/**
* Generate Earning Reports for a Specific Freelancer's Team
*
* @param integer $freelancerTeamReference Freelancer team reference
* @param array $params Parameters
* @return object
*/
public function getByFreelancersTeam($freelancerTeamReference, $params)
{
ApiDebug::p(__FUNCTION__);

$report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/earnings', $params);
ApiDebug::p('found report info', $report);

return $report;
}

/**
* Generate Earning Reports for a Specific Freelancer's Company
*
* @param integer $freelancerCompanyReference Freelancer company reference
* @param array $params Parameters
* @return object
*/
public function getByFreelancersCompany($freelancerCompanyReference, $params)
{
ApiDebug::p(__FUNCTION__);

$report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/earnings', $params);
ApiDebug::p('found report info', $report);

return $report;
}

/**
* Generate Earning Reports for a Specific Buyer's Team
*
Expand Down
2 changes: 1 addition & 1 deletion src/Upwork/API/Routers/Workdiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(ApiClient $client)
* @param array $params (Optional) Parameters
* @return object
*/
public function get($company, $date, $params = array())
public function getByCompany($company, $date, $params = array())
{
ApiDebug::p(__FUNCTION__);

Expand Down
4 changes: 3 additions & 1 deletion tests/Upwork/API/ApiExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

require __DIR__ . '/../../../vendor/autoload.php';

use PHPUnit\Framework\TestCase;
use Upwork\API\ApiException as ApiException;

class ApiExceptionTest extends \PHPUnit_Framework_TestCase
class ApiExceptionTest extends TestCase
{
/**
* @expectedException Upwork\API\ApiException
*/
public function testException()
{
$this->expectException(\Upwork\API\ApiException::class);
throw new ApiException('test');
}
}
5 changes: 4 additions & 1 deletion tests/Upwork/API/AuthTypes/AbstractOAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

require __DIR__ . '/../../../../vendor/autoload.php';

use PHPUnit\Framework\TestCase;
use Upwork\API\AuthTypes\AbstractOAuth as AbstractOAuth;

class AbstractOAuthTest extends \PHPUnit_Framework_TestCase
class AbstractOAuthTest extends TestCase
{
/**
* @test
Expand Down Expand Up @@ -104,6 +105,7 @@ public function testSetupAccessToken()
*/
public function testNoKeySpecified()
{
$this->expectException(\Upwork\API\ApiException::class);
$stub = $this->getMockForAbstractClass(
'Upwork\API\AuthTypes\AbstractOAuth',
array(null, 'secret')
Expand All @@ -119,6 +121,7 @@ public function testNoKeySpecified()
*/
public function testNoSecretSpecified()
{
$this->expectException(\Upwork\API\ApiException::class);
$stub = $this->getMockForAbstractClass(
'Upwork\API\AuthTypes\AbstractOAuth',
array('key', null)
Expand Down
42 changes: 30 additions & 12 deletions tests/Upwork/API/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

require __DIR__ . '/../../../vendor/autoload.php';

use PHPUnit\Framework\TestCase;
use Upwork\API\Debug as ApiDebug;
use Upwork\API\Config as ApiConfig;
use Upwork\API\Client as Client;

class ClientTest extends \PHPUnit_Framework_TestCase
class ClientTest extends TestCase
{
/**
* @test
Expand Down Expand Up @@ -37,14 +38,13 @@ public function testGetServer()
'consumerSecret' => 'secret'
)
);
$reflection = new \ReflectionClass('Upwork\API\Client');
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
$property = $reflection->getProperty('_server');
$property->setAccessible(true);
$helper = new Client($config);
$property->setValue($helper, new \StdClass);
$server = $helper->getServer();

$this->assertAttributeInstanceOf('StdClass', '_server', $helper);
$this->assertInstanceOf('StdClass', $server);
}

Expand All @@ -59,12 +59,14 @@ public function testGetRequestToken()
'consumerSecret' => 'secret'
)
);
$reflection = new \ReflectionClass('Upwork\API\Client');
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
$property = $reflection->getProperty('_server');
$property->setAccessible(true);
$helper = new Client($config);

$stub = $this->getMock('StdClass', array('setupRequestToken'));
$stub = $this->getMockBuilder(stdClass::class)
->setMethods(['setupRequestToken'])
->getMock();
$stub->expects($this->any())
->method('setupRequestToken')
->will($this->returnValue('testtoken'));
Expand All @@ -85,12 +87,14 @@ public function testAuth()
'consumerSecret' => 'secret'
)
);
$reflection = new \ReflectionClass('Upwork\API\Client');
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
$property = $reflection->getProperty('_server');
$property->setAccessible(true);
$helper = new Client($config);

$stub = $this->getMock('StdClass', array('option', 'auth'));
$stub = $this->getMockBuilder(stdClass::class)
->setMethods(['option', 'auth'])
->getMock();
$stub->expects($this->any())
->method('option')
->will($this->returnValue(true));
Expand All @@ -114,14 +118,16 @@ public function testRequest()
'consumerSecret' => 'secret'
)
);
$reflection = new \ReflectionClass('Upwork\API\Client');
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
$property = $reflection->getProperty('_server');
$property->setAccessible(true);
$method = $reflection->getMethod('_request');
$method->setAccessible(true);
$helper = new Client($config);

$stub = $this->getMock('StdClass', array('option', 'request'));
$stub = $this->getMockBuilder(stdClass::class)
->setMethods(['option', 'request'])
->getMock();
$stub->expects($this->any())
->method('option')
->will($this->returnValue(true));
Expand All @@ -134,7 +140,7 @@ public function testRequest()
$response = $method->invoke($helper, 'GET', 'http://www.upwork.com/api/auth/v1/info', array());
$this->assertInstanceOf('StdClass', $response);
$this->assertObjectHasAttribute('a', $response);
$this->assertInternalType('string', $response->a);
$this->assertIsString($response->a);
$this->assertSame('b', $response->a);
}

Expand All @@ -150,9 +156,21 @@ public function testRunMethod()
)
);

$stub = $this->getMock('Upwork\API\Client', array('_request'), array($config));
$stub = $this->getMockBuilder(\Upwork\API\Client::class)
->enableArgumentCloning()
->setConstructorArgs([$config])
->getMock();
$stub->expects($this->any())
->method('_request')
->method('get')
->will($this->returnValue('response'));
$stub->expects($this->any())
->method('post')
->will($this->returnValue('response'));
$stub->expects($this->any())
->method('put')
->will($this->returnValue('response'));
$stub->expects($this->any())
->method('delete')
->will($this->returnValue('response'));

foreach (array('get', 'post', 'put', 'delete') as $method) {
Expand Down
Loading

0 comments on commit b673581

Please sign in to comment.