OauthServiceInterface.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Api;
  7. use Magento\Integration\Model\Oauth\Token as OauthTokenModel;
  8. /**
  9. * Integration oAuth Service Interface
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. interface OauthServiceInterface
  15. {
  16. /**
  17. * Create a new consumer account.
  18. *
  19. * @param array $consumerData - Information provided by an integration when the integration is installed.
  20. * <pre>
  21. * array(
  22. * 'name' => 'Integration Name',
  23. * '...' => '...', // Other consumer data can be passed as well
  24. * )
  25. * </pre>
  26. * @return \Magento\Integration\Model\Oauth\Consumer
  27. * @throws \Magento\Framework\Exception\LocalizedException
  28. * @throws \Magento\Framework\Oauth\Exception
  29. */
  30. public function createConsumer($consumerData);
  31. /**
  32. * Create access token for provided consumer.
  33. *
  34. * @param int $consumerId
  35. * @param bool $clearExistingToken
  36. * @return bool If token was created
  37. */
  38. public function createAccessToken($consumerId, $clearExistingToken = false);
  39. /**
  40. * Retrieve access token assigned to the consumer.
  41. *
  42. * @param int $consumerId
  43. * @return OauthTokenModel|bool Return false if no access token is available.
  44. */
  45. public function getAccessToken($consumerId);
  46. /**
  47. * Load consumer by its ID.
  48. *
  49. * @param int $consumerId
  50. * @return \Magento\Integration\Model\Oauth\Consumer
  51. * @throws \Magento\Framework\Oauth\Exception
  52. * @throws \Magento\Framework\Exception\LocalizedException
  53. */
  54. public function loadConsumer($consumerId);
  55. /**
  56. * Load consumer by its key.
  57. *
  58. * @param string $key
  59. * @return \Magento\Integration\Model\Oauth\Consumer
  60. * @throws \Magento\Framework\Oauth\Exception
  61. * @throws \Magento\Framework\Exception\LocalizedException
  62. */
  63. public function loadConsumerByKey($key);
  64. /**
  65. * Execute post to integration (consumer) HTTP Post URL. Generate and return oauth_verifier.
  66. *
  67. * @param int $consumerId - The consumer Id.
  68. * @param string $endpointUrl - The integration endpoint Url (for HTTP Post)
  69. * @return string - The oauth_verifier.
  70. * @throws \Magento\Framework\Exception\LocalizedException
  71. * @throws \Magento\Framework\Oauth\Exception
  72. */
  73. public function postToConsumer($consumerId, $endpointUrl);
  74. /**
  75. * Delete the consumer data associated with the integration including its token and nonce
  76. *
  77. * @param int $consumerId
  78. * @return array Consumer data array
  79. */
  80. public function deleteConsumer($consumerId);
  81. /**
  82. * Remove token associated with provided consumer.
  83. *
  84. * @param int $consumerId
  85. * @return bool If token was deleted
  86. */
  87. public function deleteIntegrationToken($consumerId);
  88. }