feat: Commerce Coordinator step in retirement pipeline
This commit is contained in:
@@ -490,3 +490,17 @@ class LicenseManagerApi(BaseApiClient):
|
||||
except HttpDoesNotExistException:
|
||||
LOG.info("No license manager data found for user")
|
||||
return True
|
||||
|
||||
class CommerceCoordinatorApi(BaseApiClient):
|
||||
"""
|
||||
Commerce-Coordinator API client.
|
||||
"""
|
||||
@_retry_lms_api()
|
||||
def retire_learner(self, learner):
|
||||
"""
|
||||
Performs the learner retirement step for Commerce-Coordinator.
|
||||
Passes the learner's LMS User Id instead of username.
|
||||
"""
|
||||
data = {'edx_lms_user_id': learner['user']['id']}
|
||||
api_url = self.get_api_url('lms/user_retirement')
|
||||
return self._request('POST', api_url, json=data)
|
||||
|
||||
@@ -18,7 +18,8 @@ import yaml
|
||||
from six import text_type
|
||||
|
||||
from scripts.user_retirement.utils.edx_api import LmsApi # pylint: disable=wrong-import-position
|
||||
from scripts.user_retirement.utils.edx_api import CredentialsApi, EcommerceApi, LicenseManagerApi
|
||||
from scripts.user_retirement.utils.edx_api import CommerceCoordinatorApi, CredentialsApi, EcommerceApi, \
|
||||
LicenseManagerApi
|
||||
from scripts.user_retirement.utils.thirdparty_apis.amplitude_api import \
|
||||
AmplitudeApi # pylint: disable=wrong-import-position
|
||||
from scripts.user_retirement.utils.thirdparty_apis.braze_api import BrazeApi # pylint: disable=wrong-import-position
|
||||
@@ -154,6 +155,7 @@ def _setup_all_apis_or_exit(fail_func, fail_code, config):
|
||||
credentials_base_url = config['base_urls'].get('credentials', None)
|
||||
segment_base_url = config['base_urls'].get('segment', None)
|
||||
license_manager_base_url = config['base_urls'].get('license_manager', None)
|
||||
commerce_coordinator_base_url = config['base_urls'].get('commerce_coordinator', None)
|
||||
client_id = config['client_id']
|
||||
client_secret = config['client_secret']
|
||||
braze_api_key = config.get('braze_api_key', None)
|
||||
@@ -180,6 +182,7 @@ def _setup_all_apis_or_exit(fail_func, fail_code, config):
|
||||
('CREDENTIALS', credentials_base_url),
|
||||
('SEGMENT', segment_base_url),
|
||||
('HUBSPOT', hubspot_api_key),
|
||||
('COMMERCE_COORDINATOR', commerce_coordinator_base_url),
|
||||
):
|
||||
if state[2] == service and service_url is None:
|
||||
fail_func(fail_code, 'Service URL is not configured, but required for state {}'.format(state))
|
||||
@@ -235,5 +238,13 @@ def _setup_all_apis_or_exit(fail_func, fail_code, config):
|
||||
segment_auth_token,
|
||||
segment_workspace_slug
|
||||
)
|
||||
|
||||
if commerce_coordinator_base_url:
|
||||
config['COMMERCE_COORDINATOR'] = CommerceCoordinatorApi(
|
||||
lms_base_url,
|
||||
commerce_coordinator_base_url,
|
||||
client_id,
|
||||
client_secret,
|
||||
)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
fail_func(fail_code, 'Unexpected error occurred!', exc)
|
||||
|
||||
Reference in New Issue
Block a user