=begin
#Docusign eSignature REST API

#The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign.

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

=end

require "uri"

module DocuSign_eSign

  class ListGroupUsersOptions
    # Number of records to return. The number must be greater than 1 and less than or equal to 100. 
    attr_accessor :count

    # Starting value for the list.
    attr_accessor :start_position

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

  class ListGroupsOptions
    # Number of records to return. The number must be greater than 1 and less than or equal to 100.
    attr_accessor :count

    # 
    attr_accessor :group_type

    # 
    attr_accessor :include_usercount

    # 
    attr_accessor :search_text

    # Starting value for the list.
    attr_accessor :start_position

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


  class GroupsApi
    attr_accessor :api_client

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

    # Creates one or more groups for the account.
    # Creates one or more groups for the account.  Groups can be used to help manage users by associating users with a group. You can associate a group with a Permission Profile, which sets the user permissions for users in that group without having to set the `userSettings` property for each user. You are not required to set Permission Profiles for a group, but it makes it easier to manage user permissions for a large number of users. You can also use groups with template sharing to limit user access to templates.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [GroupInformation]
    def create_groups(account_id, group_information)
      data, _status_code, _headers = create_groups_with_http_info(account_id,  group_information)
      return data
    end

    # Creates one or more groups for the account.
    # Creates one or more groups for the account.  Groups can be used to help manage users by associating users with a group. You can associate a group with a Permission Profile, which sets the user permissions for users in that group without having to set the &#x60;userSettings&#x60; property for each user. You are not required to set Permission Profiles for a group, but it makes it easier to manage user permissions for a large number of users. You can also use groups with template sharing to limit user access to templates.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [Array<(GroupInformation, Fixnum, Hash)>] GroupInformation data, response status code and response headers
    def create_groups_with_http_info(account_id, group_information)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.create_groups ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.create_groups" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups".sub('{format}','json').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'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(group_information)
      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 => 'GroupInformation')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#create_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Deletes brand information from the requested group.
    # Deletes brand information from the requested group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param brands_request  (optional parameter)
    # @return [GroupBrands]
    def delete_brands(account_id, group_id, brands_request)
      data, _status_code, _headers = delete_brands_with_http_info(account_id, group_id,  brands_request)
      return data
    end

    # Deletes brand information from the requested group.
    # Deletes brand information from the requested group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param brands_request  (optional parameter)
    # @return [Array<(GroupBrands, Fixnum, Hash)>] GroupBrands data, response status code and response headers
    def delete_brands_with_http_info(account_id, group_id, brands_request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.delete_brands ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.delete_brands" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.delete_brands" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/brands".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_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'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(brands_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 => 'GroupBrands')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#delete_brands\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Deletes one or more users from a gro
    # Deletes one or more users from a group. 
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param user_info_list  (optional parameter)
    # @return [UsersResponse]
    def delete_group_users(account_id, group_id, user_info_list)
      data, _status_code, _headers = delete_group_users_with_http_info(account_id, group_id,  user_info_list)
      return data
    end

    # Deletes one or more users from a gro
    # Deletes one or more users from a group. 
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param user_info_list  (optional parameter)
    # @return [Array<(UsersResponse, Fixnum, Hash)>] UsersResponse data, response status code and response headers
    def delete_group_users_with_http_info(account_id, group_id, user_info_list)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.delete_group_users ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.delete_group_users" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.delete_group_users" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/users".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_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'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(user_info_list)
      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 => 'UsersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#delete_group_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Deletes an existing user group.
    # Deletes an existing user group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [GroupInformation]
    def delete_groups(account_id, group_information)
      data, _status_code, _headers = delete_groups_with_http_info(account_id,  group_information)
      return data
    end

    # Deletes an existing user group.
    # Deletes an existing user group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [Array<(GroupInformation, Fixnum, Hash)>] GroupInformation data, response status code and response headers
    def delete_groups_with_http_info(account_id, group_information)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.delete_groups ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.delete_groups" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups".sub('{format}','json').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'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(group_information)
      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 => 'GroupInformation')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#delete_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets group brand ID Information. 
    # Retrieves information about the brands associated with the requested group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @return [GroupBrands]
    def get_brands(account_id, group_id)
      data, _status_code, _headers = get_brands_with_http_info(account_id, group_id)
      return data
    end

    # Gets group brand ID Information. 
    # Retrieves information about the brands associated with the requested group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @return [Array<(GroupBrands, Fixnum, Hash)>] GroupBrands data, response status code and response headers
    def get_brands_with_http_info(account_id, group_id)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.get_brands ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.get_brands" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.get_brands" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/brands".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_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'])

      # 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 => 'GroupBrands')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#get_brands\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets a list of users in a group.
    # Retrieves a list of users in a group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param DocuSign_eSign::ListGroupUsersOptions Options for modifying the behavior of the function.
    # @return [UsersResponse]
    def list_group_users(account_id, group_id, options = DocuSign_eSign::ListGroupUsersOptions.default)
      data, _status_code, _headers = list_group_users_with_http_info(account_id, group_id, options)
      return data
    end

    # Gets a list of users in a group.
    # Retrieves a list of users in a group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param DocuSign_eSign::ListGroupUsersOptions Options for modifying the behavior of the function.
    # @return [Array<(UsersResponse, Fixnum, Hash)>] UsersResponse data, response status code and response headers
    def list_group_users_with_http_info(account_id, group_id, options = DocuSign_eSign::ListGroupUsersOptions.default)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.list_group_users ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.list_group_users" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.list_group_users" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/users".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_id.to_s)

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

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['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 => 'UsersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#list_group_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets information about groups associated with the account.
    # Retrieves information about groups associated with the account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param DocuSign_eSign::ListGroupsOptions Options for modifying the behavior of the function.
    # @return [GroupInformation]
    def list_groups(account_id, options = DocuSign_eSign::ListGroupsOptions.default)
      data, _status_code, _headers = list_groups_with_http_info(account_id, options)
      return data
    end

    # Gets information about groups associated with the account.
    # Retrieves information about groups associated with the account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param DocuSign_eSign::ListGroupsOptions Options for modifying the behavior of the function.
    # @return [Array<(GroupInformation, Fixnum, Hash)>] GroupInformation data, response status code and response headers
    def list_groups_with_http_info(account_id, options = DocuSign_eSign::ListGroupsOptions.default)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.list_groups ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.list_groups" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'count'] = options.count if !options.count.nil?
      query_params[:'group_type'] = options.group_type if !options.group_type.nil?
      query_params[:'include_usercount'] = options.include_usercount if !options.include_usercount.nil?
      query_params[:'search_text'] = options.search_text if !options.search_text.nil?
      query_params[:'start_position'] = options.start_position if !options.start_position.nil?

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['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 => 'GroupInformation')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: GroupsApi#list_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Adds group brand ID information to a group.
    # Adds group brand ID information to a group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param brands_request  (optional parameter)
    # @return [GroupBrands]
    def update_brands(account_id, group_id, brands_request)
      data, _status_code, _headers = update_brands_with_http_info(account_id, group_id,  brands_request)
      return data
    end

    # Adds group brand ID information to a group.
    # Adds group brand ID information to a group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param brands_request  (optional parameter)
    # @return [Array<(GroupBrands, Fixnum, Hash)>] GroupBrands data, response status code and response headers
    def update_brands_with_http_info(account_id, group_id, brands_request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.update_brands ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.update_brands" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.update_brands" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/brands".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_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'])

      # form parameters
      form_params = {}

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

    # Adds one or more users to an existing group.
    # Adds one or more users to an existing group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param user_info_list  (optional parameter)
    # @return [UsersResponse]
    def update_group_users(account_id, group_id, user_info_list)
      data, _status_code, _headers = update_group_users_with_http_info(account_id, group_id,  user_info_list)
      return data
    end

    # Adds one or more users to an existing group.
    # Adds one or more users to an existing group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_id The ID of the group being accessed.
    # @param user_info_list  (optional parameter)
    # @return [Array<(UsersResponse, Fixnum, Hash)>] UsersResponse data, response status code and response headers
    def update_group_users_with_http_info(account_id, group_id, user_info_list)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.update_group_users ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.update_group_users" if account_id.nil?
      # verify the required parameter 'group_id' is set
      fail ArgumentError, "Missing the required parameter 'group_id' when calling GroupsApi.update_group_users" if group_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups/{groupId}/users".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'groupId' + '}', group_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'])

      # form parameters
      form_params = {}

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

    # Updates the group information for a group.
    # Updates the group name and modifies, or sets, the permission profile for the group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [GroupInformation]
    def update_groups(account_id, group_information)
      data, _status_code, _headers = update_groups_with_http_info(account_id,  group_information)
      return data
    end

    # Updates the group information for a group.
    # Updates the group name and modifies, or sets, the permission profile for the group.
    # @param account_id The external account number (int) or account ID Guid.
    # @param group_information  (optional parameter)
    # @return [Array<(GroupInformation, Fixnum, Hash)>] GroupInformation data, response status code and response headers
    def update_groups_with_http_info(account_id, group_information)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: GroupsApi.update_groups ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling GroupsApi.update_groups" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/groups".sub('{format}','json').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'])

      # form parameters
      form_params = {}

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