# 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.AdExchangeBuyer.V2beta1.Model.Product do
  @moduledoc """
  A product is a segment of inventory that a seller wants to sell. It is associated with certain terms and targeting information which helps the buyer know more about the inventory.

  ## Attributes

  *   `availableEndTime` (*type:* `DateTime.t`, *default:* `nil`) - The proposed end time for the deal. The field will be truncated to the order of seconds during serving.
  *   `availableStartTime` (*type:* `DateTime.t`, *default:* `nil`) - Inventory availability dates. The start time will be truncated to seconds during serving. Thus, a field specified as 3:23:34.456 (HH:mm:ss.SSS) will be truncated to 3:23:34 when serving.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Creation time.
  *   `creatorContacts` (*type:* `list(GoogleApi.AdExchangeBuyer.V2beta1.Model.ContactInformation.t)`, *default:* `nil`) - Optional contact information for the creator of this product.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - The display name for this product as set by the seller.
  *   `hasCreatorSignedOff` (*type:* `boolean()`, *default:* `nil`) - If the creator has already signed off on the product, then the buyer can finalize the deal by accepting the product as is. When copying to a proposal, if any of the terms are changed, then auto_finalize is automatically set to false.
  *   `productId` (*type:* `String.t`, *default:* `nil`) - The unique ID for the product.
  *   `productRevision` (*type:* `String.t`, *default:* `nil`) - The revision number of the product (auto-assigned by Marketplace).
  *   `publisherProfileId` (*type:* `String.t`, *default:* `nil`) - An ID which can be used by the Publisher Profile API to get more information about the seller that created this product.
  *   `seller` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.Seller.t`, *default:* `nil`) - Information about the seller that created this product.
  *   `syndicationProduct` (*type:* `String.t`, *default:* `nil`) - The syndication product associated with the deal.
  *   `targetingCriterion` (*type:* `list(GoogleApi.AdExchangeBuyer.V2beta1.Model.TargetingCriteria.t)`, *default:* `nil`) - Targeting that is shared between the buyer and the seller. Each targeting criterion has a specified key and for each key there is a list of inclusion value or exclusion values.
  *   `terms` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms.t`, *default:* `nil`) - The negotiable terms of the deal.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Time of last update.
  *   `webPropertyCode` (*type:* `String.t`, *default:* `nil`) - The web-property code for the seller. This needs to be copied as is when adding a new deal to a proposal.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :availableEndTime => DateTime.t() | nil,
          :availableStartTime => DateTime.t() | nil,
          :createTime => DateTime.t() | nil,
          :creatorContacts =>
            list(GoogleApi.AdExchangeBuyer.V2beta1.Model.ContactInformation.t()) | nil,
          :displayName => String.t() | nil,
          :hasCreatorSignedOff => boolean() | nil,
          :productId => String.t() | nil,
          :productRevision => String.t() | nil,
          :publisherProfileId => String.t() | nil,
          :seller => GoogleApi.AdExchangeBuyer.V2beta1.Model.Seller.t() | nil,
          :syndicationProduct => String.t() | nil,
          :targetingCriterion =>
            list(GoogleApi.AdExchangeBuyer.V2beta1.Model.TargetingCriteria.t()) | nil,
          :terms => GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms.t() | nil,
          :updateTime => DateTime.t() | nil,
          :webPropertyCode => String.t() | nil
        }

  field(:availableEndTime, as: DateTime)
  field(:availableStartTime, as: DateTime)
  field(:createTime, as: DateTime)

  field(:creatorContacts,
    as: GoogleApi.AdExchangeBuyer.V2beta1.Model.ContactInformation,
    type: :list
  )

  field(:displayName)
  field(:hasCreatorSignedOff)
  field(:productId)
  field(:productRevision)
  field(:publisherProfileId)
  field(:seller, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.Seller)
  field(:syndicationProduct)

  field(:targetingCriterion,
    as: GoogleApi.AdExchangeBuyer.V2beta1.Model.TargetingCriteria,
    type: :list
  )

  field(:terms, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms)
  field(:updateTime, as: DateTime)
  field(:webPropertyCode)
end

defimpl Poison.Decoder, for: GoogleApi.AdExchangeBuyer.V2beta1.Model.Product do
  def decode(value, options) do
    GoogleApi.AdExchangeBuyer.V2beta1.Model.Product.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AdExchangeBuyer.V2beta1.Model.Product do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
