=begin
#Hatchet API

#The Hatchet API

The version of the OpenAPI document: 1.0.0

Generated by: https://openapi-generator.tech
Generator version: 7.14.0

=end

require 'cgi'

module HatchetSdkRest
  class UserApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # List tenant memberships
    # Lists all tenant memberships for the current user
    # @param [Hash] opts the optional parameters
    # @return [UserTenantMembershipsList]
    def tenant_memberships_list(opts = {})
      data, _status_code, _headers = tenant_memberships_list_with_http_info(opts)
      data
    end

    # List tenant memberships
    # Lists all tenant memberships for the current user
    # @param [Hash] opts the optional parameters
    # @return [Array<(UserTenantMembershipsList, Integer, Hash)>] UserTenantMembershipsList data, response status code and response headers
    def tenant_memberships_list_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.tenant_memberships_list ...'
      end
      # resource path
      local_var_path = '/api/v1/users/memberships'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'UserTenantMembershipsList'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.tenant_memberships_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#tenant_memberships_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Register user
    # Registers a user.
    # @param [Hash] opts the optional parameters
    # @option opts [UserRegisterRequest] :user_register_request
    # @return [User]
    def user_create(opts = {})
      data, _status_code, _headers = user_create_with_http_info(opts)
      data
    end

    # Register user
    # Registers a user.
    # @param [Hash] opts the optional parameters
    # @option opts [UserRegisterRequest] :user_register_request
    # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
    def user_create_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_create ...'
      end
      # resource path
      local_var_path = '/api/v1/users/register'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'user_register_request'])

      # return_type
      return_type = opts[:debug_return_type] || 'User'

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_create",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get current user
    # Gets the current user
    # @param [Hash] opts the optional parameters
    # @return [User]
    def user_get_current(opts = {})
      data, _status_code, _headers = user_get_current_with_http_info(opts)
      data
    end

    # Get current user
    # Gets the current user
    # @param [Hash] opts the optional parameters
    # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
    def user_get_current_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_get_current ...'
      end
      # resource path
      local_var_path = '/api/v1/users/current'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'User'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.user_get_current",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_get_current\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_github_oauth_callback(opts = {})
      user_update_github_oauth_callback_with_http_info(opts)
      nil
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_github_oauth_callback_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_github_oauth_callback ...'
      end
      # resource path
      local_var_path = '/api/v1/users/github/callback'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_update_github_oauth_callback",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_github_oauth_callback\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_github_oauth_start(opts = {})
      user_update_github_oauth_start_with_http_info(opts)
      nil
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_github_oauth_start_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_github_oauth_start ...'
      end
      # resource path
      local_var_path = '/api/v1/users/github/start'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_update_github_oauth_start",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_github_oauth_start\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_google_oauth_callback(opts = {})
      user_update_google_oauth_callback_with_http_info(opts)
      nil
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_google_oauth_callback_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_google_oauth_callback ...'
      end
      # resource path
      local_var_path = '/api/v1/users/google/callback'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_update_google_oauth_callback",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_google_oauth_callback\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_google_oauth_start(opts = {})
      user_update_google_oauth_start_with_http_info(opts)
      nil
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_google_oauth_start_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_google_oauth_start ...'
      end
      # resource path
      local_var_path = '/api/v1/users/google/start'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_update_google_oauth_start",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_google_oauth_start\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Login user
    # Logs in a user.
    # @param [Hash] opts the optional parameters
    # @option opts [UserLoginRequest] :user_login_request
    # @return [User]
    def user_update_login(opts = {})
      data, _status_code, _headers = user_update_login_with_http_info(opts)
      data
    end

    # Login user
    # Logs in a user.
    # @param [Hash] opts the optional parameters
    # @option opts [UserLoginRequest] :user_login_request
    # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
    def user_update_login_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_login ...'
      end
      # resource path
      local_var_path = '/api/v1/users/login'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'user_login_request'])

      # return_type
      return_type = opts[:debug_return_type] || 'User'

      # auth_names
      auth_names = opts[:debug_auth_names] || []

      new_options = opts.merge(
        :operation => :"UserApi.user_update_login",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_login\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Logout user
    # Logs out a user.
    # @param [Hash] opts the optional parameters
    # @return [User]
    def user_update_logout(opts = {})
      data, _status_code, _headers = user_update_logout_with_http_info(opts)
      data
    end

    # Logout user
    # Logs out a user.
    # @param [Hash] opts the optional parameters
    # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
    def user_update_logout_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_logout ...'
      end
      # resource path
      local_var_path = '/api/v1/users/logout'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'User'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.user_update_logout",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_logout\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Change user password
    # Update a user password.
    # @param [Hash] opts the optional parameters
    # @option opts [UserChangePasswordRequest] :user_change_password_request
    # @return [User]
    def user_update_password(opts = {})
      data, _status_code, _headers = user_update_password_with_http_info(opts)
      data
    end

    # Change user password
    # Update a user password.
    # @param [Hash] opts the optional parameters
    # @option opts [UserChangePasswordRequest] :user_change_password_request
    # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
    def user_update_password_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_password ...'
      end
      # resource path
      local_var_path = '/api/v1/users/password'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'user_change_password_request'])

      # return_type
      return_type = opts[:debug_return_type] || 'User'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.user_update_password",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_password\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_slack_oauth_callback(opts = {})
      user_update_slack_oauth_callback_with_http_info(opts)
      nil
    end

    # Complete OAuth flow
    # Completes the OAuth flow
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_slack_oauth_callback_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_slack_oauth_callback ...'
      end
      # resource path
      local_var_path = '/api/v1/users/slack/callback'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.user_update_slack_oauth_callback",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_slack_oauth_callback\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def user_update_slack_oauth_start(tenant, opts = {})
      user_update_slack_oauth_start_with_http_info(tenant, opts)
      nil
    end

    # Start OAuth flow
    # Starts the OAuth flow
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def user_update_slack_oauth_start_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserApi.user_update_slack_oauth_start ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling UserApi.user_update_slack_oauth_start"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling UserApi.user_update_slack_oauth_start, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling UserApi.user_update_slack_oauth_start, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/slack/start'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth']

      new_options = opts.merge(
        :operation => :"UserApi.user_update_slack_oauth_start",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UserApi#user_update_slack_oauth_start\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
