# This file is auto-generated by `mix graph.gen.schema`. Do not edit manually. defmodule GraphApi.Schema.Message do @moduledoc """ Auto-generated schema for `microsoft.graph.message`. """ defstruct [ :id, :subject, :body, :from, :to_recipients, :received_date_time, :is_read, :importance, :has_attachments ] @type t :: %__MODULE__{ id: String.t() | nil, subject: String.t() | nil, body: GraphApi.Schema.ItemBody.t() | nil, from: GraphApi.Schema.Recipient.t() | nil, to_recipients: [GraphApi.Schema.Recipient.t()] | nil, received_date_time: String.t() | nil, is_read: boolean() | nil, importance: String.t() | nil, has_attachments: boolean() | nil } @field_mapping %{ {"id", :id}, {"subject", :subject}, {"body", :body}, {"from", :from}, {"toRecipients", :to_recipients}, {"receivedDateTime", :received_date_time}, {"isRead", :is_read}, {"importance", :importance}, {"hasAttachments", :has_attachments} } @field_names [ "id", "subject", "body", "from", "toRecipients", "receivedDateTime", "isRead", "importance", "hasAttachments" ] @doc "Mapping from camelCase API field names to snake_case struct atoms." @spec __field_mapping__() :: %{String.t() => atom()} def __field_mapping__, do: @field_mapping @doc "List of camelCase API field names (for OData `$select`)." @spec __field_names__() :: [String.t()] def __field_names__, do: @field_names @doc "Converts a camelCase string-key map (API response) into this struct." @spec from_map(map()) :: t() def from_map(map) when is_map(map) do %__MODULE__{ id: map["id"], subject: map["subject"], body: case map["body"] do nil -> nil val -> GraphApi.Schema.ItemBody.from_map(val) end, from: case map["from"] do nil -> nil val -> GraphApi.Schema.Recipient.from_map(val) end, to_recipients: case map["toRecipients"] do nil -> nil items -> Enum.map(items, &GraphApi.Schema.Recipient.from_map/1) end, received_date_time: map["receivedDateTime"], is_read: map["isRead"], importance: map["importance"], has_attachments: map["hasAttachments"] } end @doc "Converts this struct to a camelCase string-key map. Nil fields are omitted." @spec to_map(t()) :: map() def to_map(%__MODULE__{} = struct) do [ {"id", struct.id}, {"subject", struct.subject}, {"body", case struct.body do nil -> nil val -> GraphApi.Schema.ItemBody.to_map(val) end}, {"from", case struct.from do nil -> nil val -> GraphApi.Schema.Recipient.to_map(val) end}, {"toRecipients", case struct.to_recipients do nil -> nil items -> Enum.map(items, &GraphApi.Schema.Recipient.to_map/1) end}, {"receivedDateTime", struct.received_date_time}, {"isRead", struct.is_read}, {"importance", struct.importance}, {"hasAttachments", struct.has_attachments} ] |> Enum.reject(fn {_k, v} -> is_nil(v) end) |> Map.new() end end