Packages

Elixir client for the Microsoft Graph API

Current section

Files

Jump to
keen_microsoft_graphapi lib graph_api schema user.ex
Raw

lib/graph_api/schema/user.ex

# This file is auto-generated by `mix graph.gen.schema`. Do not edit manually.
defmodule GraphApi.Schema.User do
@moduledoc """
Auto-generated schema for `microsoft.graph.user`.
"""
defstruct [
:id,
:deleted_date_time,
:display_name,
:mail,
:user_principal_name,
:job_title,
:account_enabled,
:assigned_licenses,
:password_profile,
:preferred_language,
:proxy_addresses,
:business_phones,
:age,
:height,
:company_name,
:employee_type
]
@type t :: %__MODULE__{
id: String.t() | nil,
deleted_date_time: String.t() | nil,
display_name: String.t() | nil,
mail: String.t() | nil,
user_principal_name: String.t() | nil,
job_title: String.t() | nil,
account_enabled: boolean() | nil,
assigned_licenses: [GraphApi.Schema.AssignedLicense.t()] | nil,
password_profile: GraphApi.Schema.PasswordProfile.t() | nil,
preferred_language: String.t() | nil,
proxy_addresses: [String.t()] | nil,
business_phones: [String.t()] | nil,
age: integer() | nil,
height: float() | nil,
company_name: String.t() | nil,
employee_type: String.t() | nil
}
@field_mapping %{
{"id", :id},
{"deletedDateTime", :deleted_date_time},
{"displayName", :display_name},
{"mail", :mail},
{"userPrincipalName", :user_principal_name},
{"jobTitle", :job_title},
{"accountEnabled", :account_enabled},
{"assignedLicenses", :assigned_licenses},
{"passwordProfile", :password_profile},
{"preferredLanguage", :preferred_language},
{"proxyAddresses", :proxy_addresses},
{"businessPhones", :business_phones},
{"age", :age},
{"height", :height},
{"companyName", :company_name},
{"employeeType", :employee_type}
}
@field_names [
"id",
"deletedDateTime",
"displayName",
"mail",
"userPrincipalName",
"jobTitle",
"accountEnabled",
"assignedLicenses",
"passwordProfile",
"preferredLanguage",
"proxyAddresses",
"businessPhones",
"age",
"height",
"companyName",
"employeeType"
]
@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"],
deleted_date_time: map["deletedDateTime"],
display_name: map["displayName"],
mail: map["mail"],
user_principal_name: map["userPrincipalName"],
job_title: map["jobTitle"],
account_enabled: map["accountEnabled"],
assigned_licenses:
case map["assignedLicenses"] do
nil -> nil
items -> Enum.map(items, &GraphApi.Schema.AssignedLicense.from_map/1)
end,
password_profile:
case map["passwordProfile"] do
nil -> nil
val -> GraphApi.Schema.PasswordProfile.from_map(val)
end,
preferred_language: map["preferredLanguage"],
proxy_addresses: map["proxyAddresses"],
business_phones: map["businessPhones"],
age: map["age"],
height: map["height"],
company_name: map["companyName"],
employee_type: map["employeeType"]
}
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},
{"deletedDateTime", struct.deleted_date_time},
{"displayName", struct.display_name},
{"mail", struct.mail},
{"userPrincipalName", struct.user_principal_name},
{"jobTitle", struct.job_title},
{"accountEnabled", struct.account_enabled},
{"assignedLicenses",
case struct.assigned_licenses do
nil -> nil
items -> Enum.map(items, &GraphApi.Schema.AssignedLicense.to_map/1)
end},
{"passwordProfile",
case struct.password_profile do
nil -> nil
val -> GraphApi.Schema.PasswordProfile.to_map(val)
end},
{"preferredLanguage", struct.preferred_language},
{"proxyAddresses", struct.proxy_addresses},
{"businessPhones", struct.business_phones},
{"age", struct.age},
{"height", struct.height},
{"companyName", struct.company_name},
{"employeeType", struct.employee_type}
]
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
|> Map.new()
end
end