class Pipedrive::ItemSearchApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/pipedrive-openapi-client/api/item_search_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

item_search_field_get(term, field_type, field_key, opts = {}) click to toggle source

Perform a search using a specific field from an item type Performs a search from the values of a specific field. Results can either be the distinct values of the field (useful for searching autocomplete field values), or the IDs of actual items (Deals, Persons, Organizations or Products). @param term [String] The search term to look for. Minimum 2 characters (or 1 if using exact_match). @param field_type [String] The type of the field to perform the search from @param field_key [String] The key of the field to search from. The field key can be obtained by fetching the list of the fields using any of the fields' API GET methods (dealFields, personFields, etc.). @param [Hash] opts the optional parameters @option opts [Boolean] :exact_match When enabled, only full exact matches against the given term are returned. The search <b>is</b> case sensitive. (default to false) @option opts [Boolean] :return_item_ids Whether to return the IDs of the matching items or not. When not set or set to 0 or false, only distinct values of the searched field are returned. When set to 1 or true, the ID of each found item is returned. @option opts [Integer] :start Pagination start @option opts [Integer] :limit Items shown per page @return [BaseResponse]

# File lib/pipedrive-openapi-client/api/item_search_api.rb, line 33
def item_search_field_get(term, field_type, field_key, opts = {})
  data, _status_code, _headers = item_search_field_get_with_http_info(term, field_type, field_key, opts)
  data
end
item_search_field_get_with_http_info(term, field_type, field_key, opts = {}) click to toggle source

Perform a search using a specific field from an item type Performs a search from the values of a specific field. Results can either be the distinct values of the field (useful for searching autocomplete field values), or the IDs of actual items (Deals, Persons, Organizations or Products). @param term [String] The search term to look for. Minimum 2 characters (or 1 if using exact_match). @param field_type [String] The type of the field to perform the search from @param field_key [String] The key of the field to search from. The field key can be obtained by fetching the list of the fields using any of the fields&#39; API GET methods (dealFields, personFields, etc.). @param [Hash] opts the optional parameters @option opts [Boolean] :exact_match When enabled, only full exact matches against the given term are returned. The search &lt;b&gt;is&lt;/b&gt; case sensitive. @option opts [Boolean] :return_item_ids Whether to return the IDs of the matching items or not. When not set or set to 0 or false, only distinct values of the searched field are returned. When set to 1 or true, the ID of each found item is returned. @option opts [Integer] :start Pagination start @option opts [Integer] :limit Items shown per page @return [Array<(BaseResponse, Integer, Hash)>] BaseResponse data, response status code and response headers

# File lib/pipedrive-openapi-client/api/item_search_api.rb, line 49
def item_search_field_get_with_http_info(term, field_type, field_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ItemSearchApi.item_search_field_get ...'
  end
  # verify the required parameter 'term' is set
  if @api_client.config.client_side_validation && term.nil?
    fail ArgumentError, "Missing the required parameter 'term' when calling ItemSearchApi.item_search_field_get"
  end
  # verify the required parameter 'field_type' is set
  if @api_client.config.client_side_validation && field_type.nil?
    fail ArgumentError, "Missing the required parameter 'field_type' when calling ItemSearchApi.item_search_field_get"
  end
  # verify enum value
  allowable_values = ["dealField", "personField", "organizationField", "productField"]
  if @api_client.config.client_side_validation && !allowable_values.include?(field_type)
    fail ArgumentError, "invalid value for \"field_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'field_key' is set
  if @api_client.config.client_side_validation && field_key.nil?
    fail ArgumentError, "Missing the required parameter 'field_key' when calling ItemSearchApi.item_search_field_get"
  end
  allowable_values = ["true", "false"]
  if @api_client.config.client_side_validation && opts[:'exact_match'] && !allowable_values.include?(opts[:'exact_match'])
    fail ArgumentError, "invalid value for \"exact_match\", must be one of #{allowable_values}"
  end
  allowable_values = ["true", "false"]
  if @api_client.config.client_side_validation && opts[:'return_item_ids'] && !allowable_values.include?(opts[:'return_item_ids'])
    fail ArgumentError, "invalid value for \"return_item_ids\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/itemSearch/field'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'term'] = term
  query_params[:'field_type'] = field_type
  query_params[:'field_key'] = field_key
  query_params[:'exact_match'] = opts[:'exact_match'] if !opts[:'exact_match'].nil?
  query_params[:'return_item_ids'] = opts[:'return_item_ids'] if !opts[:'return_item_ids'].nil?
  query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

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

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

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

  # return_type
  return_type = opts[:return_type] || 'BaseResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :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: ItemSearchApi#item_search_field_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
item_search_get(term, opts = {}) click to toggle source

Perform a search from multiple item types Performs a search from your choice of item types and fields. @param term [String] The search term to look for. Minimum 2 characters (or 1 if using exact_match). @param [Hash] opts the optional parameters @option opts [String] :item_types A comma-separated string array. The type of items to perform the search from. Defaults to all. @option opts [String] :fields A comma-separated string array. The fields to perform the search from. Defaults to all. Relevant for each item type are:&lt;br&gt; &lt;table&gt; &lt;tr&gt;&lt;th&gt;&lt;b&gt;Item type&lt;/b&gt;&lt;/th&gt;&lt;th&gt;&lt;b&gt;Field&lt;/b&gt;&lt;/th&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Deal&lt;/td&gt;&lt;td&gt;custom_fields, notes, title&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Person&lt;/td&gt;&lt;td&gt;custom_fields, email, name, notes, phone&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Organization&lt;/td&gt;&lt;td&gt;address, custom_fields, name, notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Product&lt;/td&gt;&lt;td&gt;code, custom_fields, name&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Lead&lt;/td&gt;&lt;td&gt;email, organization_name, person_name, phone, title&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;File&lt;/td&gt;&lt;td&gt;name&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Mail attachment&lt;/td&gt;&lt;td&gt;name&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; @option opts [Boolean] :search_for_related_items When enabled, the response will include up to 100 newest related Deals for each found Person and Organization and up to 100 newest related Persons for each found Organization. @option opts [Boolean] :exact_match When enabled, only full exact matches against the given term are returned. It is &lt;b&gt;not&lt;/b&gt; case sensitive. @option opts [String] :include_fields A comma-separated string array. Supports including optional fields in the results which are not provided by default. @option opts [Integer] :start Pagination start. Note that the pagination is based on main results and does not include related items when using search_for_related_items parameter. (default to 0) @option opts [Integer] :limit Items shown per page @return [BaseResponse]

# File lib/pipedrive-openapi-client/api/item_search_api.rb, line 136
def item_search_get(term, opts = {})
  data, _status_code, _headers = item_search_get_with_http_info(term, opts)
  data
end
item_search_get_with_http_info(term, opts = {}) click to toggle source

Perform a search from multiple item types Performs a search from your choice of item types and fields. @param term [String] The search term to look for. Minimum 2 characters (or 1 if using exact_match). @param [Hash] opts the optional parameters @option opts [String] :item_types A comma-separated string array. The type of items to perform the search from. Defaults to all. @option opts [String] :fields A comma-separated string array. The fields to perform the search from. Defaults to all. Relevant for each item type are:&lt;br&gt; &lt;table&gt; &lt;tr&gt;&lt;th&gt;&lt;b&gt;Item type&lt;/b&gt;&lt;/th&gt;&lt;th&gt;&lt;b&gt;Field&lt;/b&gt;&lt;/th&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Deal&lt;/td&gt;&lt;td&gt;custom_fields, notes, title&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Person&lt;/td&gt;&lt;td&gt;custom_fields, email, name, notes, phone&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Organization&lt;/td&gt;&lt;td&gt;address, custom_fields, name, notes&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Product&lt;/td&gt;&lt;td&gt;code, custom_fields, name&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Lead&lt;/td&gt;&lt;td&gt;email, organization_name, person_name, phone, title&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;File&lt;/td&gt;&lt;td&gt;name&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Mail attachment&lt;/td&gt;&lt;td&gt;name&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; @option opts [Boolean] :search_for_related_items When enabled, the response will include up to 100 newest related Deals for each found Person and Organization and up to 100 newest related Persons for each found Organization. @option opts [Boolean] :exact_match When enabled, only full exact matches against the given term are returned. It is &lt;b&gt;not&lt;/b&gt; case sensitive. @option opts [String] :include_fields A comma-separated string array. Supports including optional fields in the results which are not provided by default. @option opts [Integer] :start Pagination start. Note that the pagination is based on main results and does not include related items when using search_for_related_items parameter. @option opts [Integer] :limit Items shown per page @return [Array<(BaseResponse, Integer, Hash)>] BaseResponse data, response status code and response headers

# File lib/pipedrive-openapi-client/api/item_search_api.rb, line 153
def item_search_get_with_http_info(term, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ItemSearchApi.item_search_get ...'
  end
  # verify the required parameter 'term' is set
  if @api_client.config.client_side_validation && term.nil?
    fail ArgumentError, "Missing the required parameter 'term' when calling ItemSearchApi.item_search_get"
  end
  allowable_values = ["deal", "person", "organization", "product", "lead", "file", "mail_attachment"]
  if @api_client.config.client_side_validation && opts[:'item_types'] && !allowable_values.include?(opts[:'item_types'])
    fail ArgumentError, "invalid value for \"item_types\", must be one of #{allowable_values}"
  end
  allowable_values = ["address", "code", "custom_fields", "email", "name", "notes", "organization_name", "person_name", "phone", "title"]
  if @api_client.config.client_side_validation && opts[:'fields'] && !allowable_values.include?(opts[:'fields'])
    fail ArgumentError, "invalid value for \"fields\", must be one of #{allowable_values}"
  end
  allowable_values = ["true", "false"]
  if @api_client.config.client_side_validation && opts[:'search_for_related_items'] && !allowable_values.include?(opts[:'search_for_related_items'])
    fail ArgumentError, "invalid value for \"search_for_related_items\", must be one of #{allowable_values}"
  end
  allowable_values = ["true", "false"]
  if @api_client.config.client_side_validation && opts[:'exact_match'] && !allowable_values.include?(opts[:'exact_match'])
    fail ArgumentError, "invalid value for \"exact_match\", must be one of #{allowable_values}"
  end
  allowable_values = ["deal.cc_email", "person.picture", "product.price"]
  if @api_client.config.client_side_validation && opts[:'include_fields'] && !allowable_values.include?(opts[:'include_fields'])
    fail ArgumentError, "invalid value for \"include_fields\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/itemSearch'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'term'] = term
  query_params[:'item_types'] = opts[:'item_types'] if !opts[:'item_types'].nil?
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
  query_params[:'search_for_related_items'] = opts[:'search_for_related_items'] if !opts[:'search_for_related_items'].nil?
  query_params[:'exact_match'] = opts[:'exact_match'] if !opts[:'exact_match'].nil?
  query_params[:'include_fields'] = opts[:'include_fields'] if !opts[:'include_fields'].nil?
  query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

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

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

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

  # return_type
  return_type = opts[:return_type] || 'BaseResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :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: ItemSearchApi#item_search_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end