"""Email sending logic.""" # flake8: noqa import textwrap import boto3 from participant import config def send( notification_email, participant_id, participant_name, product_id, product_name, upc, vendor_id, subaccount_id, message, current_artist_name, new_artist_name, ): """Send email.""" if not notification_email: return artist_name_update_text = '' if current_artist_name and new_artist_name: artist_name_update_text = f"""Request Artist Name Update

Current Name:
{current_artist_name}

New Artist Name:
{new_artist_name}

""" message_text = '' if message: message_text = f"""Message:
{message}

""" html_email = textwrap.dedent( f""" Greetings Label Manager,
Your label listed below has notified us that there's missing or incorrect information regarding an artist in their roster. {artist_name_update_text} {message_text} Artist Name:
{participant_name}

UPC:
{upc}

Release/Product ID:
{product_id}

Product Name:
{product_name}

Participant Id:
{participant_id}

Vendor Id:
{vendor_id}

Subaccount Id:
{subaccount_id}

Cheers,
Orchard bot. """ ) ses_client = boto3.client('ses') ses_client.send_email( Source=config.EMAIL_SENDER_ADDRESS, Destination={ 'ToAddresses': [notification_email], 'CcAddresses': config.BASE_EMAIL_CC, }, Message={ 'Subject': { 'Data': 'Missing or Incorrect Artist Profile', 'Charset': 'UTF-8', }, 'Body': { 'Html': { 'Charset': 'UTF-8', 'Data': html_email, } }, }, )