=begin
#DocuSign Admin API

#An API for an organization administrator to manage organizations, accounts and users

OpenAPI spec version: v2.1
Contact: devcenter@docusign.com
Generated by: https://github.com/swagger-api/swagger-codegen.git

=end

require "uri"

module DocuSign_Admin

  class GetUserProfilesOptions
    # The email address
    attr_accessor :email

    def self.default
      @@default ||= GetUserProfilesOptions.new
    end
  end

  class GetUsersOptions
    # Index of first item to include in the response  Default value: 0
    attr_accessor :start

    # Page size of the response  Default value: 20
    attr_accessor :take

    # Index of the last item to include in the response. Ignored if 'take' parameter is specfied
    attr_accessor :_end

    # Email address of the desired user. At least one of email, account_id or organization_reserved_domain_id must be specified.
    attr_accessor :email

    # Selects users by pattern matching on the user's email address
    attr_accessor :email_user_name_like

    # Select users based on user status
    attr_accessor :status

    # Select users based on membership status
    attr_accessor :membership_status

    # Select users that are members of the specified account. At least one of email, account_id or organization_reserved_domain_id must be specified.
    attr_accessor :account_id

    # Select users that are in the specified domain. At least one of email, account_id or organization_reserved_domain_id must be specified.
    attr_accessor :organization_reserved_domain_id

    # Select users whose data have been modified since the date specified;  account_id or organization_reserved_domain_id must be specified.
    attr_accessor :last_modified_since

    def self.default
      @@default ||= GetUsersOptions.new
    end
  end


  class UsersApi
    attr_accessor :api_client

    def initialize(api_client = UsersApi.default)
      @api_client = api_client
    end

    # Activates user memberships
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param membership_id The membership ID Guid
    # @param request Additional details about the user's membership 
    # @return [UpdateResponse]
    def activate_membership(organization_id, user_id, membership_id, request)
      data, _status_code, _headers = activate_membership_with_http_info(organization_id, user_id, membership_id,  request)
      return data
    end

    # Activates user memberships
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param membership_id The membership ID Guid
    # @param request Additional details about the user's membership 
    # @return [Array<(UpdateResponse, Fixnum, Hash)>] UpdateResponse data, response status code and response headers
    def activate_membership_with_http_info(organization_id, user_id, membership_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.activate_membership ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.activate_membership" if organization_id.nil?
      # verify the required parameter 'user_id' is set
      fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.activate_membership" if user_id.nil?
      # verify the required parameter 'membership_id' is set
      fail ArgumentError, "Missing the required parameter 'membership_id' when calling UsersApi.activate_membership" if membership_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.activate_membership" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/{userId}/memberships/{membershipId}".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s).sub('{' + 'userId' + '}', user_id.to_s).sub('{' + 'membershipId' + '}', membership_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'UpdateResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#activate_membership\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Creates and updates a multi-product user
    # Required scopes: user_write
    # @param organization_id The organization ID GUID
    # @param account_id The account ID GUID
    # @param request The request object 
    # @return [AddUserResponse]
    def add_or_update_user(organization_id, account_id, request)
      data, _status_code, _headers = add_or_update_user_with_http_info(organization_id, account_id,  request)
      return data
    end

    # Creates and updates a multi-product user
    # Required scopes: user_write
    # @param organization_id The organization ID GUID
    # @param account_id The account ID GUID
    # @param request The request object 
    # @return [Array<(AddUserResponse, Fixnum, Hash)>] AddUserResponse data, response status code and response headers
    def add_or_update_user_with_http_info(organization_id, account_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.add_or_update_user ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.add_or_update_user" if organization_id.nil?
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling UsersApi.add_or_update_user" if account_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.add_or_update_user" if request.nil?
      # resource path
      local_var_path = "/v2.1/organizations/{organizationId}/accounts/{accountId}/users".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s).sub('{' + 'accountId' + '}', account_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'AddUserResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#add_or_update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Adds users to an account.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param account_id The account ID Guid
    # @param request The details for the users to add to the account 
    # @return [NewUserResponse]
    def add_users(organization_id, account_id, request)
      data, _status_code, _headers = add_users_with_http_info(organization_id, account_id,  request)
      return data
    end

    # Adds users to an account.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param account_id The account ID Guid
    # @param request The details for the users to add to the account 
    # @return [Array<(NewUserResponse, Fixnum, Hash)>] NewUserResponse data, response status code and response headers
    def add_users_with_http_info(organization_id, account_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.add_users ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.add_users" if organization_id.nil?
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling UsersApi.add_users" if account_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.add_users" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/accounts/{accountId}/users".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s).sub('{' + 'accountId' + '}', account_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'NewUserResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#add_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Closes a user's memberships.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param request The details about which membership to close 
    # @return [DeleteMembershipsResponse]
    def close_memberships(organization_id, user_id, request)
      data, _status_code, _headers = close_memberships_with_http_info(organization_id, user_id,  request)
      return data
    end

    # Closes a user&#39;s memberships.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param request The details about which membership to close 
    # @return [Array<(DeleteMembershipsResponse, Fixnum, Hash)>] DeleteMembershipsResponse data, response status code and response headers
    def close_memberships_with_http_info(organization_id, user_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.close_memberships ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.close_memberships" if organization_id.nil?
      # verify the required parameter 'user_id' is set
      fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.close_memberships" if user_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.close_memberships" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/{userId}/accounts".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s).sub('{' + 'userId' + '}', user_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'DeleteMembershipsResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#close_memberships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Creates a new user
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request Details about the user to be added 
    # @return [NewUserResponse]
    def create_user(organization_id, request)
      data, _status_code, _headers = create_user_with_http_info(organization_id,  request)
      return data
    end

    # Creates a new user
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request Details about the user to be added 
    # @return [Array<(NewUserResponse, Fixnum, Hash)>] NewUserResponse data, response status code and response headers
    def create_user_with_http_info(organization_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.create_user ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.create_user" if organization_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.create_user" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'NewUserResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Deletes user identities.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param request_model The details for the user identities to be deleted 
    # @return [DeleteResponse]
    def delete_identities(organization_id, user_id, request_model)
      data, _status_code, _headers = delete_identities_with_http_info(organization_id, user_id,  request_model)
      return data
    end

    # Deletes user identities.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param user_id The user ID Guid
    # @param request_model The details for the user identities to be deleted 
    # @return [Array<(DeleteResponse, Fixnum, Hash)>] DeleteResponse data, response status code and response headers
    def delete_identities_with_http_info(organization_id, user_id, request_model)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.delete_identities ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.delete_identities" if organization_id.nil?
      # verify the required parameter 'user_id' is set
      fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.delete_identities" if user_id.nil?
      # verify the required parameter 'request_model' is set
      fail ArgumentError, "Missing the required parameter 'request_model' when calling UsersApi.delete_identities" if request_model.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/{userId}/identities".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s).sub('{' + 'userId' + '}', user_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request_model)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'DeleteResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#delete_identities\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Returns user information.
    # Required scopes: user_read
    # @param organization_id The organization ID Guid
    # @param DocuSign_Admin::GetUserProfilesOptions Options for modifying the behavior of the function.
    # @return [UsersDrilldownResponse]
    def get_user_profiles(organization_id, options = DocuSign_Admin::GetUserProfilesOptions.default)
      data, _status_code, _headers = get_user_profiles_with_http_info(organization_id, options)
      return data
    end

    # Returns user information.
    # Required scopes: user_read
    # @param organization_id The organization ID Guid
    # @param DocuSign_Admin::GetUserProfilesOptions Options for modifying the behavior of the function.
    # @return [Array<(UsersDrilldownResponse, Fixnum, Hash)>] UsersDrilldownResponse data, response status code and response headers
    def get_user_profiles_with_http_info(organization_id, options = DocuSign_Admin::GetUserProfilesOptions.default)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.get_user_profiles ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.get_user_profiles" if organization_id.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/profile".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'email'] = options.email if !options.email.nil?

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'UsersDrilldownResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#get_user_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Returns information about the users in the organization
    # Required scopes: user_read
    # @param organization_id The organization ID Guid
    # @param DocuSign_Admin::GetUsersOptions Options for modifying the behavior of the function.
    # @return [OrganizationUsersResponse]
    def get_users(organization_id, options = DocuSign_Admin::GetUsersOptions.default)
      data, _status_code, _headers = get_users_with_http_info(organization_id, options)
      return data
    end

    # Returns information about the users in the organization
    # Required scopes: user_read
    # @param organization_id The organization ID Guid
    # @param DocuSign_Admin::GetUsersOptions Options for modifying the behavior of the function.
    # @return [Array<(OrganizationUsersResponse, Fixnum, Hash)>] OrganizationUsersResponse data, response status code and response headers
    def get_users_with_http_info(organization_id, options = DocuSign_Admin::GetUsersOptions.default)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.get_users ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.get_users" if organization_id.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'start'] = options.start if !options.start.nil?
      query_params[:'take'] = options.take if !options.take.nil?
      query_params[:'end'] = options._end if !options._end.nil?
      query_params[:'email'] = options.email if !options.email.nil?
      query_params[:'email_user_name_like'] = options.email_user_name_like if !options.email_user_name_like.nil?
      query_params[:'status'] = options.status if !options.status.nil?
      query_params[:'membership_status'] = options.membership_status if !options.membership_status.nil?
      query_params[:'account_id'] = options.account_id if !options.account_id.nil?
      query_params[:'organization_reserved_domain_id'] = options.organization_reserved_domain_id if !options.organization_reserved_domain_id.nil?
      query_params[:'last_modified_since'] = options.last_modified_since if !options.last_modified_since.nil?

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'OrganizationUsersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#get_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Updates a user's email address.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request The details about which email addresses to update 
    # @return [UsersUpdateResponse]
    def update_email_address(organization_id, request)
      data, _status_code, _headers = update_email_address_with_http_info(organization_id,  request)
      return data
    end

    # Updates a user&#39;s email address.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request The details about which email addresses to update 
    # @return [Array<(UsersUpdateResponse, Fixnum, Hash)>] UsersUpdateResponse data, response status code and response headers
    def update_email_address_with_http_info(organization_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.update_email_address ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.update_email_address" if organization_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.update_email_address" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/email_addresses".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'UsersUpdateResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#update_email_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Updates a user.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request The user details to update 
    # @return [UsersUpdateResponse]
    def update_user(organization_id, request)
      data, _status_code, _headers = update_user_with_http_info(organization_id,  request)
      return data
    end

    # Updates a user.
    # Required scopes: user_write
    # @param organization_id The organization ID Guid
    # @param request The user details to update 
    # @return [Array<(UsersUpdateResponse, Fixnum, Hash)>] UsersUpdateResponse data, response status code and response headers
    def update_user_with_http_info(organization_id, request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: UsersApi.update_user ..."
      end
      # verify the required parameter 'organization_id' is set
      fail ArgumentError, "Missing the required parameter 'organization_id' when calling UsersApi.update_user" if organization_id.nil?
      # verify the required parameter 'request' is set
      fail ArgumentError, "Missing the required parameter 'request' when calling UsersApi.update_user" if request.nil?
      # resource path
      local_var_path = "/v2/organizations/{organizationId}/users/profiles".sub('{format}','json').sub('{' + 'organizationId' + '}', organization_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'UsersUpdateResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: UsersApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end