# 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.DisplayVideo.V3.Model.Pacing do
  @moduledoc """
  Settings that control the rate at which a budget is spent.

  ## Attributes

  *   `dailyMaxImpressions` (*type:* `String.t`, *default:* `nil`) - Maximum number of impressions to serve every day. Applicable when the budget is impression based. Must be greater than 0.
  *   `dailyMaxMicros` (*type:* `String.t`, *default:* `nil`) - Maximum currency amount to spend every day in micros of advertiser's currency. Applicable when the budget is currency based. Must be greater than 0. For example, for 1.5 standard unit of the currency, set this field to 1500000. The value assigned will be rounded to whole billable units for the relevant currency by the following rules: any positive value less than a single billable unit will be rounded up to one billable unit and any value larger than a single billable unit will be rounded down to the nearest billable value. For example, if the currency's billable unit is 0.01, and this field is set to 10257770, it will round down to 10250000, a value of 10.25. If set to 505, it will round up to 10000, a value of 0.01.
  *   `pacingPeriod` (*type:* `String.t`, *default:* `nil`) - Required. The time period in which the pacing budget will be spent. When automatic budget allocation is enabled at the insertion order via automationType, this field is output only and defaults to `PACING_PERIOD_FLIGHT`.
  *   `pacingType` (*type:* `String.t`, *default:* `nil`) - Required. The type of pacing that defines how the budget amount will be spent across the pacing_period. `PACING_TYPE_ASAP` is not compatible with pacing_period `PACING_PERIOD_FLIGHT` for insertion orders.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :dailyMaxImpressions => String.t() | nil,
          :dailyMaxMicros => String.t() | nil,
          :pacingPeriod => String.t() | nil,
          :pacingType => String.t() | nil
        }

  field(:dailyMaxImpressions)
  field(:dailyMaxMicros)
  field(:pacingPeriod)
  field(:pacingType)
end

defimpl Poison.Decoder, for: GoogleApi.DisplayVideo.V3.Model.Pacing do
  def decode(value, options) do
    GoogleApi.DisplayVideo.V3.Model.Pacing.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.DisplayVideo.V3.Model.Pacing do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
