text: ﻿/**
   * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * SPDX-License-Identifier: Apache-2.0.
   */
  
  #include <aws/chime-sdk-messaging/model/ChannelMembership.h>
  #include <aws/core/utils/json/JsonSerializer.h>
  
  #include <utility>
  
  using namespace Aws::Utils::Json;
  using namespace Aws::Utils;
  
  namespace Aws
  {
  namespace ChimeSDKMessaging
  {
  namespace Model
  {
  
  ChannelMembership::ChannelMembership() : 
      m_invitedByHasBeenSet(false),
      m_type(ChannelMembershipType::NOT_SET),
      m_typeHasBeenSet(false),
      m_memberHasBeenSet(false),
      m_channelArnHasBeenSet(false),
      m_createdTimestampHasBeenSet(false),
      m_lastUpdatedTimestampHasBeenSet(false)
  {
  }
  
  ChannelMembership::ChannelMembership(JsonView jsonValue) : 
      m_invitedByHasBeenSet(false),
      m_type(ChannelMembershipType::NOT_SET),
      m_typeHasBeenSet(false),
      m_memberHasBeenSet(false),
      m_channelArnHasBeenSet(false),
      m_createdTimestampHasBeenSet(false),
      m_lastUpdatedTimestampHasBeenSet(false)
  {
    *this = jsonValue;
  }
  
  ChannelMembership& ChannelMembership::operator =(JsonView jsonValue)
  {
    if(jsonValue.ValueExists("InvitedBy"))
    {
      m_invitedBy = jsonValue.GetObject("InvitedBy");
  
      m_invitedByHasBeenSet = true;
    }
  
    if(jsonValue.ValueExists("Type"))
    {
      m_type = ChannelMembershipTypeMapper::GetChannelMembershipTypeForName(jsonValue.GetString("Type"));
  
      m_typeHasBeenSet = true;
    }
  
    if(jsonValue.ValueExists("Member"))
    {
      m_member = jsonValue.GetObject("Member");
  
      m_memberHasBeenSet = true;
    }
  
    if(jsonValue.ValueExists("ChannelArn"))
    {
      m_channelArn = jsonValue.GetString("ChannelArn");
  
      m_channelArnHasBeenSet = true;
    }
  
    if(jsonValue.ValueExists("CreatedTimestamp"))
    {
      m_createdTimestamp = jsonValue.GetDouble("CreatedTimestamp");
  
      m_createdTimestampHasBeenSet = true;
    }
  
    if(jsonValue.ValueExists("LastUpdatedTimestamp"))
    {
      m_lastUpdatedTimestamp = jsonValue.GetDouble("LastUpdatedTimestamp");
  
      m_lastUpdatedTimestampHasBeenSet = true;
    }
  
    return *this;
  }
  
  JsonValue ChannelMembership::Jsonize() const
  {
    JsonValue payload;
  
    if(m_invitedByHasBeenSet)
    {
     payload.WithObject("InvitedBy", m_invitedBy.Jsonize());
  
    }
  
    if(m_typeHasBeenSet)
    {
     payload.WithString("Type", ChannelMembershipTypeMapper::GetNameForChannelMembershipType(m_type));
    }
  
    if(m_memberHasBeenSet)
    {
     payload.WithObject("Member", m_member.Jsonize());
  
    }
  
    if(m_channelArnHasBeenSet)
    {
     payload.WithString("ChannelArn", m_channelArn);
  
    }
  
    if(m_createdTimestampHasBeenSet)
    {
     payload.WithDouble("CreatedTimestamp", m_createdTimestamp.SecondsWithMSPrecision());
    }
  
    if(m_lastUpdatedTimestampHasBeenSet)
    {
     payload.WithDouble("LastUpdatedTimestamp", m_lastUpdatedTimestamp.SecondsWithMSPrecision());
    }
  
    return payload;
  }
  
  } // namespace Model
  } // namespace ChimeSDKMessaging
  } // namespace Aws
  