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

"""
shelldatareportingapis

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from shelldatareportingapis.api_helper import APIHelper
from shelldatareportingapis.models.accounts import Accounts
from shelldatareportingapis.models.exception_product import ExceptionProduct


class TransactionExceptionsRequest(object):

    """Implementation of the 'TransactionExceptionsRequest' model.

    TODO: type model description here.

    Attributes:
        col_co_id (int): Collecting Company Id of the selected payer.  
            Optional if ColCoCode is passed else Mandatory.  Example:  1 for
            Philippines  5 for UK
        col_co_code (int): Collecting Company Code  of the selected payer.  
            Mandatory for serviced OUs such as Romania, Latvia, Lithuania,
            Estonia, Ukraine etc. It is optional for other countries if
            ColCoID is provided.  Example:  86 for Philippines  5 for UK
        payer_id (int): Payer Id of the selected payer. Optional if
            PayerNumber is passed else Mandatory
        payer_number (str): Payer Number of the selected payer. Optional if
            PayerId is passed else Mandatory
        accounts (List[Accounts]): TODO: type description here.
        transactions_from_date (str): Exceptions to be searched in
            transactions from date. Should be with in last 24 months from the
            ToDate parameter. Mandatory Format: yyyyMMdd
        transactions_to_date (str): Exceptions to be searched in transactions
            until date.  Mandatory.   Format: yyyyMMdd
        value (float): Value to be used on the Filter Condition
        condition (int): Filter condition for the Exceptions.  Mandatory  1.
            VolumeGreaterThan  2. VolumeLessThan  3. UsageGreaterThan  4.
            UsageLessThan  5. ValueGreaterThan (in Customer Currency)  6.
            ValueLessThan  (in Customer Currency)  Note: -   When “OutputType”
            = 1 is passed as input, above 3 and 4 Condition are not applicable.
        products (List[ExceptionProduct]): TODO: type description here.
        exception_period (int): Period in which the Exceptions such as
            Monthly/Weekly or Daily volume, value or usage to be identified in
            the given transactions date range. It is only applied when the
            Output Type is specified as "Cards". Mandatory when Output Type is
            Cards 1.    Month 2.    Week 3.    Day 4.    Date Range
        output_type (int): Output Type for Exceptions. Mandatory. Possible
            values: 1.    Transactions 2.    Cards
        fuel_only (bool): True/False  Optional  Default value: False.   When
            passed as ‘True’ Only returned records with Fuel transactions. 
            When passed as ‘False’ the above condition will not be checked.
        site_group_ids (List[int]): SiteGroupIds to be applied to the Filter
            Condition. Optional When not passed, ignored. When passed,
            transactions that are matching with the provided list of site
            group id’s are only returned.
        use_field_id (bool): True/False Optional Default value – False. When
            set to True, the property names in the output will be replaced by
            Field IDs.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "transactions_from_date": 'TransactionsFromDate',
        "transactions_to_date": 'TransactionsToDate',
        "condition": 'Condition',
        "output_type": 'OutputType',
        "col_co_id": 'ColCoId',
        "col_co_code": 'ColCoCode',
        "payer_id": 'PayerId',
        "payer_number": 'PayerNumber',
        "accounts": 'Accounts',
        "value": 'Value',
        "products": 'Products',
        "exception_period": 'ExceptionPeriod',
        "fuel_only": 'FuelOnly',
        "site_group_ids": 'SiteGroupIds',
        "use_field_id": 'UseFieldId'
    }

    _optionals = [
        'col_co_id',
        'col_co_code',
        'payer_id',
        'payer_number',
        'accounts',
        'value',
        'products',
        'exception_period',
        'fuel_only',
        'site_group_ids',
        'use_field_id',
    ]

    def __init__(self,
                 transactions_from_date=None,
                 transactions_to_date=None,
                 condition=None,
                 output_type=None,
                 col_co_id=APIHelper.SKIP,
                 col_co_code=APIHelper.SKIP,
                 payer_id=APIHelper.SKIP,
                 payer_number=APIHelper.SKIP,
                 accounts=APIHelper.SKIP,
                 value=APIHelper.SKIP,
                 products=APIHelper.SKIP,
                 exception_period=APIHelper.SKIP,
                 fuel_only=APIHelper.SKIP,
                 site_group_ids=APIHelper.SKIP,
                 use_field_id=APIHelper.SKIP):
        """Constructor for the TransactionExceptionsRequest class"""

        # Initialize members of the class
        if col_co_id is not APIHelper.SKIP:
            self.col_co_id = col_co_id 
        if col_co_code is not APIHelper.SKIP:
            self.col_co_code = col_co_code 
        if payer_id is not APIHelper.SKIP:
            self.payer_id = payer_id 
        if payer_number is not APIHelper.SKIP:
            self.payer_number = payer_number 
        if accounts is not APIHelper.SKIP:
            self.accounts = accounts 
        self.transactions_from_date = transactions_from_date 
        self.transactions_to_date = transactions_to_date 
        if value is not APIHelper.SKIP:
            self.value = value 
        self.condition = condition 
        if products is not APIHelper.SKIP:
            self.products = products 
        if exception_period is not APIHelper.SKIP:
            self.exception_period = exception_period 
        self.output_type = output_type 
        if fuel_only is not APIHelper.SKIP:
            self.fuel_only = fuel_only 
        if site_group_ids is not APIHelper.SKIP:
            self.site_group_ids = site_group_ids 
        if use_field_id is not APIHelper.SKIP:
            self.use_field_id = use_field_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 not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        transactions_from_date = dictionary.get("TransactionsFromDate") if dictionary.get("TransactionsFromDate") else None
        transactions_to_date = dictionary.get("TransactionsToDate") if dictionary.get("TransactionsToDate") else None
        condition = dictionary.get("Condition") if dictionary.get("Condition") else None
        output_type = dictionary.get("OutputType") if dictionary.get("OutputType") else None
        col_co_id = dictionary.get("ColCoId") if dictionary.get("ColCoId") else APIHelper.SKIP
        col_co_code = dictionary.get("ColCoCode") if dictionary.get("ColCoCode") else APIHelper.SKIP
        payer_id = dictionary.get("PayerId") if dictionary.get("PayerId") else APIHelper.SKIP
        payer_number = dictionary.get("PayerNumber") if dictionary.get("PayerNumber") else APIHelper.SKIP
        accounts = None
        if dictionary.get('Accounts') is not None:
            accounts = [Accounts.from_dictionary(x) for x in dictionary.get('Accounts')]
        else:
            accounts = APIHelper.SKIP
        value = dictionary.get("Value") if dictionary.get("Value") else APIHelper.SKIP
        products = None
        if dictionary.get('Products') is not None:
            products = [ExceptionProduct.from_dictionary(x) for x in dictionary.get('Products')]
        else:
            products = APIHelper.SKIP
        exception_period = dictionary.get("ExceptionPeriod") if dictionary.get("ExceptionPeriod") else APIHelper.SKIP
        fuel_only = dictionary.get("FuelOnly") if "FuelOnly" in dictionary.keys() else APIHelper.SKIP
        site_group_ids = dictionary.get("SiteGroupIds") if dictionary.get("SiteGroupIds") else APIHelper.SKIP
        use_field_id = dictionary.get("UseFieldId") if "UseFieldId" in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(transactions_from_date,
                   transactions_to_date,
                   condition,
                   output_type,
                   col_co_id,
                   col_co_code,
                   payer_id,
                   payer_number,
                   accounts,
                   value,
                   products,
                   exception_period,
                   fuel_only,
                   site_group_ids,
                   use_field_id)
