@@ -7,11 +7,11 @@ |
||
7 | 7 | class Respond extends Facade { |
8 | 8 | |
9 | 9 | |
10 | - /** |
|
11 | - * Get the registered name of the component. |
|
12 | - * |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - protected static function getFacadeAccessor() { return 'Anetwork\Respond\Messages'; } |
|
10 | + /** |
|
11 | + * Get the registered name of the component. |
|
12 | + * |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + protected static function getFacadeAccessor() { return 'Anetwork\Respond\Messages'; } |
|
16 | 16 | |
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -6,44 +6,44 @@ |
||
6 | 6 | |
7 | 7 | class RespondServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | 16 | |
17 | - $lang = \App::getLocale(); |
|
17 | + $lang = \App::getLocale(); |
|
18 | 18 | |
19 | - $this->publishes([ |
|
20 | - __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
21 | - ]); |
|
19 | + $this->publishes([ |
|
20 | + __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
21 | + ]); |
|
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Register any package services. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function register() |
|
32 | - { |
|
26 | + /** |
|
27 | + * Register any package services. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function register() |
|
32 | + { |
|
33 | 33 | |
34 | - $this->registerMessages(); |
|
34 | + $this->registerMessages(); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | - private function registerMessages() |
|
39 | - { |
|
38 | + private function registerMessages() |
|
39 | + { |
|
40 | 40 | |
41 | - $this->app->bind( 'Anetwork\Respond\Messages', function() { |
|
41 | + $this->app->bind( 'Anetwork\Respond\Messages', function() { |
|
42 | 42 | |
43 | - return new Messages(); |
|
43 | + return new Messages(); |
|
44 | 44 | |
45 | - }); |
|
45 | + }); |
|
46 | 46 | |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -2,196 +2,196 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - 'success' => [ |
|
6 | - |
|
7 | - 'insert' => 'The requested parameter is Added successfully!', |
|
8 | - |
|
9 | - 'delete' => 'The requested parameter is deleted successfully!', |
|
10 | - |
|
11 | - 'update' => 'The requested parameter is updated successfully!' |
|
12 | - |
|
13 | - ], |
|
14 | - |
|
15 | - 'fail' => [ |
|
16 | - |
|
17 | - 'insert' => 'The requested parameter is not Added!', |
|
18 | - |
|
19 | - 'delete' => 'The requested parameter is not deleted!', |
|
20 | - |
|
21 | - 'update' => 'The requested parameter is not updated!' |
|
22 | - |
|
23 | - ], |
|
24 | - |
|
25 | - 1001 => [ |
|
26 | - 'message' => 'Oops... Requested field is not found!', |
|
27 | - 'type' => 'error' |
|
28 | - ], |
|
29 | - |
|
30 | - 1002 => [ |
|
31 | - 'message' => 'Oops... Requested User does not exists!', |
|
32 | - 'type' => 'error' |
|
33 | - ], |
|
34 | - |
|
35 | - 1003 => [ |
|
36 | - 'message' => 'Oops... Client type is not entered!', |
|
37 | - 'type' => 'error' |
|
38 | - ], |
|
39 | - |
|
40 | - 1004 => [ |
|
41 | - 'message' => 'Failed because of duplicate', |
|
42 | - 'type' => 'error' |
|
43 | - ], |
|
44 | - |
|
45 | - 1005 => [ |
|
46 | - 'message' => 'Failed because of dablicated user role', |
|
47 | - 'type' => 'error' |
|
48 | - ], |
|
49 | - |
|
50 | - 3001 => [ |
|
51 | - 'message' => 'You are not logged on', |
|
52 | - 'type' => 'error', |
|
53 | - 'cat' => 'auth', |
|
54 | - 'short' => 'not-logged-on' |
|
55 | - ], |
|
56 | - |
|
57 | - 3002 => [ |
|
58 | - 'message' => 'Application token did not generated successfully', |
|
59 | - 'type' => 'error', |
|
60 | - 'cat' => 'auth' |
|
61 | - ], |
|
62 | - |
|
63 | - 3003 =>[ |
|
64 | - 'message' => 'User token did not generated successfully', |
|
65 | - 'type' => 'error', |
|
66 | - 'cat' => 'auth' |
|
67 | - ], |
|
68 | - |
|
69 | - 3004 => [ |
|
70 | - 'message' => 'Request token have no agency access', |
|
71 | - 'type' => 'error', |
|
72 | - 'cat' => 'auth' |
|
73 | - ], |
|
74 | - |
|
75 | - 3005 => [ |
|
76 | - 'message' => 'Request token did not contains user information', |
|
77 | - 'type' => 'error', |
|
78 | - 'cat' => 'auth' |
|
79 | - ], |
|
80 | - |
|
81 | - 3006 => [ |
|
82 | - 'message' => 'Did not set request token', |
|
83 | - 'type' => 'error', |
|
84 | - 'cat' => 'auth' |
|
85 | - ], |
|
86 | - |
|
87 | - 3007 => [ |
|
88 | - 'message' => 'can not decode the token', |
|
89 | - 'type' => 'error', |
|
90 | - 'cat' => 'auth' |
|
91 | - ], |
|
92 | - |
|
93 | - 3008 => [ |
|
94 | - 'message' => 'can not generate token for authentication', |
|
95 | - 'type' => 'error', |
|
96 | - 'cat' => 'auth' |
|
97 | - ], |
|
98 | - |
|
99 | - 3009 => [ |
|
100 | - 'message' => 'can not create token', |
|
101 | - 'type' => 'error', |
|
102 | - 'cat' => 'auth' |
|
103 | - ], |
|
104 | - |
|
105 | - 3010 => [ |
|
106 | - 'message' => 'Token expired!', |
|
107 | - 'type' => 'error', |
|
108 | - 'cat' => 'auth' |
|
109 | - ], |
|
110 | - |
|
111 | - 3011 => [ |
|
112 | - 'message' => 'Token is invalid!', |
|
113 | - 'type' => 'error', |
|
114 | - 'cat' => 'auth' |
|
115 | - ], |
|
116 | - |
|
117 | - 3012 => [ |
|
118 | - 'message' => 'Token Blacklisted', |
|
119 | - 'type' => 'error', |
|
120 | - 'cat' => 'auth' |
|
121 | - ], |
|
122 | - |
|
123 | - 3013 => [ |
|
124 | - 'message' => 'Payload invalid!', |
|
125 | - 'type' => 'error', |
|
126 | - 'cat' => 'auth' |
|
127 | - ], |
|
128 | - |
|
129 | - 3014 => [ |
|
130 | - 'message' => 'Claim Invalid', |
|
131 | - 'type' => 'error', |
|
132 | - 'cat' => 'auth' |
|
133 | - ], |
|
134 | - |
|
135 | - 3015 => [ |
|
136 | - 'message' => 'An error occurred on token validation', |
|
137 | - 'type' => 'error', |
|
138 | - 'cat' => 'auth' |
|
139 | - ], |
|
140 | - |
|
141 | - 3016 => [ |
|
142 | - |
|
143 | - 'message' => 'This domain has been blocked', |
|
144 | - 'type' => 'error' |
|
145 | - ], |
|
146 | - |
|
147 | - 5401 => [ |
|
148 | - 'message' => 'Authentication unauthorized...', |
|
149 | - 'type' => 'error' |
|
150 | - ], |
|
151 | - |
|
152 | - 5404 => [ |
|
153 | - 'message' => 'Oops... The requested page not found!', |
|
154 | - 'type' => 'error' |
|
155 | - ], |
|
156 | - |
|
157 | - 5405 => [ |
|
158 | - 'message' => 'Oops... The method you requested is not allowed!', |
|
159 | - 'type' => 'error' |
|
160 | - ], |
|
161 | - |
|
162 | - 5406 => [ |
|
163 | - 'message' => 'Oops... The parameters you entered are wrong!', |
|
164 | - 'type' => 'error' |
|
165 | - ], |
|
166 | - |
|
167 | - 5420 => [ |
|
168 | - 'message' => 'Validation Error', |
|
169 | - 'type' => 'error' |
|
170 | - ], |
|
171 | - |
|
172 | - 5422 => [ |
|
173 | - 'message' => 'Token is not valid', |
|
174 | - 'type' => 'error' |
|
175 | - ], |
|
176 | - |
|
177 | - 5445 => [ |
|
178 | - 'message' => 'Oops... Database connection refused', |
|
179 | - 'type' => 'error' |
|
180 | - ], |
|
181 | - |
|
182 | - 5448 => [ |
|
183 | - 'message' => 'Oops... Insert action was not successfully executed', |
|
184 | - 'type' => 'error' |
|
185 | - ], |
|
186 | - |
|
187 | - 5447 => [ |
|
188 | - 'message' => 'Oops... Delete action was not successfully executed', |
|
189 | - 'type' => 'error' |
|
190 | - ], |
|
191 | - |
|
192 | - 5449 => [ |
|
193 | - 'message' => 'Oops... Update action was not successfully executed', |
|
194 | - 'type' => 'error' |
|
195 | - ] |
|
5 | + 'success' => [ |
|
6 | + |
|
7 | + 'insert' => 'The requested parameter is Added successfully!', |
|
8 | + |
|
9 | + 'delete' => 'The requested parameter is deleted successfully!', |
|
10 | + |
|
11 | + 'update' => 'The requested parameter is updated successfully!' |
|
12 | + |
|
13 | + ], |
|
14 | + |
|
15 | + 'fail' => [ |
|
16 | + |
|
17 | + 'insert' => 'The requested parameter is not Added!', |
|
18 | + |
|
19 | + 'delete' => 'The requested parameter is not deleted!', |
|
20 | + |
|
21 | + 'update' => 'The requested parameter is not updated!' |
|
22 | + |
|
23 | + ], |
|
24 | + |
|
25 | + 1001 => [ |
|
26 | + 'message' => 'Oops... Requested field is not found!', |
|
27 | + 'type' => 'error' |
|
28 | + ], |
|
29 | + |
|
30 | + 1002 => [ |
|
31 | + 'message' => 'Oops... Requested User does not exists!', |
|
32 | + 'type' => 'error' |
|
33 | + ], |
|
34 | + |
|
35 | + 1003 => [ |
|
36 | + 'message' => 'Oops... Client type is not entered!', |
|
37 | + 'type' => 'error' |
|
38 | + ], |
|
39 | + |
|
40 | + 1004 => [ |
|
41 | + 'message' => 'Failed because of duplicate', |
|
42 | + 'type' => 'error' |
|
43 | + ], |
|
44 | + |
|
45 | + 1005 => [ |
|
46 | + 'message' => 'Failed because of dablicated user role', |
|
47 | + 'type' => 'error' |
|
48 | + ], |
|
49 | + |
|
50 | + 3001 => [ |
|
51 | + 'message' => 'You are not logged on', |
|
52 | + 'type' => 'error', |
|
53 | + 'cat' => 'auth', |
|
54 | + 'short' => 'not-logged-on' |
|
55 | + ], |
|
56 | + |
|
57 | + 3002 => [ |
|
58 | + 'message' => 'Application token did not generated successfully', |
|
59 | + 'type' => 'error', |
|
60 | + 'cat' => 'auth' |
|
61 | + ], |
|
62 | + |
|
63 | + 3003 =>[ |
|
64 | + 'message' => 'User token did not generated successfully', |
|
65 | + 'type' => 'error', |
|
66 | + 'cat' => 'auth' |
|
67 | + ], |
|
68 | + |
|
69 | + 3004 => [ |
|
70 | + 'message' => 'Request token have no agency access', |
|
71 | + 'type' => 'error', |
|
72 | + 'cat' => 'auth' |
|
73 | + ], |
|
74 | + |
|
75 | + 3005 => [ |
|
76 | + 'message' => 'Request token did not contains user information', |
|
77 | + 'type' => 'error', |
|
78 | + 'cat' => 'auth' |
|
79 | + ], |
|
80 | + |
|
81 | + 3006 => [ |
|
82 | + 'message' => 'Did not set request token', |
|
83 | + 'type' => 'error', |
|
84 | + 'cat' => 'auth' |
|
85 | + ], |
|
86 | + |
|
87 | + 3007 => [ |
|
88 | + 'message' => 'can not decode the token', |
|
89 | + 'type' => 'error', |
|
90 | + 'cat' => 'auth' |
|
91 | + ], |
|
92 | + |
|
93 | + 3008 => [ |
|
94 | + 'message' => 'can not generate token for authentication', |
|
95 | + 'type' => 'error', |
|
96 | + 'cat' => 'auth' |
|
97 | + ], |
|
98 | + |
|
99 | + 3009 => [ |
|
100 | + 'message' => 'can not create token', |
|
101 | + 'type' => 'error', |
|
102 | + 'cat' => 'auth' |
|
103 | + ], |
|
104 | + |
|
105 | + 3010 => [ |
|
106 | + 'message' => 'Token expired!', |
|
107 | + 'type' => 'error', |
|
108 | + 'cat' => 'auth' |
|
109 | + ], |
|
110 | + |
|
111 | + 3011 => [ |
|
112 | + 'message' => 'Token is invalid!', |
|
113 | + 'type' => 'error', |
|
114 | + 'cat' => 'auth' |
|
115 | + ], |
|
116 | + |
|
117 | + 3012 => [ |
|
118 | + 'message' => 'Token Blacklisted', |
|
119 | + 'type' => 'error', |
|
120 | + 'cat' => 'auth' |
|
121 | + ], |
|
122 | + |
|
123 | + 3013 => [ |
|
124 | + 'message' => 'Payload invalid!', |
|
125 | + 'type' => 'error', |
|
126 | + 'cat' => 'auth' |
|
127 | + ], |
|
128 | + |
|
129 | + 3014 => [ |
|
130 | + 'message' => 'Claim Invalid', |
|
131 | + 'type' => 'error', |
|
132 | + 'cat' => 'auth' |
|
133 | + ], |
|
134 | + |
|
135 | + 3015 => [ |
|
136 | + 'message' => 'An error occurred on token validation', |
|
137 | + 'type' => 'error', |
|
138 | + 'cat' => 'auth' |
|
139 | + ], |
|
140 | + |
|
141 | + 3016 => [ |
|
142 | + |
|
143 | + 'message' => 'This domain has been blocked', |
|
144 | + 'type' => 'error' |
|
145 | + ], |
|
146 | + |
|
147 | + 5401 => [ |
|
148 | + 'message' => 'Authentication unauthorized...', |
|
149 | + 'type' => 'error' |
|
150 | + ], |
|
151 | + |
|
152 | + 5404 => [ |
|
153 | + 'message' => 'Oops... The requested page not found!', |
|
154 | + 'type' => 'error' |
|
155 | + ], |
|
156 | + |
|
157 | + 5405 => [ |
|
158 | + 'message' => 'Oops... The method you requested is not allowed!', |
|
159 | + 'type' => 'error' |
|
160 | + ], |
|
161 | + |
|
162 | + 5406 => [ |
|
163 | + 'message' => 'Oops... The parameters you entered are wrong!', |
|
164 | + 'type' => 'error' |
|
165 | + ], |
|
166 | + |
|
167 | + 5420 => [ |
|
168 | + 'message' => 'Validation Error', |
|
169 | + 'type' => 'error' |
|
170 | + ], |
|
171 | + |
|
172 | + 5422 => [ |
|
173 | + 'message' => 'Token is not valid', |
|
174 | + 'type' => 'error' |
|
175 | + ], |
|
176 | + |
|
177 | + 5445 => [ |
|
178 | + 'message' => 'Oops... Database connection refused', |
|
179 | + 'type' => 'error' |
|
180 | + ], |
|
181 | + |
|
182 | + 5448 => [ |
|
183 | + 'message' => 'Oops... Insert action was not successfully executed', |
|
184 | + 'type' => 'error' |
|
185 | + ], |
|
186 | + |
|
187 | + 5447 => [ |
|
188 | + 'message' => 'Oops... Delete action was not successfully executed', |
|
189 | + 'type' => 'error' |
|
190 | + ], |
|
191 | + |
|
192 | + 5449 => [ |
|
193 | + 'message' => 'Oops... Update action was not successfully executed', |
|
194 | + 'type' => 'error' |
|
195 | + ] |
|
196 | 196 | |
197 | 197 | ]; |
@@ -6,271 +6,271 @@ |
||
6 | 6 | { |
7 | 7 | |
8 | 8 | |
9 | - /** |
|
10 | - * Request succeeded and contains json result |
|
11 | - * @param array $data |
|
12 | - * @author Shima Payro <[email protected]> |
|
13 | - * @since May 2, 2016 9:50:51 AM |
|
14 | - * @uses |
|
15 | - * @see |
|
16 | - */ |
|
17 | - public function succeed( $data ) { |
|
18 | - |
|
19 | - return $this->setStatusCode( 200 ) |
|
20 | - ->setStatusText( 'success' ) |
|
21 | - ->respondWithResult( $data ); |
|
22 | - |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Delete action is succeed |
|
27 | - * @author Shima Payro <[email protected]> |
|
28 | - * @param String $message |
|
29 | - * @since May 2, 2016 9:52:05 AM |
|
30 | - * @uses |
|
31 | - * @see |
|
32 | - */ |
|
33 | - public function deleteSucceeded( $message = null ) { |
|
34 | - |
|
35 | - if ( is_null( $message ) ) |
|
36 | - $message = $this->config[ 'success' ][ 'delete' ]; |
|
37 | - |
|
38 | - return $this->setStatusCode( 200 ) |
|
39 | - ->setStatusText( 'success' ) |
|
40 | - ->respondWithMessage( $message ); |
|
41 | - |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Update action is succeed |
|
46 | - * @author Shima Payro <[email protected]> |
|
47 | - * @param String $message |
|
48 | - * @since May 2, 2016 9:52:52 AM |
|
49 | - * @uses |
|
50 | - * @see |
|
51 | - */ |
|
52 | - public function updateSucceeded( $message = null ) { |
|
53 | - |
|
54 | - if ( is_null( $message ) ) |
|
55 | - $message = $this->config[ 'success' ][ 'update' ]; |
|
56 | - |
|
57 | - return $this->setStatusCode( 200 ) |
|
58 | - ->setStatusText( 'success' ) |
|
59 | - ->respondWithMessage( $message ); |
|
60 | - |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Insert action is succeed |
|
65 | - * @author Shima Payro <[email protected]> |
|
66 | - * @param String $message |
|
67 | - * @since May 2, 2016 9:53:26 AM |
|
68 | - * @uses |
|
69 | - * @see |
|
70 | - */ |
|
71 | - public function insertSucceeded( $message = null ) { |
|
72 | - |
|
73 | - if ( is_null( $message ) ) |
|
74 | - $message = $this->config[ 'success' ][ 'insert' ]; |
|
75 | - |
|
76 | - return $this->setStatusCode( 200 ) |
|
77 | - ->setStatusText( 'success' ) |
|
78 | - ->respondWithMessage( $message ); |
|
79 | - |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Delete action is faild |
|
84 | - * @author Shima Payro <[email protected]> |
|
85 | - * @param String $message |
|
86 | - * @since May 2, 2016 9:53:53 AM |
|
87 | - * @uses |
|
88 | - * @see |
|
89 | - */ |
|
90 | - public function deleteFaild( $message = null ) { |
|
91 | - |
|
92 | - if ( is_null( $message ) ) |
|
93 | - $message = $this->config[ 'fail' ][ 'delete' ]; |
|
94 | - |
|
95 | - return $this->setStatusCode( 447 ) |
|
96 | - ->setStatusText( 'fail' ) |
|
97 | - ->setErrorCode( 5447 ) |
|
98 | - ->respondWithMessage( $message ); |
|
99 | - |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Update action is succeed |
|
104 | - * @author Shima Payro <[email protected]> |
|
105 | - * @param String $message |
|
106 | - * @since May 2, 2016 9:54:09 AM |
|
107 | - * @uses |
|
108 | - * @see |
|
109 | - */ |
|
110 | - public function updateFaild( $message = null ) { |
|
111 | - |
|
112 | - if ( is_null( $message ) ) |
|
113 | - $message = $this->config[ 'fail' ][ 'update' ]; |
|
114 | - |
|
115 | - return $this->setStatusCode( 449 ) |
|
116 | - ->setStatusText( 'fail' ) |
|
117 | - ->setErrorCode( 5449 ) |
|
118 | - ->respondWithMessage( $message ); |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Insert action is faild |
|
124 | - * @author Shima Payro <[email protected]> |
|
125 | - * @param String $message |
|
126 | - * @since May 2, 2016 9:54:27 AM |
|
127 | - * @uses |
|
128 | - * @see |
|
129 | - */ |
|
130 | - public function insertFaild( $message = null ) { |
|
131 | - |
|
132 | - if ( is_null( $message ) ) |
|
133 | - $message = $this->config[ 'fail' ][ 'insert' ]; |
|
134 | - |
|
135 | - return $this->setStatusCode( 448 ) |
|
136 | - ->setStatusText( 'fail' ) |
|
137 | - ->setErrorCode( 5448 ) |
|
138 | - ->respondWithMessage( $message ); |
|
139 | - |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Database connection is refused |
|
144 | - * @author Shima Payro <[email protected]> |
|
145 | - * @param String $message |
|
146 | - * @since May 2, 2016 9:54:45 AM |
|
147 | - * @uses |
|
148 | - * @see |
|
149 | - */ |
|
150 | - public function connectionRefused() { |
|
151 | - |
|
152 | - return $this->setStatusCode( 445 ) |
|
153 | - ->setStatusText( 'fail' ) |
|
154 | - ->setErrorCode( 5445 ) |
|
155 | - ->respondWithMessage(); |
|
156 | - |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * page requested is not found |
|
161 | - * @author Shima Payro <[email protected]> |
|
162 | - * @param String $message |
|
163 | - * @since May 2, 2016 9:55:20 AM |
|
164 | - * @uses |
|
165 | - * @see |
|
166 | - */ |
|
167 | - public function notFound() { |
|
168 | - |
|
169 | - return $this->setStatusCode( 404 ) |
|
170 | - ->setStatusText( 'fail' ) |
|
171 | - ->setErrorCode( 5404 ) |
|
172 | - ->respondWithMessage(); |
|
173 | - |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Wrong parameters are entered |
|
178 | - * @author Shima Payro <[email protected]> |
|
179 | - * @param String $message |
|
180 | - * @since May 2, 2016 9:55:20 AM |
|
181 | - * @uses |
|
182 | - * @see |
|
183 | - */ |
|
184 | - public function wrongParameters() { |
|
185 | - |
|
186 | - return $this->setStatusCode( 406 ) |
|
187 | - ->setStatusText( 'fail' ) |
|
188 | - ->setErrorCode( 5406 ) |
|
189 | - ->respondWithMessage(); |
|
190 | - |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Method is not allowed |
|
195 | - * @author Shima Payro <[email protected]> |
|
196 | - * @param String $message |
|
197 | - * @since May 2, 2016 9:55:20 AM |
|
198 | - * @uses |
|
199 | - * @see |
|
200 | - */ |
|
201 | - public function methodNotAllowed() { |
|
202 | - |
|
203 | - return $this->setStatusCode( 405 ) |
|
204 | - ->setStatusText( 'fail' ) |
|
205 | - ->setErrorCode( 5405 ) |
|
206 | - ->respondWithMessage(); |
|
207 | - |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * There ara validation errors |
|
212 | - * @author Shima Payro <[email protected]> |
|
213 | - * @param Array $data |
|
214 | - * @since May 2, 2016 9:55:20 AM |
|
215 | - * @uses |
|
216 | - * @see |
|
217 | - */ |
|
218 | - public function validationErrors( $message = null ) { |
|
219 | - |
|
220 | - return $this->setStatusCode( 420 ) |
|
221 | - ->setStatusText( 'fail' ) |
|
222 | - ->setErrorCode( 5420 ) |
|
223 | - ->respondWithResult( $message ); |
|
224 | - |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * The request field is not found |
|
229 | - * @author Shima Payro <[email protected]> |
|
230 | - * @param String $message |
|
231 | - * @since May 2, 2016 9:55:20 AM |
|
232 | - * @uses |
|
233 | - * @see |
|
234 | - */ |
|
235 | - public function requestFieldNotFound() { |
|
236 | - |
|
237 | - return $this->setStatusCode( 446 ) |
|
238 | - ->setStatusText( 'fail' ) |
|
239 | - ->setErrorCode( 1001 ) |
|
240 | - ->respondWithMessage(); |
|
241 | - |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * The request field is doublicated |
|
246 | - * @author Mehdi Hosseini <[email protected]> |
|
247 | - * @since August 24, 2016 |
|
248 | - * @return json |
|
249 | - */ |
|
250 | - public function requestFieldDuplicated() { |
|
251 | - |
|
252 | - return $this->setStatusCode( 400 ) |
|
253 | - ->setStatusText( 'fail' ) |
|
254 | - ->SetErrorCode(1004) |
|
255 | - ->respondWithMessage(); |
|
256 | - |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Custom error message according to error config file |
|
261 | - * @author Mehdi Hosseini <[email protected]> |
|
262 | - * @since August 24, 2016 |
|
263 | - * @param $code integer |
|
264 | - * @return json |
|
265 | - */ |
|
266 | - public function error( $code ) { |
|
267 | - |
|
268 | - return $this->SetStatusCode( 400 ) |
|
269 | - ->setStatusText( 'fail' ) |
|
270 | - ->setErrorCode( $code ) |
|
271 | - ->respondWithMessage(); |
|
272 | - |
|
273 | - } |
|
9 | + /** |
|
10 | + * Request succeeded and contains json result |
|
11 | + * @param array $data |
|
12 | + * @author Shima Payro <[email protected]> |
|
13 | + * @since May 2, 2016 9:50:51 AM |
|
14 | + * @uses |
|
15 | + * @see |
|
16 | + */ |
|
17 | + public function succeed( $data ) { |
|
18 | + |
|
19 | + return $this->setStatusCode( 200 ) |
|
20 | + ->setStatusText( 'success' ) |
|
21 | + ->respondWithResult( $data ); |
|
22 | + |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Delete action is succeed |
|
27 | + * @author Shima Payro <[email protected]> |
|
28 | + * @param String $message |
|
29 | + * @since May 2, 2016 9:52:05 AM |
|
30 | + * @uses |
|
31 | + * @see |
|
32 | + */ |
|
33 | + public function deleteSucceeded( $message = null ) { |
|
34 | + |
|
35 | + if ( is_null( $message ) ) |
|
36 | + $message = $this->config[ 'success' ][ 'delete' ]; |
|
37 | + |
|
38 | + return $this->setStatusCode( 200 ) |
|
39 | + ->setStatusText( 'success' ) |
|
40 | + ->respondWithMessage( $message ); |
|
41 | + |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Update action is succeed |
|
46 | + * @author Shima Payro <[email protected]> |
|
47 | + * @param String $message |
|
48 | + * @since May 2, 2016 9:52:52 AM |
|
49 | + * @uses |
|
50 | + * @see |
|
51 | + */ |
|
52 | + public function updateSucceeded( $message = null ) { |
|
53 | + |
|
54 | + if ( is_null( $message ) ) |
|
55 | + $message = $this->config[ 'success' ][ 'update' ]; |
|
56 | + |
|
57 | + return $this->setStatusCode( 200 ) |
|
58 | + ->setStatusText( 'success' ) |
|
59 | + ->respondWithMessage( $message ); |
|
60 | + |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Insert action is succeed |
|
65 | + * @author Shima Payro <[email protected]> |
|
66 | + * @param String $message |
|
67 | + * @since May 2, 2016 9:53:26 AM |
|
68 | + * @uses |
|
69 | + * @see |
|
70 | + */ |
|
71 | + public function insertSucceeded( $message = null ) { |
|
72 | + |
|
73 | + if ( is_null( $message ) ) |
|
74 | + $message = $this->config[ 'success' ][ 'insert' ]; |
|
75 | + |
|
76 | + return $this->setStatusCode( 200 ) |
|
77 | + ->setStatusText( 'success' ) |
|
78 | + ->respondWithMessage( $message ); |
|
79 | + |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Delete action is faild |
|
84 | + * @author Shima Payro <[email protected]> |
|
85 | + * @param String $message |
|
86 | + * @since May 2, 2016 9:53:53 AM |
|
87 | + * @uses |
|
88 | + * @see |
|
89 | + */ |
|
90 | + public function deleteFaild( $message = null ) { |
|
91 | + |
|
92 | + if ( is_null( $message ) ) |
|
93 | + $message = $this->config[ 'fail' ][ 'delete' ]; |
|
94 | + |
|
95 | + return $this->setStatusCode( 447 ) |
|
96 | + ->setStatusText( 'fail' ) |
|
97 | + ->setErrorCode( 5447 ) |
|
98 | + ->respondWithMessage( $message ); |
|
99 | + |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Update action is succeed |
|
104 | + * @author Shima Payro <[email protected]> |
|
105 | + * @param String $message |
|
106 | + * @since May 2, 2016 9:54:09 AM |
|
107 | + * @uses |
|
108 | + * @see |
|
109 | + */ |
|
110 | + public function updateFaild( $message = null ) { |
|
111 | + |
|
112 | + if ( is_null( $message ) ) |
|
113 | + $message = $this->config[ 'fail' ][ 'update' ]; |
|
114 | + |
|
115 | + return $this->setStatusCode( 449 ) |
|
116 | + ->setStatusText( 'fail' ) |
|
117 | + ->setErrorCode( 5449 ) |
|
118 | + ->respondWithMessage( $message ); |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Insert action is faild |
|
124 | + * @author Shima Payro <[email protected]> |
|
125 | + * @param String $message |
|
126 | + * @since May 2, 2016 9:54:27 AM |
|
127 | + * @uses |
|
128 | + * @see |
|
129 | + */ |
|
130 | + public function insertFaild( $message = null ) { |
|
131 | + |
|
132 | + if ( is_null( $message ) ) |
|
133 | + $message = $this->config[ 'fail' ][ 'insert' ]; |
|
134 | + |
|
135 | + return $this->setStatusCode( 448 ) |
|
136 | + ->setStatusText( 'fail' ) |
|
137 | + ->setErrorCode( 5448 ) |
|
138 | + ->respondWithMessage( $message ); |
|
139 | + |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Database connection is refused |
|
144 | + * @author Shima Payro <[email protected]> |
|
145 | + * @param String $message |
|
146 | + * @since May 2, 2016 9:54:45 AM |
|
147 | + * @uses |
|
148 | + * @see |
|
149 | + */ |
|
150 | + public function connectionRefused() { |
|
151 | + |
|
152 | + return $this->setStatusCode( 445 ) |
|
153 | + ->setStatusText( 'fail' ) |
|
154 | + ->setErrorCode( 5445 ) |
|
155 | + ->respondWithMessage(); |
|
156 | + |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * page requested is not found |
|
161 | + * @author Shima Payro <[email protected]> |
|
162 | + * @param String $message |
|
163 | + * @since May 2, 2016 9:55:20 AM |
|
164 | + * @uses |
|
165 | + * @see |
|
166 | + */ |
|
167 | + public function notFound() { |
|
168 | + |
|
169 | + return $this->setStatusCode( 404 ) |
|
170 | + ->setStatusText( 'fail' ) |
|
171 | + ->setErrorCode( 5404 ) |
|
172 | + ->respondWithMessage(); |
|
173 | + |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Wrong parameters are entered |
|
178 | + * @author Shima Payro <[email protected]> |
|
179 | + * @param String $message |
|
180 | + * @since May 2, 2016 9:55:20 AM |
|
181 | + * @uses |
|
182 | + * @see |
|
183 | + */ |
|
184 | + public function wrongParameters() { |
|
185 | + |
|
186 | + return $this->setStatusCode( 406 ) |
|
187 | + ->setStatusText( 'fail' ) |
|
188 | + ->setErrorCode( 5406 ) |
|
189 | + ->respondWithMessage(); |
|
190 | + |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Method is not allowed |
|
195 | + * @author Shima Payro <[email protected]> |
|
196 | + * @param String $message |
|
197 | + * @since May 2, 2016 9:55:20 AM |
|
198 | + * @uses |
|
199 | + * @see |
|
200 | + */ |
|
201 | + public function methodNotAllowed() { |
|
202 | + |
|
203 | + return $this->setStatusCode( 405 ) |
|
204 | + ->setStatusText( 'fail' ) |
|
205 | + ->setErrorCode( 5405 ) |
|
206 | + ->respondWithMessage(); |
|
207 | + |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * There ara validation errors |
|
212 | + * @author Shima Payro <[email protected]> |
|
213 | + * @param Array $data |
|
214 | + * @since May 2, 2016 9:55:20 AM |
|
215 | + * @uses |
|
216 | + * @see |
|
217 | + */ |
|
218 | + public function validationErrors( $message = null ) { |
|
219 | + |
|
220 | + return $this->setStatusCode( 420 ) |
|
221 | + ->setStatusText( 'fail' ) |
|
222 | + ->setErrorCode( 5420 ) |
|
223 | + ->respondWithResult( $message ); |
|
224 | + |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * The request field is not found |
|
229 | + * @author Shima Payro <[email protected]> |
|
230 | + * @param String $message |
|
231 | + * @since May 2, 2016 9:55:20 AM |
|
232 | + * @uses |
|
233 | + * @see |
|
234 | + */ |
|
235 | + public function requestFieldNotFound() { |
|
236 | + |
|
237 | + return $this->setStatusCode( 446 ) |
|
238 | + ->setStatusText( 'fail' ) |
|
239 | + ->setErrorCode( 1001 ) |
|
240 | + ->respondWithMessage(); |
|
241 | + |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * The request field is doublicated |
|
246 | + * @author Mehdi Hosseini <[email protected]> |
|
247 | + * @since August 24, 2016 |
|
248 | + * @return json |
|
249 | + */ |
|
250 | + public function requestFieldDuplicated() { |
|
251 | + |
|
252 | + return $this->setStatusCode( 400 ) |
|
253 | + ->setStatusText( 'fail' ) |
|
254 | + ->SetErrorCode(1004) |
|
255 | + ->respondWithMessage(); |
|
256 | + |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Custom error message according to error config file |
|
261 | + * @author Mehdi Hosseini <[email protected]> |
|
262 | + * @since August 24, 2016 |
|
263 | + * @param $code integer |
|
264 | + * @return json |
|
265 | + */ |
|
266 | + public function error( $code ) { |
|
267 | + |
|
268 | + return $this->SetStatusCode( 400 ) |
|
269 | + ->setStatusText( 'fail' ) |
|
270 | + ->setErrorCode( $code ) |
|
271 | + ->respondWithMessage(); |
|
272 | + |
|
273 | + } |
|
274 | 274 | |
275 | 275 | |
276 | 276 | } |
@@ -6,267 +6,267 @@ |
||
6 | 6 | |
7 | 7 | class Main { |
8 | 8 | |
9 | - /** |
|
10 | - * Http status code |
|
11 | - * @var integer |
|
12 | - */ |
|
13 | - protected $statusCode = 200; |
|
14 | - |
|
15 | - /** |
|
16 | - * Status text |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - protected $statusText = 'success'; |
|
20 | - |
|
21 | - /** |
|
22 | - * Error code, message and text-key |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $error; |
|
26 | - |
|
27 | - /** |
|
28 | - * Error code |
|
29 | - * @var integer |
|
30 | - */ |
|
31 | - protected $errorCode; |
|
32 | - |
|
33 | - /** |
|
34 | - * Haeders |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected $headers = []; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $lang; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - protected $config; |
|
48 | - |
|
49 | - /** |
|
50 | - * @author Shahrokh Niakan <[email protected]> |
|
51 | - * @since Sep 24, 2016 |
|
52 | - */ |
|
53 | - public function __construct() { |
|
54 | - |
|
55 | - |
|
56 | - $this->lang = \App::getLocale(); |
|
57 | - |
|
58 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
59 | - |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Getter for $statusCode |
|
64 | - * @author Shima Payro <[email protected]> |
|
65 | - * @since May 2, 2016 9:46:27 AM |
|
66 | - * @uses |
|
67 | - * @see |
|
68 | - */ |
|
69 | - public function getStatusCode() { |
|
70 | - |
|
71 | - return $this->statusCode; |
|
72 | - |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Setter for $statusCode |
|
77 | - * @param integer $statusCode |
|
78 | - * @return App\Htpp\Responds\Respond |
|
79 | - * @author Shima Payro <[email protected]> |
|
80 | - * @since May 2, 2016 9:47:04 AM |
|
81 | - * @uses |
|
82 | - * @see |
|
83 | - */ |
|
84 | - public function setStatusCode( $statusCode ) { |
|
85 | - |
|
86 | - $this->statusCode = $statusCode; |
|
87 | - |
|
88 | - return $this; |
|
89 | - |
|
90 | - } |
|
9 | + /** |
|
10 | + * Http status code |
|
11 | + * @var integer |
|
12 | + */ |
|
13 | + protected $statusCode = 200; |
|
14 | + |
|
15 | + /** |
|
16 | + * Status text |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + protected $statusText = 'success'; |
|
20 | + |
|
21 | + /** |
|
22 | + * Error code, message and text-key |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $error; |
|
26 | + |
|
27 | + /** |
|
28 | + * Error code |
|
29 | + * @var integer |
|
30 | + */ |
|
31 | + protected $errorCode; |
|
32 | + |
|
33 | + /** |
|
34 | + * Haeders |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected $headers = []; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $lang; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + protected $config; |
|
48 | + |
|
49 | + /** |
|
50 | + * @author Shahrokh Niakan <[email protected]> |
|
51 | + * @since Sep 24, 2016 |
|
52 | + */ |
|
53 | + public function __construct() { |
|
54 | + |
|
55 | + |
|
56 | + $this->lang = \App::getLocale(); |
|
57 | + |
|
58 | + $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
59 | + |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Getter for $statusCode |
|
64 | + * @author Shima Payro <[email protected]> |
|
65 | + * @since May 2, 2016 9:46:27 AM |
|
66 | + * @uses |
|
67 | + * @see |
|
68 | + */ |
|
69 | + public function getStatusCode() { |
|
70 | + |
|
71 | + return $this->statusCode; |
|
72 | + |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Setter for $statusCode |
|
77 | + * @param integer $statusCode |
|
78 | + * @return App\Htpp\Responds\Respond |
|
79 | + * @author Shima Payro <[email protected]> |
|
80 | + * @since May 2, 2016 9:47:04 AM |
|
81 | + * @uses |
|
82 | + * @see |
|
83 | + */ |
|
84 | + public function setStatusCode( $statusCode ) { |
|
85 | + |
|
86 | + $this->statusCode = $statusCode; |
|
87 | + |
|
88 | + return $this; |
|
89 | + |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Getter for $statusText |
|
94 | - * @author Shima Payro <[email protected]> |
|
95 | - * @since May 2, 2016 9:47:36 AM |
|
96 | - * @uses |
|
97 | - * @see |
|
98 | - */ |
|
99 | - public function getStatusText() { |
|
100 | - |
|
101 | - return $this->statusText; |
|
92 | + /** |
|
93 | + * Getter for $statusText |
|
94 | + * @author Shima Payro <[email protected]> |
|
95 | + * @since May 2, 2016 9:47:36 AM |
|
96 | + * @uses |
|
97 | + * @see |
|
98 | + */ |
|
99 | + public function getStatusText() { |
|
100 | + |
|
101 | + return $this->statusText; |
|
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Setter for $statusText |
|
107 | - * @param String $statusText |
|
108 | - * @return App\HtppApp\Htpp\Responds\Respond |
|
109 | - * @author Shima Payro <[email protected]> |
|
110 | - * @since May 2, 2016 9:48:23 AM |
|
111 | - * @uses |
|
112 | - * @see |
|
113 | - */ |
|
114 | - public function setStatusText( $statusText ) { |
|
105 | + /** |
|
106 | + * Setter for $statusText |
|
107 | + * @param String $statusText |
|
108 | + * @return App\HtppApp\Htpp\Responds\Respond |
|
109 | + * @author Shima Payro <[email protected]> |
|
110 | + * @since May 2, 2016 9:48:23 AM |
|
111 | + * @uses |
|
112 | + * @see |
|
113 | + */ |
|
114 | + public function setStatusText( $statusText ) { |
|
115 | 115 | |
116 | - $this->statusText = $statusText; |
|
116 | + $this->statusText = $statusText; |
|
117 | 117 | |
118 | - return $this; |
|
118 | + return $this; |
|
119 | 119 | |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Response |
|
124 | - * @param json $data |
|
125 | - * @return jsom |
|
126 | - * @author Shima Payro <[email protected]> |
|
127 | - * @since May 2, 2016 9:48:45 AM |
|
128 | - * @uses |
|
129 | - * @see |
|
130 | - */ |
|
131 | - public function respond( $data ) { |
|
122 | + /** |
|
123 | + * Response |
|
124 | + * @param json $data |
|
125 | + * @return jsom |
|
126 | + * @author Shima Payro <[email protected]> |
|
127 | + * @since May 2, 2016 9:48:45 AM |
|
128 | + * @uses |
|
129 | + * @see |
|
130 | + */ |
|
131 | + public function respond( $data ) { |
|
132 | 132 | |
133 | - $result = array_filter( $this->getHeaders() ); |
|
133 | + $result = array_filter( $this->getHeaders() ); |
|
134 | 134 | |
135 | - if ( empty( $result ) ) |
|
136 | - return response()->json( $data, $this->getStatusCode() ); |
|
135 | + if ( empty( $result ) ) |
|
136 | + return response()->json( $data, $this->getStatusCode() ); |
|
137 | 137 | |
138 | - return response()->json( $data, $this->getStatusCode() ) |
|
139 | - ->withHeaders( $this->getHeaders() ); |
|
138 | + return response()->json( $data, $this->getStatusCode() ) |
|
139 | + ->withHeaders( $this->getHeaders() ); |
|
140 | 140 | |
141 | - } |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * Response which conteins just a message |
|
145 | - * @param string $message |
|
146 | - * @author Shima Payro <[email protected]> |
|
147 | - * @since May 2, 2016 9:49:21 AM |
|
148 | - * @return json |
|
149 | - * @uses |
|
150 | - * @see |
|
151 | - */ |
|
152 | - public function respondWithMessage( $message = null ) { |
|
143 | + /** |
|
144 | + * Response which conteins just a message |
|
145 | + * @param string $message |
|
146 | + * @author Shima Payro <[email protected]> |
|
147 | + * @since May 2, 2016 9:49:21 AM |
|
148 | + * @return json |
|
149 | + * @uses |
|
150 | + * @see |
|
151 | + */ |
|
152 | + public function respondWithMessage( $message = null ) { |
|
153 | 153 | |
154 | - $res[ 'status' ] = $this->getStatusText(); |
|
154 | + $res[ 'status' ] = $this->getStatusText(); |
|
155 | 155 | |
156 | - //if it's about failure |
|
157 | - if ( $this->getErrorCode() ) { |
|
156 | + //if it's about failure |
|
157 | + if ( $this->getErrorCode() ) { |
|
158 | 158 | |
159 | - $res[ 'error' ] = $this->getErrorCode(); |
|
159 | + $res[ 'error' ] = $this->getErrorCode(); |
|
160 | 160 | |
161 | - if ( is_null( $message ) ) |
|
162 | - $res[ 'message' ] = $this->getErrorMessage(); |
|
163 | - else |
|
164 | - $res[ 'message' ] = $message; |
|
161 | + if ( is_null( $message ) ) |
|
162 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
163 | + else |
|
164 | + $res[ 'message' ] = $message; |
|
165 | 165 | |
166 | - } else { |
|
166 | + } else { |
|
167 | 167 | |
168 | - $res[ 'message' ] = $message; |
|
168 | + $res[ 'message' ] = $message; |
|
169 | 169 | |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - return $this->respond( $res ); |
|
172 | + return $this->respond( $res ); |
|
173 | 173 | |
174 | - } |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * Set error code in our result |
|
178 | - * @author Mehdi Hosseini <[email protected]> |
|
179 | - * @since August 24, 2016 |
|
180 | - * @param $errorCode integer |
|
181 | - * @return instance |
|
182 | - */ |
|
183 | - public function setErrorCode( $errorCode ) { |
|
176 | + /** |
|
177 | + * Set error code in our result |
|
178 | + * @author Mehdi Hosseini <[email protected]> |
|
179 | + * @since August 24, 2016 |
|
180 | + * @param $errorCode integer |
|
181 | + * @return instance |
|
182 | + */ |
|
183 | + public function setErrorCode( $errorCode ) { |
|
184 | 184 | |
185 | - $this->error = $this->config[ $errorCode ]; |
|
185 | + $this->error = $this->config[ $errorCode ]; |
|
186 | 186 | |
187 | - $this->errorCode = $errorCode; |
|
187 | + $this->errorCode = $errorCode; |
|
188 | 188 | |
189 | - return $this; |
|
189 | + return $this; |
|
190 | 190 | |
191 | - } |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Return Error code |
|
195 | - * @author Mehdi Hosseini <[email protected]> |
|
196 | - * @since August 24, 2016 |
|
197 | - * @return integer |
|
198 | - */ |
|
199 | - public function getErrorCode() { |
|
193 | + /** |
|
194 | + * Return Error code |
|
195 | + * @author Mehdi Hosseini <[email protected]> |
|
196 | + * @since August 24, 2016 |
|
197 | + * @return integer |
|
198 | + */ |
|
199 | + public function getErrorCode() { |
|
200 | 200 | |
201 | - return $this->errorCode; |
|
201 | + return $this->errorCode; |
|
202 | 202 | |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Get error message |
|
207 | - * @author Mehdi Hosseini <[email protected]> |
|
208 | - * @since August 24, 2016 |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - public function getErrorMessage() { |
|
205 | + /** |
|
206 | + * Get error message |
|
207 | + * @author Mehdi Hosseini <[email protected]> |
|
208 | + * @since August 24, 2016 |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + public function getErrorMessage() { |
|
212 | 212 | |
213 | - return $this->error['message']; |
|
213 | + return $this->error['message']; |
|
214 | 214 | |
215 | - } |
|
215 | + } |
|
216 | 216 | |
217 | - /** |
|
218 | - * Get headers |
|
219 | - * @author Shima Payro <[email protected]> |
|
220 | - * @since Sep 13, 2016 |
|
221 | - * @return array |
|
222 | - */ |
|
223 | - public function getHeaders() { |
|
217 | + /** |
|
218 | + * Get headers |
|
219 | + * @author Shima Payro <[email protected]> |
|
220 | + * @since Sep 13, 2016 |
|
221 | + * @return array |
|
222 | + */ |
|
223 | + public function getHeaders() { |
|
224 | 224 | |
225 | - return $this->headers; |
|
225 | + return $this->headers; |
|
226 | 226 | |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * Set headers |
|
231 | - * @author Shima Payro <[email protected]> |
|
232 | - * @since Sep 13, 2016 |
|
233 | - * @return array |
|
234 | - */ |
|
235 | - public function setHeaders( $headers = [] ) { |
|
229 | + /** |
|
230 | + * Set headers |
|
231 | + * @author Shima Payro <[email protected]> |
|
232 | + * @since Sep 13, 2016 |
|
233 | + * @return array |
|
234 | + */ |
|
235 | + public function setHeaders( $headers = [] ) { |
|
236 | 236 | |
237 | - $this->headers = $headers; |
|
237 | + $this->headers = $headers; |
|
238 | 238 | |
239 | - return $this; |
|
239 | + return $this; |
|
240 | 240 | |
241 | - } |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Response which contains status and data |
|
245 | - * @param json $data |
|
246 | - * @author Shima Payro <[email protected]> |
|
247 | - * @since May 2, 2016 9:50:19 AM |
|
248 | - * @return json |
|
249 | - * @uses |
|
250 | - * @see |
|
251 | - */ |
|
252 | - public function respondWithResult( $data = NULL ) { |
|
243 | + /** |
|
244 | + * Response which contains status and data |
|
245 | + * @param json $data |
|
246 | + * @author Shima Payro <[email protected]> |
|
247 | + * @since May 2, 2016 9:50:19 AM |
|
248 | + * @return json |
|
249 | + * @uses |
|
250 | + * @see |
|
251 | + */ |
|
252 | + public function respondWithResult( $data = NULL ) { |
|
253 | 253 | |
254 | - $res[ 'status' ] = $this->getStatusText(); |
|
254 | + $res[ 'status' ] = $this->getStatusText(); |
|
255 | 255 | |
256 | - //if it's about laravel validation error |
|
257 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
256 | + //if it's about laravel validation error |
|
257 | + if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
258 | 258 | |
259 | - $res[ 'error' ] = $this->getErrorCode(); |
|
260 | - $res[ 'message' ] = $data; |
|
259 | + $res[ 'error' ] = $this->getErrorCode(); |
|
260 | + $res[ 'message' ] = $data; |
|
261 | 261 | |
262 | - } else { |
|
262 | + } else { |
|
263 | 263 | |
264 | - $res[ 'result' ] = $data; |
|
264 | + $res[ 'result' ] = $data; |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - return $this->respond( $res ); |
|
268 | + return $this->respond( $res ); |
|
269 | 269 | |
270 | - } |
|
270 | + } |
|
271 | 271 | |
272 | 272 | } |
@@ -2,190 +2,190 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - 'success' => [ |
|
6 | - |
|
7 | - 'insert' => 'درخواست با موفقیت درج شده است.', |
|
8 | - |
|
9 | - 'delete' => 'درخواست با موفقیت پاک شده است.', |
|
10 | - |
|
11 | - 'update' => 'درخواست با موفقیت ویرایش شده است.' |
|
12 | - |
|
13 | - ], |
|
14 | - |
|
15 | - 'fail' => [ |
|
16 | - |
|
17 | - 'insert' => 'درخواست با موفقیت درج نشد.', |
|
18 | - |
|
19 | - 'delete' => 'درخواست با موفقیت پاک نشد.', |
|
20 | - |
|
21 | - 'update' => 'درخواست با موفقیت ویرایش نشد.' |
|
22 | - |
|
23 | - ], |
|
24 | - |
|
25 | - 1001 => [ |
|
26 | - 'message' => 'درخواست مورد نظر پیدا نشده است.', |
|
27 | - 'type' => 'error' |
|
28 | - ], |
|
29 | - |
|
30 | - 1002 => [ |
|
31 | - 'message' => 'کاربر مورد نظر موجود نیست.', |
|
32 | - 'type' => 'error' |
|
33 | - ], |
|
34 | - |
|
35 | - 1003 => [ |
|
36 | - 'message' => 'نوع کاربری وارد نشده است.', |
|
37 | - 'type' => 'error' |
|
38 | - ], |
|
39 | - |
|
40 | - 1004 => [ |
|
41 | - 'message' => 'ورودی مورد نظر تکراری است.', |
|
42 | - 'type' => 'error' |
|
43 | - ], |
|
44 | - |
|
45 | - 1005 => [ |
|
46 | - 'message' => 'نقش کاربر مورد نظر تکراری است.', |
|
47 | - 'type' => 'error' |
|
48 | - ], |
|
49 | - |
|
50 | - 3001 => [ |
|
51 | - 'message' => 'شما به سیستم وارد نشده اید.', |
|
52 | - 'type' => 'error', |
|
53 | - 'cat' => 'auth', |
|
54 | - 'short' => 'not-logged-on' |
|
55 | - ], |
|
56 | - |
|
57 | - 3002 => [ |
|
58 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
59 | - 'type' => 'error', |
|
60 | - 'cat' => 'auth' |
|
61 | - ], |
|
62 | - |
|
63 | - 3003 =>[ |
|
64 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
65 | - 'type' => 'error', |
|
66 | - 'cat' => 'auth' |
|
67 | - ], |
|
68 | - |
|
69 | - 3004 => [ |
|
70 | - 'message' => 'هیچ آژانسی به نشان شناسایی دسترسی ندارد.', |
|
71 | - 'type' => 'error', |
|
72 | - 'cat' => 'auth' |
|
73 | - ], |
|
74 | - |
|
75 | - 3005 => [ |
|
76 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
77 | - 'type' => 'error', |
|
78 | - 'cat' => 'auth' |
|
79 | - ], |
|
80 | - |
|
81 | - 3006 => [ |
|
82 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
83 | - 'type' => 'error', |
|
84 | - 'cat' => 'auth' |
|
85 | - ], |
|
86 | - |
|
87 | - 3007 => [ |
|
88 | - 'message' => 'نشان شناسایی شما نمایش داده نمیشود.', |
|
89 | - 'type' => 'error', |
|
90 | - 'cat' => 'auth' |
|
91 | - ], |
|
92 | - |
|
93 | - 3008 => [ |
|
94 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
95 | - 'type' => 'error', |
|
96 | - 'cat' => 'auth' |
|
97 | - ], |
|
98 | - |
|
99 | - 3009 => [ |
|
100 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
101 | - 'type' => 'error', |
|
102 | - 'cat' => 'auth' |
|
103 | - ], |
|
104 | - |
|
105 | - 3010 => [ |
|
106 | - 'message' => 'زمان استفاده از نشان شناسایی شما گذشته است.', |
|
107 | - 'type' => 'error', |
|
108 | - 'cat' => 'auth' |
|
109 | - ], |
|
110 | - |
|
111 | - 3011 => [ |
|
112 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
113 | - 'type' => 'error', |
|
114 | - 'cat' => 'auth' |
|
115 | - ], |
|
116 | - |
|
117 | - 3012 => [ |
|
118 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
119 | - 'type' => 'error', |
|
120 | - 'cat' => 'auth' |
|
121 | - ], |
|
122 | - |
|
123 | - 3013 => [ |
|
124 | - 'message' => 'Payload معتبر نیست.', |
|
125 | - 'type' => 'error', |
|
126 | - 'cat' => 'auth' |
|
127 | - ], |
|
128 | - |
|
129 | - 3014 => [ |
|
130 | - 'message' => 'Claim معتبر نیست.', |
|
131 | - 'type' => 'error', |
|
132 | - 'cat' => 'auth' |
|
133 | - ], |
|
134 | - |
|
135 | - 3015 => [ |
|
136 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
137 | - 'type' => 'error', |
|
138 | - 'cat' => 'auth' |
|
139 | - ], |
|
140 | - |
|
141 | - 5401 => [ |
|
142 | - 'message' => 'شناسایی کاربر نامعتبر است.', |
|
143 | - 'type' => 'error' |
|
144 | - ], |
|
145 | - |
|
146 | - 5404 => [ |
|
147 | - 'message' => 'صفحه درخواست شده پیدا نمیشود.', |
|
148 | - 'type' => 'error' |
|
149 | - ], |
|
150 | - |
|
151 | - 5405 => [ |
|
152 | - 'message' => 'شما به درخواستی که داده اید دسترسی ندارید.', |
|
153 | - 'type' => 'error' |
|
154 | - ], |
|
155 | - |
|
156 | - 5406 => [ |
|
157 | - 'message' => 'پارامترهایی که شما وارد کرده اید نا معتبر است.', |
|
158 | - 'type' => 'error' |
|
159 | - ], |
|
160 | - |
|
161 | - 5420 => [ |
|
162 | - 'message' => 'خطای اعتبار سنجی.', |
|
163 | - 'type' => 'error' |
|
164 | - ], |
|
165 | - |
|
166 | - 5422 => [ |
|
167 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
168 | - 'type' => 'error' |
|
169 | - ], |
|
170 | - |
|
171 | - 5445 => [ |
|
172 | - 'message' => 'ارتباط با پایگاه داده مشکل دارد.', |
|
173 | - 'type' => 'error' |
|
174 | - ], |
|
175 | - |
|
176 | - 5448 => [ |
|
177 | - 'message' => 'عملیات درج درست اجرا نشده است.', |
|
178 | - 'type' => 'error' |
|
179 | - ], |
|
180 | - |
|
181 | - 5447 => [ |
|
182 | - 'message' => 'عملیات پاک کردن درست اجرا نشده است.', |
|
183 | - 'type' => 'error' |
|
184 | - ], |
|
185 | - |
|
186 | - 5449 => [ |
|
187 | - 'message' => 'عملیات ویرایش درست اجرا نشده است.', |
|
188 | - 'type' => 'error' |
|
189 | - ] |
|
5 | + 'success' => [ |
|
6 | + |
|
7 | + 'insert' => 'درخواست با موفقیت درج شده است.', |
|
8 | + |
|
9 | + 'delete' => 'درخواست با موفقیت پاک شده است.', |
|
10 | + |
|
11 | + 'update' => 'درخواست با موفقیت ویرایش شده است.' |
|
12 | + |
|
13 | + ], |
|
14 | + |
|
15 | + 'fail' => [ |
|
16 | + |
|
17 | + 'insert' => 'درخواست با موفقیت درج نشد.', |
|
18 | + |
|
19 | + 'delete' => 'درخواست با موفقیت پاک نشد.', |
|
20 | + |
|
21 | + 'update' => 'درخواست با موفقیت ویرایش نشد.' |
|
22 | + |
|
23 | + ], |
|
24 | + |
|
25 | + 1001 => [ |
|
26 | + 'message' => 'درخواست مورد نظر پیدا نشده است.', |
|
27 | + 'type' => 'error' |
|
28 | + ], |
|
29 | + |
|
30 | + 1002 => [ |
|
31 | + 'message' => 'کاربر مورد نظر موجود نیست.', |
|
32 | + 'type' => 'error' |
|
33 | + ], |
|
34 | + |
|
35 | + 1003 => [ |
|
36 | + 'message' => 'نوع کاربری وارد نشده است.', |
|
37 | + 'type' => 'error' |
|
38 | + ], |
|
39 | + |
|
40 | + 1004 => [ |
|
41 | + 'message' => 'ورودی مورد نظر تکراری است.', |
|
42 | + 'type' => 'error' |
|
43 | + ], |
|
44 | + |
|
45 | + 1005 => [ |
|
46 | + 'message' => 'نقش کاربر مورد نظر تکراری است.', |
|
47 | + 'type' => 'error' |
|
48 | + ], |
|
49 | + |
|
50 | + 3001 => [ |
|
51 | + 'message' => 'شما به سیستم وارد نشده اید.', |
|
52 | + 'type' => 'error', |
|
53 | + 'cat' => 'auth', |
|
54 | + 'short' => 'not-logged-on' |
|
55 | + ], |
|
56 | + |
|
57 | + 3002 => [ |
|
58 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
59 | + 'type' => 'error', |
|
60 | + 'cat' => 'auth' |
|
61 | + ], |
|
62 | + |
|
63 | + 3003 =>[ |
|
64 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
65 | + 'type' => 'error', |
|
66 | + 'cat' => 'auth' |
|
67 | + ], |
|
68 | + |
|
69 | + 3004 => [ |
|
70 | + 'message' => 'هیچ آژانسی به نشان شناسایی دسترسی ندارد.', |
|
71 | + 'type' => 'error', |
|
72 | + 'cat' => 'auth' |
|
73 | + ], |
|
74 | + |
|
75 | + 3005 => [ |
|
76 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
77 | + 'type' => 'error', |
|
78 | + 'cat' => 'auth' |
|
79 | + ], |
|
80 | + |
|
81 | + 3006 => [ |
|
82 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
83 | + 'type' => 'error', |
|
84 | + 'cat' => 'auth' |
|
85 | + ], |
|
86 | + |
|
87 | + 3007 => [ |
|
88 | + 'message' => 'نشان شناسایی شما نمایش داده نمیشود.', |
|
89 | + 'type' => 'error', |
|
90 | + 'cat' => 'auth' |
|
91 | + ], |
|
92 | + |
|
93 | + 3008 => [ |
|
94 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
95 | + 'type' => 'error', |
|
96 | + 'cat' => 'auth' |
|
97 | + ], |
|
98 | + |
|
99 | + 3009 => [ |
|
100 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
101 | + 'type' => 'error', |
|
102 | + 'cat' => 'auth' |
|
103 | + ], |
|
104 | + |
|
105 | + 3010 => [ |
|
106 | + 'message' => 'زمان استفاده از نشان شناسایی شما گذشته است.', |
|
107 | + 'type' => 'error', |
|
108 | + 'cat' => 'auth' |
|
109 | + ], |
|
110 | + |
|
111 | + 3011 => [ |
|
112 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
113 | + 'type' => 'error', |
|
114 | + 'cat' => 'auth' |
|
115 | + ], |
|
116 | + |
|
117 | + 3012 => [ |
|
118 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
119 | + 'type' => 'error', |
|
120 | + 'cat' => 'auth' |
|
121 | + ], |
|
122 | + |
|
123 | + 3013 => [ |
|
124 | + 'message' => 'Payload معتبر نیست.', |
|
125 | + 'type' => 'error', |
|
126 | + 'cat' => 'auth' |
|
127 | + ], |
|
128 | + |
|
129 | + 3014 => [ |
|
130 | + 'message' => 'Claim معتبر نیست.', |
|
131 | + 'type' => 'error', |
|
132 | + 'cat' => 'auth' |
|
133 | + ], |
|
134 | + |
|
135 | + 3015 => [ |
|
136 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
137 | + 'type' => 'error', |
|
138 | + 'cat' => 'auth' |
|
139 | + ], |
|
140 | + |
|
141 | + 5401 => [ |
|
142 | + 'message' => 'شناسایی کاربر نامعتبر است.', |
|
143 | + 'type' => 'error' |
|
144 | + ], |
|
145 | + |
|
146 | + 5404 => [ |
|
147 | + 'message' => 'صفحه درخواست شده پیدا نمیشود.', |
|
148 | + 'type' => 'error' |
|
149 | + ], |
|
150 | + |
|
151 | + 5405 => [ |
|
152 | + 'message' => 'شما به درخواستی که داده اید دسترسی ندارید.', |
|
153 | + 'type' => 'error' |
|
154 | + ], |
|
155 | + |
|
156 | + 5406 => [ |
|
157 | + 'message' => 'پارامترهایی که شما وارد کرده اید نا معتبر است.', |
|
158 | + 'type' => 'error' |
|
159 | + ], |
|
160 | + |
|
161 | + 5420 => [ |
|
162 | + 'message' => 'خطای اعتبار سنجی.', |
|
163 | + 'type' => 'error' |
|
164 | + ], |
|
165 | + |
|
166 | + 5422 => [ |
|
167 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
168 | + 'type' => 'error' |
|
169 | + ], |
|
170 | + |
|
171 | + 5445 => [ |
|
172 | + 'message' => 'ارتباط با پایگاه داده مشکل دارد.', |
|
173 | + 'type' => 'error' |
|
174 | + ], |
|
175 | + |
|
176 | + 5448 => [ |
|
177 | + 'message' => 'عملیات درج درست اجرا نشده است.', |
|
178 | + 'type' => 'error' |
|
179 | + ], |
|
180 | + |
|
181 | + 5447 => [ |
|
182 | + 'message' => 'عملیات پاک کردن درست اجرا نشده است.', |
|
183 | + 'type' => 'error' |
|
184 | + ], |
|
185 | + |
|
186 | + 5449 => [ |
|
187 | + 'message' => 'عملیات ویرایش درست اجرا نشده است.', |
|
188 | + 'type' => 'error' |
|
189 | + ] |
|
190 | 190 | |
191 | 191 | ]; |