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
c0e0b669
Commit
c0e0b669
authored
Apr 10, 2019
by
Dzulfqar Ridha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update new postman collection
parent
56e5681a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
256 additions
and
251 deletions
+256
-251
ApplicationController.php
app/Http/Controllers/ApplicationController.php
+109
-0
Controller.php
app/Http/Controllers/Controller.php
+0
-10
ExampleController.php
app/Http/Controllers/ExampleController.php
+0
-18
MasheryAPIClient.php
app/Http/Controllers/MasheryAPIClient.php
+0
-54
MasheryController.php
app/Http/Controllers/MasheryController.php
+0
-88
MasheryGetTokenController.php
app/Http/Controllers/MasheryGetTokenController.php
+0
-31
MasheryGetUserController.php
app/Http/Controllers/MasheryGetUserController.php
+0
-40
UserController.php
app/Http/Controllers/UserController.php
+36
-0
CreateDefaultApplicationRequest.php
app/Http/Request/CreateDefaultApplicationRequest.php
+45
-0
CreateUserRequest.php
app/Http/Request/CreateUserRequest.php
+48
-0
composer.lock
composer.lock
+10
-10
web.php
routes/web.php
+8
-0
No files found.
app/Http/Controllers/ApplicationController.php
0 → 100644
View file @
c0e0b669
<?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\CreateDefaultApplicationRequest
;
class
ApplicationController
extends
BaseController
{
public
function
createDefault
(
CreateDefaultApplicationRequest
$request
)
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
$url
=
'https://api.mashery.com/v3/rest/members/'
.
$request
->
get
(
'userid'
)
.
'/applications'
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'POST'
,
$url
,
[
'json'
=>
[
'name'
=>
$request
->
get
(
'marketplace-name'
)
.
'-DefaultApp'
,
'username'
=>
$request
->
get
(
'username'
),
'description'
=>
''
,
'type'
=>
''
,
'commercial'
=>
false
,
'ads'
=>
false
,
'adsSystem'
=>
''
,
'usageModel'
=>
''
,
'tags'
=>
''
,
'notes'
=>
''
,
'howDidYouHear'
=>
''
,
'preferredProtocol'
=>
''
,
'preferredOutput'
=>
''
,
'externalId'
=>
''
,
'uri'
=>
''
,
'oauthRedirectUri'
=>
''
]
]);
$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
createApp
(
CreateDefaultApplicationRequest
$request
)
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
$url
=
'https://api.mashery.com/v3/rest/members/'
.
$request
->
get
(
'userid'
)
.
'/applications'
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'POST'
,
$url
,
[
'json'
=>
[
'name'
=>
$request
->
get
(
'marketplace-name'
)
.
'-WebApp'
,
'username'
=>
$request
->
get
(
'username'
),
'description'
=>
''
,
'type'
=>
''
,
'commercial'
=>
false
,
'ads'
=>
false
,
'adsSystem'
=>
''
,
'usageModel'
=>
''
,
'tags'
=>
''
,
'notes'
=>
''
,
'howDidYouHear'
=>
''
,
'preferredProtocol'
=>
''
,
'preferredOutput'
=>
''
,
'externalId'
=>
''
,
'uri'
=>
''
,
'oauthRedirectUri'
=>
''
]
]);
$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/Controller.php
deleted
100644 → 0
View file @
56e5681a
<?php
namespace
App\Http\Controllers
;
use
Laravel\Lumen\Routing\Controller
as
BaseController
;
class
Controller
extends
BaseController
{
//
}
app/Http/Controllers/ExampleController.php
deleted
100644 → 0
View file @
56e5681a
<?php
namespace
App\Http\Controllers
;
class
ExampleController
extends
Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public
function
__construct
()
{
//
}
//
}
app/Http/Controllers/MasheryAPIClient.php
deleted
100644 → 0
View file @
56e5681a
<?php
namespace
App\Http\Controllers
;
use
GuzzleHttp\Client
;
use
Closure
;
Class
MasheryAPIClient
extends
Controller
{
private
$client
=
null
;
public
$API_URL
=
'https://api.mashery.com/v3/'
;
private
$auth_key
;
private
$auth_secret
;
public
$accessToken
;
public
function
__construct
(
$key
,
$secret
)
{
$this
->
auth_key
=
$key
;
$this
->
auth_secret
=
$secret
;
$this
->
client
=
new
Client
([
'base_uri'
=>
$this
->
API_URL
,
'headers'
=>
[
'Content-Type'
=>
'application/x-www-form-urlencoded'
,
'Authorization'
=>
'Basic eTRhNXJ6NWNjdjM3NHF1MzM1NThmNjViOnl1WlJudkt2WVk='
],
'auth'
=>
[
$this
->
auth_key
,
$this
->
auth_secret
],
]);
}
public
function
prepareAccessToken
()
{
$url
=
'token'
;
$body
=
[
'grant_type'
=>
'password'
,
'username'
=>
'marketplace.dev'
,
'password'
=>
'Marketplace123'
,
'scope'
=>
'71338066-f062-4feb-84b7-6547f0dc4e82'
];
$response
=
$this
->
client
->
request
(
'POST'
,
$url
,
[
'body'
=>
json_encode
(
$body
)
]);
$result
=
json_decode
(
$response
->
getBody
()
->
getContents
());
$this
->
accessToken
=
$result
->
access_token
;
return
$this
->
accessToken
;
}
}
\ No newline at end of file
app/Http/Controllers/MasheryController.php
View file @
c0e0b669
...
@@ -72,92 +72,4 @@ class MasheryController extends Controller
...
@@ -72,92 +72,4 @@ class MasheryController extends Controller
return
response
()
->
json
(
$mResponse
,
$statusCode
);
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
public
function
getUser
(
Request
$request
)
{
$token
=
$request
->
get
(
'token'
);
$mashUsername
=
$request
->
get
(
'username'
);
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$client
=
new
Client
([
'base_uri'
=>
'https://api.mashery.com/v3/'
,
'headers'
=>
[
'Authorization'
=>
'Bearer '
.
$token
,
],
'http_errors'
=>
true
]);
$response
=
$client
->
request
(
'GET'
,
'rest/members?filter=username:'
.
$mashUsername
);
$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
(
Request
$request
)
{
$token
=
$request
->
get
(
'token'
);
$username
=
$request
->
get
(
'username'
);
$email
=
$request
->
get
(
'email'
);
$dname
=
$request
->
get
(
'dname'
);
$pass
=
$request
->
get
(
'pass'
);
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$client
=
new
Client
([
'base_uri'
=>
'https://api.mashery.com/v3/'
,
'headers'
=>
[
'Authorization'
=>
'Bearer '
.
$token
,
],
'http_errors'
=>
false
]);
$response
=
$client
->
request
(
'POST'
,
'rest/members'
,
[
'json'
=>
[
'username'
=>
$username
,
'email'
=>
$email
,
'displayName'
=>
$dname
,
'areaStatus'
=>
'active'
,
'externalId'
=>
''
,
'passwdNew'
=>
$pass
]
]);
$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/MasheryGetTokenController.php
deleted
100644 → 0
View file @
56e5681a
<?php
namespace
App\Http\Controllers
;
require
‘
vendor
/
autoload
.
php
’
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\Exception\RequestException
;
use
GuzzleHttp\Psr7\Request
;
class
MasheryGetTokenController
extends
Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public
function
__construct
()
{
//
}
public
function
getToken
(){
$api_key
=
'y4a5rz5ccv374qu33558f65b'
;
$api_secret
=
'yuZRnvKvYY'
;
$cw_api
=
new
MasheryAPIClient
(
$api_key
,
$api_secret
);
$token
=
$cw_api
->
prepare_access_token
();
var_dump
(
$token
);
}
}
app/Http/Controllers/MasheryGetUserController.php
deleted
100644 → 0
View file @
56e5681a
<?php
namespace
App\Http\Controllers
;
use
GuzzleHttp\Client
;
use
App\Http\Controllers\MasheryAPIClient
;
use
Closure
;
Class
MasheryGetUserController
extends
controller
{
private
$client
=
null
;
private
$name
=
'marketplace.dev'
;
private
$token
=
null
;
public
function
__construct
()
{
}
public
function
getUser
()
{
$url
=
'rest/members?filter=username:'
.
$this
->
name
;
$this
->
client
=
new
Client
([
'base_uri'
=>
$this
->
API_URL
,
'headers'
=>
[
'Authorization'
=>
'Bearer '
.
$this
->
token
,
'Content-Type'
=>
'application/json'
,
]
]);
$response
=
$this
->
client
->
request
(
'GET'
,
$url
);
$result
=
json_decode
(
$response
->
getBody
()
->
getContents
());
return
response
()
->
json
(
$result
);
}
}
\ No newline at end of file
app/Http/Controllers/UserController.php
View file @
c0e0b669
...
@@ -10,6 +10,7 @@ namespace App\Http\Controllers;
...
@@ -10,6 +10,7 @@ namespace App\Http\Controllers;
use
App\Classes\MResponse
;
use
App\Classes\MResponse
;
use
App\Http\Request\UserByUsernameRequest
;
use
App\Http\Request\UserByUsernameRequest
;
use
App\Http\Request\CreateUserRequest
;
class
UserController
extends
BaseController
class
UserController
extends
BaseController
{
{
...
@@ -42,4 +43,39 @@ class UserController extends BaseController
...
@@ -42,4 +43,39 @@ class UserController extends BaseController
return
response
()
->
json
(
$mResponse
,
$statusCode
);
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
public
function
createUser
(
CreateUserRequest
$request
)
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$response
=
$this
->
masheryClient
()
->
request
(
'POST'
,
'https://api.mashery.com/v3/rest/members'
,
[
'json'
=>
[
'username'
=>
$request
->
get
(
'username'
),
'email'
=>
$request
->
get
(
'email'
),
'displayName'
=>
$request
->
get
(
'name'
),
'areaStatus'
=>
'active'
,
'externalId'
=>
''
,
'passwdNew'
=>
$request
->
get
(
'password'
)
]
]);
$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
0 → 100644
View file @
c0e0b669
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:45 PM
*/
namespace
App\Http\Request
;
class
CreateDefaultApplicationRequest
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/CreateUserRequest.php
0 → 100644
View file @
c0e0b669
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:45 PM
*/
namespace
App\Http\Request
;
class
CreateUserRequest
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'
,
'email'
=>
'required'
,
'name'
=>
'required'
,
'password'
=>
'required'
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public
function
messages
()
{
return
[];
}
protected
function
modifyData
()
{
$data
=
$this
->
validationData
();
return
$data
;
}
}
composer.lock
View file @
c0e0b669
...
@@ -1759,16 +1759,16 @@
...
@@ -1759,16 +1759,16 @@
},
},
{
{
"name": "nesbot/carbon",
"name": "nesbot/carbon",
"version": "2.16.
2
",
"version": "2.16.
3
",
"source": {
"source": {
"type": "git",
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "
720a9c36927396efeeb48a972e9d129d44b6dc28
"
"reference": "
373d9f0d58651af366435148c39beb702c2b7ef4
"
},
},
"dist": {
"dist": {
"type": "zip",
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/
720a9c36927396efeeb48a972e9d129d44b6dc28
",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/
373d9f0d58651af366435148c39beb702c2b7ef4
",
"reference": "
720a9c36927396efeeb48a972e9d129d44b6dc28
",
"reference": "
373d9f0d58651af366435148c39beb702c2b7ef4
",
"shasum": ""
"shasum": ""
},
},
"require": {
"require": {
...
@@ -1815,7 +1815,7 @@
...
@@ -1815,7 +1815,7 @@
"datetime",
"datetime",
"time"
"time"
],
],
"time": "2019-0
3-29T12:23:12
+00:00"
"time": "2019-0
4-06T17:09:23
+00:00"
},
},
{
{
"name": "nikic/fast-route",
"name": "nikic/fast-route",
...
@@ -4619,16 +4619,16 @@
...
@@ -4619,16 +4619,16 @@
},
},
{
{
"name": "theseer/tokenizer",
"name": "theseer/tokenizer",
"version": "1.1.
1
",
"version": "1.1.
2
",
"source": {
"source": {
"type": "git",
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
"url": "https://github.com/theseer/tokenizer.git",
"reference": "
06b6ce404ee574e9c1787fb67bb9980ca4387c34
"
"reference": "
1c42705be2b6c1de5904f8afacef5895cab44bf8
"
},
},
"dist": {
"dist": {
"type": "zip",
"type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/
06b6ce404ee574e9c1787fb67bb9980ca4387c34
",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/
1c42705be2b6c1de5904f8afacef5895cab44bf8
",
"reference": "
06b6ce404ee574e9c1787fb67bb9980ca4387c34
",
"reference": "
1c42705be2b6c1de5904f8afacef5895cab44bf8
",
"shasum": ""
"shasum": ""
},
},
"require": {
"require": {
...
@@ -4655,7 +4655,7 @@
...
@@ -4655,7 +4655,7 @@
}
}
],
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2019-04-0
3T18:37:40
+00:00"
"time": "2019-04-0
4T09:56:43
+00:00"
},
},
{
{
"name": "webmozart/assert",
"name": "webmozart/assert",
...
...
routes/web.php
View file @
c0e0b669
...
@@ -31,5 +31,13 @@ $router->group(['prefix' => 'mashery'], function () use ($router) {
...
@@ -31,5 +31,13 @@ $router->group(['prefix' => 'mashery'], function () use ($router) {
$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
->
post
(
'create'
,
'UserController@createUser'
);
});
$router
->
group
([
'prefix'
=>
'application'
],
function
()
use
(
$router
)
{
$router
->
post
(
'create-default'
,
'ApplicationController@createDefault'
);
$router
->
post
(
'create'
,
'ApplicationController@createApp'
);
});
});
});
});
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