# 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.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionPlacePrediction do
  @moduledoc """
  Prediction results for a Place Autocomplete prediction.

  ## Attributes

  *   `distanceMeters` (*type:* `integer()`, *default:* `nil`) - The length of the geodesic in meters from `origin` if `origin` is specified. Certain predictions such as routes may not populate this field.
  *   `place` (*type:* `String.t`, *default:* `nil`) - The resource name of the suggested Place. This name can be used in other APIs that accept Place names.
  *   `placeId` (*type:* `String.t`, *default:* `nil`) - The unique identifier of the suggested Place. This identifier can be used in other APIs that accept Place IDs.
  *   `structuredFormat` (*type:* `GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionStructuredFormat.t`, *default:* `nil`) - A breakdown of the Place prediction into main text containing the name of the Place and secondary text containing additional disambiguating features (such as a city or region). `structured_format` is recommended for developers who wish to show two separate, but related, UI elements. Developers who wish to show a single UI element may want to use `text` instead. They are two different ways to represent a Place prediction. Users should not try to parse `structured_format` into `text` or vice versa.
  *   `text` (*type:* `GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionFormattableText.t`, *default:* `nil`) - Contains the human-readable name for the returned result. For establishment results, this is usually the business name and address. `text` is recommended for developers who wish to show a single UI element. Developers who wish to show two separate, but related, UI elements may want to use `structured_format` instead. They are two different ways to represent a Place prediction. Users should not try to parse `structured_format` into `text` or vice versa. This text may be different from the `display_name` returned by GetPlace. May be in mixed languages if the request `input` and `language_code` are in different languages or if the Place does not have a translation from the local language to `language_code`.
  *   `types` (*type:* `list(String.t)`, *default:* `nil`) - List of types that apply to this Place from Table A or Table B in https://developers.google.com/maps/documentation/places/web-service/place-types. A type is a categorization of a Place. Places with shared types will share similar characteristics.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :distanceMeters => integer() | nil,
          :place => String.t() | nil,
          :placeId => String.t() | nil,
          :structuredFormat =>
            GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionStructuredFormat.t()
            | nil,
          :text =>
            GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionFormattableText.t()
            | nil,
          :types => list(String.t()) | nil
        }

  field(:distanceMeters)
  field(:place)
  field(:placeId)

  field(:structuredFormat,
    as:
      GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionStructuredFormat
  )

  field(:text,
    as:
      GoogleApi.Places.V1.Model.GoogleMapsPlacesV1AutocompletePlacesResponseSuggestionFormattableText
  )

  field(:types, type: :list)
end

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

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