-
-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added JSON-RPC API support #2273
Conversation
PHPStan fails for reasons unrelated to this PR. |
The base branch was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used a variation of this which enabled soap_v2 style calling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My test script:
public function jsonrpcAction()
{
$result = [];
$url = Mage::getStoreConfig('muze/stars/url');
$client = new Krixon_JsonRpc_Client($url);
$sessionId = Mage::getSingleton('customer/session')->getData('jsonsessionKey');
if (!$sessionId) {
$apiUser = Mage::getStoreConfig('muze/stars/user');
$apiKey = Mage::getStoreConfig('muze/stars/key');
$session = $client->call('login', [$apiUser, $apiKey]);
if ($session instanceof stdClass) {
if (property_exists($session, 'result')) {
$sessionId = $session->result;
Mage::getSingleton('customer/session')->setData('jsonsessionKey', $sessionId);
} else {
Mage::getSingleton('customer/session')->unsetData('jsonsessionKey');
return $this->_echo($session, 'cannot login');
}
} else {
return $this->_echo($session, 'unexpected response');
}
$result['new_session'] = $sessionId;
} else {
$result['session'] = $sessionId;
}
/** @var stdClass $std */
$std = $client->call('call', [$sessionId, 'magento.info', []]);
if (property_exists($std, 'error')) {
if ($std->error->code === -32002) {
Mage::getSingleton('customer/session')->unsetData('jsonsessionKey');
}
}
$result['magento.info'] = $std;
$this->_echo($result);
}
Result:
array(2) {
["new_session"] => string(32) "a3253324b025fcd5789659c2f75aaa06"
["magento.info"] => object(stdClass)#168 (3) {
["result"] => object(stdClass)#81 (3) {
["magento_edition"] => string(9) "Community"
["magento_version"] => string(7) "1.9.4.5"
["openmage_version"] => string(7) "20.0.16"
}
["id"] => string(13) "64da3c21b96ef"
["jsonrpc"] => string(3) "2.0"
}
}
Please credit the source repository @gamuzatech |
This implementation is very similar to my module: |
Please give due credit to the source repository @gamuzatech, there was time for research and development so that I could contribute to the community |
wow, zero comments in 1.1 years and 3 comments accusing me of stealing in 3 minutes. I'll put my answer in points for easier quoting
@colinmollenhour @ADDISON74 @kiatng @elidrissidev @Flyingmana what do you think we should do here? |
My opinion is that your PR solves an issue reported in OpenMage. It was suggested by a person I have not met so far in discussions that another author should be credited for this PR. The source shown does not resemble your implementation, I doubt that you analyzed it because you had to spend time to see if it solves the issue, then adapted to OpenMage not as a module but directly in the existing code. From a legal perspective, if we look at the copyright applied to the source, the situation is resolved. Before coming with legal arguments, I ask kindly the person @medeirosleandro who made the accusation that the code is taken from another repository to come with clear evidence in this regard. If it is only about the fact that there is someone else with an implementation, then the initial statement was wrong because we have to discuss about stealing code. Then we decide whether to credit the author or not. |
this PR contains 3 files
|
@fballiano - You don't have to explain, but the one who made the accusation, which seems serious to me. |
I don't see any evidence that the gamuzatech repo was used as a source - same idea, simple feature, same outcome. Given that you're implementing an interface there is basically only one way to do it and JSONRPC is an open standard.. If @medeirosleandro or @eneiasramos want to push it further I think they need to make a stronger case than just having done it first. I made a JSONRPC adapter myself for a private project back in February of 2013 which pre-dates the Gamuza one - it really wasn't hard, will gladly share it if needed but I think that is not necessary. |
I'd say it resembles the core Besides, there's only so many ways to implement such functionality, so having some resemblance between them isn't out of the ordinary. |
This PR adds support for JSON RPC protocol for API calls.
Manual testing scenarios (*)
I tested these APIs with postman using this "body" for the login method
and this "body" for the "call" method