# -*- coding: utf-8 -*-

"""
    pepipost.models.email_body

    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import pepipost.models.personalizations
import pepipost.models.mfrom
import pepipost.models.email_body_attachments
import pepipost.models.settings

class EmailBody(object):

    """Implementation of the 'emailBody' model.

    Mail Body which will be passed as json in apicall.

    Attributes:
        personalizations (list of Personalizations): TODO: type description
            here.
        tags (string): TODO: type description here.
        mfrom (From): TODO: type description here.
        subject (string): TODO: type description here.
        content (string): TODO: type description here.
        attachments (list of EmailBodyAttachments): TODO: type description
            here.
        settings (Settings): TODO: type description here.
        reply_to_id (string): TODO: type description here.
        template_id (int): TODO: type description here.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "personalizations":'personalizations',
        "tags":'tags',
        "mfrom":'from',
        "subject":'subject',
        "content":'content',
        "attachments":'attachments',
        "settings":'settings',
        "reply_to_id":'replyToId',
        "template_id":'templateId'
    }

    def __init__(self,
                 personalizations=None,
                 tags=None,
                 mfrom=None,
                 subject=None,
                 content=None,
                 attachments=None,
                 settings=None,
                 reply_to_id=None,
                 template_id=None):
        """Constructor for the EmailBody class"""

        # Initialize members of the class
        self.personalizations = personalizations
        self.tags = tags
        self.mfrom = mfrom
        self.subject = subject
        self.content = content
        self.attachments = attachments
        self.settings = settings
        self.reply_to_id = reply_to_id
        self.template_id = template_id


    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object as
            obtained from the deserialization of the server's response. The keys
            MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if dictionary is None:
            return None

        # Extract variables from the dictionary
        personalizations = None
        if dictionary.get('personalizations') != None:
            personalizations = list()
            for structure in dictionary.get('personalizations'):
                personalizations.append(pepipost.models.personalizations.Personalizations.from_dictionary(structure))
        tags = dictionary.get('tags')
        mfrom = pepipost.models.mfrom.From.from_dictionary(dictionary.get('from')) if dictionary.get('from') else None
        subject = dictionary.get('subject')
        content = dictionary.get('content')
        attachments = None
        if dictionary.get('attachments') != None:
            attachments = list()
            for structure in dictionary.get('attachments'):
                attachments.append(pepipost.models.email_body_attachments.EmailBodyAttachments.from_dictionary(structure))
        settings = pepipost.models.settings.Settings.from_dictionary(dictionary.get('settings')) if dictionary.get('settings') else None
        reply_to_id = dictionary.get('replyToId')
        template_id = dictionary.get('templateId')

        # Return an object of this model
        return cls(personalizations,
                   tags,
                   mfrom,
                   subject,
                   content,
                   attachments,
                   settings,
                   reply_to_id,
                   template_id)


