lib/chat_kitty/api/channels.ex

# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.

defmodule ChatKitty.Api.Channels do
  @moduledoc """
  API calls for all endpoints tagged `Channels`.
  """

  alias ChatKitty.Connection
  import ChatKitty.RequestBuilder


  @doc """
  Add a channel member
  Makes a user a group channel member

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - add_channel_member_request (AddChannelMemberRequest): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec add_channel_member(Tesla.Env.client, integer(), ChatKitty.Model.AddChannelMemberRequest.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def add_channel_member(connection, id, add_channel_member_request, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels/#{id}/members")
    |> add_param(:body, :body, add_channel_member_request)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end

  @doc """
  Add a channel moderator
  Makes a user a group channel moderator

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - add_channel_member_request (AddChannelMemberRequest): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatUserResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec add_channel_moderator(Tesla.Env.client, integer(), ChatKitty.Model.AddChannelMemberRequest.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChatUserResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def add_channel_moderator(connection, id, add_channel_member_request, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels/#{id}/moderators")
    |> add_param(:body, :body, add_channel_member_request)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatUserResource{}}
    ])
  end

  @doc """
  Create a channel
  Creates a new channel or returns an equivalent existing channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - create_channel_request (CreateChannelRequest): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec create_channel(Tesla.Env.client, ChatKitty.Model.CreateChannelRequest.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def create_channel(connection, create_channel_request, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels")
    |> add_param(:body, :body, create_channel_request)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end

  @doc """
  Delete a channel
  Deletes a channel by ID

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ApplicationResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec delete_channel(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ApplicationResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def delete_channel(connection, id, _opts \\ []) do
    %{}
    |> method(:delete)
    |> url("/v1/channels/#{id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ApplicationResource{}}
    ])
  end

  @doc """
  List channel invites
  Returns a page of invites sent to join this channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChannelInviteResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_invites(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.PagedModelChannelInviteResource.t} | {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_invites(connection, id, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/invites")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChannelInviteResource{}}
    ])
  end

  @doc """
  List a channel's members
  Returns a page of channel members

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChatUserResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_members(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.PagedModelChatUserResource.t} | {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_members(connection, id, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/members")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChatUserResource{}}
    ])
  end

  @doc """
  List channel memberships
  Returns a page of channel membership info for this channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChannelMembershipResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_memberships(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.PagedModelChannelMembershipResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_memberships(connection, id, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/memberships")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChannelMembershipResource{}}
    ])
  end

  @doc """
  List channel messages
  Returns a page of messages sent in this channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :size (integer()): The size of the page to be returned
    - :start (integer()): Start cursor value. Do not set manually. Provided by the Platform API pagination engine to fetch previous or next pages
    - :next (integer()): Next page cursor value. Do not set manually. Provided by the Platform API pagination engine to fetch subsequent pages
    - :relation (String.t): Page cursor relation. Do not set manually. Provided by the Platform API pagination engine to fetch previous or next pages
    - :username (String.t): 
    - :query (String.t): 
  ## Returns

  {:ok, ChatKitty.Model.CursorPagedModelMessageResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_messages(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.CursorPagedModelMessageResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_messages(connection, id, opts \\ []) do
    optional_params = %{
      :"size" => :query,
      :"start" => :query,
      :"next" => :query,
      :"relation" => :query,
      :"username" => :query,
      :"query" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/messages")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.CursorPagedModelMessageResource{}}
    ])
  end

  @doc """
  Lists a channel's moderators
  Returns a page of channel moderators

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChatUserResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_moderators(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.PagedModelChatUserResource.t} | {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_moderators(connection, id, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/moderators")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChatUserResource{}}
    ])
  end

  @doc """
  List channel participants
  Returns a page of channel active participants: members that currently online

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChatUserResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channel_participants(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.PagedModelChatUserResource.t} | {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channel_participants(connection, id, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}/participants")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChatUserResource{}}
    ])
  end

  @doc """
  List channels
  Returns a page of channels belonging to this application

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
    - :type (String.t): Filters by channel type
    - :members ([String.t]): Filters by channel members using their usernames
    - :start_time (DateTime.t): Filters for channels created within a time range: start time
    - :end_time (DateTime.t): Filters for channels created within a time range: end time
    - :properties (String.t): Filters by channel custom properties
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_channels(Tesla.Env.client, keyword()) :: {:ok, ChatKitty.Model.PagedModelChannelResource.t} | {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def list_channels(connection, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query,
      :"type" => :query,
      :"members" => :query,
      :"startTime" => :query,
      :"endTime" => :query,
      :"properties" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/channels")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChannelResource{}}
    ])
  end

  @doc """
  Remove a channel member
  Removes a member from a group channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - user_id (integer()): User ID of member to be removed
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec remove_channel_member(Tesla.Env.client, integer(), integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def remove_channel_member(connection, id, user_id, _opts \\ []) do
    %{}
    |> method(:delete)
    |> url("/v1/channels/#{id}/members/#{user_id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end

  @doc """
  Remove a channel moderator
  Removes a moderator from a group channel

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - user_id (integer()): User ID of moderator to be removed
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec remove_channel_moderator(Tesla.Env.client, integer(), integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def remove_channel_moderator(connection, id, user_id, _opts \\ []) do
    %{}
    |> method(:delete)
    |> url("/v1/channels/#{id}/moderators/#{user_id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end

  @doc """
  Retrieve a channel
  Returns a channel by ID

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec retrieve_channel(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def retrieve_channel(connection, id, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/v1/channels/#{id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end

  @doc """
  Send a channel event
  Sends a custom channel event

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - create_channel_generic_event_resource (CreateChannelGenericEventResource): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelGenericEventResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec send_channel_event(Tesla.Env.client, integer(), ChatKitty.Model.CreateChannelGenericEventResource.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelGenericEventResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def send_channel_event(connection, id, create_channel_generic_event_resource, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels/#{id}/events")
    |> add_param(:body, :body, create_channel_generic_event_resource)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelGenericEventResource{}}
    ])
  end

  @doc """
  Send a channel invite
  Sends a channel invite to user

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - create_channel_invite_resource (CreateChannelInviteResource): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChannelInviteResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec send_channel_invite(Tesla.Env.client, integer(), ChatKitty.Model.CreateChannelInviteResource.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelInviteResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def send_channel_invite(connection, id, create_channel_invite_resource, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels/#{id}/invites")
    |> add_param(:body, :body, create_channel_invite_resource)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelInviteResource{}}
    ])
  end

  @doc """
  Send a channel message
  Sends a message in this channel as the system or on behalf of a user

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - send_channel_message_request (SendChannelMessageRequest): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.MessageResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec send_channel_message(Tesla.Env.client, integer(), ChatKitty.Model.SendChannelMessageRequest.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.MessageResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def send_channel_message(connection, id, send_channel_message_request, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/channels/#{id}/messages")
    |> add_param(:body, :body, send_channel_message_request)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.MessageResource{}}
    ])
  end

  @doc """
  Update a channel
  Updates a channel properties

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - id (integer()): Channel ID
  - opts (KeywordList): [optional] Optional parameters
    - :body (ChannelPropertiesPatch): 
  ## Returns

  {:ok, ChatKitty.Model.ChannelResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_channel(Tesla.Env.client, integer(), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.ChannelResource.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:error, Tesla.Env.t}
  def update_channel(connection, id, opts \\ []) do
    optional_params = %{
      :body => :body
    }
    %{}
    |> method(:patch)
    |> url("/v1/channels/#{id}")
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChannelResource{}}
    ])
  end
end