# Path: emailcongress/utils.py
# def construct_link(protocol, hostname, path, get_param_dict=None):
#     link = protocol + '://' + hostname + path
#     if get_param_dict is not None:
#         link += '?' + parse.urlencode(get_param_dict)
#     return link


import os
import sys
import requests
import uuid
import traceback
import string
import random
import json
from django.core.management.base import BaseCommand, CommandError
from django.core import management
from django.conf import settings
from raven.contrib.django.raven_compat.models import client
from emailcongress.models import *
from emailcongress.utils import construct_link
        from tests.factories import user, user_message_info, message, admin_user
    create_test_data()


def simulate_postmark_message(from_email, to_emails=None, messageid=None):

    if from_email not in settings.POSTMARK_DEBUG_EMAILS:
        return from_email + " not in admin emails: " + str(settings.POSTMARK_DEBUG_EMAILS)

    messageid = uuid.uuid4().hex if messageid is None else messageid
    if to_emails is None:
        to_emails = [{'Email': 'Rep.Zinke@emailcongress.us'}]
    elif type(to_emails) is str:
        to_emails = [{'Email': to_emails}]
    elif type(to_emails) is list:
        to_emails = [{'Email': te} for te in to_emails]
    else:
        raise Exception('Bad input')

    params = {
        'Subject': 'Thank you!',
        'TextBody': "Thank you for everything that you do!",
        'Date': 'Thu, 5 Apr 2014 16:59:01 +0200',
        'MessageID': messageid,
        "FromFull": {
            "Email": from_email,
            "Name": "John Smith",
        },
        "ToFull": to_emails
    }
    try:

# Path: emailcongress/utils.py
# def construct_link(protocol, hostname, path, get_param_dict=None):
#     link = protocol + '://' + hostname + path
#     if get_param_dict is not None:
#         link += '?' + parse.urlencode(get_param_dict)
#     return link


# Path: emailcongress/management/commands/admin_task.py
import os
import sys
import requests
import uuid
import traceback
import string
import random
import json
from django.core.management.base import BaseCommand, CommandError
from django.core import management
from django.conf import settings
from raven.contrib.django.raven_compat.models import client
from emailcongress.models import *
from emailcongress.utils import construct_link
        from tests.factories import user, user_message_info, message, admin_user

    create_test_data()


def simulate_postmark_message(from_email, to_emails=None, messageid=None):

    if from_email not in settings.POSTMARK_DEBUG_EMAILS:
        return from_email + " not in admin emails: " + str(settings.POSTMARK_DEBUG_EMAILS)

    messageid = uuid.uuid4().hex if messageid is None else messageid
    if to_emails is None:
        to_emails = [{'Email': 'Rep.Zinke@emailcongress.us'}]
    elif type(to_emails) is str:
        to_emails = [{'Email': to_emails}]
    elif type(to_emails) is list:
        to_emails = [{'Email': te} for te in to_emails]
    else:
        raise Exception('Bad input')

    params = {
        'Subject': 'Thank you!',
        'TextBody': "Thank you for everything that you do!",
        'Date': 'Thu, 5 Apr 2014 16:59:01 +0200',
        'MessageID': messageid,
        "FromFull": {
            "Email": from_email,
            "Name": "John Smith",
        },
        "ToFull": to_emails
    }
    try:

        url = construct_link(settings.PROTOCOL, settings.HOSTNAME, '/postmark/inbound')