GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 0e4df4...84c959 )
by Igor
01:44 queued 12s
created
UnitTestFiles/Test/V5/TeamManagementUnitTests.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -12,184 +12,184 @@
 block discarded – undo
12 12
 
13 13
 final class TeamManagementUnitTests extends \PHPUnit\Framework\TestCase
14 14
 {
15
-    public static ?int $member_id = null;
16
-    public static ?int $owner_member_id = null;
17
-
18
-    public static function setUpBeforeClass() : void
19
-    {
20
-        Route4Me::setApiKey(Constants::API_KEY);
21
-    }
22
-
23
-    public function testOwnerMemberMustExists() : void
24
-    {
25
-        $member = new Member();
26
-        $res_members = $member->getUsers();
15
+	public static ?int $member_id = null;
16
+	public static ?int $owner_member_id = null;
17
+
18
+	public static function setUpBeforeClass() : void
19
+	{
20
+		Route4Me::setApiKey(Constants::API_KEY);
21
+	}
22
+
23
+	public function testOwnerMemberMustExists() : void
24
+	{
25
+		$member = new Member();
26
+		$res_members = $member->getUsers();
27 27
     
28
-        if (is_array($res_members) && isset($res_members['results'])) {
29
-            foreach ($res_members['results'] as $key => $value) {
30
-                if ($value['OWNER_MEMBER_ID'] == 0) {
31
-                    self::$owner_member_id = $value['member_id'];
32
-                    break;
33
-                }
34
-            }
35
-        }
36
-        $this->assertNotNull(self::$owner_member_id);
37
-    }
38
-
39
-    public function testOptionCanBeCreateEmpty() : void
40
-    {
41
-        $this->assertInstanceOf(Option::class, new Option());
42
-    }
43
-
44
-    public function testOptionCanBeCreateFromArray() : void
45
-    {
46
-        $this->assertInstanceOf(Option::class, new Option([
47
-            'value' => '1',
48
-            'title' => '2'
49
-        ]));
50
-    }
51
-
52
-    public function testPermissionCanBeCreateEmpty() : void
53
-    {
54
-        $this->assertInstanceOf(Permission::class, new Permission());
55
-    }
56
-
57
-    public function testPermissionCanBeCreateFromArray() : void
58
-    {
59
-        $this->assertInstanceOf(Permission::class, new Permission([
60
-            'id' => '1',
61
-            'options' => [
62
-                [
63
-                    'value' => '2',
64
-                    'title' => '3'
65
-                ], [
66
-                    'value' => '4',
67
-                    'title' => '5'
68
-                ]
69
-            ]
70
-        ]));
71
-    }
72
-
73
-    public function testResponseTeamCanBeCreateEmpty() : void
74
-    {
75
-        $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam());
76
-    }
77
-
78
-    public function testResponseTeamCanBeCreateFromArray() : void
79
-    {
80
-        $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([
81
-            'member_id' => '1',
82
-            'member_first_name' => '2'
83
-        ]));
84
-    }
85
-
86
-    public function testTeamManagementCanBeCreateEmpty() : void
87
-    {
88
-        $this->assertInstanceOf(TeamManagement::class, new TeamManagement());
89
-    }
90
-
91
-    public function testCreateMustReturnResponseTeam() : void
92
-    {
93
-        $team_mng = new TeamManagement();
94
-        $res_team = $team_mng->create([
95
-            'new_password' => '12345&Qwerty',
96
-            'member_first_name' => 'Tusha I',
97
-            'member_last_name' => 'Pupkindzes',
98
-            'member_email' => '[email protected]',
99
-            'member_type' => 'SUB_ACCOUNT_DRIVER',
100
-            'OWNER_MEMBER_ID' => self::$owner_member_id
101
-        ]);
102
-
103
-        $this->assertInstanceOf(ResponseTeam::class, $res_team);
104
-        $this->assertNotNull($res_team->member_id);
105
-        $this->assertEquals($res_team->member_first_name, 'Tusha I');
28
+		if (is_array($res_members) && isset($res_members['results'])) {
29
+			foreach ($res_members['results'] as $key => $value) {
30
+				if ($value['OWNER_MEMBER_ID'] == 0) {
31
+					self::$owner_member_id = $value['member_id'];
32
+					break;
33
+				}
34
+			}
35
+		}
36
+		$this->assertNotNull(self::$owner_member_id);
37
+	}
38
+
39
+	public function testOptionCanBeCreateEmpty() : void
40
+	{
41
+		$this->assertInstanceOf(Option::class, new Option());
42
+	}
43
+
44
+	public function testOptionCanBeCreateFromArray() : void
45
+	{
46
+		$this->assertInstanceOf(Option::class, new Option([
47
+			'value' => '1',
48
+			'title' => '2'
49
+		]));
50
+	}
51
+
52
+	public function testPermissionCanBeCreateEmpty() : void
53
+	{
54
+		$this->assertInstanceOf(Permission::class, new Permission());
55
+	}
56
+
57
+	public function testPermissionCanBeCreateFromArray() : void
58
+	{
59
+		$this->assertInstanceOf(Permission::class, new Permission([
60
+			'id' => '1',
61
+			'options' => [
62
+				[
63
+					'value' => '2',
64
+					'title' => '3'
65
+				], [
66
+					'value' => '4',
67
+					'title' => '5'
68
+				]
69
+			]
70
+		]));
71
+	}
72
+
73
+	public function testResponseTeamCanBeCreateEmpty() : void
74
+	{
75
+		$this->assertInstanceOf(ResponseTeam::class, new ResponseTeam());
76
+	}
77
+
78
+	public function testResponseTeamCanBeCreateFromArray() : void
79
+	{
80
+		$this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([
81
+			'member_id' => '1',
82
+			'member_first_name' => '2'
83
+		]));
84
+	}
85
+
86
+	public function testTeamManagementCanBeCreateEmpty() : void
87
+	{
88
+		$this->assertInstanceOf(TeamManagement::class, new TeamManagement());
89
+	}
90
+
91
+	public function testCreateMustReturnResponseTeam() : void
92
+	{
93
+		$team_mng = new TeamManagement();
94
+		$res_team = $team_mng->create([
95
+			'new_password' => '12345&Qwerty',
96
+			'member_first_name' => 'Tusha I',
97
+			'member_last_name' => 'Pupkindzes',
98
+			'member_email' => '[email protected]',
99
+			'member_type' => 'SUB_ACCOUNT_DRIVER',
100
+			'OWNER_MEMBER_ID' => self::$owner_member_id
101
+		]);
102
+
103
+		$this->assertInstanceOf(ResponseTeam::class, $res_team);
104
+		$this->assertNotNull($res_team->member_id);
105
+		$this->assertEquals($res_team->member_first_name, 'Tusha I');
106 106
         
107
-        self::$member_id = $res_team->member_id;
108
-    }
109
-
110
-    public function testGetUserMustReturnResponseTeam() : void
111
-    {
112
-        $team_mng = new TeamManagement();
113
-        $res_team = $team_mng->getUser(self::$member_id);
114
-
115
-        $this->assertInstanceOf(ResponseTeam::class, $res_team);
116
-        $this->assertNotNull($res_team->member_id);
117
-        $this->assertEquals($res_team->member_first_name, 'Tusha I');
118
-    }
119
-
120
-    public function testGetUsersMustReturnArrayOfResponseTeam() : void
121
-    {
122
-        $team_mng = new TeamManagement();
123
-        $result = $team_mng->getUsers();
124
-
125
-        $this->assertIsArray($result);
126
-        if (count($result) > 0) {
127
-            $this->assertInstanceOf(ResponseTeam::class, $result[0]);
128
-        }
129
-    }
130
-
131
-    public function testUpdateMustReturnUpdatedResponseTeam() : void
132
-    {
133
-        $team_mng = new TeamManagement();
134
-        $res_team = $team_mng->update(self::$member_id, [
135
-            'HIDE_ROUTED_ADDRESSES' => true,
136
-            'member_type' => 'SUB_ACCOUNT_DISPATCHER'
137
-        ]);
138
-
139
-        $this->assertInstanceOf(ResponseTeam::class, $res_team);
140
-        $this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1);
141
-        $this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER');
142
-    }
143
-
144
-    public function testDeleteMustReturnDeletedResponseTeam() : void
145
-    {
146
-        $team_mng = new TeamManagement();
147
-        $res_team = $team_mng->delete(self::$member_id);
148
-
149
-        $this->assertInstanceOf(ResponseTeam::class, $res_team);
150
-        $this->assertNotNull($res_team->member_id);
151
-        $this->assertEquals($res_team->member_first_name, 'Tusha I');
152
-    }
153
-
154
-    public function testBulkInsertMustAddNewMembers() : void
155
-    {
156
-        $team_mng = new TeamManagement();
157
-        $result = $team_mng->bulkInsert([
158
-            [
159
-                'new_password' => '12345&Qwerty',
160
-                'member_first_name' => 'Tusha I',
161
-                'member_last_name' => 'Pupkindzes',
162
-                'member_email' => '[email protected]',
163
-                'member_type' => 'SUB_ACCOUNT_DRIVER',
164
-                'OWNER_MEMBER_ID' => self::$owner_member_id
165
-            ], [
166
-                'new_password' => '12345&Qwerty',
167
-                'member_first_name' => 'Tusha II',
168
-                'member_last_name' => 'Pupkindzes',
169
-                'member_email' => '[email protected]',
170
-                'member_type' => 'SUB_ACCOUNT_DRIVER',
171
-                'OWNER_MEMBER_ID' => self::$owner_member_id
172
-                ]
173
-        ], [
174
-            'conflicts' => 'overwrite'
175
-        ]);
176
-
177
-        $this->assertIsArray($result);
178
-    }
107
+		self::$member_id = $res_team->member_id;
108
+	}
109
+
110
+	public function testGetUserMustReturnResponseTeam() : void
111
+	{
112
+		$team_mng = new TeamManagement();
113
+		$res_team = $team_mng->getUser(self::$member_id);
114
+
115
+		$this->assertInstanceOf(ResponseTeam::class, $res_team);
116
+		$this->assertNotNull($res_team->member_id);
117
+		$this->assertEquals($res_team->member_first_name, 'Tusha I');
118
+	}
119
+
120
+	public function testGetUsersMustReturnArrayOfResponseTeam() : void
121
+	{
122
+		$team_mng = new TeamManagement();
123
+		$result = $team_mng->getUsers();
124
+
125
+		$this->assertIsArray($result);
126
+		if (count($result) > 0) {
127
+			$this->assertInstanceOf(ResponseTeam::class, $result[0]);
128
+		}
129
+	}
130
+
131
+	public function testUpdateMustReturnUpdatedResponseTeam() : void
132
+	{
133
+		$team_mng = new TeamManagement();
134
+		$res_team = $team_mng->update(self::$member_id, [
135
+			'HIDE_ROUTED_ADDRESSES' => true,
136
+			'member_type' => 'SUB_ACCOUNT_DISPATCHER'
137
+		]);
138
+
139
+		$this->assertInstanceOf(ResponseTeam::class, $res_team);
140
+		$this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1);
141
+		$this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER');
142
+	}
143
+
144
+	public function testDeleteMustReturnDeletedResponseTeam() : void
145
+	{
146
+		$team_mng = new TeamManagement();
147
+		$res_team = $team_mng->delete(self::$member_id);
148
+
149
+		$this->assertInstanceOf(ResponseTeam::class, $res_team);
150
+		$this->assertNotNull($res_team->member_id);
151
+		$this->assertEquals($res_team->member_first_name, 'Tusha I');
152
+	}
153
+
154
+	public function testBulkInsertMustAddNewMembers() : void
155
+	{
156
+		$team_mng = new TeamManagement();
157
+		$result = $team_mng->bulkInsert([
158
+			[
159
+				'new_password' => '12345&Qwerty',
160
+				'member_first_name' => 'Tusha I',
161
+				'member_last_name' => 'Pupkindzes',
162
+				'member_email' => '[email protected]',
163
+				'member_type' => 'SUB_ACCOUNT_DRIVER',
164
+				'OWNER_MEMBER_ID' => self::$owner_member_id
165
+			], [
166
+				'new_password' => '12345&Qwerty',
167
+				'member_first_name' => 'Tusha II',
168
+				'member_last_name' => 'Pupkindzes',
169
+				'member_email' => '[email protected]',
170
+				'member_type' => 'SUB_ACCOUNT_DRIVER',
171
+				'OWNER_MEMBER_ID' => self::$owner_member_id
172
+				]
173
+		], [
174
+			'conflicts' => 'overwrite'
175
+		]);
176
+
177
+		$this->assertIsArray($result);
178
+	}
179 179
     
180
-    public static function tearDownAfterClass() : void
181
-    {
182
-        sleep(5);
183
-
184
-        $team_mng = new TeamManagement();
185
-        $result = $team_mng->getUsers();
186
-
187
-        if (is_array($result)) {
188
-            foreach ($result as $key => $member) {
189
-                if ($member->member_last_name == 'Pupkindzes') {
190
-                    $team_mng->delete($member->member_id);
191
-                }
192
-            }
193
-        }
194
-    }
180
+	public static function tearDownAfterClass() : void
181
+	{
182
+		sleep(5);
183
+
184
+		$team_mng = new TeamManagement();
185
+		$result = $team_mng->getUsers();
186
+
187
+		if (is_array($result)) {
188
+			foreach ($result as $key => $member) {
189
+				if ($member->member_last_name == 'Pupkindzes') {
190
+					$team_mng->delete($member->member_id);
191
+				}
192
+			}
193
+		}
194
+	}
195 195
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/TeamManagement/Option.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
  */
14 14
 class Option extends Common
15 15
 {
16
-    public ?string $value = null;
17
-    public ?string $title = null;
16
+	public ?string $value = null;
17
+	public ?string $title = null;
18 18
 
19
-    public function __construct(?array $params = null)
20
-    {
21
-        if ($params !== null) {
22
-            $this->fillFromArray($params);
23
-        }
24
-    }
19
+	public function __construct(?array $params = null)
20
+	{
21
+		if ($params !== null) {
22
+			$this->fillFromArray($params);
23
+		}
24
+	}
25 25
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/TeamManagement/ResponseTeam.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -13,139 +13,139 @@
 block discarded – undo
13 13
  */
14 14
 class ResponseTeam extends Common
15 15
 {
16
-    /**
17
-     * The member ID
18
-     */
19
-    public ?int $member_id = null;
20
-
21
-    /**
22
-     * The user's account owner ID
23
-     */
24
-    public ?int $OWNER_MEMBER_ID = null;
25
-
26
-    /**
27
-     * User's first name
28
-     */
29
-    public ?string $member_first_name = null;
30
-
31
-    /**
32
-     * User's last name
33
-     */
34
-    public ?string $member_last_name = null;
35
-
36
-    /**
37
-     * User's email
38
-     */
39
-    public ?string $member_email = null;
40
-
41
-    /**
42
-     * User's image
43
-     * @example '/uploads/cc6aba1a0e68ea429c51e3f9cb12e1ac/profile_c96135b77f6fc42be64cd98e0c21d341.jpg'
44
-     */
45
-    public ?string $member_picture = null;
46
-
47
-    /**
48
-     * Member type.
49
-     * Available values: 'PRIMARY_ACCOUNT', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER',
50
-     *   'SUB_ACCOUNT_DISPATCHER', 'SUB_ACCOUNT_PLANNER', "SUB_ACCOUNT_DRIVER'
51
-     * @example 'SUB_ACCOUNT_DISPATCHER'
52
-     */
53
-    public ?string $member_type = null;
54
-
55
-    /**
56
-     * If true, the routed addresses will be hidden.
57
-     */
58
-    public ?bool $HIDE_ROUTED_ADDRESSES = null;
59
-
60
-    /**
61
-     * If true, the visited addresses will be hidden.
62
-     */
63
-    public ?bool $HIDE_VISITED_ADDRESSES = null;
64
-
65
-    /**
66
-     * If true, the nonfuture routes will be hidden.
67
-     */
68
-    public ?bool $HIDE_NONFUTURE_ROUTES = null;
69
-
70
-    /**
71
-     * If true, the user has read-only access type.
72
-     */
73
-    public ?bool $READONLY_USER = null;
74
-
75
-    /**
76
-     * If true, the global address book contacts are visible in a user account.
77
-     */
78
-    public ?bool $SHOW_SUSR_ADDR = null;
79
-
80
-    /**
81
-     * If true, the global orders are visible in a user account.
82
-     */
83
-    public ?bool $SHOW_SUSR_ORDERS = null;
84
-
85
-    /**
86
-     * If true, all drivers are visible to the user.
87
-     */
88
-    public ?bool $SHOW_ALL_DRIVERS = null;
89
-
90
-    /**
91
-     * If true, all vehicles are visible to the user.
92
-     */
93
-    public ?bool $SHOW_ALL_VEHICLES = null;
94
-
95
-    /**
96
-     * Allowed sub-member types in the user's account.
97
-     * String array, available types: 'SUB_ACCOUNT_DRIVER', 'SUB_ACCOUNT_DISPATCHER',
98
-     *   'SUB_ACCOUNT_PLANNER', 'SUB_ACCOUNT_ANALYST', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER'
99
-     */
100
-    public ?array $allowed_submember_types = null;
101
-
102
-    /**
103
-     * If true, the user can edit the account data.
104
-     */
105
-    public ?bool $can_edit = null;
106
-
107
-    /**
108
-     * If true, the user can delete the account data.
109
-     */
110
-    public ?bool $can_delete = null;
111
-
112
-    /**
113
-     * The user's custom data.
114
-     * @example ['custom_data_key' => 'custom_data_value']
115
-     */
116
-    public ?array $custom_data = null;
117
-
118
-    /**
119
-     * Optimization profile ID
120
-     * @example '18a6e1c5-0a02-4c58-a2d3-5c842ab550be'
121
-     */
122
-    public ?string $optimization_profile_id = null;
123
-
124
-    /**
125
-     * Member type title
126
-     */
127
-    public ?string $member_type_title = null;
128
-
129
-    /**
130
-     * User's permissions
131
-     */
132
-    public ?array $permissions = null;
133
-
134
-    public function __construct(?array $params = null)
135
-    {
136
-        if ($params !== null) {
137
-            foreach ($this as $key => $value) {
138
-                if (isset($params[$key])) {
139
-                    if ($key === 'permissions') {
140
-                        $this->{$key} = array();
141
-                        foreach ($params[$key] as $perm_key => $perm_value) {
142
-                            array_push($this->{$key}, new Permission($perm_value));
143
-                        }
144
-                    } else {
145
-                        $this->{$key} = $params[$key];
146
-                    }
147
-                }
148
-            }
149
-        }
150
-    }
16
+	/**
17
+	 * The member ID
18
+	 */
19
+	public ?int $member_id = null;
20
+
21
+	/**
22
+	 * The user's account owner ID
23
+	 */
24
+	public ?int $OWNER_MEMBER_ID = null;
25
+
26
+	/**
27
+	 * User's first name
28
+	 */
29
+	public ?string $member_first_name = null;
30
+
31
+	/**
32
+	 * User's last name
33
+	 */
34
+	public ?string $member_last_name = null;
35
+
36
+	/**
37
+	 * User's email
38
+	 */
39
+	public ?string $member_email = null;
40
+
41
+	/**
42
+	 * User's image
43
+	 * @example '/uploads/cc6aba1a0e68ea429c51e3f9cb12e1ac/profile_c96135b77f6fc42be64cd98e0c21d341.jpg'
44
+	 */
45
+	public ?string $member_picture = null;
46
+
47
+	/**
48
+	 * Member type.
49
+	 * Available values: 'PRIMARY_ACCOUNT', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER',
50
+	 *   'SUB_ACCOUNT_DISPATCHER', 'SUB_ACCOUNT_PLANNER', "SUB_ACCOUNT_DRIVER'
51
+	 * @example 'SUB_ACCOUNT_DISPATCHER'
52
+	 */
53
+	public ?string $member_type = null;
54
+
55
+	/**
56
+	 * If true, the routed addresses will be hidden.
57
+	 */
58
+	public ?bool $HIDE_ROUTED_ADDRESSES = null;
59
+
60
+	/**
61
+	 * If true, the visited addresses will be hidden.
62
+	 */
63
+	public ?bool $HIDE_VISITED_ADDRESSES = null;
64
+
65
+	/**
66
+	 * If true, the nonfuture routes will be hidden.
67
+	 */
68
+	public ?bool $HIDE_NONFUTURE_ROUTES = null;
69
+
70
+	/**
71
+	 * If true, the user has read-only access type.
72
+	 */
73
+	public ?bool $READONLY_USER = null;
74
+
75
+	/**
76
+	 * If true, the global address book contacts are visible in a user account.
77
+	 */
78
+	public ?bool $SHOW_SUSR_ADDR = null;
79
+
80
+	/**
81
+	 * If true, the global orders are visible in a user account.
82
+	 */
83
+	public ?bool $SHOW_SUSR_ORDERS = null;
84
+
85
+	/**
86
+	 * If true, all drivers are visible to the user.
87
+	 */
88
+	public ?bool $SHOW_ALL_DRIVERS = null;
89
+
90
+	/**
91
+	 * If true, all vehicles are visible to the user.
92
+	 */
93
+	public ?bool $SHOW_ALL_VEHICLES = null;
94
+
95
+	/**
96
+	 * Allowed sub-member types in the user's account.
97
+	 * String array, available types: 'SUB_ACCOUNT_DRIVER', 'SUB_ACCOUNT_DISPATCHER',
98
+	 *   'SUB_ACCOUNT_PLANNER', 'SUB_ACCOUNT_ANALYST', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER'
99
+	 */
100
+	public ?array $allowed_submember_types = null;
101
+
102
+	/**
103
+	 * If true, the user can edit the account data.
104
+	 */
105
+	public ?bool $can_edit = null;
106
+
107
+	/**
108
+	 * If true, the user can delete the account data.
109
+	 */
110
+	public ?bool $can_delete = null;
111
+
112
+	/**
113
+	 * The user's custom data.
114
+	 * @example ['custom_data_key' => 'custom_data_value']
115
+	 */
116
+	public ?array $custom_data = null;
117
+
118
+	/**
119
+	 * Optimization profile ID
120
+	 * @example '18a6e1c5-0a02-4c58-a2d3-5c842ab550be'
121
+	 */
122
+	public ?string $optimization_profile_id = null;
123
+
124
+	/**
125
+	 * Member type title
126
+	 */
127
+	public ?string $member_type_title = null;
128
+
129
+	/**
130
+	 * User's permissions
131
+	 */
132
+	public ?array $permissions = null;
133
+
134
+	public function __construct(?array $params = null)
135
+	{
136
+		if ($params !== null) {
137
+			foreach ($this as $key => $value) {
138
+				if (isset($params[$key])) {
139
+					if ($key === 'permissions') {
140
+						$this->{$key} = array();
141
+						foreach ($params[$key] as $perm_key => $perm_value) {
142
+							array_push($this->{$key}, new Permission($perm_value));
143
+						}
144
+					} else {
145
+						$this->{$key} = $params[$key];
146
+					}
147
+				}
148
+			}
149
+		}
150
+	}
151 151
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/TeamManagement/Permission.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@
 block discarded – undo
14 14
  */
15 15
 class Permission extends Common
16 16
 {
17
-    public ?string $id = null;
18
-    public ?string $title = null;
19
-    public ?string $type = null;
17
+	public ?string $id = null;
18
+	public ?string $title = null;
19
+	public ?string $type = null;
20 20
 
21
-    /**
22
-     * Array of Options
23
-     */
24
-    public ?array $options = null;
21
+	/**
22
+	 * Array of Options
23
+	 */
24
+	public ?array $options = null;
25 25
 
26
-    /**
27
-     * Array of strings
28
-     */
29
-    public ?array $value = null;
26
+	/**
27
+	 * Array of strings
28
+	 */
29
+	public ?array $value = null;
30 30
 
31
-    public function __construct(?array $params = null)
32
-    {
33
-        if ($params !== null) {
34
-            foreach ($this as $key => $value) {
35
-                if (isset($params[$key])) {
36
-                    if ($key === 'options') {
37
-                        $this->{$key} = array();
38
-                        foreach ($params[$key] as $opt_key => $opt_value) {
39
-                            array_push($this->{$key}, new Option($opt_value));
40
-                        }
41
-                    } else {
42
-                        $this->{$key} = $params[$key];
43
-                    }
44
-                }
45
-            }
46
-        }
47
-    }
31
+	public function __construct(?array $params = null)
32
+	{
33
+		if ($params !== null) {
34
+			foreach ($this as $key => $value) {
35
+				if (isset($params[$key])) {
36
+					if ($key === 'options') {
37
+						$this->{$key} = array();
38
+						foreach ($params[$key] as $opt_key => $opt_value) {
39
+							array_push($this->{$key}, new Option($opt_value));
40
+						}
41
+					} else {
42
+						$this->{$key} = $params[$key];
43
+					}
44
+				}
45
+			}
46
+		}
47
+	}
48 48
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/TeamManagement/TeamManagement.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -17,277 +17,277 @@
 block discarded – undo
17 17
  */
18 18
 class TeamManagement extends Common
19 19
 {
20
-    public function __construct()
21
-    {
22
-        Route4Me::setBaseUrl('');
23
-    }
20
+	public function __construct()
21
+	{
22
+		Route4Me::setBaseUrl('');
23
+	}
24 24
 
25
-    /**
26
-     * Add a new sub-user to the Member account by sending the corresponding
27
-     * body payload with the sub-users' parameters.
28
-     *
29
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
30
-     *
31
-     * @param  array $params                   - Sub-user properties.
32
-     *   string new_password                   - Password.
33
-     *   string new_member_picture             - Member picture.
34
-     *   string member_first_name              - First name.
35
-     *   string member_last_name               - Last name.
36
-     *   string member_email                   - E-mail.
37
-     *   string member_company                 - Company.
38
-     *   string member_type                    - Member type.
39
-     *   int    OWNER_MEMBER_ID                - Owner member ID.
40
-     *   string member_phone                   - Phone.
41
-     *   string date_of_birth                  - Date of birth.
42
-     *   int    user_reg_state_id              - User state ID.
43
-     *   int    user_reg_country_id            - User country ID.
44
-     *   float  DriverHourlyRate               - Drive hourly rate.
45
-     *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
46
-     *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
47
-     *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
48
-     *   bool   READONLY_USER                  - Readonly user.
49
-     *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
50
-     *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
51
-     *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
52
-     *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
53
-     *   bool   display_max_routes_future_days - Display max routes.
54
-     *   int    vendor_id                      - Vendoe ID.
55
-     *   float  driving_rate                   - Driving rate.
56
-     *   float  working_rate                   - Working rate.
57
-     *   float  mile_rate                      - Mile rate.
58
-     *   float  idling_rate                    - Idling rate.
59
-     *   string timezone                       - Timezone.
60
-     *   string optimization_profile_id        - Optimization profile ID.
61
-     *   array  permissions                    - Array of permissions
62
-     *     string id                           - ID of permission
63
-     *     array  value                        - Array of string values
64
-     * @return ResponseTeam
65
-     * @throws Exception\ApiError
66
-     */
67
-    public function create(array $params) : ResponseTeam
68
-    {
69
-        $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
70
-            'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
71
-            'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
72
-            'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
73
-            'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
74
-            'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
75
-        ];
25
+	/**
26
+	 * Add a new sub-user to the Member account by sending the corresponding
27
+	 * body payload with the sub-users' parameters.
28
+	 *
29
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
30
+	 *
31
+	 * @param  array $params                   - Sub-user properties.
32
+	 *   string new_password                   - Password.
33
+	 *   string new_member_picture             - Member picture.
34
+	 *   string member_first_name              - First name.
35
+	 *   string member_last_name               - Last name.
36
+	 *   string member_email                   - E-mail.
37
+	 *   string member_company                 - Company.
38
+	 *   string member_type                    - Member type.
39
+	 *   int    OWNER_MEMBER_ID                - Owner member ID.
40
+	 *   string member_phone                   - Phone.
41
+	 *   string date_of_birth                  - Date of birth.
42
+	 *   int    user_reg_state_id              - User state ID.
43
+	 *   int    user_reg_country_id            - User country ID.
44
+	 *   float  DriverHourlyRate               - Drive hourly rate.
45
+	 *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
46
+	 *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
47
+	 *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
48
+	 *   bool   READONLY_USER                  - Readonly user.
49
+	 *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
50
+	 *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
51
+	 *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
52
+	 *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
53
+	 *   bool   display_max_routes_future_days - Display max routes.
54
+	 *   int    vendor_id                      - Vendoe ID.
55
+	 *   float  driving_rate                   - Driving rate.
56
+	 *   float  working_rate                   - Working rate.
57
+	 *   float  mile_rate                      - Mile rate.
58
+	 *   float  idling_rate                    - Idling rate.
59
+	 *   string timezone                       - Timezone.
60
+	 *   string optimization_profile_id        - Optimization profile ID.
61
+	 *   array  permissions                    - Array of permissions
62
+	 *     string id                           - ID of permission
63
+	 *     array  value                        - Array of string values
64
+	 * @return ResponseTeam
65
+	 * @throws Exception\ApiError
66
+	 */
67
+	public function create(array $params) : ResponseTeam
68
+	{
69
+		$allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
70
+			'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
71
+			'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
72
+			'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
73
+			'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
74
+			'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
75
+		];
76 76
 
77
-        return $this->toResponseTeam(Route4Me::makeRequst([
78
-            'url' => Endpoint::TEAM_USERS,
79
-            'method' => 'POST',
80
-            'HTTPHEADER' => 'Content-Type: application/json',
81
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
82
-        ]));
83
-    }
77
+		return $this->toResponseTeam(Route4Me::makeRequst([
78
+			'url' => Endpoint::TEAM_USERS,
79
+			'method' => 'POST',
80
+			'HTTPHEADER' => 'Content-Type: application/json',
81
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
82
+		]));
83
+	}
84 84
 
85
-    /**
86
-     * View all existing sub-users associated with the Member’s account.
87
-     *
88
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
89
-     *
90
-     * @return ResponseTeam[]
91
-     * @throws Exception\ApiError
92
-     */
93
-    public function getUsers() : ?array
94
-    {
95
-        $result = Route4Me::makeRequst([
96
-            'url' => Endpoint::TEAM_USERS,
97
-            'method' => 'GET'
98
-        ]);
85
+	/**
86
+	 * View all existing sub-users associated with the Member’s account.
87
+	 *
88
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
89
+	 *
90
+	 * @return ResponseTeam[]
91
+	 * @throws Exception\ApiError
92
+	 */
93
+	public function getUsers() : ?array
94
+	{
95
+		$result = Route4Me::makeRequst([
96
+			'url' => Endpoint::TEAM_USERS,
97
+			'method' => 'GET'
98
+		]);
99 99
 
100
-        if (is_array($result)) {
101
-            $arr = [];
102
-            foreach ($result as $key => $value) {
103
-                array_push($arr, $this->toResponseTeam($value));
104
-            }
105
-            return $arr;
106
-        }
107
-        return null;
108
-    }
100
+		if (is_array($result)) {
101
+			$arr = [];
102
+			foreach ($result as $key => $value) {
103
+				array_push($arr, $this->toResponseTeam($value));
104
+			}
105
+			return $arr;
106
+		}
107
+		return null;
108
+	}
109 109
 
110
-    /**
111
-     * Get the sub-user by specifying the path parameter ID.
112
-     *
113
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
114
-     *
115
-     * @param  int $userId                                  - User ID.
116
-     * @return ResponseTeam
117
-     * @throws Exception\ApiError
118
-     */
119
-    public function getUser(int $userId) : ResponseTeam
120
-    {
121
-        return $this->toResponseTeam(Route4Me::makeRequst([
122
-            'url' => Endpoint::TEAM_USERS . '/' . $userId,
123
-            'method' => 'GET'
124
-        ]));
125
-    }
110
+	/**
111
+	 * Get the sub-user by specifying the path parameter ID.
112
+	 *
113
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
114
+	 *
115
+	 * @param  int $userId                                  - User ID.
116
+	 * @return ResponseTeam
117
+	 * @throws Exception\ApiError
118
+	 */
119
+	public function getUser(int $userId) : ResponseTeam
120
+	{
121
+		return $this->toResponseTeam(Route4Me::makeRequst([
122
+			'url' => Endpoint::TEAM_USERS . '/' . $userId,
123
+			'method' => 'GET'
124
+		]));
125
+	}
126 126
 
127
-    /**
128
-     * Delete the sub-user by specifying the path parameter ID.
129
-     *
130
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
131
-     *
132
-     * @param  int $userId                                  - User ID.
133
-     * @return ResponseTeam                                 - Deleted object
134
-     * @throws Exception\ApiError
135
-     */
136
-    public function delete(int $userId) : ResponseTeam
137
-    {
138
-        return $this->toResponseTeam(Route4Me::makeRequst([
139
-            'url' => Endpoint::TEAM_USERS . '/' . $userId,
140
-            'method' => 'DELETE'
141
-        ]));
142
-    }
127
+	/**
128
+	 * Delete the sub-user by specifying the path parameter ID.
129
+	 *
130
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
131
+	 *
132
+	 * @param  int $userId                                  - User ID.
133
+	 * @return ResponseTeam                                 - Deleted object
134
+	 * @throws Exception\ApiError
135
+	 */
136
+	public function delete(int $userId) : ResponseTeam
137
+	{
138
+		return $this->toResponseTeam(Route4Me::makeRequst([
139
+			'url' => Endpoint::TEAM_USERS . '/' . $userId,
140
+			'method' => 'DELETE'
141
+		]));
142
+	}
143 143
 
144
-    /**
145
-     * Update the sub-user by specifying the path parameter ID and by sending the
146
-     * corresponding body payload with the sub-user's parameters..
147
-     *
148
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
149
-     *
150
-     * @param int $userId                                  - User ID.
151
-     * @param  array $params                   - Sub-user properties.
152
-     *   string new_password                   - Password.
153
-     *   string new_member_picture             - Member picture.
154
-     *   string member_first_name              - First name.
155
-     *   string member_last_name               - Last name.
156
-     *   string member_email                   - E-mail.
157
-     *   string member_company                 - Company.
158
-     *   string member_type                    - Member type.
159
-     *   int    OWNER_MEMBER_ID                - Owner member ID.
160
-     *   string member_phone                   - Phone.
161
-     *   string date_of_birth                  - Date of birth.
162
-     *   int    user_reg_state_id              - User state ID.
163
-     *   int    user_reg_country_id            - User country ID.
164
-     *   float  DriverHourlyRate               - Drive hourly rate.
165
-     *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
166
-     *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
167
-     *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
168
-     *   bool   READONLY_USER                  - Readonly user.
169
-     *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
170
-     *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
171
-     *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
172
-     *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
173
-     *   bool   display_max_routes_future_days - Display max routes.
174
-     *   int    vendor_id                      - Vendoe ID.
175
-     *   float  driving_rate                   - Driving rate.
176
-     *   float  working_rate                   - Working rate.
177
-     *   float  mile_rate                      - Mile rate.
178
-     *   float  idling_rate                    - Idling rate.
179
-     *   string timezone                       - Timezone.
180
-     *   string optimization_profile_id        - Optimization profile ID.
181
-     *   array  permissions                    - Array of permissions
182
-     *     string id                           - ID of permission
183
-     *     array  value                        - Array of string values
184
-     * @return ResponseTeam
185
-     * @throws Exception\ApiError
186
-     */
187
-    public function update(int $userId, array $params) : ResponseTeam
188
-    {
189
-        $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
190
-            'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
191
-            'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
192
-            'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
193
-            'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
194
-            'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
195
-        ];
144
+	/**
145
+	 * Update the sub-user by specifying the path parameter ID and by sending the
146
+	 * corresponding body payload with the sub-user's parameters..
147
+	 *
148
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
149
+	 *
150
+	 * @param int $userId                                  - User ID.
151
+	 * @param  array $params                   - Sub-user properties.
152
+	 *   string new_password                   - Password.
153
+	 *   string new_member_picture             - Member picture.
154
+	 *   string member_first_name              - First name.
155
+	 *   string member_last_name               - Last name.
156
+	 *   string member_email                   - E-mail.
157
+	 *   string member_company                 - Company.
158
+	 *   string member_type                    - Member type.
159
+	 *   int    OWNER_MEMBER_ID                - Owner member ID.
160
+	 *   string member_phone                   - Phone.
161
+	 *   string date_of_birth                  - Date of birth.
162
+	 *   int    user_reg_state_id              - User state ID.
163
+	 *   int    user_reg_country_id            - User country ID.
164
+	 *   float  DriverHourlyRate               - Drive hourly rate.
165
+	 *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
166
+	 *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
167
+	 *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
168
+	 *   bool   READONLY_USER                  - Readonly user.
169
+	 *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
170
+	 *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
171
+	 *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
172
+	 *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
173
+	 *   bool   display_max_routes_future_days - Display max routes.
174
+	 *   int    vendor_id                      - Vendoe ID.
175
+	 *   float  driving_rate                   - Driving rate.
176
+	 *   float  working_rate                   - Working rate.
177
+	 *   float  mile_rate                      - Mile rate.
178
+	 *   float  idling_rate                    - Idling rate.
179
+	 *   string timezone                       - Timezone.
180
+	 *   string optimization_profile_id        - Optimization profile ID.
181
+	 *   array  permissions                    - Array of permissions
182
+	 *     string id                           - ID of permission
183
+	 *     array  value                        - Array of string values
184
+	 * @return ResponseTeam
185
+	 * @throws Exception\ApiError
186
+	 */
187
+	public function update(int $userId, array $params) : ResponseTeam
188
+	{
189
+		$allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
190
+			'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
191
+			'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
192
+			'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
193
+			'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
194
+			'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
195
+		];
196 196
 
197
-        return $this->toResponseTeam(Route4Me::makeRequst([
198
-            'url' => Endpoint::TEAM_USERS . '/' . $userId,
199
-            'method' => 'PATCH',
200
-            'HTTPHEADER' => 'Content-Type: application/json',
201
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
202
-        ]));
203
-    }
197
+		return $this->toResponseTeam(Route4Me::makeRequst([
198
+			'url' => Endpoint::TEAM_USERS . '/' . $userId,
199
+			'method' => 'PATCH',
200
+			'HTTPHEADER' => 'Content-Type: application/json',
201
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
202
+		]));
203
+	}
204 204
 
205
-    /**
206
-     * Add multiple sub-users to the User account by sending the corresponding
207
-     * body payload with the array of the sub-users' parameters
208
-     *
209
-     * @see {@link https://virtserver.swaggerhub.com/Route4Me}
210
-     *
211
-     * @param  array $params                   - Array of array of Sub-user properties.
212
-     *   string new_password                   - Password.
213
-     *   string new_member_picture             - Member picture.
214
-     *   string member_first_name              - First name.
215
-     *   string member_last_name               - Last name.
216
-     *   string member_email                   - E-mail.
217
-     *   string member_company                 - Company.
218
-     *   string member_type                    - Member type.
219
-     *   int    OWNER_MEMBER_ID                - Owner member ID.
220
-     *   string member_phone                   - Phone.
221
-     *   string date_of_birth                  - Date of birth.
222
-     *   int    user_reg_state_id              - User state ID.
223
-     *   int    user_reg_country_id            - User country ID.
224
-     *   float  DriverHourlyRate               - Drive hourly rate.
225
-     *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
226
-     *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
227
-     *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
228
-     *   bool   READONLY_USER                  - Readonly user.
229
-     *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
230
-     *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
231
-     *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
232
-     *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
233
-     *   bool   display_max_routes_future_days - Display max routes.
234
-     *   int    vendor_id                      - Vendoe ID.
235
-     *   float  driving_rate                   - Driving rate.
236
-     *   float  working_rate                   - Working rate.
237
-     *   float  mile_rate                      - Mile rate.
238
-     *   float  idling_rate                    - Idling rate.
239
-     *   string timezone                       - Timezone.
240
-     *   string optimization_profile_id        - Optimization profile ID.
241
-     *   array  permissions                    - Array of permissions
242
-     *     string id                           - ID of permission
243
-     *     array  value                        - Array of string values
244
-     * @param  array options                   - Array of insert options.
245
-     *   string [api_key]                      - User API key.
246
-     *   string [conflicts]                    - Conflict resolving rule.
247
-     *                                           Possible values: 'fail', 'overwrite' and 'skip'.
248
-     * @return ResponseTeam
249
-     * @throws Exception\ApiError
250
-     */
251
-    public function bulkInsert(array $params, ?array $options = null)
252
-    {
253
-        $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
254
-            'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
255
-            'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
256
-            'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
257
-            'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
258
-            'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
259
-        ];
205
+	/**
206
+	 * Add multiple sub-users to the User account by sending the corresponding
207
+	 * body payload with the array of the sub-users' parameters
208
+	 *
209
+	 * @see {@link https://virtserver.swaggerhub.com/Route4Me}
210
+	 *
211
+	 * @param  array $params                   - Array of array of Sub-user properties.
212
+	 *   string new_password                   - Password.
213
+	 *   string new_member_picture             - Member picture.
214
+	 *   string member_first_name              - First name.
215
+	 *   string member_last_name               - Last name.
216
+	 *   string member_email                   - E-mail.
217
+	 *   string member_company                 - Company.
218
+	 *   string member_type                    - Member type.
219
+	 *   int    OWNER_MEMBER_ID                - Owner member ID.
220
+	 *   string member_phone                   - Phone.
221
+	 *   string date_of_birth                  - Date of birth.
222
+	 *   int    user_reg_state_id              - User state ID.
223
+	 *   int    user_reg_country_id            - User country ID.
224
+	 *   float  DriverHourlyRate               - Drive hourly rate.
225
+	 *   bool   HIDE_ROUTED_ADDRESSES          - Hide routed addresses.
226
+	 *   bool   HIDE_VISITED_ADDRESSES         - Hide visited addresses.
227
+	 *   bool   HIDE_NONFUTURE_ROUTES          - Hide nonfuture routes.
228
+	 *   bool   READONLY_USER                  - Readonly user.
229
+	 *   bool   SHOW_SUSR_ADDR                 - Show sub-user addresses.
230
+	 *   bool   SHOW_SUSR_ORDERS               - Show sub-user orders.
231
+	 *   bool   SHOW_ALL_DRIVERS               - Show all drivers.
232
+	 *   bool   SHOW_ALL_VEHICLES              - Show all vehicles.
233
+	 *   bool   display_max_routes_future_days - Display max routes.
234
+	 *   int    vendor_id                      - Vendoe ID.
235
+	 *   float  driving_rate                   - Driving rate.
236
+	 *   float  working_rate                   - Working rate.
237
+	 *   float  mile_rate                      - Mile rate.
238
+	 *   float  idling_rate                    - Idling rate.
239
+	 *   string timezone                       - Timezone.
240
+	 *   string optimization_profile_id        - Optimization profile ID.
241
+	 *   array  permissions                    - Array of permissions
242
+	 *     string id                           - ID of permission
243
+	 *     array  value                        - Array of string values
244
+	 * @param  array options                   - Array of insert options.
245
+	 *   string [api_key]                      - User API key.
246
+	 *   string [conflicts]                    - Conflict resolving rule.
247
+	 *                                           Possible values: 'fail', 'overwrite' and 'skip'.
248
+	 * @return ResponseTeam
249
+	 * @throws Exception\ApiError
250
+	 */
251
+	public function bulkInsert(array $params, ?array $options = null)
252
+	{
253
+		$allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name',
254
+			'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth',
255
+			'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES',
256
+			'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS',
257
+			'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate',
258
+			'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions'
259
+		];
260 260
 
261
-        $allQueryFields = ['api_key', 'conflicts'];
261
+		$allQueryFields = ['api_key', 'conflicts'];
262 262
 
263
-        $body = [];
264
-        foreach ($params as $key => $value) {
265
-            $body[] = Route4Me::generateRequestParameters($allBodyFields, $value);
266
-        }
263
+		$body = [];
264
+		foreach ($params as $key => $value) {
265
+			$body[] = Route4Me::generateRequestParameters($allBodyFields, $value);
266
+		}
267 267
 
268
-        $result = Route4Me::makeRequst([
269
-            'url' => Endpoint::TEAM_USERS_BULK_INSERT,
270
-            'method' => 'POST',
271
-            'HTTPHEADER' => 'Content-Type: application/json',
272
-            'body' => ['users' => $body],
273
-            'query' => Route4Me::generateRequestParameters($allQueryFields, $options)
274
-        ]);
268
+		$result = Route4Me::makeRequst([
269
+			'url' => Endpoint::TEAM_USERS_BULK_INSERT,
270
+			'method' => 'POST',
271
+			'HTTPHEADER' => 'Content-Type: application/json',
272
+			'body' => ['users' => $body],
273
+			'query' => Route4Me::generateRequestParameters($allQueryFields, $options)
274
+		]);
275 275
 
276
-        if (is_array($result)) {
277
-            $arr = [];
278
-            foreach ($result as $key => $value) {
279
-                array_push($arr, $this->toResponseTeam($value));
280
-            }
281
-            return $arr;
282
-        }
283
-        return null;
284
-    }
276
+		if (is_array($result)) {
277
+			$arr = [];
278
+			foreach ($result as $key => $value) {
279
+				array_push($arr, $this->toResponseTeam($value));
280
+			}
281
+			return $arr;
282
+		}
283
+		return null;
284
+	}
285 285
 
286
-    private function toResponseTeam($result) : ResponseTeam
287
-    {
288
-        if (is_array($result)) {
289
-            return new ResponseTeam($result);
290
-        }
291
-        throw new ApiError('Can not convert result to ResponseTeam object.');
292
-    }
286
+	private function toResponseTeam($result) : ResponseTeam
287
+	{
288
+		if (is_array($result)) {
289
+			return new ResponseTeam($result);
290
+		}
291
+		throw new ApiError('Can not convert result to ResponseTeam object.');
292
+	}
293 293
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Enum/Endpoint.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,105 +6,105 @@
 block discarded – undo
6 6
 
7 7
 class Endpoint
8 8
 {
9
-    const API_VERSION = "5";
9
+	const API_VERSION = "5";
10 10
 
11
-    const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0";
11
+	const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0";
12 12
 
13
-    const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0";
13
+	const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0";
14 14
 
15
-    // <editor-fold defaultstate="collapsed" desc="region Routes">
15
+	// <editor-fold defaultstate="collapsed" desc="region Routes">
16 16
 
17
-    const Routes = self::MAIN_HOST . "/routes";
18
-    const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate";
19
-    const RoutesMerge = self::MAIN_HOST . "/routes/merge";
20
-    const RoutesPaginate = self::MAIN_HOST . "/routes/paginate";
21
-    const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate";
22
-    const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable";
23
-    const RoutesFallback = self::MAIN_HOST . "/routes/fallback";
24
-    const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback";
25
-    const RoutesDatatable = self::MAIN_HOST . "/routes/datatable";
26
-    const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config";
27
-    const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config";
17
+	const Routes = self::MAIN_HOST . "/routes";
18
+	const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate";
19
+	const RoutesMerge = self::MAIN_HOST . "/routes/merge";
20
+	const RoutesPaginate = self::MAIN_HOST . "/routes/paginate";
21
+	const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate";
22
+	const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable";
23
+	const RoutesFallback = self::MAIN_HOST . "/routes/fallback";
24
+	const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback";
25
+	const RoutesDatatable = self::MAIN_HOST . "/routes/datatable";
26
+	const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config";
27
+	const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config";
28 28
 
29
-    // </editor-fold>
29
+	// </editor-fold>
30 30
 
31
-    // <editor-fold defaultstate="collapsed" desc="Team Users">
31
+	// <editor-fold defaultstate="collapsed" desc="Team Users">
32 32
 
33
-    const TEAM_USERS = self::MAIN_HOST . "/team/users";
34
-    const TEAM_USERS_BULK_INSERT = self::MAIN_HOST . "/team/bulk-insert";
35
-    const DriverReview = self::MAIN_HOST . "/driver-reviews";
33
+	const TEAM_USERS = self::MAIN_HOST . "/team/users";
34
+	const TEAM_USERS_BULK_INSERT = self::MAIN_HOST . "/team/bulk-insert";
35
+	const DriverReview = self::MAIN_HOST . "/driver-reviews";
36 36
 
37
-    // </editor-fold>
37
+	// </editor-fold>
38 38
     
39
-    const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api";
40
-
41
-    // <editor-fold defaultstate="collapsed" desc="Vehicles">
42
-
43
-    const Vehicles = self::MAIN_HOST . "/vehicles";
44
-    const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign";
45
-    const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute";
46
-    const VehicleLocation = self::MAIN_HOST . "/vehicles/location";
47
-    const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles";
48
-    const VehicleLicense = self::MAIN_HOST . "/vehicles/license";
49
-    const VehicleSearch = self::MAIN_HOST . "/vehicles/search";
50
-
51
-    const RECURRING_ROUTES = self::MAIN_HOST . "/recurring-routes";
52
-    const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST . "/recurring-routes/schedules";
53
-    const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST . "/recurring-routes/schedules/pagination";
54
-    const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST . "/recurring-routes/route-schedules";
55
-    const RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION =
56
-        self::MAIN_HOST . "/recurring-routes/route-schedules/pagination";
57
-    const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST . "/recurring-routes/route-schedules/replace";
58
-    const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST . "/recurring-routes/scheduled-routes/is-copy";
59
-    const RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES =
60
-        self::MAIN_HOST . "/recurring-routes/scheduled-routes/get-copies";
61
-    const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST . "/recurring-routes/master-routes";
62
-
63
-    // </editor-fold>
39
+	const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api";
40
+
41
+	// <editor-fold defaultstate="collapsed" desc="Vehicles">
42
+
43
+	const Vehicles = self::MAIN_HOST . "/vehicles";
44
+	const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign";
45
+	const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute";
46
+	const VehicleLocation = self::MAIN_HOST . "/vehicles/location";
47
+	const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles";
48
+	const VehicleLicense = self::MAIN_HOST . "/vehicles/license";
49
+	const VehicleSearch = self::MAIN_HOST . "/vehicles/search";
50
+
51
+	const RECURRING_ROUTES = self::MAIN_HOST . "/recurring-routes";
52
+	const RECURRING_ROUTES_SCHEDULES = self::MAIN_HOST . "/recurring-routes/schedules";
53
+	const RECURRING_ROUTES_SCHEDULES_PAGINATION = self::MAIN_HOST . "/recurring-routes/schedules/pagination";
54
+	const RECURRING_ROUTES_ROUTE_SCHEDULES = self::MAIN_HOST . "/recurring-routes/route-schedules";
55
+	const RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION =
56
+		self::MAIN_HOST . "/recurring-routes/route-schedules/pagination";
57
+	const RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE = self::MAIN_HOST . "/recurring-routes/route-schedules/replace";
58
+	const RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY = self::MAIN_HOST . "/recurring-routes/scheduled-routes/is-copy";
59
+	const RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES =
60
+		self::MAIN_HOST . "/recurring-routes/scheduled-routes/get-copies";
61
+	const RECURRING_ROUTES_MASTER_ROUTES = self::MAIN_HOST . "/recurring-routes/master-routes";
62
+
63
+	// </editor-fold>
64 64
  
65
-    // <editor-fold defaultstate="collapsed" desc="Telematicx Platform">
65
+	// <editor-fold defaultstate="collapsed" desc="Telematicx Platform">
66 66
     
67
-        const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0";
67
+		const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0";
68 68
 
69
-        const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections";
70
-        const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles";
69
+		const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections";
70
+		const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles";
71 71
 
72
-        const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens";
73
-        const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules";
74
-        const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items";
72
+		const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens";
73
+		const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules";
74
+		const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items";
75 75
 
76
-        const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups";
77
-        const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}";
78
-        const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}";
76
+		const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups";
77
+		const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}";
78
+		const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}";
79 79
 
80
-        const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members";
81
-        const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles";
82
-        const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track";
83
-        const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members";
80
+		const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members";
81
+		const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles";
82
+		const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track";
83
+		const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members";
84 84
 
85
-        const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses";
85
+		const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses";
86 86
 
87
-        const TELEMATICS_Errors = self::STAGING_HOST . "/errors";
87
+		const TELEMATICS_Errors = self::STAGING_HOST . "/errors";
88 88
 
89
-        const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "​/customers​/{customer_id}​/notifications​";
90
-        const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers";
91
-        const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}";
89
+		const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "​/customers​/{customer_id}​/notifications​";
90
+		const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers";
91
+		const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}";
92 92
 
93
-        const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items";
94
-        const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules";
95
-        const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}";
96
-        const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "​/one-time-notifications";
93
+		const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items";
94
+		const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules";
95
+		const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}";
96
+		const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "​/one-time-notifications";
97 97
 
98
-        const TELEMATICS_MEMBER = self::STAGING_HOST;
98
+		const TELEMATICS_MEMBER = self::STAGING_HOST;
99 99
 
100
-        const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "​/user-activated-modules";
100
+		const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "​/user-activated-modules";
101 101
 
102
-        const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "​/user-activated-modules/{module_id}";
103
-        const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "​​/user-activated-modules​/{module_id}​/vehicles";
104
-        const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "​​​/user-activated-modules​/{module_id}​/vehicles​/{vehicle_id}";
102
+		const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "​/user-activated-modules/{module_id}";
103
+		const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "​​/user-activated-modules​/{module_id}​/vehicles";
104
+		const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "​​​/user-activated-modules​/{module_id}​/vehicles​/{vehicle_id}";
105 105
 
106
-        const TELEMATICS_VENDORS = self::STAGING_HOST . "​/vendors";
107
-        const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "​​/vendors​/{vendor_id}";
106
+		const TELEMATICS_VENDORS = self::STAGING_HOST . "​/vendors";
107
+		const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "​​/vendors​/{vendor_id}";
108 108
     
109
-    // </editor-fold>
109
+	// </editor-fold>
110 110
 }
111 111
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 1 patch
Indentation   +317 added lines, -317 removed lines patch added patch discarded remove patch
@@ -7,321 +7,321 @@
 block discarded – undo
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
-    public static function makeRequst($options)
34
-    {
35
-        $method = isset($options['method']) ? $options['method'] : 'GET';
36
-        $query = isset($options['query'])
37
-            ? array_filter($options['query'], function ($x) {
38
-                return !is_null($x);
39
-            }) : [];
40
-
41
-        $body = isset($options['body']) ? $options['body'] : null;
42
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
43
-        $headers = [
44
-            'User-Agent: Route4Me php-sdk',
45
-        ];
46
-
47
-        if (isset($options['HTTPHEADER'])) {
48
-            $headers[] = $options['HTTPHEADER'];
49
-        }
50
-
51
-        if (isset($options['HTTPHEADERS'])) {
52
-            foreach ($options['HTTPHEADERS'] as $header) {
53
-                $headers[] = $header;
54
-            }
55
-        }
56
-
57
-        $ch = curl_init();
58
-
59
-        $url = isset($options['url'])
60
-            ? $options['url'] . '?' . http_build_query(array_merge(
61
-                $query,
62
-                ['api_key' => self::getApiKey()]
63
-            )) : '';
64
-
65
-        $baseUrl = self::getBaseUrl();
66
-
67
-        $curlOpts = [
68
-            CURLOPT_URL             => $baseUrl.$url,
69
-            CURLOPT_RETURNTRANSFER  => true,
70
-            CURLOPT_TIMEOUT         => 120,
71
-            CURLOPT_FOLLOWLOCATION  => true,
72
-            CURLOPT_SSL_VERIFYHOST  => false,
73
-            CURLOPT_SSL_VERIFYPEER  => false,
74
-            CURLOPT_HTTPHEADER      => $headers,
75
-        ];
76
-
77
-        curl_setopt_array($ch, $curlOpts);
78
-
79
-        if (null != $file) {
80
-            $cfile = new \CURLFile($file, '', '');
81
-            $body['strFilename']=$cfile;
82
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
83
-            curl_setopt($ch, CURLOPT_POST, true);
84
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
85
-        } else {
86
-            switch ($method) {
87
-                case 'DELETE':
88
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
89
-                    break;
90
-                case 'DELETEARRAY':
91
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
92
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
93
-                    break;
94
-                case 'PUT':
95
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
96
-                    break;
97
-                case 'POST':
98
-                    if (isset($body)) {
99
-                        $bodyData = json_encode($body);
100
-                        if (isset($options['HTTPHEADER'])) {
101
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
102
-                                $bodyData = $body;
103
-                            }
104
-                        }
105
-
106
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
107
-                    }
108
-                    break;
109
-                case 'ADD':
110
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
111
-                    break;
112
-                case 'PATCH':
113
-                    if (isset($body)) {
114
-                        $bodyData = json_encode($body);
115
-                        if (isset($options['HTTPHEADER'])) {
116
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
117
-                                $bodyData = $body;
118
-                            }
119
-                        }
120
-                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
121
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
122
-                    }
123
-                    break;
124
-            }
125
-
126
-            if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
127
-                if (isset($body)) {
128
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
129
-                }
130
-            }
131
-        }
132
-
133
-        $result = curl_exec($ch);
134
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
135
-        curl_close($ch);
136
-
137
-        $json = null;
138
-        if (strpos($result, '<?xml') > -1) {
139
-            $xml = simplexml_load_string($result);
140
-            $json = self::object2array($xml);
141
-        } else {
142
-            $json = json_decode($result, true);
143
-        }
144
-
145
-        if (200 == $code || 202 == $code) {
146
-            if (isset($json['errors'])) {
147
-                throw new ApiError(implode(', ', $json['errors']), $code, $result);
148
-            } else {
149
-                return $json;
150
-            }
151
-        } elseif (isset($code) && (!isset($result) || !$result)) {
152
-            throw new ApiError('', $code, $result);
153
-        } else {
154
-            if (isset($json['messages'])) {
155
-                $msg = '';
156
-                foreach ($json['messages'] as $key => $value) {
157
-                    if ($msg !== '') {
158
-                        $msg .= PHP_EOL;
159
-                    }
160
-                    $msg .= $key . ': ' . implode(', ', $value);
161
-                }
162
-                throw new ApiError($msg, $code, $result);
163
-            } elseif (isset($json['errors'])) {
164
-                $msg = '';
165
-                foreach ($json['errors'] as $key => $value) {
166
-                    if ($msg !== '') {
167
-                        $msg .= PHP_EOL;
168
-                    }
169
-                    $msg .= $value;
170
-                }
171
-                throw new ApiError($msg, $code, $result);
172
-            } else {
173
-                throw new ApiError($result, $code, $result);
174
-            }
175
-        }
176
-    }
177
-
178
-    /**
179
-     * @param $object: JSON object
180
-     */
181
-    public static function object2array($object)
182
-    {
183
-        return @json_decode(@json_encode($object), 1);
184
-    }
185
-
186
-    /**
187
-     * Prints on the screen main keys and values of the array.
188
-     *
189
-     * @param $results: object to be printed on the screen
190
-     * @param $deepPrinting: if true, object will be printed recursively
191
-     */
192
-    public static function simplePrint($results, $deepPrinting = null)
193
-    {
194
-        if (isset($results)) {
195
-            if (is_array($results)) {
196
-                foreach ($results as $key => $result) {
197
-                    if (is_array($result)) {
198
-                        foreach ($result as $key1 => $result1) {
199
-                            if (is_array($result1)) {
200
-                                if ($deepPrinting) {
201
-                                    echo "<br>$key1 ------><br>";
202
-                                    self::simplePrint($result1, true);
203
-                                    echo '------<br>';
204
-                                } else {
205
-                                    echo $key1.' --> '.'Array() <br>';
206
-                                }
207
-                            } else {
208
-                                if (is_object($result1)) {
209
-                                    if ($deepPrinting) {
210
-                                        echo "<br>$key1 ------><br>";
211
-                                        $oarray = (array) $result1;
212
-                                        self::simplePrint($oarray, true);
213
-                                        echo '------<br>';
214
-                                    } else {
215
-                                        echo $key1.' --> '.'Object <br>';
216
-                                    }
217
-                                } else {
218
-                                    if (!is_null($result1)) {
219
-                                        echo $key1.' --> '.$result1.'<br>';
220
-                                    }
221
-                                }
222
-                            }
223
-                        }
224
-                    } else {
225
-                        if (is_object($result)) {
226
-                            if ($deepPrinting) {
227
-                                echo "<br>$key ------><br>";
228
-                                $oarray = (array) $result;
229
-                                self::simplePrint($oarray, true);
230
-                                echo '------<br>';
231
-                            } else {
232
-                                echo $key.' --> '.'Object <br>';
233
-                            }
234
-                        } else {
235
-                            if (!is_null($result)) {
236
-                                echo $key.' --> '.$result.'<br>';
237
-                            }
238
-                        }
239
-                    }
240
-                    //echo "<br>";
241
-                }
242
-            }
243
-        }
244
-    }
245
-
246
-    /**
247
-     * Generates query or body parameters.
248
-     *
249
-     * @param $allFields: all known fields could be used for parameters generation
250
-     * @param $params: input parameters (array or object)
251
-     */
252
-    public static function generateRequestParameters($allFields, $params)
253
-    {
254
-        $generatedParams = [];
255
-
256
-        if (is_array($params)) {
257
-            foreach ($allFields as $field) {
258
-                if (isset($params[$field])) {
259
-                    $generatedParams[$field] = $params[$field];
260
-                }
261
-            }
262
-        } elseif (is_object($params)) {
263
-            foreach ($allFields as $field) {
264
-                if (isset($params->{$field})) {
265
-                    $generatedParams[$field] = $params->{$field};
266
-                }
267
-            }
268
-        }
269
-
270
-        return $generatedParams;
271
-    }
272
-
273
-    /**
274
-     * Returns an array of the object properties.
275
-     *
276
-     * @param $object: An object
277
-     * @param $exclude: array of the object parameters to be excluded from the returned array
278
-     */
279
-    public static function getObjectProperties($object, $exclude)
280
-    {
281
-        $objectParameters = [];
282
-
283
-        foreach (get_object_vars($object) as $key => $value) {
284
-            if (property_exists($object, $key)) {
285
-                if (!is_numeric(array_search($key, $exclude))) {
286
-                    array_push($objectParameters, $key);
287
-                }
288
-            }
289
-        }
290
-
291
-        return $objectParameters;
292
-    }
293
-
294
-    /**
295
-     * Returns url path generated from the array of the fields and parameters.
296
-     *
297
-     * @param $allFields; array of the paossible fields (parameter names)
298
-     * @param $params: input parameters (array or object)
299
-     */
300
-    public static function generateUrlPath($allFields, $params)
301
-    {
302
-        $generatedPath = '';
303
-
304
-        if (is_array($params)) {
305
-            foreach ($allFields as $field) {
306
-                if (isset($params[$field])) {
307
-                    $generatedPath .= $params[$field].'/';
308
-                }
309
-            }
310
-        } elseif (is_object($params)) {
311
-            foreach ($allFields as $field) {
312
-                if (isset($params->{$field})) {
313
-                    $generatedPath .= $params->{$field}.'/';
314
-                }
315
-            }
316
-        }
317
-
318
-        return $generatedPath;
319
-    }
320
-
321
-    public static function getFileRealPath($fileName)
322
-    {
323
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
324
-
325
-        return $rpath;
326
-    }
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
+	public static function makeRequst($options)
34
+	{
35
+		$method = isset($options['method']) ? $options['method'] : 'GET';
36
+		$query = isset($options['query'])
37
+			? array_filter($options['query'], function ($x) {
38
+				return !is_null($x);
39
+			}) : [];
40
+
41
+		$body = isset($options['body']) ? $options['body'] : null;
42
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
43
+		$headers = [
44
+			'User-Agent: Route4Me php-sdk',
45
+		];
46
+
47
+		if (isset($options['HTTPHEADER'])) {
48
+			$headers[] = $options['HTTPHEADER'];
49
+		}
50
+
51
+		if (isset($options['HTTPHEADERS'])) {
52
+			foreach ($options['HTTPHEADERS'] as $header) {
53
+				$headers[] = $header;
54
+			}
55
+		}
56
+
57
+		$ch = curl_init();
58
+
59
+		$url = isset($options['url'])
60
+			? $options['url'] . '?' . http_build_query(array_merge(
61
+				$query,
62
+				['api_key' => self::getApiKey()]
63
+			)) : '';
64
+
65
+		$baseUrl = self::getBaseUrl();
66
+
67
+		$curlOpts = [
68
+			CURLOPT_URL             => $baseUrl.$url,
69
+			CURLOPT_RETURNTRANSFER  => true,
70
+			CURLOPT_TIMEOUT         => 120,
71
+			CURLOPT_FOLLOWLOCATION  => true,
72
+			CURLOPT_SSL_VERIFYHOST  => false,
73
+			CURLOPT_SSL_VERIFYPEER  => false,
74
+			CURLOPT_HTTPHEADER      => $headers,
75
+		];
76
+
77
+		curl_setopt_array($ch, $curlOpts);
78
+
79
+		if (null != $file) {
80
+			$cfile = new \CURLFile($file, '', '');
81
+			$body['strFilename']=$cfile;
82
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
83
+			curl_setopt($ch, CURLOPT_POST, true);
84
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
85
+		} else {
86
+			switch ($method) {
87
+				case 'DELETE':
88
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
89
+					break;
90
+				case 'DELETEARRAY':
91
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
92
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
93
+					break;
94
+				case 'PUT':
95
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
96
+					break;
97
+				case 'POST':
98
+					if (isset($body)) {
99
+						$bodyData = json_encode($body);
100
+						if (isset($options['HTTPHEADER'])) {
101
+							if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
102
+								$bodyData = $body;
103
+							}
104
+						}
105
+
106
+						curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
107
+					}
108
+					break;
109
+				case 'ADD':
110
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
111
+					break;
112
+				case 'PATCH':
113
+					if (isset($body)) {
114
+						$bodyData = json_encode($body);
115
+						if (isset($options['HTTPHEADER'])) {
116
+							if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
117
+								$bodyData = $body;
118
+							}
119
+						}
120
+						curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
121
+						curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
122
+					}
123
+					break;
124
+			}
125
+
126
+			if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
127
+				if (isset($body)) {
128
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
129
+				}
130
+			}
131
+		}
132
+
133
+		$result = curl_exec($ch);
134
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
135
+		curl_close($ch);
136
+
137
+		$json = null;
138
+		if (strpos($result, '<?xml') > -1) {
139
+			$xml = simplexml_load_string($result);
140
+			$json = self::object2array($xml);
141
+		} else {
142
+			$json = json_decode($result, true);
143
+		}
144
+
145
+		if (200 == $code || 202 == $code) {
146
+			if (isset($json['errors'])) {
147
+				throw new ApiError(implode(', ', $json['errors']), $code, $result);
148
+			} else {
149
+				return $json;
150
+			}
151
+		} elseif (isset($code) && (!isset($result) || !$result)) {
152
+			throw new ApiError('', $code, $result);
153
+		} else {
154
+			if (isset($json['messages'])) {
155
+				$msg = '';
156
+				foreach ($json['messages'] as $key => $value) {
157
+					if ($msg !== '') {
158
+						$msg .= PHP_EOL;
159
+					}
160
+					$msg .= $key . ': ' . implode(', ', $value);
161
+				}
162
+				throw new ApiError($msg, $code, $result);
163
+			} elseif (isset($json['errors'])) {
164
+				$msg = '';
165
+				foreach ($json['errors'] as $key => $value) {
166
+					if ($msg !== '') {
167
+						$msg .= PHP_EOL;
168
+					}
169
+					$msg .= $value;
170
+				}
171
+				throw new ApiError($msg, $code, $result);
172
+			} else {
173
+				throw new ApiError($result, $code, $result);
174
+			}
175
+		}
176
+	}
177
+
178
+	/**
179
+	 * @param $object: JSON object
180
+	 */
181
+	public static function object2array($object)
182
+	{
183
+		return @json_decode(@json_encode($object), 1);
184
+	}
185
+
186
+	/**
187
+	 * Prints on the screen main keys and values of the array.
188
+	 *
189
+	 * @param $results: object to be printed on the screen
190
+	 * @param $deepPrinting: if true, object will be printed recursively
191
+	 */
192
+	public static function simplePrint($results, $deepPrinting = null)
193
+	{
194
+		if (isset($results)) {
195
+			if (is_array($results)) {
196
+				foreach ($results as $key => $result) {
197
+					if (is_array($result)) {
198
+						foreach ($result as $key1 => $result1) {
199
+							if (is_array($result1)) {
200
+								if ($deepPrinting) {
201
+									echo "<br>$key1 ------><br>";
202
+									self::simplePrint($result1, true);
203
+									echo '------<br>';
204
+								} else {
205
+									echo $key1.' --> '.'Array() <br>';
206
+								}
207
+							} else {
208
+								if (is_object($result1)) {
209
+									if ($deepPrinting) {
210
+										echo "<br>$key1 ------><br>";
211
+										$oarray = (array) $result1;
212
+										self::simplePrint($oarray, true);
213
+										echo '------<br>';
214
+									} else {
215
+										echo $key1.' --> '.'Object <br>';
216
+									}
217
+								} else {
218
+									if (!is_null($result1)) {
219
+										echo $key1.' --> '.$result1.'<br>';
220
+									}
221
+								}
222
+							}
223
+						}
224
+					} else {
225
+						if (is_object($result)) {
226
+							if ($deepPrinting) {
227
+								echo "<br>$key ------><br>";
228
+								$oarray = (array) $result;
229
+								self::simplePrint($oarray, true);
230
+								echo '------<br>';
231
+							} else {
232
+								echo $key.' --> '.'Object <br>';
233
+							}
234
+						} else {
235
+							if (!is_null($result)) {
236
+								echo $key.' --> '.$result.'<br>';
237
+							}
238
+						}
239
+					}
240
+					//echo "<br>";
241
+				}
242
+			}
243
+		}
244
+	}
245
+
246
+	/**
247
+	 * Generates query or body parameters.
248
+	 *
249
+	 * @param $allFields: all known fields could be used for parameters generation
250
+	 * @param $params: input parameters (array or object)
251
+	 */
252
+	public static function generateRequestParameters($allFields, $params)
253
+	{
254
+		$generatedParams = [];
255
+
256
+		if (is_array($params)) {
257
+			foreach ($allFields as $field) {
258
+				if (isset($params[$field])) {
259
+					$generatedParams[$field] = $params[$field];
260
+				}
261
+			}
262
+		} elseif (is_object($params)) {
263
+			foreach ($allFields as $field) {
264
+				if (isset($params->{$field})) {
265
+					$generatedParams[$field] = $params->{$field};
266
+				}
267
+			}
268
+		}
269
+
270
+		return $generatedParams;
271
+	}
272
+
273
+	/**
274
+	 * Returns an array of the object properties.
275
+	 *
276
+	 * @param $object: An object
277
+	 * @param $exclude: array of the object parameters to be excluded from the returned array
278
+	 */
279
+	public static function getObjectProperties($object, $exclude)
280
+	{
281
+		$objectParameters = [];
282
+
283
+		foreach (get_object_vars($object) as $key => $value) {
284
+			if (property_exists($object, $key)) {
285
+				if (!is_numeric(array_search($key, $exclude))) {
286
+					array_push($objectParameters, $key);
287
+				}
288
+			}
289
+		}
290
+
291
+		return $objectParameters;
292
+	}
293
+
294
+	/**
295
+	 * Returns url path generated from the array of the fields and parameters.
296
+	 *
297
+	 * @param $allFields; array of the paossible fields (parameter names)
298
+	 * @param $params: input parameters (array or object)
299
+	 */
300
+	public static function generateUrlPath($allFields, $params)
301
+	{
302
+		$generatedPath = '';
303
+
304
+		if (is_array($params)) {
305
+			foreach ($allFields as $field) {
306
+				if (isset($params[$field])) {
307
+					$generatedPath .= $params[$field].'/';
308
+				}
309
+			}
310
+		} elseif (is_object($params)) {
311
+			foreach ($allFields as $field) {
312
+				if (isset($params->{$field})) {
313
+					$generatedPath .= $params->{$field}.'/';
314
+				}
315
+			}
316
+		}
317
+
318
+		return $generatedPath;
319
+	}
320
+
321
+	public static function getFileRealPath($fileName)
322
+	{
323
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
324
+
325
+		return $rpath;
326
+	}
327 327
 }
Please login to merge, or discard this patch.
examples/TeamManagement/CreateSubUser.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -18,37 +18,37 @@
 block discarded – undo
18 18
 Route4Me::setApiKey(Constants::API_KEY);
19 19
 
20 20
 try {
21
-    // get OWNER_MEMBER_ID
22
-    $owner_member_id = null;
23
-    $member = new Member();
24
-    $res_members = $member->getUsers();
25
-
26
-    if (is_array($res_members) && isset($res_members['results'])) {
27
-        foreach ($res_members['results'] as $key => $value) {
28
-            if ($value['OWNER_MEMBER_ID'] == 0) {
29
-                $owner_member_id = $value['member_id'];
30
-                break;
31
-            }
32
-        }
33
-    }
34
-
35
-    if (!$owner_member_id) {
36
-        throw new Exception("Cannot find OWNER_MEMBER_ID.");
37
-    }
38
-
39
-    // new sub-user
40
-    $params = [
41
-        'new_password' => '12345#Tusha',
42
-        'member_first_name' => 'Tusha I',
43
-        'member_last_name' => 'Pupkindzes',
44
-        'member_email' => '[email protected]',
45
-        'member_type' => 'SUB_ACCOUNT_DRIVER',
46
-        'OWNER_MEMBER_ID' => $owner_member_id
47
-    ];
48
-
49
-    $tm = new TeamManagement();
50
-    $res = $tm->create($params);
51
-    print_r($res);
21
+	// get OWNER_MEMBER_ID
22
+	$owner_member_id = null;
23
+	$member = new Member();
24
+	$res_members = $member->getUsers();
25
+
26
+	if (is_array($res_members) && isset($res_members['results'])) {
27
+		foreach ($res_members['results'] as $key => $value) {
28
+			if ($value['OWNER_MEMBER_ID'] == 0) {
29
+				$owner_member_id = $value['member_id'];
30
+				break;
31
+			}
32
+		}
33
+	}
34
+
35
+	if (!$owner_member_id) {
36
+		throw new Exception("Cannot find OWNER_MEMBER_ID.");
37
+	}
38
+
39
+	// new sub-user
40
+	$params = [
41
+		'new_password' => '12345#Tusha',
42
+		'member_first_name' => 'Tusha I',
43
+		'member_last_name' => 'Pupkindzes',
44
+		'member_email' => '[email protected]',
45
+		'member_type' => 'SUB_ACCOUNT_DRIVER',
46
+		'OWNER_MEMBER_ID' => $owner_member_id
47
+	];
48
+
49
+	$tm = new TeamManagement();
50
+	$res = $tm->create($params);
51
+	print_r($res);
52 52
 } catch (Exception | ApiError $e) {
53
-    echo $e->getMessage() . PHP_EOL;
53
+	echo $e->getMessage() . PHP_EOL;
54 54
 }
Please login to merge, or discard this patch.
examples/TeamManagement/GetSubUser.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@
 block discarded – undo
18 18
 $userId = 2565363;
19 19
 
20 20
 try {
21
-    $tm = new TeamManagement();
22
-    $res = $tm->getUser($userId);
23
-    print_r($res);
21
+	$tm = new TeamManagement();
22
+	$res = $tm->getUser($userId);
23
+	print_r($res);
24 24
 } catch (ApiError $e) {
25
-    echo 'Cannot get user with ID: ' . $userId . PHP_EOL;
25
+	echo 'Cannot get user with ID: ' . $userId . PHP_EOL;
26 26
 }
Please login to merge, or discard this patch.