# 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.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaConversionValues do
  @moduledoc """
  Conversion value settings for a postback window for SKAdNetwork conversion value schema.

  ## Attributes

  *   `coarseValue` (*type:* `String.t`, *default:* `nil`) - Required. A coarse grained conversion value. This value is not guaranteed to be unique.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - Display name of the SKAdNetwork conversion value. The max allowed display name length is 50 UTF-16 code units.
  *   `eventMappings` (*type:* `list(GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaEventMapping.t)`, *default:* `nil`) - Event conditions that must be met for this Conversion Value to be achieved. The conditions in this list are ANDed together. It must have minimum of 1 entry and maximum of 3 entries, if the postback window is enabled.
  *   `fineValue` (*type:* `integer()`, *default:* `nil`) - The fine-grained conversion value. This is applicable only to the first postback window. Its valid values are [0,63], both inclusive. It must be set for postback window 1, and must not be set for postback window 2 & 3. This value is not guaranteed to be unique. If the configuration for the first postback window is re-used for second or third postback windows this field has no effect.
  *   `lockEnabled` (*type:* `boolean()`, *default:* `nil`) - If true, the SDK should lock to this conversion value for the current postback window.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :coarseValue => String.t() | nil,
          :displayName => String.t() | nil,
          :eventMappings =>
            list(
              GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaEventMapping.t()
            )
            | nil,
          :fineValue => integer() | nil,
          :lockEnabled => boolean() | nil
        }

  field(:coarseValue)
  field(:displayName)

  field(:eventMappings,
    as: GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaEventMapping,
    type: :list
  )

  field(:fineValue)
  field(:lockEnabled)
end

defimpl Poison.Decoder,
  for: GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaConversionValues do
  def decode(value, options) do
    GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaConversionValues.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaConversionValues do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
