2 Commits
v1.0 ... v1.0.1

Author SHA1 Message Date
27bafb5d6d 增加加工工单创建接口 2023-09-07 15:30:08 +08:00
21e28aee92 增加SDK签名时间戳参数 2023-09-07 14:46:18 +08:00
3 changed files with 31 additions and 4 deletions

View File

@ -1 +1 @@
{"version":1,"defects":{"Feature\\OrderTest::testGetProductOrder":5},"times":{"Unit\\OrderTest::testGetWeatherWithInvalidType":0.041,"Feature\\OrderTest::testGetWeatherWithInvalidType":0.026,"Unit\\OrderTest::testGetWeatherWithInvalidFormat":0,"Feature\\OrderTest::testGetWeatherWithInvalidFormat":0,"Feature\\OrderTest::testGetWeatherWithGuzzleRuntimeException":0.074,"Feature\\OrderTest::testGetHttpClient":0.015,"Feature\\OrderTest::testSetGuzzleOptions":0.002,"Unit\\OrderTest::testGetWeatherWithGuzzleRuntimeException":0.101,"Unit\\OrderTest::testGetHttpClient":0.02,"Unit\\OrderTest::testSetGuzzleOptions":0.004,"Feature\\OrderTest::testGetProductOrder":0.202}}
{"version":1,"defects":{"Feature\\OrderTest::testGetProductOrder":5},"times":{"Unit\\OrderTest::testGetWeatherWithInvalidType":0.041,"Feature\\OrderTest::testGetWeatherWithInvalidType":0.107,"Unit\\OrderTest::testGetWeatherWithInvalidFormat":0,"Feature\\OrderTest::testGetWeatherWithInvalidFormat":0,"Feature\\OrderTest::testGetWeatherWithGuzzleRuntimeException":0.217,"Feature\\OrderTest::testGetHttpClient":0.043,"Feature\\OrderTest::testSetGuzzleOptions":0.01,"Unit\\OrderTest::testGetWeatherWithGuzzleRuntimeException":0.101,"Unit\\OrderTest::testGetHttpClient":0.02,"Unit\\OrderTest::testSetGuzzleOptions":0.004,"Feature\\OrderTest::testGetProductOrder":0.491,"Feature\\OrderTest::testCreateProductOrder":0.146}}

View File

@ -53,14 +53,15 @@ class Order
/**
* @param $params
* @param $api
* @return mixed|string
* @throws GuzzleException
* @throws HttpException
* @throws InvalidArgumentException
*/
public function baseFun($params)
public function baseFun($params, $api)
{
$url = $this->apiUrl . 'production.status';
$url = $this->apiUrl . $api;
if (!in_array(strtolower($this->format), ['xml', 'json'])) {
throw new InvalidArgumentException('Invalid response format: ' . $this->format);
@ -70,6 +71,8 @@ class Order
throw new InvalidArgumentException('Invalid type value(base/all): ' . $this->type);
}
// 附加参数
$params['times'] = time();
$params['output'] = $this->format;
$params['extensions'] = $this->type;
@ -109,6 +112,18 @@ class Order
$data = [
'order_sn' => $order_sn
];
return $this->baseFun($data);
return $this->baseFun($data, 'production.status');
}
/**
* 加工工单创建
* @return mixed|string
* @throws GuzzleException
* @throws HttpException
* @throws InvalidArgumentException
*/
public function createProductOrder($data)
{
return $this->baseFun($data, 'production.create');
}
}

View File

@ -87,4 +87,16 @@ class OrderTest extends TestCase
$w->getProductOrder('SN23454324565432');
$this->assertInstanceOf(ClientInterface::class, $w->getHttpClient());
}
public function testCreateProductOrder()
{
$w = new Order('mock-key');
$data = [
'cube_plan' => 32.12,
'owner' => 'ykxiao'
];
$w->createProductOrder($data);
$this->assertInstanceOf(ClientInterface::class, $w->getHttpClient());
}
}