Skip to content

Commit b673581

Browse files
authored
Merge pull request #32 from upwork/v1.4.0
V1.4.0
2 parents a36e863 + acc8f50 commit b673581

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+157
-217
lines changed

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
language: php
22

33
php:
4-
- "5.6"
4+
- "7.3"
5+
- "7.4"
56
- hhvm
67

78
before_script:
@@ -10,9 +11,10 @@ before_script:
1011
matrix:
1112
allow_failures:
1213
- php: hhvm
14+
- "5.6"
1315
fast_finish: true
1416

15-
script: ./vendor/phpunit/phpunit/phpunit.php --stderr
17+
script: ./vendor/phpunit/phpunit/phpunit --stderr
1618

1719
notifications:
1820
email:

CHANGES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release History
22

3+
## 1.4.0
4+
* Send Message to a Batch of Rooms API
5+
* Workdiary::get was replaced with Workdiary::getByCompany (breaking!)
6+
* Milestones::delete was replaced with Milestones::deleteMilestone (breaking!)
7+
* Migrate tests
8+
* Bug fixes
9+
* Stop supporting some Reports API according to announce from Thursday, 2018-06-28
10+
311
## 1.3.3
412
* Add Room Messages API
513

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "upwork/php-upwork",
33
"description": "PHP bindings for Upwork API",
4-
"version": "v1.3.3",
4+
"version": "v1.4.0",
55
"type": "library",
66
"keywords": ["upwork", "php", "api"],
77
"homepage": "http://www.upwork.com",
8-
"time": "2020-05-08",
8+
"time": "2020-09-09",
99
"license": "Apache-2.0",
1010
"authors": [
1111
{
@@ -32,7 +32,7 @@
3232
"ext-json": "*"
3333
},
3434
"require-dev": {
35-
"phpunit/phpunit": "3.7.*",
35+
"phpunit/phpunit": "^9",
3636
"phpunit/php-invoker": "*"
3737
},
3838
"autoload": {

src/Upwork/API/Routers/Hr/Milestones.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function approve($milestoneId, $params)
147147
* @param integer $milestoneId Milestone ID
148148
* @return object
149149
*/
150-
public function delete($milestoneId)
150+
public function deleteMilestone($milestoneId)
151151
{
152152
ApiDebug::p(__FUNCTION__);
153153

src/Upwork/API/Routers/Messages.php

+18
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ public function sendMessageToRoom($company, $roomId, $params = array())
190190
return $response;
191191
}
192192

193+
/**
194+
* Send a message to a batch of rooms
195+
*
196+
* @param string $company Company ID
197+
* @param array $params List of parameters
198+
* @access public
199+
* @return object
200+
*/
201+
public function sendMessageToRooms($company, $params = array())
202+
{
203+
ApiDebug::p(__FUNCTION__);
204+
205+
$response = $this->_client->post('/messages/v3/' . $company . '/stories/batch', $params);
206+
ApiDebug::p('received data', $response);
207+
208+
return $response;
209+
}
210+
193211
/**
194212
* Update a room settings
195213
*

src/Upwork/API/Routers/Reports/Finance/Accounts.php

-17
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@ public function __construct(ApiClient $client)
4242
parent::$_epoint = self::ENTRY_POINT;
4343
}
4444

45-
/**
46-
* Generate Financial Reports for an owned Account
47-
*
48-
* @param integer $freelancerReference Freelancer reference
49-
* @param array $params Parameters
50-
* @return object
51-
*/
52-
public function getOwned($freelancerReference, $params)
53-
{
54-
ApiDebug::p(__FUNCTION__);
55-
56-
$report = $this->_client->get('/finreports/v2/financial_account_owner/' . $freelancerReference, $params);
57-
ApiDebug::p('found report info', $report);
58-
59-
return $report;
60-
}
61-
6245
/**
6346
* Generate Financial Reports for a Specific Account
6447
*

src/Upwork/API/Routers/Reports/Finance/Billings.php

-34
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params)
5959
return $report;
6060
}
6161

62-
/**
63-
* Generate Billing Reports for a Specific Freelancer's Team
64-
*
65-
* @param integer $freelancerTeamReference Freelancer team reference
66-
* @param array $params Parameters
67-
* @return object
68-
*/
69-
public function getByFreelancersTeam($freelancerTeamReference, $params)
70-
{
71-
ApiDebug::p(__FUNCTION__);
72-
73-
$report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/billings', $params);
74-
ApiDebug::p('found report info', $report);
75-
76-
return $report;
77-
}
78-
79-
/**
80-
* Generate Billing Reports for a Specific Freelancer's Company
81-
*
82-
* @param integer $freelancerCompanyReference Freelancer company reference
83-
* @param array $params Parameters
84-
* @return object
85-
*/
86-
public function getByFreelancersCompany($freelancerCompanyReference, $params)
87-
{
88-
ApiDebug::p(__FUNCTION__);
89-
90-
$report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/billings', $params);
91-
ApiDebug::p('found report info', $report);
92-
93-
return $report;
94-
}
95-
9662
/**
9763
* Generate Billing Reports for a Specific Buyer's Team
9864
*

src/Upwork/API/Routers/Reports/Finance/Earnings.php

-34
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params)
5959
return $report;
6060
}
6161

62-
/**
63-
* Generate Earning Reports for a Specific Freelancer's Team
64-
*
65-
* @param integer $freelancerTeamReference Freelancer team reference
66-
* @param array $params Parameters
67-
* @return object
68-
*/
69-
public function getByFreelancersTeam($freelancerTeamReference, $params)
70-
{
71-
ApiDebug::p(__FUNCTION__);
72-
73-
$report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/earnings', $params);
74-
ApiDebug::p('found report info', $report);
75-
76-
return $report;
77-
}
78-
79-
/**
80-
* Generate Earning Reports for a Specific Freelancer's Company
81-
*
82-
* @param integer $freelancerCompanyReference Freelancer company reference
83-
* @param array $params Parameters
84-
* @return object
85-
*/
86-
public function getByFreelancersCompany($freelancerCompanyReference, $params)
87-
{
88-
ApiDebug::p(__FUNCTION__);
89-
90-
$report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/earnings', $params);
91-
ApiDebug::p('found report info', $report);
92-
93-
return $report;
94-
}
95-
9662
/**
9763
* Generate Earning Reports for a Specific Buyer's Team
9864
*

src/Upwork/API/Routers/Workdiary.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(ApiClient $client)
5050
* @param array $params (Optional) Parameters
5151
* @return object
5252
*/
53-
public function get($company, $date, $params = array())
53+
public function getByCompany($company, $date, $params = array())
5454
{
5555
ApiDebug::p(__FUNCTION__);
5656

tests/Upwork/API/ApiExceptionTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33

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

6+
use PHPUnit\Framework\TestCase;
67
use Upwork\API\ApiException as ApiException;
78

8-
class ApiExceptionTest extends \PHPUnit_Framework_TestCase
9+
class ApiExceptionTest extends TestCase
910
{
1011
/**
1112
* @expectedException Upwork\API\ApiException
1213
*/
1314
public function testException()
1415
{
16+
$this->expectException(\Upwork\API\ApiException::class);
1517
throw new ApiException('test');
1618
}
1719
}

tests/Upwork/API/AuthTypes/AbstractOAuthTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

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

6+
use PHPUnit\Framework\TestCase;
67
use Upwork\API\AuthTypes\AbstractOAuth as AbstractOAuth;
78

8-
class AbstractOAuthTest extends \PHPUnit_Framework_TestCase
9+
class AbstractOAuthTest extends TestCase
910
{
1011
/**
1112
* @test
@@ -104,6 +105,7 @@ public function testSetupAccessToken()
104105
*/
105106
public function testNoKeySpecified()
106107
{
108+
$this->expectException(\Upwork\API\ApiException::class);
107109
$stub = $this->getMockForAbstractClass(
108110
'Upwork\API\AuthTypes\AbstractOAuth',
109111
array(null, 'secret')
@@ -119,6 +121,7 @@ public function testNoKeySpecified()
119121
*/
120122
public function testNoSecretSpecified()
121123
{
124+
$this->expectException(\Upwork\API\ApiException::class);
122125
$stub = $this->getMockForAbstractClass(
123126
'Upwork\API\AuthTypes\AbstractOAuth',
124127
array('key', null)

tests/Upwork/API/ClientTest.php

+30-12
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

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

6+
use PHPUnit\Framework\TestCase;
67
use Upwork\API\Debug as ApiDebug;
78
use Upwork\API\Config as ApiConfig;
89
use Upwork\API\Client as Client;
910

10-
class ClientTest extends \PHPUnit_Framework_TestCase
11+
class ClientTest extends TestCase
1112
{
1213
/**
1314
* @test
@@ -37,14 +38,13 @@ public function testGetServer()
3738
'consumerSecret' => 'secret'
3839
)
3940
);
40-
$reflection = new \ReflectionClass('Upwork\API\Client');
41+
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
4142
$property = $reflection->getProperty('_server');
4243
$property->setAccessible(true);
4344
$helper = new Client($config);
4445
$property->setValue($helper, new \StdClass);
4546
$server = $helper->getServer();
4647

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

@@ -59,12 +59,14 @@ public function testGetRequestToken()
5959
'consumerSecret' => 'secret'
6060
)
6161
);
62-
$reflection = new \ReflectionClass('Upwork\API\Client');
62+
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
6363
$property = $reflection->getProperty('_server');
6464
$property->setAccessible(true);
6565
$helper = new Client($config);
6666

67-
$stub = $this->getMock('StdClass', array('setupRequestToken'));
67+
$stub = $this->getMockBuilder(stdClass::class)
68+
->setMethods(['setupRequestToken'])
69+
->getMock();
6870
$stub->expects($this->any())
6971
->method('setupRequestToken')
7072
->will($this->returnValue('testtoken'));
@@ -85,12 +87,14 @@ public function testAuth()
8587
'consumerSecret' => 'secret'
8688
)
8789
);
88-
$reflection = new \ReflectionClass('Upwork\API\Client');
90+
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
8991
$property = $reflection->getProperty('_server');
9092
$property->setAccessible(true);
9193
$helper = new Client($config);
9294

93-
$stub = $this->getMock('StdClass', array('option', 'auth'));
95+
$stub = $this->getMockBuilder(stdClass::class)
96+
->setMethods(['option', 'auth'])
97+
->getMock();
9498
$stub->expects($this->any())
9599
->method('option')
96100
->will($this->returnValue(true));
@@ -114,14 +118,16 @@ public function testRequest()
114118
'consumerSecret' => 'secret'
115119
)
116120
);
117-
$reflection = new \ReflectionClass('Upwork\API\Client');
121+
$reflection = new \ReflectionClass(\Upwork\API\Client::class);
118122
$property = $reflection->getProperty('_server');
119123
$property->setAccessible(true);
120124
$method = $reflection->getMethod('_request');
121125
$method->setAccessible(true);
122126
$helper = new Client($config);
123127

124-
$stub = $this->getMock('StdClass', array('option', 'request'));
128+
$stub = $this->getMockBuilder(stdClass::class)
129+
->setMethods(['option', 'request'])
130+
->getMock();
125131
$stub->expects($this->any())
126132
->method('option')
127133
->will($this->returnValue(true));
@@ -134,7 +140,7 @@ public function testRequest()
134140
$response = $method->invoke($helper, 'GET', 'http://www.upwork.com/api/auth/v1/info', array());
135141
$this->assertInstanceOf('StdClass', $response);
136142
$this->assertObjectHasAttribute('a', $response);
137-
$this->assertInternalType('string', $response->a);
143+
$this->assertIsString($response->a);
138144
$this->assertSame('b', $response->a);
139145
}
140146

@@ -150,9 +156,21 @@ public function testRunMethod()
150156
)
151157
);
152158

153-
$stub = $this->getMock('Upwork\API\Client', array('_request'), array($config));
159+
$stub = $this->getMockBuilder(\Upwork\API\Client::class)
160+
->enableArgumentCloning()
161+
->setConstructorArgs([$config])
162+
->getMock();
154163
$stub->expects($this->any())
155-
->method('_request')
164+
->method('get')
165+
->will($this->returnValue('response'));
166+
$stub->expects($this->any())
167+
->method('post')
168+
->will($this->returnValue('response'));
169+
$stub->expects($this->any())
170+
->method('put')
171+
->will($this->returnValue('response'));
172+
$stub->expects($this->any())
173+
->method('delete')
156174
->will($this->returnValue('response'));
157175

158176
foreach (array('get', 'post', 'put', 'delete') as $method) {

0 commit comments

Comments
 (0)