Packages

Elixir client for the Microsoft Graph API

Current section

Files

Jump to
keen_microsoft_graphapi lib graph_api schema mail_folder.ex
Raw

lib/graph_api/schema/mail_folder.ex

# This file is auto-generated by `mix graph.gen.schema`. Do not edit manually.
defmodule GraphApi.Schema.MailFolder do
@moduledoc """
Auto-generated schema for `microsoft.graph.mailFolder`.
"""
defstruct [
:id,
:display_name,
:parent_folder_id,
:child_folder_count,
:unread_item_count,
:total_item_count
]
@type t :: %__MODULE__{
id: String.t() | nil,
display_name: String.t() | nil,
parent_folder_id: String.t() | nil,
child_folder_count: integer() | nil,
unread_item_count: integer() | nil,
total_item_count: integer() | nil
}
@field_mapping %{
{"id", :id},
{"displayName", :display_name},
{"parentFolderId", :parent_folder_id},
{"childFolderCount", :child_folder_count},
{"unreadItemCount", :unread_item_count},
{"totalItemCount", :total_item_count}
}
@field_names [
"id",
"displayName",
"parentFolderId",
"childFolderCount",
"unreadItemCount",
"totalItemCount"
]
@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"],
display_name: map["displayName"],
parent_folder_id: map["parentFolderId"],
child_folder_count: map["childFolderCount"],
unread_item_count: map["unreadItemCount"],
total_item_count: map["totalItemCount"]
}
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},
{"displayName", struct.display_name},
{"parentFolderId", struct.parent_folder_id},
{"childFolderCount", struct.child_folder_count},
{"unreadItemCount", struct.unread_item_count},
{"totalItemCount", struct.total_item_count}
]
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
|> Map.new()
end
end