# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.YouTube.V3.Api.Search do
  @moduledoc """
  API calls for all endpoints tagged `Search`.
  """

  alias GoogleApi.YouTube.V3.Connection
  alias GoogleApi.Gax.{Request, Response}

  @library_version Mix.Project.config() |> Keyword.get(:version, "")

  @doc """
  Retrieves a list of search resources

  ## Parameters

  *   `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server
  *   `part` (*type:* `list(String.t)`) - The *part* parameter specifies a comma-separated list of one or more search resource properties that the API response will include. Set the parameter value to snippet.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:channelId` (*type:* `String.t`) - Filter on resources belonging to this channelId.
      *   `:channelType` (*type:* `String.t`) - Add a filter on the channel search.
      *   `:eventType` (*type:* `String.t`) - Filter on the livestream status of the videos.
      *   `:forContentOwner` (*type:* `boolean()`) - Search owned by a content owner.
      *   `:forDeveloper` (*type:* `boolean()`) - Restrict the search to only retrieve videos uploaded using the project id of the authenticated user.
      *   `:forMine` (*type:* `boolean()`) - Search for the private videos of the authenticated user.
      *   `:location` (*type:* `String.t`) - Filter on location of the video
      *   `:locationRadius` (*type:* `String.t`) - Filter on distance from the location (specified above).
      *   `:maxResults` (*type:* `integer()`) - The *maxResults* parameter specifies the maximum number of items that should be returned in the result set.
      *   `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.
      *   `:order` (*type:* `String.t`) - Sort order of the results.
      *   `:pageToken` (*type:* `String.t`) - The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved.
      *   `:publishedAfter` (*type:* `DateTime.t`) - Filter on resources published after this date.
      *   `:publishedBefore` (*type:* `DateTime.t`) - Filter on resources published before this date.
      *   `:q` (*type:* `String.t`) - Textual search terms to match.
      *   `:regionCode` (*type:* `String.t`) - Display the content as seen by viewers in this country.
      *   `:relevanceLanguage` (*type:* `String.t`) - Return results relevant to this language.
      *   `:safeSearch` (*type:* `String.t`) - Indicates whether the search results should include restricted content as well as standard content.
      *   `:topicId` (*type:* `String.t`) - Restrict results to a particular topic.
      *   `:type` (*type:* `list(String.t)`) - Restrict results to a particular set of resource types from One Platform.
      *   `:videoCaption` (*type:* `String.t`) - Filter on the presence of captions on the videos.
      *   `:videoCategoryId` (*type:* `String.t`) - Filter on videos in a specific category.
      *   `:videoDefinition` (*type:* `String.t`) - Filter on the definition of the videos.
      *   `:videoDimension` (*type:* `String.t`) - Filter on 3d videos.
      *   `:videoDuration` (*type:* `String.t`) - Filter on the duration of the videos.
      *   `:videoEmbeddable` (*type:* `String.t`) - Filter on embeddable videos.
      *   `:videoLicense` (*type:* `String.t`) - Filter on the license of the videos.
      *   `:videoPaidProductPlacement` (*type:* `String.t`) - 
      *   `:videoSyndicated` (*type:* `String.t`) - Filter on syndicated videos.
      *   `:videoType` (*type:* `String.t`) - Filter on videos of a specific type.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.YouTube.V3.Model.SearchListResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec youtube_search_list(Tesla.Env.client(), list(String.t()), keyword(), keyword()) ::
          {:ok, GoogleApi.YouTube.V3.Model.SearchListResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def youtube_search_list(connection, part, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :channelId => :query,
      :channelType => :query,
      :eventType => :query,
      :forContentOwner => :query,
      :forDeveloper => :query,
      :forMine => :query,
      :location => :query,
      :locationRadius => :query,
      :maxResults => :query,
      :onBehalfOfContentOwner => :query,
      :order => :query,
      :pageToken => :query,
      :publishedAfter => :query,
      :publishedBefore => :query,
      :q => :query,
      :regionCode => :query,
      :relevanceLanguage => :query,
      :safeSearch => :query,
      :topicId => :query,
      :type => :query,
      :videoCaption => :query,
      :videoCategoryId => :query,
      :videoDefinition => :query,
      :videoDimension => :query,
      :videoDuration => :query,
      :videoEmbeddable => :query,
      :videoLicense => :query,
      :videoPaidProductPlacement => :query,
      :videoSyndicated => :query,
      :videoType => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/youtube/v3/search", %{})
      |> Request.add_param(:query, :part, part)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.YouTube.V3.Model.SearchListResponse{}])
  end
end
