Class: Pipedrive::ItemSearchApi

Inherits:
Object
  • Object
show all
Defined in:
lib/pipedrive-openapi-client/api/item_search_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ItemSearchApi

Returns a new instance of ItemSearchApi.



19
20
21
# File 'lib/pipedrive-openapi-client/api/item_search_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/pipedrive-openapi-client/api/item_search_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#item_search_field_get(term, field_type, field_key, opts = {}) ⇒ BaseResponse

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).

Parameters:

  • term (String)

    The search term to look for. Minimum 2 characters (or 1 if using exact_match).

  • field_type (String)

    The type of the field to perform the search from

  • 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.).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :exact_match (Boolean)

    When enabled, only full exact matches against the given term are returned. The search <b>is</b> case sensitive. (default to false)

  • :return_item_ids (Boolean)

    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.

  • :start (Integer)

    Pagination start

  • :limit (Integer)

    Items shown per page

Returns:



33
34
35
36
# 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 = {}) ⇒ Array<(BaseResponse, Integer, Hash)>

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).

Parameters:

  • term (String)

    The search term to look for. Minimum 2 characters (or 1 if using exact_match).

  • field_type (String)

    The type of the field to perform the search from

  • 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.).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :exact_match (Boolean)

    When enabled, only full exact matches against the given term are returned. The search &lt;b&gt;is&lt;/b&gt; case sensitive.

  • :return_item_ids (Boolean)

    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.

  • :start (Integer)

    Pagination start

  • :limit (Integer)

    Items shown per page

Returns:

  • (Array<(BaseResponse, Integer, Hash)>)

    BaseResponse data, response status code and response headers



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# 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 = {}) ⇒ BaseResponse

Perform a search from multiple item types Performs a search from your choice of item types and fields.

Parameters:

  • term (String)

    The search term to look for. Minimum 2 characters (or 1 if using exact_match).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :item_types (String)

    A comma-separated string array. The type of items to perform the search from. Defaults to all.

  • :fields (String)

    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;

  • :search_for_related_items (Boolean)

    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.

  • :exact_match (Boolean)

    When enabled, only full exact matches against the given term are returned. It is &lt;b&gt;not&lt;/b&gt; case sensitive.

  • :include_fields (String)

    A comma-separated string array. Supports including optional fields in the results which are not provided by default.

  • :start (Integer)

    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)

  • :limit (Integer)

    Items shown per page

Returns:



136
137
138
139
# 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 = {}) ⇒ Array<(BaseResponse, Integer, Hash)>

Perform a search from multiple item types Performs a search from your choice of item types and fields.

Parameters:

  • term (String)

    The search term to look for. Minimum 2 characters (or 1 if using exact_match).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :item_types (String)

    A comma-separated string array. The type of items to perform the search from. Defaults to all.

  • :fields (String)

    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;

  • :search_for_related_items (Boolean)

    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.

  • :exact_match (Boolean)

    When enabled, only full exact matches against the given term are returned. It is &lt;b&gt;not&lt;/b&gt; case sensitive.

  • :include_fields (String)

    A comma-separated string array. Supports including optional fields in the results which are not provided by default.

  • :start (Integer)

    Pagination start. Note that the pagination is based on main results and does not include related items when using search_for_related_items parameter.

  • :limit (Integer)

    Items shown per page

Returns:

  • (Array<(BaseResponse, Integer, Hash)>)

    BaseResponse data, response status code and response headers



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# 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