package com.prodhack.moscow2025.data.dto

import com.prodhack.moscow2025.domain.models.UpdateUserData
import com.prodhack.moscow2025.domain.models.User
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserPatchRequest(
	val email: String?,
	@SerialName("display_name")
	val displayName: String? = null,
	@SerialName("first_name")
	val firstName: String? = null,
	@SerialName("last_name")
	val lastName: String? = null,
	@SerialName("avatar_url")
	val avatarUrl: String? = null,
	val phone: String? = null,
)

fun UpdateUserData.mapToData(): UserPatchRequest = UserPatchRequest(
	email = email,
	displayName = displayName,
	firstName = firstName,
	lastName = lastName,
	avatarUrl = avatarUrl,
	phone = phone
)

@Serializable
data class UserResponse(
	val id: String,
	val email: String,
	@SerialName("display_name")
	val displayName: String? = null,
	@SerialName("first_name")
	val firstName: String? = null,
	@SerialName("last_name")
	val lastName: String? = null,
	@SerialName("avatar_url")
	val avatarUrl: String? = null,
	val phone: String? = null,
) {
	fun mapToDomain(): User = User(
		id = id,
		email = email,
		displayName = displayName,
		firstName = firstName,
		lastName = lastName,
		avatarUrl = avatarUrl,
		phone = phone
	)
}