# This file is auto-generated by `mix graph.gen.schema`. Do not edit manually. defmodule GraphApi.Schema.Calendar do @moduledoc """ Auto-generated schema for `microsoft.graph.calendar`. """ defstruct [:id, :name, :color, :can_edit, :can_share, :owner] @type t :: %__MODULE__{ id: String.t() | nil, name: String.t() | nil, color: String.t() | nil, can_edit: boolean() | nil, can_share: boolean() | nil, owner: GraphApi.Schema.EmailAddress.t() | nil } @field_mapping %{ {"id", :id}, {"name", :name}, {"color", :color}, {"canEdit", :can_edit}, {"canShare", :can_share}, {"owner", :owner} } @field_names [ "id", "name", "color", "canEdit", "canShare", "owner" ] @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"], name: map["name"], color: map["color"], can_edit: map["canEdit"], can_share: map["canShare"], owner: case map["owner"] do nil -> nil val -> GraphApi.Schema.EmailAddress.from_map(val) end } 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}, {"name", struct.name}, {"color", struct.color}, {"canEdit", struct.can_edit}, {"canShare", struct.can_share}, {"owner", case struct.owner do nil -> nil val -> GraphApi.Schema.EmailAddress.to_map(val) end} ] |> Enum.reject(fn {_k, v} -> is_nil(v) end) |> Map.new() end end