1. Go to this page and download the library: Download yiiman/apistorm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$api = new TestApi();//This is a test API SDK class
$response=$api->createProduct(//This method will send data to server
[//Our data is an array!
'name'=>'Pen',//We dont know this parameter is e'=>3000
]
);
//$response is an array! and we dont know what is happening in every method without read documents
$api = new TestApi();//This is a test API SDK class
$data = new PostCreateProduct();//This is our input Class that extended from apiStorm classes
$data->name0 = 'Pen';//This is an at's mean this field is if ($response && $response->isSuccess()) {//Here we check status of sent request
echo $response->created_id;//If success we have classified response
}else{
var_export($response->getError());//If error, we have classified error
}
}
class TestApi
{
public $protocol = 'https';
public $baseURl = 'n8.yiiman.ir/webhook';
}
class TestApi
{
public $protocol = 'https';
public $baseURl = 'n8.yiiman.ir/webhook';
/**
* @param YiiMan\ApiStorm\Post\BasePostData $dataClass
* @return YiiMan\ApiStorm\Core\Res
*/
private function call($path, $dataClass, $method = 'post')
{
$servedArrayOfDataClass = $dataClass->serve();
$connection = new YiiMan\ApiStorm\Core\Connection();
$connection->baseURL = $this->baseURl;
$connection->protocol = 'https';
return $connection->call($path, [], $servedArrayOfDataClass, [],$method);
}
/**
* @param PostCreateProduct $product
* @return CreateProductResponse|bool
*/
public function createProduct(PostCreateProduct $product)
{
if ($product->validated()) {
// you will send $product to your server
$response = $this->call('6c81aa91-63a1-43d9-abb6-6b5398716f81', $product,'get');
if ($response->isSuccess()) {
$response = new CreateProductResponse($response);
}
return $response;
// </ Here, you will classify response >
} else {
return false;
}
}
/**
* @param PostCreateProduct $product
* @return CreateProductResponse|bool
*/
public function createProduct2(PostCreateProduct $product)
{
if ($product->validated()) {
// you will send $product to your server
$response = $this->call('6c81aa91-63a1-43d9-abb6-6b5398716f81', $product);
if ($response->isSuccess()) {
$response = new CreateProductResponse($response);
}
return $response;
// </ Here, you will classify response >
} else {
return false;
}
}
}
---src\
|
---Responses\
|
---ResponseClass1.php // extended from YiiMan\ApiStorm\Response\BaseResponse
|--- public $responseField1='int'; // you can define one of this data types : int|string|float|serialize|json|array|class|classArray
|--- public $responseField2=''; // if you set empty string, its main string type
|
---ResponseClass2.php // extended from YiiMan\ApiStorm\Response\BaseResponse
|--- public $responseField1='int'; // you can define one of this data types : int|string|float|serialize|json|array|class|classArray
|--- public $responseField2=''; // if you set empty string, its main string type
|
.
.
.
|
---Posts\
|
---PostClass1.php // extended from YiiMan\ApiStorm\Post\BasePostData
|--- public int $field0; // Required fields will ends by "0"
|--- public string $anotherField='test'; // Optional field
|--- public function rules(): array
{
return
[
'field' => 'int',//You should define input field type: int|string|array|float|object
'anotherField' => 'string',
];
}
|
---PostClass2.php // extended from YiiMan\ApiStorm\Post\BasePostData
|--- public array $field0; // Required fields will ends by "0"
|--- public int $anotherField=2; // Optional field
|--- public function rules(): array
{
return
[
'field' => 'float',//You should define input field type: int|string|array|float|object
'anotherField' => 'int',
];
}
|
|
.
.
.
|
--- SDKClass.php
|--- public $protocol = 'https';
|--- public $baseURl = 'someURL';
|--- firstMethod(PostClass1 $data):ResponseClass1{
if ($data->validated()) {
// you will send $data to your server
$response = $this->call('path/to/api/url', $data);
if ($response->isSuccess()) {
$response = new CreateProductResponse($response);
}
// < Here, you have classified response >
return $response;
// </ Here, you have classified response >
} else {
return false;
}
}
|
.
.
.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.