# 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.CloudBilling.V1.Model.PricingExpression do
  @moduledoc """
  Expresses a mathematical pricing formula. For Example:- `usage_unit: GBy` `tiered_rates:` `[start_usage_amount: 20, unit_price: $10]` `[start_usage_amount: 100, unit_price: $5]` The above expresses a pricing formula where the first 20GB is free, the next 80GB is priced at $10 per GB followed by $5 per GB for additional usage.

  ## Attributes

  *   `baseUnit` (*type:* `String.t`, *default:* `nil`) - The base unit for the SKU which is the unit used in usage exports. Example: "By"
  *   `baseUnitConversionFactor` (*type:* `float()`, *default:* `nil`) - Conversion factor for converting from price per usage_unit to price per base_unit, and start_usage_amount to start_usage_amount in base_unit. unit_price / base_unit_conversion_factor = price per base_unit. start_usage_amount * base_unit_conversion_factor = start_usage_amount in base_unit.
  *   `baseUnitDescription` (*type:* `String.t`, *default:* `nil`) - The base unit in human readable form. Example: "byte".
  *   `displayQuantity` (*type:* `float()`, *default:* `nil`) - The recommended quantity of units for displaying pricing info. When displaying pricing info it is recommended to display: (unit_price * display_quantity) per display_quantity usage_unit. This field does not affect the pricing formula and is for display purposes only. Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and the display_quantity is "1000" then the recommended way of displaying the pricing info is "0.10 USD per 1000 GB"
  *   `tieredRates` (*type:* `list(GoogleApi.CloudBilling.V1.Model.TierRate.t)`, *default:* `nil`) - The list of tiered rates for this pricing. The total cost is computed by applying each of the tiered rates on usage. This repeated list is sorted by ascending order of start_usage_amount.
  *   `usageUnit` (*type:* `String.t`, *default:* `nil`) - The short hand for unit of usage this pricing is specified in. Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte".
  *   `usageUnitDescription` (*type:* `String.t`, *default:* `nil`) - The unit of usage in human readable form. Example: "gibi byte".
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :baseUnit => String.t() | nil,
          :baseUnitConversionFactor => float() | nil,
          :baseUnitDescription => String.t() | nil,
          :displayQuantity => float() | nil,
          :tieredRates => list(GoogleApi.CloudBilling.V1.Model.TierRate.t()) | nil,
          :usageUnit => String.t() | nil,
          :usageUnitDescription => String.t() | nil
        }

  field(:baseUnit)
  field(:baseUnitConversionFactor)
  field(:baseUnitDescription)
  field(:displayQuantity)
  field(:tieredRates, as: GoogleApi.CloudBilling.V1.Model.TierRate, type: :list)
  field(:usageUnit)
  field(:usageUnitDescription)
end

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

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