@@ -14,205 +14,205 @@ |
||
| 14 | 14 | |
| 15 | 15 | final class PodWorkflowsTests extends \PHPUnit\Framework\TestCase |
| 16 | 16 | { |
| 17 | - public static ?string $created_guid = null; |
|
| 18 | - |
|
| 19 | - public static function setUpBeforeClass() : void |
|
| 20 | - { |
|
| 21 | - Route4Me::setApiKey(Constants::API_KEY); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function testOptionCanBeCreateEmpty() : void |
|
| 25 | - { |
|
| 26 | - $this->assertInstanceOf(Option::class, new Option()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function testOptionCanBeCreateFromArray() : void |
|
| 30 | - { |
|
| 31 | - $this->assertInstanceOf(Option::class, new Option([ |
|
| 32 | - 'name' => '1', |
|
| 33 | - 'value' => '2' |
|
| 34 | - ])); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function testActionCanBeCreateEmpty() : void |
|
| 38 | - { |
|
| 39 | - $this->assertInstanceOf(Action::class, new Action()); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function testActionCanBeCreateFromArray() : void |
|
| 43 | - { |
|
| 44 | - $this->assertInstanceOf(Action::class, new Action([ |
|
| 45 | - 'title' => 'ti', |
|
| 46 | - 'type' => 'ty', |
|
| 47 | - 'required' => false, |
|
| 48 | - 'options' => [ |
|
| 49 | - [ |
|
| 50 | - 'name' => '2', |
|
| 51 | - 'value' => '3' |
|
| 52 | - ], [ |
|
| 53 | - 'name' => '4', |
|
| 54 | - 'value' => '5' |
|
| 55 | - ] |
|
| 56 | - ] |
|
| 57 | - ])); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function testResponsePodWorkflowCanBeCreateEmpty() : void |
|
| 61 | - { |
|
| 62 | - $this->assertInstanceOf(ResponsePodWorkflow::class, new ResponsePodWorkflow()); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function testResponsePodWorkflowBeCreateFromArray() : void |
|
| 66 | - { |
|
| 67 | - $this->assertInstanceOf(ResponsePodWorkflow::class, new ResponsePodWorkflow([ |
|
| 68 | - 'workflow_guid' => '1', |
|
| 69 | - 'workflow_id' => '2', |
|
| 70 | - 'root_member_id' => 3, |
|
| 71 | - 'is_enabled' => false, |
|
| 72 | - 'is_default' => false, |
|
| 73 | - 'title' => '4', |
|
| 74 | - 'done_actions' => [ |
|
| 75 | - [ |
|
| 76 | - 'title' => 'da_ti1', |
|
| 77 | - 'type' => 'da_ty1', |
|
| 78 | - 'required' => false, |
|
| 79 | - 'options' => [ |
|
| 80 | - [ |
|
| 81 | - 'name' => 'da_21', |
|
| 82 | - 'value' => 'da_31' |
|
| 83 | - ], [ |
|
| 84 | - 'name' => 'da_41', |
|
| 85 | - 'value' => 'da_51' |
|
| 86 | - ] |
|
| 87 | - ] |
|
| 88 | - ], [ |
|
| 89 | - 'title' => 'da_ti2', |
|
| 90 | - 'type' => 'da_ty2', |
|
| 91 | - 'required' => false, |
|
| 92 | - 'options' => [ |
|
| 93 | - [ |
|
| 94 | - 'name' => 'da_22', |
|
| 95 | - 'value' => 'da_32' |
|
| 96 | - ], [ |
|
| 97 | - 'name' => 'da_42', |
|
| 98 | - 'value' => 'da_52' |
|
| 99 | - ] |
|
| 100 | - ] |
|
| 101 | - ] |
|
| 102 | - ], |
|
| 103 | - 'failed_actions' => [[ |
|
| 104 | - 'title' => 'fa_ti', |
|
| 105 | - 'type' => 'fa_ty', |
|
| 106 | - 'required' => false, |
|
| 107 | - 'options' => [ |
|
| 108 | - [ |
|
| 109 | - 'name' => 'fa_2', |
|
| 110 | - 'value' => 'fa_3' |
|
| 111 | - ], [ |
|
| 112 | - 'name' => 'fa_4', |
|
| 113 | - 'value' => 'fa_5' |
|
| 114 | - ] |
|
| 115 | - ] |
|
| 116 | - ]], |
|
| 117 | - ])); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function testPodWorkflowsCanBeCreateEmpty() : void |
|
| 121 | - { |
|
| 122 | - $this->assertInstanceOf(PodWorkflows::class, new PodWorkflows()); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - public function testCreateMustReturnResponsePodWorkflow() : void |
|
| 126 | - { |
|
| 127 | - $pod_workflows = new PodWorkflows(); |
|
| 128 | - $res_pod = $pod_workflows->createPodWorkflow([ |
|
| 129 | - 'workflow_id' => 'workflow_super_ID', |
|
| 130 | - 'is_enabled' => false, |
|
| 131 | - 'is_default' => false, |
|
| 132 | - 'title' => 'Super title from 15', |
|
| 133 | - 'done_actions' => [[ |
|
| 134 | - 'title' => 'Signee Name', |
|
| 135 | - 'type' => 'signeeName', |
|
| 136 | - 'required' => true |
|
| 137 | - ]], |
|
| 138 | - 'failed_actions' => [[ |
|
| 139 | - 'title' => 'Signee Name Failed', |
|
| 140 | - 'type' => 'signeeName', |
|
| 141 | - 'required' => false |
|
| 142 | - ]] |
|
| 143 | - ]); |
|
| 144 | - |
|
| 145 | - $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 146 | - $this->assertNotNull($res_pod->workflow_guid); |
|
| 147 | - $this->assertEquals($res_pod->title, 'Super title from 15'); |
|
| 17 | + public static ?string $created_guid = null; |
|
| 18 | + |
|
| 19 | + public static function setUpBeforeClass() : void |
|
| 20 | + { |
|
| 21 | + Route4Me::setApiKey(Constants::API_KEY); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function testOptionCanBeCreateEmpty() : void |
|
| 25 | + { |
|
| 26 | + $this->assertInstanceOf(Option::class, new Option()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function testOptionCanBeCreateFromArray() : void |
|
| 30 | + { |
|
| 31 | + $this->assertInstanceOf(Option::class, new Option([ |
|
| 32 | + 'name' => '1', |
|
| 33 | + 'value' => '2' |
|
| 34 | + ])); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function testActionCanBeCreateEmpty() : void |
|
| 38 | + { |
|
| 39 | + $this->assertInstanceOf(Action::class, new Action()); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function testActionCanBeCreateFromArray() : void |
|
| 43 | + { |
|
| 44 | + $this->assertInstanceOf(Action::class, new Action([ |
|
| 45 | + 'title' => 'ti', |
|
| 46 | + 'type' => 'ty', |
|
| 47 | + 'required' => false, |
|
| 48 | + 'options' => [ |
|
| 49 | + [ |
|
| 50 | + 'name' => '2', |
|
| 51 | + 'value' => '3' |
|
| 52 | + ], [ |
|
| 53 | + 'name' => '4', |
|
| 54 | + 'value' => '5' |
|
| 55 | + ] |
|
| 56 | + ] |
|
| 57 | + ])); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function testResponsePodWorkflowCanBeCreateEmpty() : void |
|
| 61 | + { |
|
| 62 | + $this->assertInstanceOf(ResponsePodWorkflow::class, new ResponsePodWorkflow()); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function testResponsePodWorkflowBeCreateFromArray() : void |
|
| 66 | + { |
|
| 67 | + $this->assertInstanceOf(ResponsePodWorkflow::class, new ResponsePodWorkflow([ |
|
| 68 | + 'workflow_guid' => '1', |
|
| 69 | + 'workflow_id' => '2', |
|
| 70 | + 'root_member_id' => 3, |
|
| 71 | + 'is_enabled' => false, |
|
| 72 | + 'is_default' => false, |
|
| 73 | + 'title' => '4', |
|
| 74 | + 'done_actions' => [ |
|
| 75 | + [ |
|
| 76 | + 'title' => 'da_ti1', |
|
| 77 | + 'type' => 'da_ty1', |
|
| 78 | + 'required' => false, |
|
| 79 | + 'options' => [ |
|
| 80 | + [ |
|
| 81 | + 'name' => 'da_21', |
|
| 82 | + 'value' => 'da_31' |
|
| 83 | + ], [ |
|
| 84 | + 'name' => 'da_41', |
|
| 85 | + 'value' => 'da_51' |
|
| 86 | + ] |
|
| 87 | + ] |
|
| 88 | + ], [ |
|
| 89 | + 'title' => 'da_ti2', |
|
| 90 | + 'type' => 'da_ty2', |
|
| 91 | + 'required' => false, |
|
| 92 | + 'options' => [ |
|
| 93 | + [ |
|
| 94 | + 'name' => 'da_22', |
|
| 95 | + 'value' => 'da_32' |
|
| 96 | + ], [ |
|
| 97 | + 'name' => 'da_42', |
|
| 98 | + 'value' => 'da_52' |
|
| 99 | + ] |
|
| 100 | + ] |
|
| 101 | + ] |
|
| 102 | + ], |
|
| 103 | + 'failed_actions' => [[ |
|
| 104 | + 'title' => 'fa_ti', |
|
| 105 | + 'type' => 'fa_ty', |
|
| 106 | + 'required' => false, |
|
| 107 | + 'options' => [ |
|
| 108 | + [ |
|
| 109 | + 'name' => 'fa_2', |
|
| 110 | + 'value' => 'fa_3' |
|
| 111 | + ], [ |
|
| 112 | + 'name' => 'fa_4', |
|
| 113 | + 'value' => 'fa_5' |
|
| 114 | + ] |
|
| 115 | + ] |
|
| 116 | + ]], |
|
| 117 | + ])); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public function testPodWorkflowsCanBeCreateEmpty() : void |
|
| 121 | + { |
|
| 122 | + $this->assertInstanceOf(PodWorkflows::class, new PodWorkflows()); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + public function testCreateMustReturnResponsePodWorkflow() : void |
|
| 126 | + { |
|
| 127 | + $pod_workflows = new PodWorkflows(); |
|
| 128 | + $res_pod = $pod_workflows->createPodWorkflow([ |
|
| 129 | + 'workflow_id' => 'workflow_super_ID', |
|
| 130 | + 'is_enabled' => false, |
|
| 131 | + 'is_default' => false, |
|
| 132 | + 'title' => 'Super title from 15', |
|
| 133 | + 'done_actions' => [[ |
|
| 134 | + 'title' => 'Signee Name', |
|
| 135 | + 'type' => 'signeeName', |
|
| 136 | + 'required' => true |
|
| 137 | + ]], |
|
| 138 | + 'failed_actions' => [[ |
|
| 139 | + 'title' => 'Signee Name Failed', |
|
| 140 | + 'type' => 'signeeName', |
|
| 141 | + 'required' => false |
|
| 142 | + ]] |
|
| 143 | + ]); |
|
| 144 | + |
|
| 145 | + $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 146 | + $this->assertNotNull($res_pod->workflow_guid); |
|
| 147 | + $this->assertEquals($res_pod->title, 'Super title from 15'); |
|
| 148 | 148 | |
| 149 | - self::$created_guid = $res_pod->workflow_guid; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - public function testGetAllPodWorkflowsMustReturnResponsePodWorkflows() : void |
|
| 153 | - { |
|
| 154 | - $pod_workflows = new PodWorkflows(); |
|
| 155 | - $result = $pod_workflows->getAllPodWorkflows([ |
|
| 156 | - 'search_query' => 'Super title from 15', |
|
| 157 | - 'order_by' => [['last_updated_timestamp', 'asc']], |
|
| 158 | - 'per_page' => 5 |
|
| 159 | - ]); |
|
| 160 | - |
|
| 161 | - $this->assertInstanceOf(ResponsePodWorkflows::class, $result); |
|
| 162 | - $this->assertNotNull($result->next_page_cursor); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - public function testGetPodWorkflowMustReturnResponsePodWorkflow() : void |
|
| 166 | - { |
|
| 167 | - $pod_workflows = new PodWorkflows(); |
|
| 168 | - $res_pod = $pod_workflows->getPodWorkflow(self::$created_guid); |
|
| 169 | - |
|
| 170 | - $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 171 | - $this->assertNotNull($res_pod->workflow_guid); |
|
| 172 | - $this->assertEquals($res_pod->workflow_guid, self::$created_guid); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - public function testupdatePodWorkflowMustReturnUpdatedResponsePodWorkflow() : void |
|
| 176 | - { |
|
| 177 | - $pod_workflows = new PodWorkflows(); |
|
| 178 | - $res_pod = $pod_workflows->updatePodWorkflow(self::$created_guid, [ |
|
| 179 | - 'workflow_id' => 'workflow_super_ID', |
|
| 180 | - 'is_enabled' => false, |
|
| 181 | - 'is_default' => false, |
|
| 182 | - 'title' => 'A new Super title from 15', |
|
| 183 | - 'done_actions' => [[ |
|
| 184 | - 'title' => 'Signee Name', |
|
| 185 | - 'type' => 'signeeName', |
|
| 186 | - 'required' => true |
|
| 187 | - ]], |
|
| 188 | - 'failed_actions' => [[ |
|
| 189 | - 'title' => 'Signee Name Failed', |
|
| 190 | - 'type' => 'signeeName', |
|
| 191 | - 'required' => false |
|
| 192 | - ]] |
|
| 193 | - ]); |
|
| 194 | - |
|
| 195 | - $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 196 | - $this->assertNotNull($res_pod->title); |
|
| 197 | - $this->assertEquals($res_pod->title, 'A new Super title from 15'); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - public function testDeleteMustReturnDeletedResponsePodWorkflow() : void |
|
| 201 | - { |
|
| 202 | - $pod_workflows = new PodWorkflows(); |
|
| 203 | - $result = $pod_workflows->deletePodWorkflow(self::$created_guid); |
|
| 204 | - |
|
| 205 | - $this->assertNotNull($result); |
|
| 206 | - self::$created_guid = null; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - public static function tearDownAfterClass() : void |
|
| 210 | - { |
|
| 211 | - sleep(5); |
|
| 212 | - |
|
| 213 | - if (self::$created_guid !== null) { |
|
| 214 | - $pod_workflows = new PodWorkflows(); |
|
| 215 | - $pod_workflows->deletePodWorkflow(self::$created_guid); |
|
| 216 | - } |
|
| 217 | - } |
|
| 149 | + self::$created_guid = $res_pod->workflow_guid; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + public function testGetAllPodWorkflowsMustReturnResponsePodWorkflows() : void |
|
| 153 | + { |
|
| 154 | + $pod_workflows = new PodWorkflows(); |
|
| 155 | + $result = $pod_workflows->getAllPodWorkflows([ |
|
| 156 | + 'search_query' => 'Super title from 15', |
|
| 157 | + 'order_by' => [['last_updated_timestamp', 'asc']], |
|
| 158 | + 'per_page' => 5 |
|
| 159 | + ]); |
|
| 160 | + |
|
| 161 | + $this->assertInstanceOf(ResponsePodWorkflows::class, $result); |
|
| 162 | + $this->assertNotNull($result->next_page_cursor); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + public function testGetPodWorkflowMustReturnResponsePodWorkflow() : void |
|
| 166 | + { |
|
| 167 | + $pod_workflows = new PodWorkflows(); |
|
| 168 | + $res_pod = $pod_workflows->getPodWorkflow(self::$created_guid); |
|
| 169 | + |
|
| 170 | + $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 171 | + $this->assertNotNull($res_pod->workflow_guid); |
|
| 172 | + $this->assertEquals($res_pod->workflow_guid, self::$created_guid); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + public function testupdatePodWorkflowMustReturnUpdatedResponsePodWorkflow() : void |
|
| 176 | + { |
|
| 177 | + $pod_workflows = new PodWorkflows(); |
|
| 178 | + $res_pod = $pod_workflows->updatePodWorkflow(self::$created_guid, [ |
|
| 179 | + 'workflow_id' => 'workflow_super_ID', |
|
| 180 | + 'is_enabled' => false, |
|
| 181 | + 'is_default' => false, |
|
| 182 | + 'title' => 'A new Super title from 15', |
|
| 183 | + 'done_actions' => [[ |
|
| 184 | + 'title' => 'Signee Name', |
|
| 185 | + 'type' => 'signeeName', |
|
| 186 | + 'required' => true |
|
| 187 | + ]], |
|
| 188 | + 'failed_actions' => [[ |
|
| 189 | + 'title' => 'Signee Name Failed', |
|
| 190 | + 'type' => 'signeeName', |
|
| 191 | + 'required' => false |
|
| 192 | + ]] |
|
| 193 | + ]); |
|
| 194 | + |
|
| 195 | + $this->assertInstanceOf(ResponsePodWorkflow::class, $res_pod); |
|
| 196 | + $this->assertNotNull($res_pod->title); |
|
| 197 | + $this->assertEquals($res_pod->title, 'A new Super title from 15'); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + public function testDeleteMustReturnDeletedResponsePodWorkflow() : void |
|
| 201 | + { |
|
| 202 | + $pod_workflows = new PodWorkflows(); |
|
| 203 | + $result = $pod_workflows->deletePodWorkflow(self::$created_guid); |
|
| 204 | + |
|
| 205 | + $this->assertNotNull($result); |
|
| 206 | + self::$created_guid = null; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + public static function tearDownAfterClass() : void |
|
| 210 | + { |
|
| 211 | + sleep(5); |
|
| 212 | + |
|
| 213 | + if (self::$created_guid !== null) { |
|
| 214 | + $pod_workflows = new PodWorkflows(); |
|
| 215 | + $pod_workflows->deletePodWorkflow(self::$created_guid); |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | } |
@@ -210,7 +210,7 @@ |
||
| 210 | 210 | { |
| 211 | 211 | sleep(5); |
| 212 | 212 | |
| 213 | - if (self::$created_guid !== null) { |
|
| 213 | + if (self::$created_guid!==null) { |
|
| 214 | 214 | $pod_workflows = new PodWorkflows(); |
| 215 | 215 | $pod_workflows->deletePodWorkflow(self::$created_guid); |
| 216 | 216 | } |
@@ -18,137 +18,137 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class PodWorkflows extends Common |
| 20 | 20 | { |
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - Route4Me::setBaseUrl(''); |
|
| 24 | - } |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + Route4Me::setBaseUrl(''); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Create a new PodWorkflow by sending the corresponding data. |
|
| 28 | - * |
|
| 29 | - * @since 1.2.10 |
|
| 30 | - * |
|
| 31 | - * @param array $params |
|
| 32 | - * string workflow_id - PodWorkflow ID, |
|
| 33 | - * int [root_member_id] - Member ID, |
|
| 34 | - * bool is_enabled - If true, the PodWorkflow is enabled, |
|
| 35 | - * bool is_default - If true, the PodWorkflow is default, |
|
| 36 | - * string title - The title of PodWorkflow, |
|
| 37 | - * Action[] [done_actions] - Array of done actions, |
|
| 38 | - * Action[] [failed_actions] - Array of failed actions, |
|
| 39 | - * @return ResponsePodWorkflow |
|
| 40 | - * @throws Exception\ApiError |
|
| 41 | - */ |
|
| 42 | - public function createPodWorkflow(array $params) : ResponsePodWorkflow |
|
| 43 | - { |
|
| 44 | - $allBodyFields = ['workflow_id', 'root_member_id', 'is_enabled', 'is_default', |
|
| 45 | - 'title', 'done_actions', 'failed_actions']; |
|
| 26 | + /** |
|
| 27 | + * Create a new PodWorkflow by sending the corresponding data. |
|
| 28 | + * |
|
| 29 | + * @since 1.2.10 |
|
| 30 | + * |
|
| 31 | + * @param array $params |
|
| 32 | + * string workflow_id - PodWorkflow ID, |
|
| 33 | + * int [root_member_id] - Member ID, |
|
| 34 | + * bool is_enabled - If true, the PodWorkflow is enabled, |
|
| 35 | + * bool is_default - If true, the PodWorkflow is default, |
|
| 36 | + * string title - The title of PodWorkflow, |
|
| 37 | + * Action[] [done_actions] - Array of done actions, |
|
| 38 | + * Action[] [failed_actions] - Array of failed actions, |
|
| 39 | + * @return ResponsePodWorkflow |
|
| 40 | + * @throws Exception\ApiError |
|
| 41 | + */ |
|
| 42 | + public function createPodWorkflow(array $params) : ResponsePodWorkflow |
|
| 43 | + { |
|
| 44 | + $allBodyFields = ['workflow_id', 'root_member_id', 'is_enabled', 'is_default', |
|
| 45 | + 'title', 'done_actions', 'failed_actions']; |
|
| 46 | 46 | |
| 47 | - return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 48 | - 'url' => Endpoint::POD_WORKFLOW, |
|
| 49 | - 'method' => 'POST', |
|
| 50 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
| 51 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 52 | - ])); |
|
| 53 | - } |
|
| 47 | + return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 48 | + 'url' => Endpoint::POD_WORKFLOW, |
|
| 49 | + 'method' => 'POST', |
|
| 50 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
| 51 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 52 | + ])); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get the list of all PodWorkflow filtered by specifying the corresponding query parameters. |
|
| 57 | - * |
|
| 58 | - * @since 1.2.10 |
|
| 59 | - * |
|
| 60 | - * @param array [$params] |
|
| 61 | - * int [per_page] - Number of PodWorkflows per page, |
|
| 62 | - * string [cursor] |
|
| 63 | - * string [search_query] - Search in the PodWorkflows by the corresponding query phrase. |
|
| 64 | - * array [order_by] - Array of pairs PodWorkflow field and its sorting direction, |
|
| 65 | - * e.g. [["title", "asc"], ["last_updated_timestamp", "desc"]] |
|
| 66 | - * @return ResponsePodWorkflows |
|
| 67 | - * @throws Exception\ApiError |
|
| 68 | - */ |
|
| 69 | - public function getAllPodWorkflows(?array $params = null) : ResponsePodWorkflows |
|
| 70 | - { |
|
| 71 | - $allBodyFields = ['per_page', 'cursor', 'search_query', 'order_by']; |
|
| 55 | + /** |
|
| 56 | + * Get the list of all PodWorkflow filtered by specifying the corresponding query parameters. |
|
| 57 | + * |
|
| 58 | + * @since 1.2.10 |
|
| 59 | + * |
|
| 60 | + * @param array [$params] |
|
| 61 | + * int [per_page] - Number of PodWorkflows per page, |
|
| 62 | + * string [cursor] |
|
| 63 | + * string [search_query] - Search in the PodWorkflows by the corresponding query phrase. |
|
| 64 | + * array [order_by] - Array of pairs PodWorkflow field and its sorting direction, |
|
| 65 | + * e.g. [["title", "asc"], ["last_updated_timestamp", "desc"]] |
|
| 66 | + * @return ResponsePodWorkflows |
|
| 67 | + * @throws Exception\ApiError |
|
| 68 | + */ |
|
| 69 | + public function getAllPodWorkflows(?array $params = null) : ResponsePodWorkflows |
|
| 70 | + { |
|
| 71 | + $allBodyFields = ['per_page', 'cursor', 'search_query', 'order_by']; |
|
| 72 | 72 | |
| 73 | - $result = Route4Me::makeRequst([ |
|
| 74 | - 'url' => Endpoint::POD_WORKFLOW, |
|
| 75 | - 'method' => 'GET', |
|
| 76 | - 'query' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 77 | - ]); |
|
| 73 | + $result = Route4Me::makeRequst([ |
|
| 74 | + 'url' => Endpoint::POD_WORKFLOW, |
|
| 75 | + 'method' => 'GET', |
|
| 76 | + 'query' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 77 | + ]); |
|
| 78 | 78 | |
| 79 | - if (is_array($result) && isset($result['data'])) { |
|
| 80 | - return new ResponsePodWorkflows($result); |
|
| 81 | - } |
|
| 82 | - throw new ApiError('Can not convert result to ResponsePodWorkflows object.'); |
|
| 83 | - } |
|
| 79 | + if (is_array($result) && isset($result['data'])) { |
|
| 80 | + return new ResponsePodWorkflows($result); |
|
| 81 | + } |
|
| 82 | + throw new ApiError('Can not convert result to ResponsePodWorkflows object.'); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Get the PodWorkflow by specifying the PodWorkflow GUID. |
|
| 87 | - * |
|
| 88 | - * @since 1.2.10 |
|
| 89 | - * |
|
| 90 | - * @param string $workflow_guid - PodWorkflow GUID. |
|
| 91 | - * @return ResponsePodWorkflow |
|
| 92 | - * @throws Exception\ApiError |
|
| 93 | - */ |
|
| 94 | - public function getPodWorkflow(string $workflow_guid) : ResponsePodWorkflow |
|
| 95 | - { |
|
| 96 | - return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 97 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 98 | - 'method' => 'GET' |
|
| 99 | - ])); |
|
| 100 | - } |
|
| 85 | + /** |
|
| 86 | + * Get the PodWorkflow by specifying the PodWorkflow GUID. |
|
| 87 | + * |
|
| 88 | + * @since 1.2.10 |
|
| 89 | + * |
|
| 90 | + * @param string $workflow_guid - PodWorkflow GUID. |
|
| 91 | + * @return ResponsePodWorkflow |
|
| 92 | + * @throws Exception\ApiError |
|
| 93 | + */ |
|
| 94 | + public function getPodWorkflow(string $workflow_guid) : ResponsePodWorkflow |
|
| 95 | + { |
|
| 96 | + return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 97 | + 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 98 | + 'method' => 'GET' |
|
| 99 | + ])); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Update the PodWorkflow by specifying the GUID and the corresponding PodWorkflow parameters. |
|
| 104 | - * |
|
| 105 | - * @since 1.2.10 |
|
| 106 | - * |
|
| 107 | - * @param string $workflow_guid - PodWorkflow GUID. |
|
| 108 | - * @param array $params - PodWorkflow properties, look for more |
|
| 109 | - * information in createPodWorkflow |
|
| 110 | - * @return ResponsePodWorkflow |
|
| 111 | - * @throws Exception\ApiError |
|
| 112 | - */ |
|
| 113 | - public function updatePodWorkflow(string $workflow_guid, array $params) : ResponsePodWorkflow |
|
| 114 | - { |
|
| 115 | - $allBodyFields = ['workflow_id', 'root_member_id', 'is_enabled', 'is_default', |
|
| 116 | - 'title', 'done_actions', 'failed_actions']; |
|
| 102 | + /** |
|
| 103 | + * Update the PodWorkflow by specifying the GUID and the corresponding PodWorkflow parameters. |
|
| 104 | + * |
|
| 105 | + * @since 1.2.10 |
|
| 106 | + * |
|
| 107 | + * @param string $workflow_guid - PodWorkflow GUID. |
|
| 108 | + * @param array $params - PodWorkflow properties, look for more |
|
| 109 | + * information in createPodWorkflow |
|
| 110 | + * @return ResponsePodWorkflow |
|
| 111 | + * @throws Exception\ApiError |
|
| 112 | + */ |
|
| 113 | + public function updatePodWorkflow(string $workflow_guid, array $params) : ResponsePodWorkflow |
|
| 114 | + { |
|
| 115 | + $allBodyFields = ['workflow_id', 'root_member_id', 'is_enabled', 'is_default', |
|
| 116 | + 'title', 'done_actions', 'failed_actions']; |
|
| 117 | 117 | |
| 118 | - return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 119 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 120 | - 'method' => 'PUT', |
|
| 121 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
| 122 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 123 | - ])); |
|
| 124 | - } |
|
| 118 | + return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
|
| 119 | + 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 120 | + 'method' => 'PUT', |
|
| 121 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
| 122 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 123 | + ])); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Delete the PodWorkflow by specifying the GUID. |
|
| 128 | - * |
|
| 129 | - * @since 1.2.10 |
|
| 130 | - * |
|
| 131 | - * @param string $workflow_guid - PodWorkflow GUID. |
|
| 132 | - * @return bool |
|
| 133 | - * @throws Exception\ApiError |
|
| 134 | - */ |
|
| 135 | - public function deletePodWorkflow(string $workflow_guid) : bool |
|
| 136 | - { |
|
| 137 | - $res = Route4Me::makeRequst([ |
|
| 138 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 139 | - 'method' => 'DELETE' |
|
| 140 | - ]); |
|
| 141 | - return isset($res); |
|
| 142 | - } |
|
| 126 | + /** |
|
| 127 | + * Delete the PodWorkflow by specifying the GUID. |
|
| 128 | + * |
|
| 129 | + * @since 1.2.10 |
|
| 130 | + * |
|
| 131 | + * @param string $workflow_guid - PodWorkflow GUID. |
|
| 132 | + * @return bool |
|
| 133 | + * @throws Exception\ApiError |
|
| 134 | + */ |
|
| 135 | + public function deletePodWorkflow(string $workflow_guid) : bool |
|
| 136 | + { |
|
| 137 | + $res = Route4Me::makeRequst([ |
|
| 138 | + 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 139 | + 'method' => 'DELETE' |
|
| 140 | + ]); |
|
| 141 | + return isset($res); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - private function toResponsePodWorkflow($result) : ResponsePodWorkflow |
|
| 145 | - { |
|
| 146 | - if (is_array($result) && isset($result['data'])) { |
|
| 147 | - $data = $result['data']; |
|
| 148 | - if (is_array($data)) { |
|
| 149 | - return new ResponsePodWorkflow($data); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - throw new ApiError('Can not convert result to ResponsePodWorkflow object.'); |
|
| 153 | - } |
|
| 144 | + private function toResponsePodWorkflow($result) : ResponsePodWorkflow |
|
| 145 | + { |
|
| 146 | + if (is_array($result) && isset($result['data'])) { |
|
| 147 | + $data = $result['data']; |
|
| 148 | + if (is_array($data)) { |
|
| 149 | + return new ResponsePodWorkflow($data); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + throw new ApiError('Can not convert result to ResponsePodWorkflow object.'); |
|
| 153 | + } |
|
| 154 | 154 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | public function getPodWorkflow(string $workflow_guid) : ResponsePodWorkflow |
| 95 | 95 | { |
| 96 | 96 | return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
| 97 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 97 | + 'url' => Endpoint::POD_WORKFLOW.'/'.$workflow_guid, |
|
| 98 | 98 | 'method' => 'GET' |
| 99 | 99 | ])); |
| 100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | 'title', 'done_actions', 'failed_actions']; |
| 117 | 117 | |
| 118 | 118 | return $this->toResponsePodWorkflow(Route4Me::makeRequst([ |
| 119 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 119 | + 'url' => Endpoint::POD_WORKFLOW.'/'.$workflow_guid, |
|
| 120 | 120 | 'method' => 'PUT', |
| 121 | 121 | 'HTTPHEADER' => 'Content-Type: application/json', |
| 122 | 122 | 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | public function deletePodWorkflow(string $workflow_guid) : bool |
| 136 | 136 | { |
| 137 | 137 | $res = Route4Me::makeRequst([ |
| 138 | - 'url' => Endpoint::POD_WORKFLOW . '/' . $workflow_guid, |
|
| 138 | + 'url' => Endpoint::POD_WORKFLOW.'/'.$workflow_guid, |
|
| 139 | 139 | 'method' => 'DELETE' |
| 140 | 140 | ]); |
| 141 | 141 | return isset($res); |
@@ -14,36 +14,36 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class ResponsePodWorkflows extends Common |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * An array of PodWorkflows |
|
| 19 | - */ |
|
| 20 | - public ?array $data = null; |
|
| 17 | + /** |
|
| 18 | + * An array of PodWorkflows |
|
| 19 | + */ |
|
| 20 | + public ?array $data = null; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Name of next page cursor |
|
| 24 | - */ |
|
| 25 | - public ?string $next_page_cursor = null; |
|
| 22 | + /** |
|
| 23 | + * Name of next page cursor |
|
| 24 | + */ |
|
| 25 | + public ?string $next_page_cursor = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Total items count |
|
| 29 | - */ |
|
| 30 | - public ?int $total_items_count = null; |
|
| 27 | + /** |
|
| 28 | + * Total items count |
|
| 29 | + */ |
|
| 30 | + public ?int $total_items_count = null; |
|
| 31 | 31 | |
| 32 | - public function __construct(?array $params = null) |
|
| 33 | - { |
|
| 34 | - if ($params !== null) { |
|
| 35 | - foreach ($this as $key => $value) { |
|
| 36 | - if (isset($params[$key])) { |
|
| 37 | - if ($key === 'data') { |
|
| 38 | - $this->{$key} = array(); |
|
| 39 | - foreach ($params[$key] as $pod_wf => $value) { |
|
| 40 | - array_push($this->{$key}, new ResponsePodWorkflow($value)); |
|
| 41 | - } |
|
| 42 | - } else { |
|
| 43 | - $this->{$key} = $params[$key]; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 32 | + public function __construct(?array $params = null) |
|
| 33 | + { |
|
| 34 | + if ($params !== null) { |
|
| 35 | + foreach ($this as $key => $value) { |
|
| 36 | + if (isset($params[$key])) { |
|
| 37 | + if ($key === 'data') { |
|
| 38 | + $this->{$key} = array(); |
|
| 39 | + foreach ($params[$key] as $pod_wf => $value) { |
|
| 40 | + array_push($this->{$key}, new ResponsePodWorkflow($value)); |
|
| 41 | + } |
|
| 42 | + } else { |
|
| 43 | + $this->{$key} = $params[$key]; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -31,10 +31,10 @@ |
||
| 31 | 31 | |
| 32 | 32 | public function __construct(?array $params = null) |
| 33 | 33 | { |
| 34 | - if ($params !== null) { |
|
| 34 | + if ($params!==null) { |
|
| 35 | 35 | foreach ($this as $key => $value) { |
| 36 | 36 | if (isset($params[$key])) { |
| 37 | - if ($key === 'data') { |
|
| 37 | + if ($key==='data') { |
|
| 38 | 38 | $this->{$key} = array(); |
| 39 | 39 | foreach ($params[$key] as $pod_wf => $value) { |
| 40 | 40 | array_push($this->{$key}, new ResponsePodWorkflow($value)); |
@@ -14,66 +14,66 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class ResponsePodWorkflow extends Common |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * PodWorkflow GUID |
|
| 19 | - */ |
|
| 20 | - public ?string $workflow_guid = null; |
|
| 17 | + /** |
|
| 18 | + * PodWorkflow GUID |
|
| 19 | + */ |
|
| 20 | + public ?string $workflow_guid = null; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * PodWorkflow ID |
|
| 24 | - */ |
|
| 25 | - public ?string $workflow_id = null; |
|
| 22 | + /** |
|
| 23 | + * PodWorkflow ID |
|
| 24 | + */ |
|
| 25 | + public ?string $workflow_id = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Member ID |
|
| 29 | - */ |
|
| 30 | - public ?int $root_member_id = null; |
|
| 27 | + /** |
|
| 28 | + * Member ID |
|
| 29 | + */ |
|
| 30 | + public ?int $root_member_id = null; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * If true, the PodWorkflow is enabled |
|
| 34 | - */ |
|
| 35 | - public ?bool $is_enabled = null; |
|
| 32 | + /** |
|
| 33 | + * If true, the PodWorkflow is enabled |
|
| 34 | + */ |
|
| 35 | + public ?bool $is_enabled = null; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * If true, the PodWorkflow is default |
|
| 39 | - */ |
|
| 40 | - public ?bool $is_default = null; |
|
| 37 | + /** |
|
| 38 | + * If true, the PodWorkflow is default |
|
| 39 | + */ |
|
| 40 | + public ?bool $is_default = null; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The title of PodWorkflow |
|
| 44 | - */ |
|
| 45 | - public ?string $title = null; |
|
| 42 | + /** |
|
| 43 | + * The title of PodWorkflow |
|
| 44 | + */ |
|
| 45 | + public ?string $title = null; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Done actions as array of Actions |
|
| 49 | - */ |
|
| 50 | - public ?array $done_actions = null; |
|
| 47 | + /** |
|
| 48 | + * Done actions as array of Actions |
|
| 49 | + */ |
|
| 50 | + public ?array $done_actions = null; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Failed actions as array of Actions |
|
| 54 | - */ |
|
| 55 | - public ?array $failed_actions = null; |
|
| 52 | + /** |
|
| 53 | + * Failed actions as array of Actions |
|
| 54 | + */ |
|
| 55 | + public ?array $failed_actions = null; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * The Timestamp of last update |
|
| 59 | - */ |
|
| 60 | - public ?int $last_updated_timestamp = null; |
|
| 57 | + /** |
|
| 58 | + * The Timestamp of last update |
|
| 59 | + */ |
|
| 60 | + public ?int $last_updated_timestamp = null; |
|
| 61 | 61 | |
| 62 | - public function __construct(?array $params = null) |
|
| 63 | - { |
|
| 64 | - if ($params !== null) { |
|
| 65 | - foreach ($this as $key => $value) { |
|
| 66 | - if (isset($params[$key])) { |
|
| 67 | - if ($key === 'done_actions' || $key === 'failed_actions') { |
|
| 68 | - $this->{$key} = array(); |
|
| 69 | - foreach ($params[$key] as $action => $value) { |
|
| 70 | - array_push($this->{$key}, new Action($value)); |
|
| 71 | - } |
|
| 72 | - } else { |
|
| 73 | - $this->{$key} = $params[$key]; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 62 | + public function __construct(?array $params = null) |
|
| 63 | + { |
|
| 64 | + if ($params !== null) { |
|
| 65 | + foreach ($this as $key => $value) { |
|
| 66 | + if (isset($params[$key])) { |
|
| 67 | + if ($key === 'done_actions' || $key === 'failed_actions') { |
|
| 68 | + $this->{$key} = array(); |
|
| 69 | + foreach ($params[$key] as $action => $value) { |
|
| 70 | + array_push($this->{$key}, new Action($value)); |
|
| 71 | + } |
|
| 72 | + } else { |
|
| 73 | + $this->{$key} = $params[$key]; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -61,10 +61,10 @@ |
||
| 61 | 61 | |
| 62 | 62 | public function __construct(?array $params = null) |
| 63 | 63 | { |
| 64 | - if ($params !== null) { |
|
| 64 | + if ($params!==null) { |
|
| 65 | 65 | foreach ($this as $key => $value) { |
| 66 | 66 | if (isset($params[$key])) { |
| 67 | - if ($key === 'done_actions' || $key === 'failed_actions') { |
|
| 67 | + if ($key==='done_actions' || $key==='failed_actions') { |
|
| 68 | 68 | $this->{$key} = array(); |
| 69 | 69 | foreach ($params[$key] as $action => $value) { |
| 70 | 70 | array_push($this->{$key}, new Action($value)); |
@@ -13,20 +13,20 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Option extends Common |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Title of action |
|
| 18 | - */ |
|
| 19 | - public ?string $name = null; |
|
| 16 | + /** |
|
| 17 | + * Title of action |
|
| 18 | + */ |
|
| 19 | + public ?string $name = null; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Type of action |
|
| 23 | - */ |
|
| 24 | - public ?string $value = null; |
|
| 21 | + /** |
|
| 22 | + * Type of action |
|
| 23 | + */ |
|
| 24 | + public ?string $value = null; |
|
| 25 | 25 | |
| 26 | - public function __construct(?array $params = null) |
|
| 27 | - { |
|
| 28 | - if ($params !== null) { |
|
| 29 | - $this->fillFromArray($params); |
|
| 30 | - } |
|
| 31 | - } |
|
| 26 | + public function __construct(?array $params = null) |
|
| 27 | + { |
|
| 28 | + if ($params !== null) { |
|
| 29 | + $this->fillFromArray($params); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | public function __construct(?array $params = null) |
| 37 | 37 | { |
| 38 | - if ($params !== null) { |
|
| 38 | + if ($params!==null) { |
|
| 39 | 39 | $this->fillFromArray($params); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -14,41 +14,41 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Action extends Common |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Title of action |
|
| 19 | - */ |
|
| 20 | - public ?string $title = null; |
|
| 17 | + /** |
|
| 18 | + * Title of action |
|
| 19 | + */ |
|
| 20 | + public ?string $title = null; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Type of action |
|
| 24 | - */ |
|
| 25 | - public ?string $type = null; |
|
| 22 | + /** |
|
| 23 | + * Type of action |
|
| 24 | + */ |
|
| 25 | + public ?string $type = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * If true, the action is required |
|
| 29 | - */ |
|
| 30 | - public ?bool $required = null; |
|
| 27 | + /** |
|
| 28 | + * If true, the action is required |
|
| 29 | + */ |
|
| 30 | + public ?bool $required = null; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Options of the action as array of Options |
|
| 34 | - */ |
|
| 35 | - public ?array $options = null; |
|
| 32 | + /** |
|
| 33 | + * Options of the action as array of Options |
|
| 34 | + */ |
|
| 35 | + public ?array $options = null; |
|
| 36 | 36 | |
| 37 | - public function __construct(?array $params = null) |
|
| 38 | - { |
|
| 39 | - if ($params !== null) { |
|
| 40 | - foreach ($this as $key => $value) { |
|
| 41 | - if (isset($params[$key])) { |
|
| 42 | - if ($key === 'options') { |
|
| 43 | - $this->{$key} = array(); |
|
| 44 | - foreach ($params[$key] as $option => $value) { |
|
| 45 | - array_push($this->{$key}, new Option($value)); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - $this->{$key} = $params[$key]; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - } |
|
| 37 | + public function __construct(?array $params = null) |
|
| 38 | + { |
|
| 39 | + if ($params !== null) { |
|
| 40 | + foreach ($this as $key => $value) { |
|
| 41 | + if (isset($params[$key])) { |
|
| 42 | + if ($key === 'options') { |
|
| 43 | + $this->{$key} = array(); |
|
| 44 | + foreach ($params[$key] as $option => $value) { |
|
| 45 | + array_push($this->{$key}, new Option($value)); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + $this->{$key} = $params[$key]; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -36,10 +36,10 @@ |
||
| 36 | 36 | |
| 37 | 37 | public function __construct(?array $params = null) |
| 38 | 38 | { |
| 39 | - if ($params !== null) { |
|
| 39 | + if ($params!==null) { |
|
| 40 | 40 | foreach ($this as $key => $value) { |
| 41 | 41 | if (isset($params[$key])) { |
| 42 | - if ($key === 'options') { |
|
| 42 | + if ($key==='options') { |
|
| 43 | 43 | $this->{$key} = array(); |
| 44 | 44 | foreach ($params[$key] as $option => $value) { |
| 45 | 45 | array_push($this->{$key}, new Option($value)); |
@@ -4,125 +4,125 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Endpoint |
| 6 | 6 | { |
| 7 | - const API_VERSION = "5"; |
|
| 7 | + const API_VERSION = "5"; |
|
| 8 | 8 | |
| 9 | - const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0"; |
|
| 9 | + const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0"; |
|
| 10 | 10 | |
| 11 | - const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0"; |
|
| 11 | + const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0"; |
|
| 12 | 12 | |
| 13 | - // <editor-fold defaultstate="collapsed" desc="region Routes"> |
|
| 13 | + // <editor-fold defaultstate="collapsed" desc="region Routes"> |
|
| 14 | 14 | |
| 15 | - const Routes = self::MAIN_HOST . "/routes"; |
|
| 16 | - const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate"; |
|
| 17 | - const RoutesMerge = self::MAIN_HOST . "/routes/merge"; |
|
| 18 | - const RoutesPaginate = self::MAIN_HOST . "/routes/paginate"; |
|
| 19 | - const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate"; |
|
| 20 | - const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable"; |
|
| 21 | - const RoutesFallback = self::MAIN_HOST . "/routes/fallback"; |
|
| 22 | - const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback"; |
|
| 23 | - const RoutesDatatable = self::MAIN_HOST . "/routes/datatable"; |
|
| 24 | - const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config"; |
|
| 25 | - const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config"; |
|
| 15 | + const Routes = self::MAIN_HOST . "/routes"; |
|
| 16 | + const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate"; |
|
| 17 | + const RoutesMerge = self::MAIN_HOST . "/routes/merge"; |
|
| 18 | + const RoutesPaginate = self::MAIN_HOST . "/routes/paginate"; |
|
| 19 | + const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate"; |
|
| 20 | + const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable"; |
|
| 21 | + const RoutesFallback = self::MAIN_HOST . "/routes/fallback"; |
|
| 22 | + const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback"; |
|
| 23 | + const RoutesDatatable = self::MAIN_HOST . "/routes/datatable"; |
|
| 24 | + const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config"; |
|
| 25 | + const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config"; |
|
| 26 | 26 | |
| 27 | - // </editor-fold> |
|
| 27 | + // </editor-fold> |
|
| 28 | 28 | |
| 29 | - // <editor-fold defaultstate="collapsed" desc="Team Users"> |
|
| 29 | + // <editor-fold defaultstate="collapsed" desc="Team Users"> |
|
| 30 | 30 | |
| 31 | - const TEAM_USERS = self::MAIN_HOST . "/team/users"; |
|
| 32 | - const TEAM_USERS_BULK_INSERT = self::MAIN_HOST . "/team/bulk-insert"; |
|
| 33 | - const DriverReview = self::MAIN_HOST . "/driver-reviews"; |
|
| 31 | + const TEAM_USERS = self::MAIN_HOST . "/team/users"; |
|
| 32 | + const TEAM_USERS_BULK_INSERT = self::MAIN_HOST . "/team/bulk-insert"; |
|
| 33 | + const DriverReview = self::MAIN_HOST . "/driver-reviews"; |
|
| 34 | 34 | |
| 35 | - // </editor-fold> |
|
| 35 | + // </editor-fold> |
|
| 36 | 36 | |
| 37 | - const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api"; |
|
| 38 | - |
|
| 39 | - // <editor-fold defaultstate="collapsed" desc="Vehicles"> |
|
| 40 | - |
|
| 41 | - const Vehicles = self::MAIN_HOST . "/vehicles"; |
|
| 42 | - const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign"; |
|
| 43 | - const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute"; |
|
| 44 | - const VehicleLocation = self::MAIN_HOST . "/vehicles/location"; |
|
| 45 | - const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles"; |
|
| 46 | - const VehicleLicense = self::MAIN_HOST . "/vehicles/license"; |
|
| 47 | - const VehicleSearch = self::MAIN_HOST . "/vehicles/search"; |
|
| 48 | - |
|
| 49 | - const RECURRING_ROUTES = self::MAIN_HOST . "/recurring-routes"; |
|
| 50 | - const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST . "/recurring-routes/schedules"; |
|
| 51 | - const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST . "/recurring-routes/schedules/pagination"; |
|
| 52 | - const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST . "/recurring-routes/route-schedules"; |
|
| 53 | - const RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION = |
|
| 54 | - self::MAIN_HOST . "/recurring-routes/route-schedules/pagination"; |
|
| 55 | - const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST . "/recurring-routes/route-schedules/replace"; |
|
| 56 | - const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST . "/recurring-routes/scheduled-routes/is-copy"; |
|
| 57 | - const RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES = |
|
| 58 | - self::MAIN_HOST . "/recurring-routes/scheduled-routes/get-copies"; |
|
| 59 | - const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST . "/recurring-routes/master-routes"; |
|
| 60 | - |
|
| 61 | - // </editor-fold> |
|
| 37 | + const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api"; |
|
| 38 | + |
|
| 39 | + // <editor-fold defaultstate="collapsed" desc="Vehicles"> |
|
| 40 | + |
|
| 41 | + const Vehicles = self::MAIN_HOST . "/vehicles"; |
|
| 42 | + const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign"; |
|
| 43 | + const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute"; |
|
| 44 | + const VehicleLocation = self::MAIN_HOST . "/vehicles/location"; |
|
| 45 | + const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles"; |
|
| 46 | + const VehicleLicense = self::MAIN_HOST . "/vehicles/license"; |
|
| 47 | + const VehicleSearch = self::MAIN_HOST . "/vehicles/search"; |
|
| 48 | + |
|
| 49 | + const RECURRING_ROUTES = self::MAIN_HOST . "/recurring-routes"; |
|
| 50 | + const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST . "/recurring-routes/schedules"; |
|
| 51 | + const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST . "/recurring-routes/schedules/pagination"; |
|
| 52 | + const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST . "/recurring-routes/route-schedules"; |
|
| 53 | + const RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION = |
|
| 54 | + self::MAIN_HOST . "/recurring-routes/route-schedules/pagination"; |
|
| 55 | + const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST . "/recurring-routes/route-schedules/replace"; |
|
| 56 | + const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST . "/recurring-routes/scheduled-routes/is-copy"; |
|
| 57 | + const RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES = |
|
| 58 | + self::MAIN_HOST . "/recurring-routes/scheduled-routes/get-copies"; |
|
| 59 | + const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST . "/recurring-routes/master-routes"; |
|
| 60 | + |
|
| 61 | + // </editor-fold> |
|
| 62 | 62 | |
| 63 | - // <editor-fold defaultstate="collapsed" desc="Telematicx Platform"> |
|
| 63 | + // <editor-fold defaultstate="collapsed" desc="Telematicx Platform"> |
|
| 64 | 64 | |
| 65 | - const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0"; |
|
| 65 | + const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0"; |
|
| 66 | 66 | |
| 67 | - const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections"; |
|
| 68 | - const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles"; |
|
| 67 | + const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections"; |
|
| 68 | + const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles"; |
|
| 69 | 69 | |
| 70 | - const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens"; |
|
| 71 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules"; |
|
| 72 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items"; |
|
| 70 | + const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens"; |
|
| 71 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules"; |
|
| 72 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items"; |
|
| 73 | 73 | |
| 74 | - const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups"; |
|
| 75 | - const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
| 76 | - const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}"; |
|
| 74 | + const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups"; |
|
| 75 | + const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
| 76 | + const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}"; |
|
| 77 | 77 | |
| 78 | - const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members"; |
|
| 79 | - const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles"; |
|
| 80 | - const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track"; |
|
| 81 | - const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members"; |
|
| 78 | + const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members"; |
|
| 79 | + const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles"; |
|
| 80 | + const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track"; |
|
| 81 | + const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members"; |
|
| 82 | 82 | |
| 83 | - const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses"; |
|
| 83 | + const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses"; |
|
| 84 | 84 | |
| 85 | - const TELEMATICS_Errors = self::STAGING_HOST . "/errors"; |
|
| 85 | + const TELEMATICS_Errors = self::STAGING_HOST . "/errors"; |
|
| 86 | 86 | |
| 87 | - const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "/customers/{customer_id}/notifications"; |
|
| 88 | - const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers"; |
|
| 89 | - const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}"; |
|
| 87 | + const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "/customers/{customer_id}/notifications"; |
|
| 88 | + const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers"; |
|
| 89 | + const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}"; |
|
| 90 | 90 | |
| 91 | - const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items"; |
|
| 92 | - const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules"; |
|
| 93 | - const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}"; |
|
| 94 | - const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "/one-time-notifications"; |
|
| 91 | + const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items"; |
|
| 92 | + const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules"; |
|
| 93 | + const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}"; |
|
| 94 | + const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "/one-time-notifications"; |
|
| 95 | 95 | |
| 96 | - const TELEMATICS_MEMBER = self::STAGING_HOST; |
|
| 96 | + const TELEMATICS_MEMBER = self::STAGING_HOST; |
|
| 97 | 97 | |
| 98 | - const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "/user-activated-modules"; |
|
| 98 | + const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "/user-activated-modules"; |
|
| 99 | 99 | |
| 100 | - const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}"; |
|
| 101 | - const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles"; |
|
| 102 | - const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
| 100 | + const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}"; |
|
| 101 | + const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles"; |
|
| 102 | + const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
| 103 | 103 | |
| 104 | - const TELEMATICS_VENDORS = self::STAGING_HOST . "/vendors"; |
|
| 105 | - const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "/vendors/{vendor_id}"; |
|
| 104 | + const TELEMATICS_VENDORS = self::STAGING_HOST . "/vendors"; |
|
| 105 | + const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "/vendors/{vendor_id}"; |
|
| 106 | 106 | |
| 107 | - // </editor-fold> |
|
| 108 | - |
|
| 109 | - const ADDRESSES = self::MAIN_HOST . "/address-book/addresses"; |
|
| 110 | - const ADDRESSES_BATCH_CREATE = self::MAIN_HOST . "/address-book/addresses/batch-create"; |
|
| 111 | - const ADDRESSES_INDEX_ALL = self::MAIN_HOST . "/address-book/addresses/index/all"; |
|
| 112 | - const ADDRESSES_INDEX_PAGINATION = self::MAIN_HOST . "/address-book/addresses/index/pagination"; |
|
| 113 | - const ADDRESSES_INDEX_CLUSTERING = self::MAIN_HOST . "/address-book/addresses/index/clustering"; |
|
| 114 | - const ADDRESSES_SHOW = self::MAIN_HOST . "/address-book/addresses/show"; |
|
| 115 | - const ADDRESSES_BATCH_UPDATE = self::MAIN_HOST . "/address-book/addresses/batch-update"; |
|
| 116 | - const ADDRESSES_UPDATE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/update-by-areas"; |
|
| 117 | - const ADDRESSES_DELETE = self::MAIN_HOST . "/address-book/addresses/delete"; |
|
| 118 | - const ADDRESSES_DELETE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/delete-by-areas"; |
|
| 119 | - const ADDRESSES_CUSTOM_FIELDS = self::MAIN_HOST . "/address-book/addresses/custom-fields"; |
|
| 120 | - const ADDRESSES_DEPOTS = self::MAIN_HOST . "/address-book/addresses/depots"; |
|
| 121 | - const ADDRESSES_EXPORT = self::MAIN_HOST . "/address-book/addresses/export"; |
|
| 122 | - const ADDRESSES_EXPORT_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/export-by-areas"; |
|
| 123 | - const ADDRESSES_EXPORT_BY_AREA_IDS = self::MAIN_HOST . "/address-book/addresses/export-by-area-ids"; |
|
| 124 | - const ADDRESSES_JOB_TRACKER_STATUS = self::MAIN_HOST . "/address-book/addresses/job-tracker/status"; |
|
| 125 | - const ADDRESSES_JOB_TRACKER_RESULT = self::MAIN_HOST . "/address-book/addresses/job-tracker/result"; |
|
| 126 | - |
|
| 127 | - const POD_WORKFLOW = self::MAIN_HOST . "/workflows"; |
|
| 107 | + // </editor-fold> |
|
| 108 | + |
|
| 109 | + const ADDRESSES = self::MAIN_HOST . "/address-book/addresses"; |
|
| 110 | + const ADDRESSES_BATCH_CREATE = self::MAIN_HOST . "/address-book/addresses/batch-create"; |
|
| 111 | + const ADDRESSES_INDEX_ALL = self::MAIN_HOST . "/address-book/addresses/index/all"; |
|
| 112 | + const ADDRESSES_INDEX_PAGINATION = self::MAIN_HOST . "/address-book/addresses/index/pagination"; |
|
| 113 | + const ADDRESSES_INDEX_CLUSTERING = self::MAIN_HOST . "/address-book/addresses/index/clustering"; |
|
| 114 | + const ADDRESSES_SHOW = self::MAIN_HOST . "/address-book/addresses/show"; |
|
| 115 | + const ADDRESSES_BATCH_UPDATE = self::MAIN_HOST . "/address-book/addresses/batch-update"; |
|
| 116 | + const ADDRESSES_UPDATE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/update-by-areas"; |
|
| 117 | + const ADDRESSES_DELETE = self::MAIN_HOST . "/address-book/addresses/delete"; |
|
| 118 | + const ADDRESSES_DELETE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/delete-by-areas"; |
|
| 119 | + const ADDRESSES_CUSTOM_FIELDS = self::MAIN_HOST . "/address-book/addresses/custom-fields"; |
|
| 120 | + const ADDRESSES_DEPOTS = self::MAIN_HOST . "/address-book/addresses/depots"; |
|
| 121 | + const ADDRESSES_EXPORT = self::MAIN_HOST . "/address-book/addresses/export"; |
|
| 122 | + const ADDRESSES_EXPORT_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/export-by-areas"; |
|
| 123 | + const ADDRESSES_EXPORT_BY_AREA_IDS = self::MAIN_HOST . "/address-book/addresses/export-by-area-ids"; |
|
| 124 | + const ADDRESSES_JOB_TRACKER_STATUS = self::MAIN_HOST . "/address-book/addresses/job-tracker/status"; |
|
| 125 | + const ADDRESSES_JOB_TRACKER_RESULT = self::MAIN_HOST . "/address-book/addresses/job-tracker/result"; |
|
| 126 | + |
|
| 127 | + const POD_WORKFLOW = self::MAIN_HOST . "/workflows"; |
|
| 128 | 128 | } |
@@ -12,51 +12,51 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // <editor-fold defaultstate="collapsed" desc="region Routes"> |
| 14 | 14 | |
| 15 | - const Routes = self::MAIN_HOST . "/routes"; |
|
| 16 | - const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate"; |
|
| 17 | - const RoutesMerge = self::MAIN_HOST . "/routes/merge"; |
|
| 18 | - const RoutesPaginate = self::MAIN_HOST . "/routes/paginate"; |
|
| 19 | - const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate"; |
|
| 20 | - const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable"; |
|
| 21 | - const RoutesFallback = self::MAIN_HOST . "/routes/fallback"; |
|
| 22 | - const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback"; |
|
| 23 | - const RoutesDatatable = self::MAIN_HOST . "/routes/datatable"; |
|
| 24 | - const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config"; |
|
| 25 | - const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config"; |
|
| 15 | + const Routes = self::MAIN_HOST."/routes"; |
|
| 16 | + const RoutesDuplicate = self::MAIN_HOST."/routes/duplicate"; |
|
| 17 | + const RoutesMerge = self::MAIN_HOST."/routes/merge"; |
|
| 18 | + const RoutesPaginate = self::MAIN_HOST."/routes/paginate"; |
|
| 19 | + const RoutesFallbackPaginate = self::MAIN_HOST."/routes/fallback/paginate"; |
|
| 20 | + const RoutesFallbackDatatable = self::MAIN_HOST."/routes/fallback/datatable"; |
|
| 21 | + const RoutesFallback = self::MAIN_HOST."/routes/fallback"; |
|
| 22 | + const RoutesReindexCallback = self::MAIN_HOST."/routes/reindex-callback"; |
|
| 23 | + const RoutesDatatable = self::MAIN_HOST."/routes/datatable"; |
|
| 24 | + const RoutesDatatableConfig = self::MAIN_HOST."/routes/datatable/config"; |
|
| 25 | + const RoutesDatatableConfigFallback = self::MAIN_HOST."/routes/fallback/datatable/config"; |
|
| 26 | 26 | |
| 27 | 27 | // </editor-fold> |
| 28 | 28 | |
| 29 | 29 | // <editor-fold defaultstate="collapsed" desc="Team Users"> |
| 30 | 30 | |
| 31 | - const TEAM_USERS = self::MAIN_HOST . "/team/users"; |
|
| 32 | - const TEAM_USERS_BULK_INSERT = self::MAIN_HOST . "/team/bulk-insert"; |
|
| 33 | - const DriverReview = self::MAIN_HOST . "/driver-reviews"; |
|
| 31 | + const TEAM_USERS = self::MAIN_HOST."/team/users"; |
|
| 32 | + const TEAM_USERS_BULK_INSERT = self::MAIN_HOST."/team/bulk-insert"; |
|
| 33 | + const DriverReview = self::MAIN_HOST."/driver-reviews"; |
|
| 34 | 34 | |
| 35 | 35 | // </editor-fold> |
| 36 | 36 | |
| 37 | - const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api"; |
|
| 37 | + const ACCOUNT_PROFILE = self::MAIN_HOST."/profile-api"; |
|
| 38 | 38 | |
| 39 | 39 | // <editor-fold defaultstate="collapsed" desc="Vehicles"> |
| 40 | 40 | |
| 41 | - const Vehicles = self::MAIN_HOST . "/vehicles"; |
|
| 42 | - const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign"; |
|
| 43 | - const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute"; |
|
| 44 | - const VehicleLocation = self::MAIN_HOST . "/vehicles/location"; |
|
| 45 | - const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles"; |
|
| 46 | - const VehicleLicense = self::MAIN_HOST . "/vehicles/license"; |
|
| 47 | - const VehicleSearch = self::MAIN_HOST . "/vehicles/search"; |
|
| 48 | - |
|
| 49 | - const RECURRING_ROUTES = self::MAIN_HOST . "/recurring-routes"; |
|
| 50 | - const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST . "/recurring-routes/schedules"; |
|
| 51 | - const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST . "/recurring-routes/schedules/pagination"; |
|
| 52 | - const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST . "/recurring-routes/route-schedules"; |
|
| 41 | + const Vehicles = self::MAIN_HOST."/vehicles"; |
|
| 42 | + const VehicleTemporary = self::MAIN_HOST."/vehicles/assign"; |
|
| 43 | + const VehicleExecuteOrder = self::MAIN_HOST."/vehicles/execute"; |
|
| 44 | + const VehicleLocation = self::MAIN_HOST."/vehicles/location"; |
|
| 45 | + const VehicleProfiles = self::MAIN_HOST."/vehicle-profiles"; |
|
| 46 | + const VehicleLicense = self::MAIN_HOST."/vehicles/license"; |
|
| 47 | + const VehicleSearch = self::MAIN_HOST."/vehicles/search"; |
|
| 48 | + |
|
| 49 | + const RECURRING_ROUTES = self::MAIN_HOST."/recurring-routes"; |
|
| 50 | + const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST."/recurring-routes/schedules"; |
|
| 51 | + const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST."/recurring-routes/schedules/pagination"; |
|
| 52 | + const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST."/recurring-routes/route-schedules"; |
|
| 53 | 53 | const RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION = |
| 54 | - self::MAIN_HOST . "/recurring-routes/route-schedules/pagination"; |
|
| 55 | - const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST . "/recurring-routes/route-schedules/replace"; |
|
| 56 | - const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST . "/recurring-routes/scheduled-routes/is-copy"; |
|
| 54 | + self::MAIN_HOST."/recurring-routes/route-schedules/pagination"; |
|
| 55 | + const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST."/recurring-routes/route-schedules/replace"; |
|
| 56 | + const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST."/recurring-routes/scheduled-routes/is-copy"; |
|
| 57 | 57 | const RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES = |
| 58 | - self::MAIN_HOST . "/recurring-routes/scheduled-routes/get-copies"; |
|
| 59 | - const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST . "/recurring-routes/master-routes"; |
|
| 58 | + self::MAIN_HOST."/recurring-routes/scheduled-routes/get-copies"; |
|
| 59 | + const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST."/recurring-routes/master-routes"; |
|
| 60 | 60 | |
| 61 | 61 | // </editor-fold> |
| 62 | 62 | |
@@ -65,64 +65,64 @@ discard block |
||
| 65 | 65 | const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0"; |
| 66 | 66 | |
| 67 | 67 | const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections"; |
| 68 | - const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles"; |
|
| 68 | + const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST."/connections/{connection_token}/vehicles"; |
|
| 69 | 69 | |
| 70 | - const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens"; |
|
| 71 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules"; |
|
| 72 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items"; |
|
| 70 | + const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST."/access-tokens"; |
|
| 71 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST."/access-token-schedules"; |
|
| 72 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST."/access-token-schedules/{schedule_id}/items"; |
|
| 73 | 73 | |
| 74 | - const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups"; |
|
| 75 | - const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
| 76 | - const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}"; |
|
| 74 | + const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST."/vehicle-groups"; |
|
| 75 | + const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST."/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
| 76 | + const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST."/vehicles/{vehicle_id}/{relation}"; |
|
| 77 | 77 | |
| 78 | - const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members"; |
|
| 79 | - const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles"; |
|
| 80 | - const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track"; |
|
| 81 | - const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members"; |
|
| 78 | + const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST."/info/members"; |
|
| 79 | + const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST."/info/vehicles"; |
|
| 80 | + const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST."/info/vehicle/{vehicle_id}/track"; |
|
| 81 | + const TELEMATICS_INFO_MODULES = self::STAGING_HOST."/info/members"; |
|
| 82 | 82 | |
| 83 | - const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses"; |
|
| 83 | + const TELEMATICS_ADDRESSES = self::STAGING_HOST."/addresses"; |
|
| 84 | 84 | |
| 85 | - const TELEMATICS_Errors = self::STAGING_HOST . "/errors"; |
|
| 85 | + const TELEMATICS_Errors = self::STAGING_HOST."/errors"; |
|
| 86 | 86 | |
| 87 | - const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "/customers/{customer_id}/notifications"; |
|
| 88 | - const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers"; |
|
| 89 | - const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}"; |
|
| 87 | + const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST."/customers/{customer_id}/notifications"; |
|
| 88 | + const TELEMATICS_CUSTOMERS = self::STAGING_HOST."/customers"; |
|
| 89 | + const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST."/customers/{customer_id}"; |
|
| 90 | 90 | |
| 91 | - const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items"; |
|
| 92 | - const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules"; |
|
| 93 | - const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}"; |
|
| 94 | - const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "/one-time-notifications"; |
|
| 91 | + const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST."/notification-schedules/{notification_schedule_id}/items"; |
|
| 92 | + const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST."/notification-schedules"; |
|
| 93 | + const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST."/notification-schedules/{schedule_id}"; |
|
| 94 | + const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST."/one-time-notifications"; |
|
| 95 | 95 | |
| 96 | 96 | const TELEMATICS_MEMBER = self::STAGING_HOST; |
| 97 | 97 | |
| 98 | - const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "/user-activated-modules"; |
|
| 98 | + const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST."/user-activated-modules"; |
|
| 99 | 99 | |
| 100 | - const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}"; |
|
| 101 | - const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles"; |
|
| 102 | - const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
| 100 | + const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST."/user-activated-modules/{module_id}"; |
|
| 101 | + const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST."/user-activated-modules/{module_id}/vehicles"; |
|
| 102 | + const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST."/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
| 103 | 103 | |
| 104 | - const TELEMATICS_VENDORS = self::STAGING_HOST . "/vendors"; |
|
| 105 | - const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "/vendors/{vendor_id}"; |
|
| 104 | + const TELEMATICS_VENDORS = self::STAGING_HOST."/vendors"; |
|
| 105 | + const TELEMATICS_VENDOR_ID = self::STAGING_HOST."/vendors/{vendor_id}"; |
|
| 106 | 106 | |
| 107 | 107 | // </editor-fold> |
| 108 | 108 | |
| 109 | - const ADDRESSES = self::MAIN_HOST . "/address-book/addresses"; |
|
| 110 | - const ADDRESSES_BATCH_CREATE = self::MAIN_HOST . "/address-book/addresses/batch-create"; |
|
| 111 | - const ADDRESSES_INDEX_ALL = self::MAIN_HOST . "/address-book/addresses/index/all"; |
|
| 112 | - const ADDRESSES_INDEX_PAGINATION = self::MAIN_HOST . "/address-book/addresses/index/pagination"; |
|
| 113 | - const ADDRESSES_INDEX_CLUSTERING = self::MAIN_HOST . "/address-book/addresses/index/clustering"; |
|
| 114 | - const ADDRESSES_SHOW = self::MAIN_HOST . "/address-book/addresses/show"; |
|
| 115 | - const ADDRESSES_BATCH_UPDATE = self::MAIN_HOST . "/address-book/addresses/batch-update"; |
|
| 116 | - const ADDRESSES_UPDATE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/update-by-areas"; |
|
| 117 | - const ADDRESSES_DELETE = self::MAIN_HOST . "/address-book/addresses/delete"; |
|
| 118 | - const ADDRESSES_DELETE_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/delete-by-areas"; |
|
| 119 | - const ADDRESSES_CUSTOM_FIELDS = self::MAIN_HOST . "/address-book/addresses/custom-fields"; |
|
| 120 | - const ADDRESSES_DEPOTS = self::MAIN_HOST . "/address-book/addresses/depots"; |
|
| 121 | - const ADDRESSES_EXPORT = self::MAIN_HOST . "/address-book/addresses/export"; |
|
| 122 | - const ADDRESSES_EXPORT_BY_AREAS = self::MAIN_HOST . "/address-book/addresses/export-by-areas"; |
|
| 123 | - const ADDRESSES_EXPORT_BY_AREA_IDS = self::MAIN_HOST . "/address-book/addresses/export-by-area-ids"; |
|
| 124 | - const ADDRESSES_JOB_TRACKER_STATUS = self::MAIN_HOST . "/address-book/addresses/job-tracker/status"; |
|
| 125 | - const ADDRESSES_JOB_TRACKER_RESULT = self::MAIN_HOST . "/address-book/addresses/job-tracker/result"; |
|
| 126 | - |
|
| 127 | - const POD_WORKFLOW = self::MAIN_HOST . "/workflows"; |
|
| 109 | + const ADDRESSES = self::MAIN_HOST."/address-book/addresses"; |
|
| 110 | + const ADDRESSES_BATCH_CREATE = self::MAIN_HOST."/address-book/addresses/batch-create"; |
|
| 111 | + const ADDRESSES_INDEX_ALL = self::MAIN_HOST."/address-book/addresses/index/all"; |
|
| 112 | + const ADDRESSES_INDEX_PAGINATION = self::MAIN_HOST."/address-book/addresses/index/pagination"; |
|
| 113 | + const ADDRESSES_INDEX_CLUSTERING = self::MAIN_HOST."/address-book/addresses/index/clustering"; |
|
| 114 | + const ADDRESSES_SHOW = self::MAIN_HOST."/address-book/addresses/show"; |
|
| 115 | + const ADDRESSES_BATCH_UPDATE = self::MAIN_HOST."/address-book/addresses/batch-update"; |
|
| 116 | + const ADDRESSES_UPDATE_BY_AREAS = self::MAIN_HOST."/address-book/addresses/update-by-areas"; |
|
| 117 | + const ADDRESSES_DELETE = self::MAIN_HOST."/address-book/addresses/delete"; |
|
| 118 | + const ADDRESSES_DELETE_BY_AREAS = self::MAIN_HOST."/address-book/addresses/delete-by-areas"; |
|
| 119 | + const ADDRESSES_CUSTOM_FIELDS = self::MAIN_HOST."/address-book/addresses/custom-fields"; |
|
| 120 | + const ADDRESSES_DEPOTS = self::MAIN_HOST."/address-book/addresses/depots"; |
|
| 121 | + const ADDRESSES_EXPORT = self::MAIN_HOST."/address-book/addresses/export"; |
|
| 122 | + const ADDRESSES_EXPORT_BY_AREAS = self::MAIN_HOST."/address-book/addresses/export-by-areas"; |
|
| 123 | + const ADDRESSES_EXPORT_BY_AREA_IDS = self::MAIN_HOST."/address-book/addresses/export-by-area-ids"; |
|
| 124 | + const ADDRESSES_JOB_TRACKER_STATUS = self::MAIN_HOST."/address-book/addresses/job-tracker/status"; |
|
| 125 | + const ADDRESSES_JOB_TRACKER_RESULT = self::MAIN_HOST."/address-book/addresses/job-tracker/result"; |
|
| 126 | + |
|
| 127 | + const POD_WORKFLOW = self::MAIN_HOST."/workflows"; |
|
| 128 | 128 | } |
@@ -7,374 +7,374 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Route4Me |
| 9 | 9 | { |
| 10 | - public static $apiKey; |
|
| 11 | - public static $baseUrl = Endpoint::BASE_URL; |
|
| 12 | - |
|
| 13 | - public static function setApiKey($apiKey) |
|
| 14 | - { |
|
| 15 | - self::$apiKey = $apiKey; |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public static function getApiKey() |
|
| 19 | - { |
|
| 20 | - return self::$apiKey; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public static function setBaseUrl($baseUrl) |
|
| 24 | - { |
|
| 25 | - self::$baseUrl = $baseUrl; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public static function getBaseUrl() |
|
| 29 | - { |
|
| 30 | - return self::$baseUrl; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Make request with CURL |
|
| 35 | - * |
|
| 36 | - * @since 1.2.3 changed error handling |
|
| 37 | - * @since 1.2.8 added $options['return_headers'] |
|
| 38 | - * |
|
| 39 | - * @param array $options |
|
| 40 | - * string url - HTTP URL. |
|
| 41 | - * string method - HTTP method. |
|
| 42 | - * string api_key - API key to access to route4me server. |
|
| 43 | - * array query - Array of query parameters. |
|
| 44 | - * array body - Array of body parameters. |
|
| 45 | - * string HTTPHEADER - Content type of body e.g. |
|
| 46 | - * 'Content-Type: application/json' |
|
| 47 | - * 'Content-Type: multipart/form-data' |
|
| 48 | - * array HTTPHEADERS - Array of headers. |
|
| 49 | - * string FILE - Path to uploading file. |
|
| 50 | - * array return_headers - Array of response headers to return as a result. |
|
| 51 | - * @throws Exception\ApiError |
|
| 52 | - */ |
|
| 53 | - public static function makeRequst($options) |
|
| 54 | - { |
|
| 55 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 56 | - $query = isset($options['query']) |
|
| 57 | - ? array_filter($options['query'], function ($x) { |
|
| 58 | - return !is_null($x); |
|
| 59 | - }) : []; |
|
| 60 | - |
|
| 61 | - $body = isset($options['body']) ? $options['body'] : null; |
|
| 62 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 63 | - $headers = [ |
|
| 64 | - 'User-Agent: Route4Me php-sdk', |
|
| 65 | - ]; |
|
| 66 | - |
|
| 67 | - $return_headers = (isset($options['return_headers']) ? $options['return_headers'] : null); |
|
| 68 | - |
|
| 69 | - if (isset($options['HTTPHEADER'])) { |
|
| 70 | - $headers[] = $options['HTTPHEADER']; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - if (isset($options['HTTPHEADERS'])) { |
|
| 74 | - foreach ($options['HTTPHEADERS'] as $header) { |
|
| 75 | - $headers[] = $header; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $ch = curl_init(); |
|
| 80 | - |
|
| 81 | - $url = isset($options['url']) |
|
| 82 | - ? $options['url'] . '?' . http_build_query(array_merge( |
|
| 83 | - $query, |
|
| 84 | - ['api_key' => self::getApiKey()] |
|
| 85 | - )) : ''; |
|
| 86 | - |
|
| 87 | - $baseUrl = self::getBaseUrl(); |
|
| 88 | - |
|
| 89 | - $curlOpts = [ |
|
| 90 | - CURLOPT_URL => $baseUrl.$url, |
|
| 91 | - CURLOPT_RETURNTRANSFER => true, |
|
| 92 | - CURLOPT_TIMEOUT => 120, |
|
| 93 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 94 | - CURLOPT_SSL_VERIFYHOST => false, |
|
| 95 | - CURLOPT_SSL_VERIFYPEER => false, |
|
| 96 | - CURLOPT_HTTPHEADER => $headers, |
|
| 97 | - ]; |
|
| 98 | - |
|
| 99 | - curl_setopt_array($ch, $curlOpts); |
|
| 100 | - |
|
| 101 | - // read response headers if need |
|
| 102 | - $response_headers = []; |
|
| 103 | - if ($return_headers) { |
|
| 104 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) { |
|
| 105 | - $len = strlen($header); |
|
| 106 | - $header = explode(':', $header, 2); |
|
| 107 | - if (count($header) >= 2) { |
|
| 108 | - $response_headers[strtolower(trim($header[0]))] = trim($header[1]); |
|
| 109 | - } |
|
| 110 | - return $len; |
|
| 111 | - }); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if (null != $file) { |
|
| 115 | - $cfile = new \CURLFile($file, '', ''); |
|
| 116 | - $body['strFilename']=$cfile; |
|
| 117 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 118 | - curl_setopt($ch, CURLOPT_POST, true); |
|
| 119 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
|
| 120 | - } else { |
|
| 121 | - switch ($method) { |
|
| 122 | - case 'DELETE': |
|
| 123 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 124 | - break; |
|
| 125 | - case 'DELETEARRAY': |
|
| 126 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 127 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 128 | - break; |
|
| 129 | - case 'PUT': |
|
| 130 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 131 | - break; |
|
| 132 | - case 'POST': |
|
| 133 | - if (isset($body)) { |
|
| 134 | - if (isset($options['HTTPHEADER']) |
|
| 135 | - && strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 136 | - $bodyData = $body; |
|
| 137 | - } else { |
|
| 138 | - $bodyData = json_encode($body); |
|
| 139 | - } |
|
| 140 | - curl_setopt($ch, CURLOPT_POST, 1); |
|
| 141 | - curl_setopt($ch, CURLOPT_POSTREDIR, 7); |
|
| 142 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 143 | - } |
|
| 144 | - break; |
|
| 145 | - case 'ADD': |
|
| 146 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 147 | - break; |
|
| 148 | - case 'PATCH': |
|
| 149 | - if (isset($body)) { |
|
| 150 | - $bodyData = json_encode($body); |
|
| 151 | - if (isset($options['HTTPHEADER'])) { |
|
| 152 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 153 | - $bodyData = $body; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 157 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 158 | - } |
|
| 159 | - break; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |
|
| 163 | - if (isset($body)) { |
|
| 164 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $result = curl_exec($ch); |
|
| 170 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 171 | - curl_close($ch); |
|
| 172 | - |
|
| 173 | - $json = null; |
|
| 174 | - if (strpos($result, '<?xml') > -1) { |
|
| 175 | - $xml = simplexml_load_string($result); |
|
| 176 | - $json = self::object2array($xml); |
|
| 177 | - } else { |
|
| 178 | - $json = json_decode($result, true); |
|
| 179 | - } |
|
| 180 | - if (200 == $code || 201 == $code || 202 == $code || 204 == $code) { |
|
| 181 | - if (isset($json['errors'])) { |
|
| 182 | - throw new ApiError(implode(', ', $json['errors']), $code, $result); |
|
| 183 | - } else { |
|
| 184 | - // return response headers if they were asked for |
|
| 185 | - if (count($response_headers) !== 0) { |
|
| 186 | - $res = [ |
|
| 187 | - 'code' => $code, |
|
| 188 | - 'data' => $json |
|
| 189 | - ]; |
|
| 190 | - foreach ($return_headers as $key => $value) { |
|
| 191 | - // most headers has char '-' but it is forbidden in PHP names replace it with '_' |
|
| 192 | - $res[strtolower(str_replace('-', '_', $value))] = |
|
| 193 | - (isset($response_headers[$value]) ? $response_headers[$value] : null); |
|
| 194 | - } |
|
| 195 | - return $res; |
|
| 196 | - } |
|
| 197 | - if (204 == $code) { |
|
| 198 | - return true; |
|
| 199 | - } |
|
| 200 | - return $json; |
|
| 201 | - } |
|
| 202 | - } elseif (isset($code) && (!isset($result) || !$result)) { |
|
| 203 | - throw new ApiError('', $code, $result); |
|
| 204 | - } else { |
|
| 205 | - if (isset($json['messages'])) { |
|
| 206 | - $msg = ''; |
|
| 207 | - foreach ($json['messages'] as $key => $value) { |
|
| 208 | - if ($msg !== '') { |
|
| 209 | - $msg .= PHP_EOL; |
|
| 210 | - } |
|
| 211 | - $msg .= $key . ': ' . (is_array($value) ? implode(', ', $value) : $value); |
|
| 212 | - } |
|
| 213 | - throw new ApiError($msg, $code, $result); |
|
| 214 | - } elseif (isset($json['error']) && !empty($json['error'])) { |
|
| 215 | - throw new ApiError($json['error'], $code, $result); |
|
| 216 | - } elseif (isset($json['error'])) { |
|
| 217 | - $msg = ''; |
|
| 218 | - foreach ($json['errors'] as $key => $value) { |
|
| 219 | - if ($msg !== '') { |
|
| 220 | - $msg .= PHP_EOL; |
|
| 221 | - } |
|
| 222 | - $msg .= $value; |
|
| 223 | - } |
|
| 224 | - throw new ApiError($msg, $code, $result); |
|
| 225 | - } else { |
|
| 226 | - throw new ApiError($result, $code, $result); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @param $object: JSON object |
|
| 233 | - */ |
|
| 234 | - public static function object2array($object) |
|
| 235 | - { |
|
| 236 | - return @json_decode(@json_encode($object), 1); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Prints on the screen main keys and values of the array. |
|
| 241 | - * |
|
| 242 | - * @param $results: object to be printed on the screen |
|
| 243 | - * @param $deepPrinting: if true, object will be printed recursively |
|
| 244 | - */ |
|
| 245 | - public static function simplePrint($results, $deepPrinting = null) |
|
| 246 | - { |
|
| 247 | - if (isset($results)) { |
|
| 248 | - if (is_array($results)) { |
|
| 249 | - foreach ($results as $key => $result) { |
|
| 250 | - if (is_array($result)) { |
|
| 251 | - foreach ($result as $key1 => $result1) { |
|
| 252 | - if (is_array($result1)) { |
|
| 253 | - if ($deepPrinting) { |
|
| 254 | - echo "<br>$key1 ------><br>"; |
|
| 255 | - self::simplePrint($result1, true); |
|
| 256 | - echo '------<br>'; |
|
| 257 | - } else { |
|
| 258 | - echo $key1.' --> '.'Array() <br>'; |
|
| 259 | - } |
|
| 260 | - } else { |
|
| 261 | - if (is_object($result1)) { |
|
| 262 | - if ($deepPrinting) { |
|
| 263 | - echo "<br>$key1 ------><br>"; |
|
| 264 | - $oarray = (array) $result1; |
|
| 265 | - self::simplePrint($oarray, true); |
|
| 266 | - echo '------<br>'; |
|
| 267 | - } else { |
|
| 268 | - echo $key1.' --> '.'Object <br>'; |
|
| 269 | - } |
|
| 270 | - } else { |
|
| 271 | - if (!is_null($result1)) { |
|
| 272 | - echo $key1.' --> '.$result1.'<br>'; |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - } else { |
|
| 278 | - if (is_object($result)) { |
|
| 279 | - if ($deepPrinting) { |
|
| 280 | - echo "<br>$key ------><br>"; |
|
| 281 | - $oarray = (array) $result; |
|
| 282 | - self::simplePrint($oarray, true); |
|
| 283 | - echo '------<br>'; |
|
| 284 | - } else { |
|
| 285 | - echo $key.' --> '.'Object <br>'; |
|
| 286 | - } |
|
| 287 | - } else { |
|
| 288 | - if (!is_null($result)) { |
|
| 289 | - echo $key.' --> '.$result.'<br>'; |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - //echo "<br>"; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Generates query or body parameters. |
|
| 301 | - * |
|
| 302 | - * @param $allFields: all known fields could be used for parameters generation |
|
| 303 | - * @param $params: input parameters (array or object) |
|
| 304 | - */ |
|
| 305 | - public static function generateRequestParameters($allFields, $params) |
|
| 306 | - { |
|
| 307 | - $generatedParams = []; |
|
| 308 | - |
|
| 309 | - if (is_array($params)) { |
|
| 310 | - foreach ($allFields as $field) { |
|
| 311 | - if (isset($params[$field])) { |
|
| 312 | - $generatedParams[$field] = $params[$field]; |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - } elseif (is_object($params)) { |
|
| 316 | - foreach ($allFields as $field) { |
|
| 317 | - if (isset($params->{$field})) { |
|
| 318 | - $generatedParams[$field] = $params->{$field}; |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - return $generatedParams; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Returns an array of the object properties. |
|
| 328 | - * |
|
| 329 | - * @param $object: An object |
|
| 330 | - * @param $exclude: array of the object parameters to be excluded from the returned array |
|
| 331 | - */ |
|
| 332 | - public static function getObjectProperties($object, $exclude) |
|
| 333 | - { |
|
| 334 | - $objectParameters = []; |
|
| 335 | - |
|
| 336 | - foreach (get_object_vars($object) as $key => $value) { |
|
| 337 | - if (property_exists($object, $key)) { |
|
| 338 | - if (!is_numeric(array_search($key, $exclude))) { |
|
| 339 | - array_push($objectParameters, $key); |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - return $objectParameters; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Returns url path generated from the array of the fields and parameters. |
|
| 349 | - * |
|
| 350 | - * @param $allFields; array of the paossible fields (parameter names) |
|
| 351 | - * @param $params: input parameters (array or object) |
|
| 352 | - */ |
|
| 353 | - public static function generateUrlPath($allFields, $params) |
|
| 354 | - { |
|
| 355 | - $generatedPath = ''; |
|
| 356 | - |
|
| 357 | - if (is_array($params)) { |
|
| 358 | - foreach ($allFields as $field) { |
|
| 359 | - if (isset($params[$field])) { |
|
| 360 | - $generatedPath .= $params[$field].'/'; |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - } elseif (is_object($params)) { |
|
| 364 | - foreach ($allFields as $field) { |
|
| 365 | - if (isset($params->{$field})) { |
|
| 366 | - $generatedPath .= $params->{$field}.'/'; |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - return $generatedPath; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - public static function getFileRealPath($fileName) |
|
| 375 | - { |
|
| 376 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName); |
|
| 377 | - |
|
| 378 | - return $rpath; |
|
| 379 | - } |
|
| 10 | + public static $apiKey; |
|
| 11 | + public static $baseUrl = Endpoint::BASE_URL; |
|
| 12 | + |
|
| 13 | + public static function setApiKey($apiKey) |
|
| 14 | + { |
|
| 15 | + self::$apiKey = $apiKey; |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public static function getApiKey() |
|
| 19 | + { |
|
| 20 | + return self::$apiKey; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public static function setBaseUrl($baseUrl) |
|
| 24 | + { |
|
| 25 | + self::$baseUrl = $baseUrl; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public static function getBaseUrl() |
|
| 29 | + { |
|
| 30 | + return self::$baseUrl; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Make request with CURL |
|
| 35 | + * |
|
| 36 | + * @since 1.2.3 changed error handling |
|
| 37 | + * @since 1.2.8 added $options['return_headers'] |
|
| 38 | + * |
|
| 39 | + * @param array $options |
|
| 40 | + * string url - HTTP URL. |
|
| 41 | + * string method - HTTP method. |
|
| 42 | + * string api_key - API key to access to route4me server. |
|
| 43 | + * array query - Array of query parameters. |
|
| 44 | + * array body - Array of body parameters. |
|
| 45 | + * string HTTPHEADER - Content type of body e.g. |
|
| 46 | + * 'Content-Type: application/json' |
|
| 47 | + * 'Content-Type: multipart/form-data' |
|
| 48 | + * array HTTPHEADERS - Array of headers. |
|
| 49 | + * string FILE - Path to uploading file. |
|
| 50 | + * array return_headers - Array of response headers to return as a result. |
|
| 51 | + * @throws Exception\ApiError |
|
| 52 | + */ |
|
| 53 | + public static function makeRequst($options) |
|
| 54 | + { |
|
| 55 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 56 | + $query = isset($options['query']) |
|
| 57 | + ? array_filter($options['query'], function ($x) { |
|
| 58 | + return !is_null($x); |
|
| 59 | + }) : []; |
|
| 60 | + |
|
| 61 | + $body = isset($options['body']) ? $options['body'] : null; |
|
| 62 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 63 | + $headers = [ |
|
| 64 | + 'User-Agent: Route4Me php-sdk', |
|
| 65 | + ]; |
|
| 66 | + |
|
| 67 | + $return_headers = (isset($options['return_headers']) ? $options['return_headers'] : null); |
|
| 68 | + |
|
| 69 | + if (isset($options['HTTPHEADER'])) { |
|
| 70 | + $headers[] = $options['HTTPHEADER']; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + if (isset($options['HTTPHEADERS'])) { |
|
| 74 | + foreach ($options['HTTPHEADERS'] as $header) { |
|
| 75 | + $headers[] = $header; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $ch = curl_init(); |
|
| 80 | + |
|
| 81 | + $url = isset($options['url']) |
|
| 82 | + ? $options['url'] . '?' . http_build_query(array_merge( |
|
| 83 | + $query, |
|
| 84 | + ['api_key' => self::getApiKey()] |
|
| 85 | + )) : ''; |
|
| 86 | + |
|
| 87 | + $baseUrl = self::getBaseUrl(); |
|
| 88 | + |
|
| 89 | + $curlOpts = [ |
|
| 90 | + CURLOPT_URL => $baseUrl.$url, |
|
| 91 | + CURLOPT_RETURNTRANSFER => true, |
|
| 92 | + CURLOPT_TIMEOUT => 120, |
|
| 93 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 94 | + CURLOPT_SSL_VERIFYHOST => false, |
|
| 95 | + CURLOPT_SSL_VERIFYPEER => false, |
|
| 96 | + CURLOPT_HTTPHEADER => $headers, |
|
| 97 | + ]; |
|
| 98 | + |
|
| 99 | + curl_setopt_array($ch, $curlOpts); |
|
| 100 | + |
|
| 101 | + // read response headers if need |
|
| 102 | + $response_headers = []; |
|
| 103 | + if ($return_headers) { |
|
| 104 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) { |
|
| 105 | + $len = strlen($header); |
|
| 106 | + $header = explode(':', $header, 2); |
|
| 107 | + if (count($header) >= 2) { |
|
| 108 | + $response_headers[strtolower(trim($header[0]))] = trim($header[1]); |
|
| 109 | + } |
|
| 110 | + return $len; |
|
| 111 | + }); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if (null != $file) { |
|
| 115 | + $cfile = new \CURLFile($file, '', ''); |
|
| 116 | + $body['strFilename']=$cfile; |
|
| 117 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 118 | + curl_setopt($ch, CURLOPT_POST, true); |
|
| 119 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
|
| 120 | + } else { |
|
| 121 | + switch ($method) { |
|
| 122 | + case 'DELETE': |
|
| 123 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 124 | + break; |
|
| 125 | + case 'DELETEARRAY': |
|
| 126 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 127 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 128 | + break; |
|
| 129 | + case 'PUT': |
|
| 130 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 131 | + break; |
|
| 132 | + case 'POST': |
|
| 133 | + if (isset($body)) { |
|
| 134 | + if (isset($options['HTTPHEADER']) |
|
| 135 | + && strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 136 | + $bodyData = $body; |
|
| 137 | + } else { |
|
| 138 | + $bodyData = json_encode($body); |
|
| 139 | + } |
|
| 140 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
| 141 | + curl_setopt($ch, CURLOPT_POSTREDIR, 7); |
|
| 142 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 143 | + } |
|
| 144 | + break; |
|
| 145 | + case 'ADD': |
|
| 146 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 147 | + break; |
|
| 148 | + case 'PATCH': |
|
| 149 | + if (isset($body)) { |
|
| 150 | + $bodyData = json_encode($body); |
|
| 151 | + if (isset($options['HTTPHEADER'])) { |
|
| 152 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 153 | + $bodyData = $body; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 157 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 158 | + } |
|
| 159 | + break; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |
|
| 163 | + if (isset($body)) { |
|
| 164 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $result = curl_exec($ch); |
|
| 170 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 171 | + curl_close($ch); |
|
| 172 | + |
|
| 173 | + $json = null; |
|
| 174 | + if (strpos($result, '<?xml') > -1) { |
|
| 175 | + $xml = simplexml_load_string($result); |
|
| 176 | + $json = self::object2array($xml); |
|
| 177 | + } else { |
|
| 178 | + $json = json_decode($result, true); |
|
| 179 | + } |
|
| 180 | + if (200 == $code || 201 == $code || 202 == $code || 204 == $code) { |
|
| 181 | + if (isset($json['errors'])) { |
|
| 182 | + throw new ApiError(implode(', ', $json['errors']), $code, $result); |
|
| 183 | + } else { |
|
| 184 | + // return response headers if they were asked for |
|
| 185 | + if (count($response_headers) !== 0) { |
|
| 186 | + $res = [ |
|
| 187 | + 'code' => $code, |
|
| 188 | + 'data' => $json |
|
| 189 | + ]; |
|
| 190 | + foreach ($return_headers as $key => $value) { |
|
| 191 | + // most headers has char '-' but it is forbidden in PHP names replace it with '_' |
|
| 192 | + $res[strtolower(str_replace('-', '_', $value))] = |
|
| 193 | + (isset($response_headers[$value]) ? $response_headers[$value] : null); |
|
| 194 | + } |
|
| 195 | + return $res; |
|
| 196 | + } |
|
| 197 | + if (204 == $code) { |
|
| 198 | + return true; |
|
| 199 | + } |
|
| 200 | + return $json; |
|
| 201 | + } |
|
| 202 | + } elseif (isset($code) && (!isset($result) || !$result)) { |
|
| 203 | + throw new ApiError('', $code, $result); |
|
| 204 | + } else { |
|
| 205 | + if (isset($json['messages'])) { |
|
| 206 | + $msg = ''; |
|
| 207 | + foreach ($json['messages'] as $key => $value) { |
|
| 208 | + if ($msg !== '') { |
|
| 209 | + $msg .= PHP_EOL; |
|
| 210 | + } |
|
| 211 | + $msg .= $key . ': ' . (is_array($value) ? implode(', ', $value) : $value); |
|
| 212 | + } |
|
| 213 | + throw new ApiError($msg, $code, $result); |
|
| 214 | + } elseif (isset($json['error']) && !empty($json['error'])) { |
|
| 215 | + throw new ApiError($json['error'], $code, $result); |
|
| 216 | + } elseif (isset($json['error'])) { |
|
| 217 | + $msg = ''; |
|
| 218 | + foreach ($json['errors'] as $key => $value) { |
|
| 219 | + if ($msg !== '') { |
|
| 220 | + $msg .= PHP_EOL; |
|
| 221 | + } |
|
| 222 | + $msg .= $value; |
|
| 223 | + } |
|
| 224 | + throw new ApiError($msg, $code, $result); |
|
| 225 | + } else { |
|
| 226 | + throw new ApiError($result, $code, $result); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @param $object: JSON object |
|
| 233 | + */ |
|
| 234 | + public static function object2array($object) |
|
| 235 | + { |
|
| 236 | + return @json_decode(@json_encode($object), 1); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Prints on the screen main keys and values of the array. |
|
| 241 | + * |
|
| 242 | + * @param $results: object to be printed on the screen |
|
| 243 | + * @param $deepPrinting: if true, object will be printed recursively |
|
| 244 | + */ |
|
| 245 | + public static function simplePrint($results, $deepPrinting = null) |
|
| 246 | + { |
|
| 247 | + if (isset($results)) { |
|
| 248 | + if (is_array($results)) { |
|
| 249 | + foreach ($results as $key => $result) { |
|
| 250 | + if (is_array($result)) { |
|
| 251 | + foreach ($result as $key1 => $result1) { |
|
| 252 | + if (is_array($result1)) { |
|
| 253 | + if ($deepPrinting) { |
|
| 254 | + echo "<br>$key1 ------><br>"; |
|
| 255 | + self::simplePrint($result1, true); |
|
| 256 | + echo '------<br>'; |
|
| 257 | + } else { |
|
| 258 | + echo $key1.' --> '.'Array() <br>'; |
|
| 259 | + } |
|
| 260 | + } else { |
|
| 261 | + if (is_object($result1)) { |
|
| 262 | + if ($deepPrinting) { |
|
| 263 | + echo "<br>$key1 ------><br>"; |
|
| 264 | + $oarray = (array) $result1; |
|
| 265 | + self::simplePrint($oarray, true); |
|
| 266 | + echo '------<br>'; |
|
| 267 | + } else { |
|
| 268 | + echo $key1.' --> '.'Object <br>'; |
|
| 269 | + } |
|
| 270 | + } else { |
|
| 271 | + if (!is_null($result1)) { |
|
| 272 | + echo $key1.' --> '.$result1.'<br>'; |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + if (is_object($result)) { |
|
| 279 | + if ($deepPrinting) { |
|
| 280 | + echo "<br>$key ------><br>"; |
|
| 281 | + $oarray = (array) $result; |
|
| 282 | + self::simplePrint($oarray, true); |
|
| 283 | + echo '------<br>'; |
|
| 284 | + } else { |
|
| 285 | + echo $key.' --> '.'Object <br>'; |
|
| 286 | + } |
|
| 287 | + } else { |
|
| 288 | + if (!is_null($result)) { |
|
| 289 | + echo $key.' --> '.$result.'<br>'; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + //echo "<br>"; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Generates query or body parameters. |
|
| 301 | + * |
|
| 302 | + * @param $allFields: all known fields could be used for parameters generation |
|
| 303 | + * @param $params: input parameters (array or object) |
|
| 304 | + */ |
|
| 305 | + public static function generateRequestParameters($allFields, $params) |
|
| 306 | + { |
|
| 307 | + $generatedParams = []; |
|
| 308 | + |
|
| 309 | + if (is_array($params)) { |
|
| 310 | + foreach ($allFields as $field) { |
|
| 311 | + if (isset($params[$field])) { |
|
| 312 | + $generatedParams[$field] = $params[$field]; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + } elseif (is_object($params)) { |
|
| 316 | + foreach ($allFields as $field) { |
|
| 317 | + if (isset($params->{$field})) { |
|
| 318 | + $generatedParams[$field] = $params->{$field}; |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + return $generatedParams; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Returns an array of the object properties. |
|
| 328 | + * |
|
| 329 | + * @param $object: An object |
|
| 330 | + * @param $exclude: array of the object parameters to be excluded from the returned array |
|
| 331 | + */ |
|
| 332 | + public static function getObjectProperties($object, $exclude) |
|
| 333 | + { |
|
| 334 | + $objectParameters = []; |
|
| 335 | + |
|
| 336 | + foreach (get_object_vars($object) as $key => $value) { |
|
| 337 | + if (property_exists($object, $key)) { |
|
| 338 | + if (!is_numeric(array_search($key, $exclude))) { |
|
| 339 | + array_push($objectParameters, $key); |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + return $objectParameters; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Returns url path generated from the array of the fields and parameters. |
|
| 349 | + * |
|
| 350 | + * @param $allFields; array of the paossible fields (parameter names) |
|
| 351 | + * @param $params: input parameters (array or object) |
|
| 352 | + */ |
|
| 353 | + public static function generateUrlPath($allFields, $params) |
|
| 354 | + { |
|
| 355 | + $generatedPath = ''; |
|
| 356 | + |
|
| 357 | + if (is_array($params)) { |
|
| 358 | + foreach ($allFields as $field) { |
|
| 359 | + if (isset($params[$field])) { |
|
| 360 | + $generatedPath .= $params[$field].'/'; |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + } elseif (is_object($params)) { |
|
| 364 | + foreach ($allFields as $field) { |
|
| 365 | + if (isset($params->{$field})) { |
|
| 366 | + $generatedPath .= $params->{$field}.'/'; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + return $generatedPath; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + public static function getFileRealPath($fileName) |
|
| 375 | + { |
|
| 376 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName); |
|
| 377 | + |
|
| 378 | + return $rpath; |
|
| 379 | + } |
|
| 380 | 380 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
| 56 | 56 | $query = isset($options['query']) |
| 57 | - ? array_filter($options['query'], function ($x) { |
|
| 57 | + ? array_filter($options['query'], function($x) { |
|
| 58 | 58 | return !is_null($x); |
| 59 | 59 | }) : []; |
| 60 | 60 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $ch = curl_init(); |
| 80 | 80 | |
| 81 | 81 | $url = isset($options['url']) |
| 82 | - ? $options['url'] . '?' . http_build_query(array_merge( |
|
| 82 | + ? $options['url'].'?'.http_build_query(array_merge( |
|
| 83 | 83 | $query, |
| 84 | 84 | ['api_key' => self::getApiKey()] |
| 85 | 85 | )) : ''; |
@@ -101,19 +101,19 @@ discard block |
||
| 101 | 101 | // read response headers if need |
| 102 | 102 | $response_headers = []; |
| 103 | 103 | if ($return_headers) { |
| 104 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) { |
|
| 104 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$response_headers) { |
|
| 105 | 105 | $len = strlen($header); |
| 106 | 106 | $header = explode(':', $header, 2); |
| 107 | - if (count($header) >= 2) { |
|
| 107 | + if (count($header)>=2) { |
|
| 108 | 108 | $response_headers[strtolower(trim($header[0]))] = trim($header[1]); |
| 109 | 109 | } |
| 110 | 110 | return $len; |
| 111 | 111 | }); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (null != $file) { |
|
| 114 | + if (null!=$file) { |
|
| 115 | 115 | $cfile = new \CURLFile($file, '', ''); |
| 116 | - $body['strFilename']=$cfile; |
|
| 116 | + $body['strFilename'] = $cfile; |
|
| 117 | 117 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 118 | 118 | curl_setopt($ch, CURLOPT_POST, true); |
| 119 | 119 | curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | case 'POST': |
| 133 | 133 | if (isset($body)) { |
| 134 | 134 | if (isset($options['HTTPHEADER']) |
| 135 | - && strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 135 | + && strpos($options['HTTPHEADER'], 'multipart/form-data')>0) { |
|
| 136 | 136 | $bodyData = $body; |
| 137 | 137 | } else { |
| 138 | 138 | $bodyData = json_encode($body); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | if (isset($body)) { |
| 150 | 150 | $bodyData = json_encode($body); |
| 151 | 151 | if (isset($options['HTTPHEADER'])) { |
| 152 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 152 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data')>0) { |
|
| 153 | 153 | $bodyData = $body; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | curl_close($ch); |
| 172 | 172 | |
| 173 | 173 | $json = null; |
| 174 | - if (strpos($result, '<?xml') > -1) { |
|
| 174 | + if (strpos($result, '<?xml')>-1) { |
|
| 175 | 175 | $xml = simplexml_load_string($result); |
| 176 | 176 | $json = self::object2array($xml); |
| 177 | 177 | } else { |
| 178 | 178 | $json = json_decode($result, true); |
| 179 | 179 | } |
| 180 | - if (200 == $code || 201 == $code || 202 == $code || 204 == $code) { |
|
| 180 | + if (200==$code || 201==$code || 202==$code || 204==$code) { |
|
| 181 | 181 | if (isset($json['errors'])) { |
| 182 | 182 | throw new ApiError(implode(', ', $json['errors']), $code, $result); |
| 183 | 183 | } else { |
| 184 | 184 | // return response headers if they were asked for |
| 185 | - if (count($response_headers) !== 0) { |
|
| 185 | + if (count($response_headers)!==0) { |
|
| 186 | 186 | $res = [ |
| 187 | 187 | 'code' => $code, |
| 188 | 188 | 'data' => $json |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | return $res; |
| 196 | 196 | } |
| 197 | - if (204 == $code) { |
|
| 197 | + if (204==$code) { |
|
| 198 | 198 | return true; |
| 199 | 199 | } |
| 200 | 200 | return $json; |
@@ -205,10 +205,10 @@ discard block |
||
| 205 | 205 | if (isset($json['messages'])) { |
| 206 | 206 | $msg = ''; |
| 207 | 207 | foreach ($json['messages'] as $key => $value) { |
| 208 | - if ($msg !== '') { |
|
| 208 | + if ($msg!=='') { |
|
| 209 | 209 | $msg .= PHP_EOL; |
| 210 | 210 | } |
| 211 | - $msg .= $key . ': ' . (is_array($value) ? implode(', ', $value) : $value); |
|
| 211 | + $msg .= $key.': '.(is_array($value) ? implode(', ', $value) : $value); |
|
| 212 | 212 | } |
| 213 | 213 | throw new ApiError($msg, $code, $result); |
| 214 | 214 | } elseif (isset($json['error']) && !empty($json['error'])) { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } elseif (isset($json['error'])) { |
| 217 | 217 | $msg = ''; |
| 218 | 218 | foreach ($json['errors'] as $key => $value) { |
| 219 | - if ($msg !== '') { |
|
| 219 | + if ($msg!=='') { |
|
| 220 | 220 | $msg .= PHP_EOL; |
| 221 | 221 | } |
| 222 | 222 | $msg .= $value; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | if (is_object($result1)) { |
| 262 | 262 | if ($deepPrinting) { |
| 263 | 263 | echo "<br>$key1 ------><br>"; |
| 264 | - $oarray = (array) $result1; |
|
| 264 | + $oarray = (array)$result1; |
|
| 265 | 265 | self::simplePrint($oarray, true); |
| 266 | 266 | echo '------<br>'; |
| 267 | 267 | } else { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | if (is_object($result)) { |
| 279 | 279 | if ($deepPrinting) { |
| 280 | 280 | echo "<br>$key ------><br>"; |
| 281 | - $oarray = (array) $result; |
|
| 281 | + $oarray = (array)$result; |
|
| 282 | 282 | self::simplePrint($oarray, true); |
| 283 | 283 | echo '------<br>'; |
| 284 | 284 | } else { |
@@ -20,58 +20,58 @@ |
||
| 20 | 20 | |
| 21 | 21 | // new PoD Workflow |
| 22 | 22 | $params = [ |
| 23 | - 'workflow_id' => 'workflow_super_ID', |
|
| 24 | - 'is_enabled' => false, |
|
| 25 | - 'is_default' => false, |
|
| 26 | - 'title' => 'Super title from 15', |
|
| 27 | - 'done_actions' => [[ |
|
| 28 | - 'title' => 'Signee Name', |
|
| 29 | - 'type' => 'signeeName', |
|
| 30 | - 'required' => true |
|
| 31 | - ]], |
|
| 32 | - 'failed_actions' => [[ |
|
| 33 | - 'title' => 'Signee Name Failed', |
|
| 34 | - 'type' => 'signeeName', |
|
| 35 | - 'required' => false |
|
| 36 | - ]] |
|
| 23 | + 'workflow_id' => 'workflow_super_ID', |
|
| 24 | + 'is_enabled' => false, |
|
| 25 | + 'is_default' => false, |
|
| 26 | + 'title' => 'Super title from 15', |
|
| 27 | + 'done_actions' => [[ |
|
| 28 | + 'title' => 'Signee Name', |
|
| 29 | + 'type' => 'signeeName', |
|
| 30 | + 'required' => true |
|
| 31 | + ]], |
|
| 32 | + 'failed_actions' => [[ |
|
| 33 | + 'title' => 'Signee Name Failed', |
|
| 34 | + 'type' => 'signeeName', |
|
| 35 | + 'required' => false |
|
| 36 | + ]] |
|
| 37 | 37 | ]; |
| 38 | 38 | |
| 39 | 39 | $pws = new PodWorkflows(); |
| 40 | 40 | |
| 41 | 41 | try { |
| 42 | - // create |
|
| 43 | - $new_pod = $pws->createPodWorkflow($params); |
|
| 42 | + // create |
|
| 43 | + $new_pod = $pws->createPodWorkflow($params); |
|
| 44 | 44 | |
| 45 | - if (isset($new_pod->workflow_guid)) { |
|
| 46 | - $created_pod_guid = $new_pod->workflow_guid; |
|
| 47 | - echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 45 | + if (isset($new_pod->workflow_guid)) { |
|
| 46 | + $created_pod_guid = $new_pod->workflow_guid; |
|
| 47 | + echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 48 | 48 | |
| 49 | - // read |
|
| 50 | - $read_pod = $pws->getPodWorkflow($created_pod_guid); |
|
| 51 | - echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL; |
|
| 49 | + // read |
|
| 50 | + $read_pod = $pws->getPodWorkflow($created_pod_guid); |
|
| 51 | + echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL; |
|
| 52 | 52 | |
| 53 | - // update |
|
| 54 | - $params['title'] = 'A new Super title from 15'; |
|
| 55 | - $updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params); |
|
| 56 | - echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid |
|
| 57 | - . ', new title is "'. $updated_pod->title . '"' . PHP_EOL; |
|
| 53 | + // update |
|
| 54 | + $params['title'] = 'A new Super title from 15'; |
|
| 55 | + $updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params); |
|
| 56 | + echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid |
|
| 57 | + . ', new title is "'. $updated_pod->title . '"' . PHP_EOL; |
|
| 58 | 58 | |
| 59 | - //delete |
|
| 60 | - $res = $pws->deletePodWorkflow($created_pod_guid); |
|
| 61 | - echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 62 | - } else { |
|
| 63 | - echo 'Error creating PodWorkflow.' . PHP_EOL; |
|
| 64 | - } |
|
| 59 | + //delete |
|
| 60 | + $res = $pws->deletePodWorkflow($created_pod_guid); |
|
| 61 | + echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 62 | + } else { |
|
| 63 | + echo 'Error creating PodWorkflow.' . PHP_EOL; |
|
| 64 | + } |
|
| 65 | 65 | } catch (Exception | ApiError $e) { |
| 66 | - echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL; |
|
| 66 | + echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL; |
|
| 67 | 67 | |
| 68 | - if ($created_pod_guid) { |
|
| 69 | - echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 70 | - try { |
|
| 71 | - $pws->deletePodWorkflow($created_pod_guid); |
|
| 72 | - } catch (Exception | ApiError $e) { |
|
| 73 | - echo 'Error: Cleanup.' . PHP_EOL; |
|
| 74 | - echo $e->getMessage() . PHP_EOL; |
|
| 75 | - } |
|
| 76 | - } |
|
| 68 | + if ($created_pod_guid) { |
|
| 69 | + echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 70 | + try { |
|
| 71 | + $pws->deletePodWorkflow($created_pod_guid); |
|
| 72 | + } catch (Exception | ApiError $e) { |
|
| 73 | + echo 'Error: Cleanup.' . PHP_EOL; |
|
| 74 | + echo $e->getMessage() . PHP_EOL; |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -44,34 +44,34 @@ |
||
| 44 | 44 | |
| 45 | 45 | if (isset($new_pod->workflow_guid)) { |
| 46 | 46 | $created_pod_guid = $new_pod->workflow_guid; |
| 47 | - echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 47 | + echo 'Created PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL; |
|
| 48 | 48 | |
| 49 | 49 | // read |
| 50 | 50 | $read_pod = $pws->getPodWorkflow($created_pod_guid); |
| 51 | - echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL; |
|
| 51 | + echo 'Read PodWorkflow with GUID: '.$read_pod->workflow_guid.PHP_EOL; |
|
| 52 | 52 | |
| 53 | 53 | // update |
| 54 | 54 | $params['title'] = 'A new Super title from 15'; |
| 55 | 55 | $updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params); |
| 56 | - echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid |
|
| 57 | - . ', new title is "'. $updated_pod->title . '"' . PHP_EOL; |
|
| 56 | + echo 'Updated PodWorkflow with GUID: '.$updated_pod->workflow_guid |
|
| 57 | + . ', new title is "'.$updated_pod->title.'"'.PHP_EOL; |
|
| 58 | 58 | |
| 59 | 59 | //delete |
| 60 | 60 | $res = $pws->deletePodWorkflow($created_pod_guid); |
| 61 | - echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 61 | + echo 'Deleted PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL; |
|
| 62 | 62 | } else { |
| 63 | - echo 'Error creating PodWorkflow.' . PHP_EOL; |
|
| 63 | + echo 'Error creating PodWorkflow.'.PHP_EOL; |
|
| 64 | 64 | } |
| 65 | 65 | } catch (Exception | ApiError $e) { |
| 66 | - echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL; |
|
| 66 | + echo 'Error, Code: '.$e->getCode().PHP_EOL.'Message: '.$e->getMessage().PHP_EOL; |
|
| 67 | 67 | |
| 68 | 68 | if ($created_pod_guid) { |
| 69 | - echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL; |
|
| 69 | + echo 'Cleanup PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL; |
|
| 70 | 70 | try { |
| 71 | 71 | $pws->deletePodWorkflow($created_pod_guid); |
| 72 | 72 | } catch (Exception | ApiError $e) { |
| 73 | - echo 'Error: Cleanup.' . PHP_EOL; |
|
| 74 | - echo $e->getMessage() . PHP_EOL; |
|
| 73 | + echo 'Error: Cleanup.'.PHP_EOL; |
|
| 74 | + echo $e->getMessage().PHP_EOL; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |