# 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.AnalyticsReporting.V4.Model.Cohort do
  @moduledoc """
  Defines a cohort. A cohort is a group of users who share a common characteristic. For example, all users with the same acquisition date belong to the same cohort.

  ## Attributes

  *   `dateRange` (*type:* `GoogleApi.AnalyticsReporting.V4.Model.DateRange.t`, *default:* `nil`) - This is used for `FIRST_VISIT_DATE` cohort, the cohort selects users whose first visit date is between start date and end date defined in the DateRange. The date ranges should be aligned for cohort requests. If the request contains `ga:cohortNthDay` it should be exactly one day long, if `ga:cohortNthWeek` it should be aligned to the week boundary (starting at Sunday and ending Saturday), and for `ga:cohortNthMonth` the date range should be aligned to the month (starting at the first and ending on the last day of the month). For LTV requests there are no such restrictions. You do not need to supply a date range for the `reportsRequest.dateRanges` field.
  *   `name` (*type:* `String.t`, *default:* `nil`) - A unique name for the cohort. If not defined name will be auto-generated with values cohort_[1234...].
  *   `type` (*type:* `String.t`, *default:* `nil`) - Type of the cohort. The only supported type as of now is `FIRST_VISIT_DATE`. If this field is unspecified the cohort is treated as `FIRST_VISIT_DATE` type cohort.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :dateRange => GoogleApi.AnalyticsReporting.V4.Model.DateRange.t() | nil,
          :name => String.t() | nil,
          :type => String.t() | nil
        }

  field(:dateRange, as: GoogleApi.AnalyticsReporting.V4.Model.DateRange)
  field(:name)
  field(:type)
end

defimpl Poison.Decoder, for: GoogleApi.AnalyticsReporting.V4.Model.Cohort do
  def decode(value, options) do
    GoogleApi.AnalyticsReporting.V4.Model.Cohort.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AnalyticsReporting.V4.Model.Cohort do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
