Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
MP-Tsel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dzulfiqar Ridha
MP-Tsel
Commits
efc9e391
Commit
efc9e391
authored
Apr 10, 2019
by
Dzulfqar Ridha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
package $ plan
parent
e3fe7711
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
339 additions
and
11 deletions
+339
-11
ApplicationController.php
app/Http/Controllers/ApplicationController.php
+1
-1
Controller.php
app/Http/Controllers/Controller.php
+10
-0
ExampleController.php
app/Http/Controllers/ExampleController.php
+18
-0
PackagePlanController.php
app/Http/Controllers/PackagePlanController.php
+103
-0
UserController.php
app/Http/Controllers/UserController.php
+60
-2
CreateDefaultApplicationRequest.php
...p/Request/Application/CreateDefaultApplicationRequest.php
+0
-0
PlanRequest.php
app/Http/Request/PackagePlan/PlanRequest.php
+45
-0
CreateUserRequest.php
app/Http/Request/User/CreateUserRequest.php
+0
-0
UpdateUserRequest.php
app/Http/Request/User/UpdateUserRequest.php
+45
-0
UserByIdRequest.php
app/Http/Request/User/UserByIdRequest.php
+45
-0
UserByUsernameRequest.php
app/Http/Request/User/UserByUsernameRequest.php
+0
-0
web.php
routes/web.php
+12
-8
No files found.
app/Http/Controllers/ApplicationController.php
View file @
efc9e391
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Classes\MResponse
;
use
App\Classes\MResponse
;
use
App\Http\Request\CreateDefaultApplicationRequest
;
use
App\Http\Request\
Application\
CreateDefaultApplicationRequest
;
class
ApplicationController
extends
BaseController
class
ApplicationController
extends
BaseController
{
{
...
...
app/Http/Controllers/Controller.php
0 → 100644
View file @
efc9e391
<?php
namespace
App\Http\Controllers
;
use
Laravel\Lumen\Routing\Controller
as
BaseController
;
class
Controller
extends
BaseController
{
//
}
app/Http/Controllers/ExampleController.php
0 → 100644
View file @
efc9e391
<?php
namespace
App\Http\Controllers
;
class
ExampleController
extends
Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public
function
__construct
()
{
//
}
//
}
app/Http/Controllers/PackagePlanController.php
0 → 100644
View file @
efc9e391
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:24 PM
*/
namespace
App\Http\Controllers
;
use
App\Classes\MResponse
;
use
App\Http\Request\PackagePlan\PlanRequest
;
class
PackagePlanController
extends
BaseController
{
public
function
getPackagePlan
()
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'GET'
,
'https://api.mashery.com/v3/rest/packages'
,
[
'query'
=>
[
'fields'
=>
'id,name,description,plans.id,plans.name,plans.description'
]
]);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
public
function
getPackage
()
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'GET'
,
'https://api.mashery.com/v3/rest/packages'
,
[
'query'
=>
[
'fields'
=>
'id,name,description'
]
]);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
public
function
getPlan
(
PlanRequest
$request
)
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
$url
=
'https://api.mashery.com/v3/rest/packages/'
.
$request
->
get
(
'pkgid'
)
.
'/plans'
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'GET'
,
$url
);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
app/Http/Controllers/UserController.php
View file @
efc9e391
...
@@ -9,8 +9,10 @@
...
@@ -9,8 +9,10 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Classes\MResponse
;
use
App\Classes\MResponse
;
use
App\Http\Request\UserByUsernameRequest
;
use
App\Http\Request\User\UserByUsernameRequest
;
use
App\Http\Request\CreateUserRequest
;
use
App\Http\Request\User\CreateUserRequest
;
use
App\Http\Request\User\UserByIdRequest
;
use
App\Http\Request\User\UpdateUserRequest
;
class
UserController
extends
BaseController
class
UserController
extends
BaseController
{
{
...
@@ -44,6 +46,33 @@ class UserController extends BaseController
...
@@ -44,6 +46,33 @@ class UserController extends BaseController
return
response
()
->
json
(
$mResponse
,
$statusCode
);
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
public
function
getById
(
UserByIdRequest
$request
){
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
$url
=
'https://api.mashery.com/v3/rest/members/'
.
$request
->
get
(
'userid'
);
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'GET'
,
$url
);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
public
function
createUser
(
CreateUserRequest
$request
)
public
function
createUser
(
CreateUserRequest
$request
)
{
{
$mResponse
=
new
MResponse
();
$mResponse
=
new
MResponse
();
...
@@ -78,4 +107,33 @@ class UserController extends BaseController
...
@@ -78,4 +107,33 @@ class UserController extends BaseController
return
response
()
->
json
(
$mResponse
,
$statusCode
);
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
public
function
updateUser
(
UpdateUserRequest
$request
){
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'GET'
,
'https://api.mashery.com/v3/rest/members'
,
[
'query'
=>
[
'filter'
=>
'username:'
.
$request
->
get
(
'username'
)
]
]);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
}
app/Http/Request/CreateDefaultApplicationRequest.php
→
app/Http/Request/
Application/
CreateDefaultApplicationRequest.php
View file @
efc9e391
File moved
app/Http/Request/PackagePlan/PlanRequest.php
0 → 100644
View file @
efc9e391
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:45 PM
*/
namespace
App\Http\Request
;
class
PlanRequest
extends
FormRequestErrors
{
protected
function
validationData
()
{
return
$this
->
all
();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'pkgid'
=>
'required'
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public
function
messages
()
{
return
[];
}
protected
function
modifyData
()
{
$data
=
$this
->
validationData
();
return
$data
;
}
}
app/Http/Request/CreateUserRequest.php
→
app/Http/Request/
User/
CreateUserRequest.php
View file @
efc9e391
File moved
app/Http/Request/User/UpdateUserRequest.php
0 → 100644
View file @
efc9e391
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:45 PM
*/
namespace
App\Http\Request
;
class
UpdateUserRequest
extends
FormRequestErrors
{
protected
function
validationData
()
{
return
$this
->
all
();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'username'
=>
'required'
,
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public
function
messages
()
{
return
[];
}
protected
function
modifyData
()
{
$data
=
$this
->
validationData
();
return
$data
;
}
}
app/Http/Request/User/UserByIdRequest.php
0 → 100644
View file @
efc9e391
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:45 PM
*/
namespace
App\Http\Request
;
class
UserByIdRequest
extends
FormRequestErrors
{
protected
function
validationData
()
{
return
$this
->
all
();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'userid'
=>
'required'
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public
function
messages
()
{
return
[];
}
protected
function
modifyData
()
{
$data
=
$this
->
validationData
();
return
$data
;
}
}
app/Http/Request/UserByUsernameRequest.php
→
app/Http/Request/User
/User
ByUsernameRequest.php
View file @
efc9e391
File moved
routes/web.php
View file @
efc9e391
...
@@ -15,23 +15,19 @@ $router->get('/', function () use ($router) {
...
@@ -15,23 +15,19 @@ $router->get('/', function () use ($router) {
return
$router
->
app
->
version
();
return
$router
->
app
->
version
();
});
});
$router
->
get
(
'/getUser'
,
'MasheryGetUserController@getUser'
);
$router
->
group
([
'prefix'
=>
'mashery'
],
function
()
use
(
$router
)
{
$router
->
group
([
'prefix'
=>
'mashery'
],
function
()
use
(
$router
)
{
//mashery/token
//mashery/token
$router
->
get
(
'token'
,
'MasheryController@getToken'
);
$router
->
get
(
'token'
,
'MasheryController@getToken'
);
//mashery/getUser?token={token}&username={mashery_username}
$router
->
get
(
'getUser'
,
'MasheryController@getUser'
);
//mashery/createUser?token={}&username={}&email={}&dname={}&pass={}
$router
->
get
(
'createUser'
,
'MasheryController@createUser'
);
});
});
$router
->
group
([
'middleware'
=>
'client.auth'
],
function
()
use
(
$router
)
{
$router
->
group
([
'middleware'
=>
'client.auth'
],
function
()
use
(
$router
)
{
$router
->
group
([
'prefix'
=>
'user'
],
function
()
use
(
$router
)
{
$router
->
group
([
'prefix'
=>
'user'
],
function
()
use
(
$router
)
{
$router
->
get
(
'by-username'
,
'UserController@getByUsername'
);
$router
->
get
(
'by-username'
,
'UserController@getByUsername'
);
$router
->
get
(
'by-id'
,
'UserController@getById'
);
$router
->
get
(
'update'
,
'UserController@updateUser'
);
$router
->
post
(
'create'
,
'UserController@createUser'
);
$router
->
post
(
'create'
,
'UserController@createUser'
);
});
});
...
@@ -40,4 +36,12 @@ $router->group(['middleware' => 'client.auth'], function () use ($router) {
...
@@ -40,4 +36,12 @@ $router->group(['middleware' => 'client.auth'], function () use ($router) {
$router
->
post
(
'create'
,
'ApplicationController@createApp'
);
$router
->
post
(
'create'
,
'ApplicationController@createApp'
);
});
});
$router
->
group
([
'prefix'
=>
'package'
],
function
()
use
(
$router
)
{
$router
->
get
(
'package'
,
'PackagePlanController@getPackage'
);
$router
->
get
(
'plan'
,
'PackagePlanController@getPlan'
);
$router
->
get
(
'package-plan'
,
'PackagePlanController@getPackagePlan'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment