# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHours do
  @moduledoc """
  Information about business hour of the place.

  ## Attributes

  *   `nextCloseTime` (*type:* `DateTime.t`, *default:* `nil`) - The next time the current opening hours period ends up to 7 days in the future. This field is only populated if the opening hours period is active at the time of serving the request.
  *   `nextOpenTime` (*type:* `DateTime.t`, *default:* `nil`) - The next time the current opening hours period starts up to 7 days in the future. This field is only populated if the opening hours period is not active at the time of serving the request.
  *   `openNow` (*type:* `boolean()`, *default:* `nil`) - Whether the opening hours period is currently active. For regular opening hours and current opening hours, this field means whether the place is open. For secondary opening hours and current secondary opening hours, this field means whether the secondary hours of this place is active.
  *   `periods` (*type:* `list(GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursPeriod.t)`, *default:* `nil`) - The periods that this place is open during the week. The periods are in chronological order, starting with Sunday in the place-local timezone. An empty (but not absent) value indicates a place that is never open, e.g. because it is closed temporarily for renovations.
  *   `secondaryHoursType` (*type:* `String.t`, *default:* `nil`) - A type string used to identify the type of secondary hours.
  *   `specialDays` (*type:* `list(GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursSpecialDay.t)`, *default:* `nil`) - Structured information for special days that fall within the period that the returned opening hours cover. Special days are days that could impact the business hours of a place, e.g. Christmas day. Set for current_opening_hours and current_secondary_opening_hours if there are exceptional hours.
  *   `weekdayDescriptions` (*type:* `list(String.t)`, *default:* `nil`) - Localized strings describing the opening hours of this place, one string for each day of the week. Will be empty if the hours are unknown or could not be converted to localized text. Example: "Sun: 18:00–06:00"
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :nextCloseTime => DateTime.t() | nil,
          :nextOpenTime => DateTime.t() | nil,
          :openNow => boolean() | nil,
          :periods =>
            list(GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursPeriod.t()) | nil,
          :secondaryHoursType => String.t() | nil,
          :specialDays =>
            list(GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursSpecialDay.t())
            | nil,
          :weekdayDescriptions => list(String.t()) | nil
        }

  field(:nextCloseTime, as: DateTime)
  field(:nextOpenTime, as: DateTime)
  field(:openNow)

  field(:periods,
    as: GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursPeriod,
    type: :list
  )

  field(:secondaryHoursType)

  field(:specialDays,
    as: GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHoursSpecialDay,
    type: :list
  )

  field(:weekdayDescriptions, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHours do
  def decode(value, options) do
    GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHours.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Places.V1.Model.GoogleMapsPlacesV1PlaceOpeningHours do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
