# 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.PubSub.V1.Model.ReceivedMessage do
  @moduledoc """
  A message and its corresponding acknowledgment ID.

  ## Attributes

  *   `ackId` (*type:* `String.t`, *default:* `nil`) - Optional. This ID can be used to acknowledge the received message.
  *   `deliveryAttempt` (*type:* `integer()`, *default:* `nil`) - Optional. The approximate number of times that Pub/Sub has attempted to deliver the associated message to a subscriber. More precisely, this is 1 + (number of NACKs) + (number of ack_deadline exceeds) for this message. A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline exceeds event is whenever a message is not acknowledged within ack_deadline. Note that ack_deadline is initially Subscription.ackDeadlineSeconds, but may get extended automatically by the client library. Upon the first delivery of a given message, `delivery_attempt` will have a value of 1. The value is calculated at best effort and is approximate. If a DeadLetterPolicy is not set on the subscription, this will be 0.
  *   `message` (*type:* `GoogleApi.PubSub.V1.Model.PubsubMessage.t`, *default:* `nil`) - Optional. The message.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :ackId => String.t() | nil,
          :deliveryAttempt => integer() | nil,
          :message => GoogleApi.PubSub.V1.Model.PubsubMessage.t() | nil
        }

  field(:ackId)
  field(:deliveryAttempt)
  field(:message, as: GoogleApi.PubSub.V1.Model.PubsubMessage)
end

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

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