"""cellpointapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.travel_leg import TravelLeg


class TravelJourney(object):
    """Implementation of the 'TravelJourney' model.

    Traveling from an origin to a destination. May have multiple Travel Legs as part
    of a journey to get to the final destination.
    Note that during a One-Way itinerary, there will be exactly 1 journey.
    On a Round-Trip itinerary, there will be exactly 2 journeys.
    Multi-City may have between 2+ journeys.

    Attributes:
        journey_segment (JourneySegment): Segment of the journey.   Given an the
            following `ItineraryType`, here are the example JourneySegment to use:
            <table> <thead>   <tr>     <th>Itinerary Type</th>     <th>Journey
            Segment</th>     <th>Description</th>   </tr> </thead> <tbody>   <tr>
            <td>ONE_WAY</td>     <td>OUTBOUND</td>     <td>Single Journey</td>
            </tr>   <tr>     <td>ROUND_TRIP</td>     <td>OUTBOUND</td>     <td>First
            Journey, leaving.</td>   </tr>   <tr>     <td>ROUND_TRIP</td>
            <td>INBOUND</td>     <td>Second Journey, returning.</td>   </tr>   <tr>
            <td>MULTI_CITY</td>     <td>MULTI_CITY_1</td>     <td>First Journey </td>
            </tr>   <tr>     <td>MULTI_CITY</td>     <td>MULTI_CITY_2</td>
            <td>Second Journey </td>   </tr>   <tr>     <td>MULTI_CITY</td>
            <td>MULTI_CITY_3</td>     <td>Third Journey </td>   </tr> </tbody>
            </table>
        legs (List[TravelLeg]): A collection of travel legs that make up the journey.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "journey_segment": "journeySegment",
        "legs": "legs",
    }

    def __init__(
        self,
        journey_segment=None,
        legs=None,
        additional_properties=None):
        """Initialize a TravelJourney instance."""
        # Initialize members of the class
        self.journey_segment = journey_segment
        self.legs = legs

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create 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
        journey_segment =\
            dictionary.get("journeySegment")\
            if dictionary.get("journeySegment")\
                else None
        legs = None
        if dictionary.get("legs") is not None:
            legs = [
                TravelLeg.from_dictionary(x)
                    for x in dictionary.get("legs")
            ]

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(journey_segment,
                   legs,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _journey_segment=self.journey_segment
        _legs=self.legs
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"journey_segment={_journey_segment!r}, "
            f"legs={_legs!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _journey_segment=self.journey_segment
        _legs=self.legs
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"journey_segment={_journey_segment!s}, "
            f"legs={_legs!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
