# 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.Deal do
  @moduledoc """
  A deal represents a segment of inventory for displaying ads on. A proposal can contain multiple deals. A deal contains the terms and targeting information that is used for serving.

  ## Attributes

  *   `availableEndTime` (*type:* `DateTime.t`, *default:* `nil`) - Proposed flight end time of the deal. This will generally be stored in a granularity of a second. A value is not required for Private Auction deals or Preferred Deals.
  *   `availableStartTime` (*type:* `DateTime.t`, *default:* `nil`) - Optional. Proposed flight start time of the deal. This will generally be stored in the granularity of one second since deal serving starts at seconds boundary. Any time specified with more granularity (for example, in milliseconds) will be truncated towards the start of time in seconds.
  *   `buyerPrivateData` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.PrivateData.t`, *default:* `nil`) - Buyer private data (hidden from seller).
  *   `createProductId` (*type:* `String.t`, *default:* `nil`) - The product ID from which this deal was created. Note: This field may be set only when creating the resource. Modifying this field while updating the resource will result in an error.
  *   `createProductRevision` (*type:* `String.t`, *default:* `nil`) - Optional. Revision number of the product that the deal was created from. If present on create, and the server `product_revision` has advanced since the passed-in `create_product_revision`, an `ABORTED` error will be returned. Note: This field may be set only when creating the resource. Modifying this field while updating the resource will result in an error.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time of the deal creation.
  *   `creativePreApprovalPolicy` (*type:* `String.t`, *default:* `nil`) - Output only. Specifies the creative pre-approval policy.
  *   `creativeRestrictions` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.CreativeRestrictions.t`, *default:* `nil`) - Output only. Restricitions about the creatives associated with the deal (for example, size) This is available for Programmatic Guaranteed/Preferred Deals in Ad Manager.
  *   `creativeSafeFrameCompatibility` (*type:* `String.t`, *default:* `nil`) - Output only. Specifies whether the creative is safeFrame compatible.
  *   `dealId` (*type:* `String.t`, *default:* `nil`) - Output only. A unique deal ID for the deal (server-assigned).
  *   `dealServingMetadata` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.DealServingMetadata.t`, *default:* `nil`) - Output only. Metadata about the serving status of this deal.
  *   `dealTerms` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms.t`, *default:* `nil`) - The negotiable terms of the deal.
  *   `deliveryControl` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.DeliveryControl.t`, *default:* `nil`) - The set of fields around delivery control that are interesting for a buyer to see but are non-negotiable. These are set by the publisher.
  *   `description` (*type:* `String.t`, *default:* `nil`) - Description for the deal terms.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - The name of the deal.
  *   `externalDealId` (*type:* `String.t`, *default:* `nil`) - Output only. The external deal ID assigned to this deal once the deal is finalized. This is the deal ID that shows up in serving/reporting etc.
  *   `isSetupComplete` (*type:* `boolean()`, *default:* `nil`) - Output only. True, if the buyside inventory setup is complete for this deal.
  *   `programmaticCreativeSource` (*type:* `String.t`, *default:* `nil`) - Output only. Specifies the creative source for programmatic deals. PUBLISHER means creative is provided by seller and ADVERTISER means creative is provided by buyer.
  *   `proposalId` (*type:* `String.t`, *default:* `nil`) - Output only. ID of the proposal that this deal is part of.
  *   `sellerContacts` (*type:* `list(GoogleApi.AdExchangeBuyer.V2beta1.Model.ContactInformation.t)`, *default:* `nil`) - Output only. Seller contact information for the deal.
  *   `syndicationProduct` (*type:* `String.t`, *default:* `nil`) - The syndication product associated with the deal. Note: This field may be set only when creating the resource. Modifying this field while updating the resource will result in an error.
  *   `targeting` (*type:* `GoogleApi.AdExchangeBuyer.V2beta1.Model.MarketplaceTargeting.t`, *default:* `nil`) - Output only. Specifies the subset of inventory targeted by the deal.
  *   `targetingCriterion` (*type:* `list(GoogleApi.AdExchangeBuyer.V2beta1.Model.TargetingCriteria.t)`, *default:* `nil`) - The shared targeting visible to buyers and sellers. Each shared targeting entity is AND'd together.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the deal was last updated.
  *   `webPropertyCode` (*type:* `String.t`, *default:* `nil`) - The web property code for the seller copied over from the product.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :availableEndTime => DateTime.t() | nil,
          :availableStartTime => DateTime.t() | nil,
          :buyerPrivateData => GoogleApi.AdExchangeBuyer.V2beta1.Model.PrivateData.t() | nil,
          :createProductId => String.t() | nil,
          :createProductRevision => String.t() | nil,
          :createTime => DateTime.t() | nil,
          :creativePreApprovalPolicy => String.t() | nil,
          :creativeRestrictions =>
            GoogleApi.AdExchangeBuyer.V2beta1.Model.CreativeRestrictions.t() | nil,
          :creativeSafeFrameCompatibility => String.t() | nil,
          :dealId => String.t() | nil,
          :dealServingMetadata =>
            GoogleApi.AdExchangeBuyer.V2beta1.Model.DealServingMetadata.t() | nil,
          :dealTerms => GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms.t() | nil,
          :deliveryControl => GoogleApi.AdExchangeBuyer.V2beta1.Model.DeliveryControl.t() | nil,
          :description => String.t() | nil,
          :displayName => String.t() | nil,
          :externalDealId => String.t() | nil,
          :isSetupComplete => boolean() | nil,
          :programmaticCreativeSource => String.t() | nil,
          :proposalId => String.t() | nil,
          :sellerContacts =>
            list(GoogleApi.AdExchangeBuyer.V2beta1.Model.ContactInformation.t()) | nil,
          :syndicationProduct => String.t() | nil,
          :targeting => GoogleApi.AdExchangeBuyer.V2beta1.Model.MarketplaceTargeting.t() | nil,
          :targetingCriterion =>
            list(GoogleApi.AdExchangeBuyer.V2beta1.Model.TargetingCriteria.t()) | nil,
          :updateTime => DateTime.t() | nil,
          :webPropertyCode => String.t() | nil
        }

  field(:availableEndTime, as: DateTime)
  field(:availableStartTime, as: DateTime)
  field(:buyerPrivateData, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.PrivateData)
  field(:createProductId)
  field(:createProductRevision)
  field(:createTime, as: DateTime)
  field(:creativePreApprovalPolicy)
  field(:creativeRestrictions, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.CreativeRestrictions)
  field(:creativeSafeFrameCompatibility)
  field(:dealId)
  field(:dealServingMetadata, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.DealServingMetadata)
  field(:dealTerms, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.DealTerms)
  field(:deliveryControl, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.DeliveryControl)
  field(:description)
  field(:displayName)
  field(:externalDealId)
  field(:isSetupComplete)
  field(:programmaticCreativeSource)
  field(:proposalId)

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

  field(:syndicationProduct)
  field(:targeting, as: GoogleApi.AdExchangeBuyer.V2beta1.Model.MarketplaceTargeting)

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

  field(:updateTime, as: DateTime)
  field(:webPropertyCode)
end

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

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