diff --git a/api/.env.sample b/api/.env.sample
index 8e69ad308..f3efbbf76 100644
--- a/api/.env.sample
+++ b/api/.env.sample
@@ -81,3 +81,6 @@ MRAS_SVC_API_KEY=
# Local development only
DISABLE_NAMEREQUEST_SOLR_UPDATES=1
+
+# launchdarkly
+NAMEX_LD_SDK_ID=sdk-075200eb-4ff7-4e0e-872a-848585d3d460
diff --git a/api/Makefile b/api/Makefile
index 9e91ec385..8db037f30 100644
--- a/api/Makefile
+++ b/api/Makefile
@@ -143,4 +143,4 @@ db: ## Update the local database
.DEFAULT_GOAL := help
help:
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
\ No newline at end of file
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
diff --git a/api/namex/resources/name_requests/report_resource.py b/api/namex/resources/name_requests/report_resource.py
index 31e8e3cf9..e69ef11bf 100644
--- a/api/namex/resources/name_requests/report_resource.py
+++ b/api/namex/resources/name_requests/report_resource.py
@@ -174,12 +174,6 @@ def _get_template_data(nr_model):
nr_report_json['applicants']['countryName'] = \
pycountry.countries.search_fuzzy(nr_report_json['applicants']['countryTypeCd'])[0].name
actions_obj = ReportResource._get_next_action_text(nr_model['entity_type_cd'])
- structured_log(request, "DEBUG", f"NR_notification - NameX API: {actions_obj}")
- current_app.logger.debug(f"NR_notification - NameX API: {actions_obj}")
- structured_log(request, "DEBUG", f"NR_notification - NameX API: {nr_report_json['request_action_cd']}")
- current_app.logger.debug(f"NR_notification - NameX API: {nr_report_json['request_action_cd']}")
- structured_log(request, "DEBUG", f"NR_notification - NameX API: {nr_model['entity_type_cd']}")
- current_app.logger.debug(f"NR_notification - NameX API: {nr_model['entity_type_cd']}")
if actions_obj:
action_text = actions_obj.get(nr_report_json['request_action_cd'])
if not action_text:
@@ -283,7 +277,7 @@ def _is_modernized(legal_type):
@staticmethod
def _is_colin(legal_type):
- colin_list = ['XCR', 'XUL', 'RLC']
+ colin_list = ['CR', 'UL', 'CC', 'XCR', 'XUL', 'RLC']
return legal_type in colin_list
@staticmethod
@@ -292,24 +286,13 @@ def _is_society(legal_type):
return legal_type in society_list
@staticmethod
- def _is_potential_colin(legal_type):
- potential_colin_list = ['CR', 'UL', 'CC']
- return legal_type in potential_colin_list
-
- @staticmethod
- def _get_instruction_group(legal_type, request_action, corpNum):
- if request_action == RequestAction.CHG.value or RequestAction.CNV.value:
- # For the 'Name Change' or 'Alteration', return 'modernized' if the company is in LEAR, and 'colin' if not
- return 'modernized' if ReportResource._is_lear_entity(corpNum) else 'colin'
+ def _get_instruction_group(legal_type):
if ReportResource._is_modernized(legal_type):
return 'modernized'
if ReportResource._is_colin(legal_type):
return 'colin'
if ReportResource._is_society(legal_type):
return 'so'
- # return "new" for BC/CC/ULC IAs, "colin" for for BC/CC/ULC others
- if ReportResource._is_potential_colin(legal_type):
- return 'new' if request_action == RequestAction.NEW.value else 'colin'
return ''
@staticmethod
@@ -388,12 +371,10 @@ def _get_next_action_text(entity_type_cd: str):
next_action_text = {
# BC Types
'CR': {
- 'NEW': 'Check your email for instructions on how to complete your application using this name request.',
'DEFAULT': f'Use this name request to complete your application by visiting '
f'{url}'
},
'UL': {
- 'NEW': 'Check your email for instructions on how to complete your application using this name request.',
'DEFAULT': f'Use this name request to complete your application by visiting '
f'{url}'
},
@@ -436,7 +417,6 @@ def _get_next_action_text(entity_type_cd: str):
'DEFAULT': f'Use this name request to complete your application by visiting {url}'
},
'CC': {
- 'NEW': 'Check your email for instructions on how to complete your application using this name request.',
'DEFAULT': f'Use this name request to complete your application by visiting '
f'{url}'
},
diff --git a/services/emailer/.env.sample b/services/emailer/.env.sample
index 4b42328a6..32359d165 100644
--- a/services/emailer/.env.sample
+++ b/services/emailer/.env.sample
@@ -26,4 +26,5 @@
DASHBOARD_URL=
AUTH_WEB_URL=
BUSINESS_REGISTRY_URL=
-
\ No newline at end of file
+
+ NAMEX_LD_SDK_ID=sdk-075200eb-4ff7-4e0e-872a-848585d3d460
diff --git a/services/emailer/config.py b/services/emailer/config.py
index 3d39cf39b..73d630ca6 100644
--- a/services/emailer/config.py
+++ b/services/emailer/config.py
@@ -73,7 +73,7 @@ class Config: # pylint: disable=too-few-public-methods
ENVIRONMENT = os.getenv("APP_ENV", "prod")
- LD_SDK_KEY = os.getenv("LD_SDK_KEY", None)
+ NAMEX_LD_SDK_ID = os.getenv("NAMEX_LD_SDK_ID", None)
SENTRY_DSN = os.getenv("SENTRY_DSN", None)
@@ -90,8 +90,8 @@ class Config: # pylint: disable=too-few-public-methods
NOTIFY_API_VERSION = os.getenv("NOTIFY_API_VERSION", "")
NAMEX_API_URL = os.getenv("NAMEX_API_URL", "")
NAMEX_API_VERSION = os.getenv("NAMEX_API_VERSION", "")
- LEGAL_API_URL = os.getenv("NOTIFY_API_URL", "https://legal-api-dev.apps.silver.devops.gov.bc.ca")
- LEGAL_API_VERSION = os.getenv("NOTIFY_API_VERSION", "/api/v2")
+ LEGAL_API_URL = os.getenv("LEGAL_API_URL", "https://legal-api-dev.apps.silver.devops.gov.bc.ca")
+ LEGAL_API_VERSION = os.getenv("LEGAL_API_VERSION", "/api/v1")
NOTIFY_API_URL = f"{NOTIFY_API_URL + NOTIFY_API_VERSION}/notify"
NAMEX_SVC_URL = f"{NAMEX_API_URL + NAMEX_API_VERSION}"
diff --git a/services/emailer/devops/vault.json b/services/emailer/devops/vault.json
index 688ddd9d3..bf0dc7377 100644
--- a/services/emailer/devops/vault.json
+++ b/services/emailer/devops/vault.json
@@ -40,5 +40,11 @@
"auth-web",
"business-registry-ui"
]
+ },
+ {
+ "vault": "launchdarkly",
+ "application": [
+ "namex"
+ ]
}
]
\ No newline at end of file
diff --git a/services/emailer/devops/vaults.gcp.env b/services/emailer/devops/vaults.gcp.env
index 572ad5327..731b7baeb 100644
--- a/services/emailer/devops/vaults.gcp.env
+++ b/services/emailer/devops/vaults.gcp.env
@@ -22,4 +22,6 @@ BUSINESS_REGISTRY_URL="op://web-url/$APP_ENV/business-registry-ui/BUSINESS_REGIS
REPORT_API_URL="op://API/$APP_ENV/report-api/REPORT_API_URL"
REPORT_API_VERSION="op://API/$APP_ENV/report-api/REPORT_API_VERSION"
LEGAL_API_URL="op://API/$APP_ENV/legal-api/LEGAL_API_URL"
+LEGAL_API_VERSION="op://API/$APP_ENV/legal-api/LEGAL_API_VERSION"
+NAMEX_LD_SDK_ID="op://launchdarkly/$APP_ENV/namex/NAMEX_LD_SDK_ID"
SENTRY_DSN=""
diff --git a/services/emailer/src/namex_emailer/email_processors/nr_notification.py b/services/emailer/src/namex_emailer/email_processors/nr_notification.py
index e2650013d..b57d4e5fb 100644
--- a/services/emailer/src/namex_emailer/email_processors/nr_notification.py
+++ b/services/emailer/src/namex_emailer/email_processors/nr_notification.py
@@ -27,7 +27,7 @@
from namex.constants import RequestAction
from namex.resources.name_requests import ReportResource
from namex_emailer.email_processors import substitute_template_parts
-from namex_emailer.services.helpers import as_legislation_timezone, format_as_report_string, get_magic_link, query_nr_number, get_instruction_group
+from namex_emailer.services.helpers import as_legislation_timezone, format_as_report_string, get_magic_link, query_nr_number
class Option(Enum):
"""NR notification option."""
@@ -89,9 +89,7 @@ def process(email_info: SimpleCloudEvent, option) -> dict: # pylint: disable-ms
legal_type = nr_data["entity_type_cd"]
request_action = nr_data["request_action_cd"]
corpNum = nr_data["corpNum"]
- # This function will be restred after the emailer service and NameX API are sync well.
- # group = ReportResource._get_instruction_group(legal_type, request_action, corpNum)
- group = get_instruction_group(legal_type, request_action, corpNum)
+ group = ReportResource._get_instruction_group(legal_type, request_action, corpNum)
if group:
instruction_group = "-" + group
file_name_suffix += instruction_group.upper()
diff --git a/services/emailer/src/namex_emailer/email_processors/nr_result.py b/services/emailer/src/namex_emailer/email_processors/nr_result.py
index 11fdd85ce..9e4597c8d 100644
--- a/services/emailer/src/namex_emailer/email_processors/nr_result.py
+++ b/services/emailer/src/namex_emailer/email_processors/nr_result.py
@@ -10,7 +10,7 @@
from simple_cloudevent import SimpleCloudEvent
from datetime import datetime
-from namex_emailer.services.helpers import get_magic_link, query_nr_number, get_instruction_group
+from namex_emailer.services.helpers import get_magic_link, query_nr_number
RESULT_EMAIL_SUBJECT = 'Name Request Results from Corporate Registry'
CONSENT_EMAIL_SUBJECT = 'Consent Received by Corporate Registry'
@@ -50,11 +50,7 @@ def email_consent_letter(email_info: SimpleCloudEvent):
template_path = current_app.config.get('REPORT_TEMPLATE_PATH')
file_name = 'consent'
legal_type = nr_model['entity_type_cd']
- request_action = nr_model["request_action_cd"]
- corpNum = nr_model["corpNum"]
- # This function will be restred after the emailer service and NameX API are sync well.
- # instruction_group = ReportResource._get_instruction_group(legal_type, request_action, corpNum)
- instruction_group = get_instruction_group(legal_type, request_action, corpNum)
+ instruction_group = ReportResource._get_instruction_group(legal_type)
if instruction_group:
file_name = f"{file_name}-{instruction_group}"
email_template = Path(f'{template_path}/{file_name}.md').read_text()
@@ -102,12 +98,7 @@ def email_report(email_info: SimpleCloudEvent):
email_template = Path(f'{template_path}/rejected.md').read_text()
if nr_model['stateCd'] in [State.APPROVED, State.CONDITIONAL]:
legal_type = nr_model['entity_type_cd']
- request_action = nr_model["request_action_cd"]
- corpNum = nr_model["corpNum"]
- # This function will be restred after the emailer service and NameX API are sync well.
- # instruction_group = ReportResource._get_instruction_group(legal_type, request_action, corpNum)
- instruction_group = get_instruction_group(legal_type, request_action, corpNum)
- structured_log(request, "DEBUG", f"NR_notification: {instruction_group}")
+ instruction_group = ReportResource._get_instruction_group(legal_type)
file_name=''
if nr_model['consentFlag'] in ['Y', 'R']:
file_name = 'conditional'
@@ -120,7 +111,6 @@ def email_report(email_info: SimpleCloudEvent):
email_template = Path(f'{template_path}/{file_name}.md').read_text()
- structured_log(request, "DEBUG", f"NR_notification: {nr_model}")
email_body = _build_email_body(email_template, nr_model, recipient_emails[0], recipient_phones[0])
email = {
@@ -163,4 +153,4 @@ def _build_email_body(template: str, nr_model, email, phone):
if isinstance(val, datetime):
val = val.strftime(DATE_FORMAT)
template = template.replace(template_string, val)
- return template
\ No newline at end of file
+ return template
diff --git a/services/emailer/src/namex_emailer/services/helpers.py b/services/emailer/src/namex_emailer/services/helpers.py
index d064e087b..a39ff055c 100644
--- a/services/emailer/src/namex_emailer/services/helpers.py
+++ b/services/emailer/src/namex_emailer/services/helpers.py
@@ -2,10 +2,12 @@
import pytz
import requests
-from flask import current_app
+from http import HTTPStatus
+from flask import current_app, request
+from gcp_queue.logging import structured_log
from cachetools import cached, TTLCache
from urllib.parse import urlencode
-from namex.constants import RequestAction
+from namex.resources.name_requests import ReportResource
@staticmethod
@cached(cache=TTLCache(maxsize=1, ttl=180))
@@ -70,41 +72,3 @@ def get_magic_link(nr_number, email, phone):
}
encoded_params = urlencode(params)
return f'{BUSINESS_REGISTRY_URL}incorporateNow/?{encoded_params}'
-
-
-@staticmethod
-def _is_lear_entity(corpNum):
- if not corpNum:
- return False
- entity_url = f'{current_app.config.get("ENTITY_SVC_URL")}/businesses/{corpNum}'
- token = get_bearer_token()
- response = requests.get(entity_url, headers={
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + token
- })
-
- return response
-
-
-# This function will be removed if the emailer service and NameX API are in sync well
-@staticmethod
-def get_instruction_group(legal_type, request_action, corpNum):
- legal_type_groups = {
- 'modernized': ['GP', 'DBA', 'FR', 'CP', 'BC'],
- 'colin': ['XCR', 'XUL', 'RLC'],
- 'society': ['SO', 'XSO'],
- 'potential_colin': ['CR', 'UL', 'CC']
- }
-
- if request_action in {RequestAction.CHG.value, RequestAction.CNV.value}:
- return 'modernized' if _is_lear_entity(corpNum) else 'colin'
- if legal_type in legal_type_groups['modernized']:
- return 'modernized'
- if legal_type in legal_type_groups['colin']:
- return 'colin'
- if legal_type in legal_type_groups['society']:
- return 'so'
- if legal_type in legal_type_groups['potential_colin']:
- return 'new' if request_action == RequestAction.NEW.value else 'colin'
-
- return ''