class ReliefWebAPI::TrainingApi

Attributes

api_client[RW]

Public Class Methods

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

Public Instance Methods

get_training(opts = {}) click to toggle source

List or search humanitarian learning opportunities.

@param [Hash] opts the optional parameters @option opts [String] :query_value Specify the terms of your fuzzy search. The default is no query. @option opts [String] :query_operator Specify the operator by which your search query words will be combined. @option opts [Array<String>] :query_fields Specify which fields to target with your search. You may use boost syntax here, see the Advanced API Usage documentation. @option opts [String] :filter_field Field to filter by. Every condition must contain either a &lt;code&gt;field&lt;/code&gt; or &lt;code&gt;conditions&lt;/code&gt; property. @option opts [Array<String>] :filter_value Value for the field being filtered. Leave blank to require existence of the field, must be present for &lt;code&gt;range&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt; conditions. @option opts [String] :filter_operator Operator by which filters will be combined. @option opts [BOOLEAN] :filter_negate Reverse the filter to include those items that do not match. @option opts [Array<String>] :filter_conditions This property is used to combine conditions with a logical connector (the &lt;code&gt;operator&lt;/code&gt; property). Every condition must contain one of the &lt;code&gt;field&lt;/code&gt; or &lt;code&gt;conditions&lt;/code&gt; properties. @option opts [String] :facets_field Field to facet by. May include dates, references or the status field. @option opts [String] :facets_name Identifier for resulting facet data. Useful when faceting multiple ways on the same field. @option opts [Integer] :facets_limit Limit the number of facets returned for non-date based facets. @option opts [String] :facets_sort The sort order of non-date facets. Sorting may be by &lt;code&gt;value&lt;/code&gt; or &lt;code&gt;count&lt;/code&gt; of terms, and ascending or descending. &lt;code&gt;count&lt;/code&gt; defaults to &lt;code&gt;desc&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt; defaults to &lt;code&gt;asc&lt;/code&gt;. @option opts [Array<String>] :facets_filter Apply all the same capabilities of the filter parameter to the specific results of this facet request. @option opts [String] :facets_interval Round date information to the nearest interval unit. Apply all the same capabilities of the filter parameter to the specific results of this facet request. @option opts [Array<String>] :fields_include Specify which fields to include for each item. Defaults to an item label. @option opts [Array<String>] :fields_exclude Specify sub-fields to exclude from overall results. For example, if you include &lt;code&gt;date&lt;/code&gt; you may exclude &lt;code&gt;date.changed&lt;/code&gt;. @option opts [Integer] :limit The maximum number of items to return for a list query. The default is &lt;code&gt;10&lt;/code&gt; and the maximum &lt;code&gt;1000&lt;/code&gt;. (default to 10) @option opts [Integer] :offset The offset from which to return the items in a list query. Allows paging through all results. The default is &lt;code&gt;0&lt;/code&gt;. (default to 0) @option opts [Array<String>] :sort Sort the list results. Defaults to search relevance. Values in the form of &lt;code&gt;fieldname:(asc|desc)&lt;/code&gt;. @option opts [String] :profile Pre-built standard selections of fields to return for ease of displaying lists or items. @option opts [String] :preset Pre-built standard configurations of queries, filters and sorts for common use cases. @return [Training]

# File lib/reliefweb-api/api/training_api.rb, line 47
def get_training(opts = {})
  data, _status_code, _headers = get_training_with_http_info(opts)
  data
end
get_training_by_id(training_id, opts = {}) click to toggle source

Find training by its unique ID Individual training opportunities. @param training_id The identifier of the training opportunity. @param [Hash] opts the optional parameters @option opts [String] :profile Pre-built standard selections of fields to return for ease of displaying lists or items. @option opts [Array<String>] :fields_include Specify which fields to include for each item. Defaults to an item label. @option opts [Array<String>] :fields_exclude Specify sub-fields to exclude from overall results. For example, if you include &lt;code&gt;date&lt;/code&gt; you may exclude &lt;code&gt;date.changed&lt;/code&gt;. @return [Training]

# File lib/reliefweb-api/api/training_api.rb, line 168
def get_training_by_id(training_id, opts = {})
  data, _status_code, _headers = get_training_by_id_with_http_info(training_id, opts)
  data
end
get_training_by_id_with_http_info(training_id, opts = {}) click to toggle source

Find training by its unique ID Individual training opportunities. @param training_id The identifier of the training opportunity. @param [Hash] opts the optional parameters @option opts [String] :profile Pre-built standard selections of fields to return for ease of displaying lists or items. @option opts [Array<String>] :fields_include Specify which fields to include for each item. Defaults to an item label. @option opts [Array<String>] :fields_exclude Specify sub-fields to exclude from overall results. For example, if you include &lt;code&gt;date&lt;/code&gt; you may exclude &lt;code&gt;date.changed&lt;/code&gt;. @return [Array<(Training, Fixnum, Hash)>] Training data, response status code and response headers

# File lib/reliefweb-api/api/training_api.rb, line 181
def get_training_by_id_with_http_info(training_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrainingApi.get_training_by_id ...'
  end
  # verify the required parameter 'training_id' is set
  if @api_client.config.client_side_validation && training_id.nil?
    fail ArgumentError, "Missing the required parameter 'training_id' when calling TrainingApi.get_training_by_id"
  end
  if @api_client.config.client_side_validation && opts[:'profile'] && !['full', 'list', 'minimal'].include?(opts[:'profile'])
    fail ArgumentError, 'invalid value for "profile", must be one of full, list, minimal'
  end
  # resource path
  local_var_path = '/training/{trainingId}'.sub('{' + 'trainingId' + '}', training_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  query_params[:'fields[include][]'] = @api_client.build_collection_param(opts[:'fields_include'], :csv) if !opts[:'fields_include'].nil?
  query_params[:'fields[exclude][]'] = @api_client.build_collection_param(opts[:'fields_exclude'], :csv) if !opts[:'fields_exclude'].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(['text/plain; charset=utf-8', '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 => 'Training')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrainingApi#get_training_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_training_with_http_info(opts = {}) click to toggle source

List or search humanitarian learning opportunities.

@param [Hash] opts the optional parameters @option opts [String] :query_value Specify the terms of your fuzzy search. The default is no query. @option opts [String] :query_operator Specify the operator by which your search query words will be combined. @option opts [Array<String>] :query_fields Specify which fields to target with your search. You may use boost syntax here, see the Advanced API Usage documentation. @option opts [String] :filter_field Field to filter by. Every condition must contain either a &lt;code&gt;field&lt;/code&gt; or &lt;code&gt;conditions&lt;/code&gt; property. @option opts [Array<String>] :filter_value Value for the field being filtered. Leave blank to require existence of the field, must be present for &lt;code&gt;range&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt; conditions. @option opts [String] :filter_operator Operator by which filters will be combined. @option opts [BOOLEAN] :filter_negate Reverse the filter to include those items that do not match. @option opts [Array<String>] :filter_conditions This property is used to combine conditions with a logical connector (the &lt;code&gt;operator&lt;/code&gt; property). Every condition must contain one of the &lt;code&gt;field&lt;/code&gt; or &lt;code&gt;conditions&lt;/code&gt; properties. @option opts [String] :facets_field Field to facet by. May include dates, references or the status field. @option opts [String] :facets_name Identifier for resulting facet data. Useful when faceting multiple ways on the same field. @option opts [Integer] :facets_limit Limit the number of facets returned for non-date based facets. @option opts [String] :facets_sort The sort order of non-date facets. Sorting may be by &lt;code&gt;value&lt;/code&gt; or &lt;code&gt;count&lt;/code&gt; of terms, and ascending or descending. &lt;code&gt;count&lt;/code&gt; defaults to &lt;code&gt;desc&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt; defaults to &lt;code&gt;asc&lt;/code&gt;. @option opts [Array<String>] :facets_filter Apply all the same capabilities of the filter parameter to the specific results of this facet request. @option opts [String] :facets_interval Round date information to the nearest interval unit. Apply all the same capabilities of the filter parameter to the specific results of this facet request. @option opts [Array<String>] :fields_include Specify which fields to include for each item. Defaults to an item label. @option opts [Array<String>] :fields_exclude Specify sub-fields to exclude from overall results. For example, if you include &lt;code&gt;date&lt;/code&gt; you may exclude &lt;code&gt;date.changed&lt;/code&gt;. @option opts [Integer] :limit The maximum number of items to return for a list query. The default is &lt;code&gt;10&lt;/code&gt; and the maximum &lt;code&gt;1000&lt;/code&gt;. @option opts [Integer] :offset The offset from which to return the items in a list query. Allows paging through all results. The default is &lt;code&gt;0&lt;/code&gt;. @option opts [Array<String>] :sort Sort the list results. Defaults to search relevance. Values in the form of &lt;code&gt;fieldname:(asc|desc)&lt;/code&gt;. @option opts [String] :profile Pre-built standard selections of fields to return for ease of displaying lists or items. @option opts [String] :preset Pre-built standard configurations of queries, filters and sorts for common use cases. @return [Array<(Training, Fixnum, Hash)>] Training data, response status code and response headers

# File lib/reliefweb-api/api/training_api.rb, line 77
def get_training_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrainingApi.get_training ...'
  end
  if @api_client.config.client_side_validation && opts[:'query_operator'] && !['AND', 'OR'].include?(opts[:'query_operator'])
    fail ArgumentError, 'invalid value for "query_operator", must be one of AND, OR'
  end
  if @api_client.config.client_side_validation && opts[:'filter_operator'] && !['AND', 'OR'].include?(opts[:'filter_operator'])
    fail ArgumentError, 'invalid value for "filter_operator", must be one of AND, OR'
  end
  if @api_client.config.client_side_validation && opts[:'facets_interval'] && !['year', 'month', 'week', 'day'].include?(opts[:'facets_interval'])
    fail ArgumentError, 'invalid value for "facets_interval", must be one of year, month, week, day'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling TrainingApi.get_training, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling TrainingApi.get_training, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling TrainingApi.get_training, must be greater than or equal to 0.'
  end

  if @api_client.config.client_side_validation && opts[:'profile'] && !['full', 'list', 'minimal'].include?(opts[:'profile'])
    fail ArgumentError, 'invalid value for "profile", must be one of full, list, minimal'
  end
  if @api_client.config.client_side_validation && opts[:'preset'] && !['analysis', 'latest', 'minimal'].include?(opts[:'preset'])
    fail ArgumentError, 'invalid value for "preset", must be one of analysis, latest, minimal'
  end
  # resource path
  local_var_path = '/training'

  # query parameters
  query_params = {}
  query_params[:'query[value]'] = opts[:'query_value'] if !opts[:'query_value'].nil?
  query_params[:'query[operator]'] = opts[:'query_operator'] if !opts[:'query_operator'].nil?
  query_params[:'query[fields][]'] = @api_client.build_collection_param(opts[:'query_fields'], :csv) if !opts[:'query_fields'].nil?
  query_params[:'filter[field]'] = opts[:'filter_field'] if !opts[:'filter_field'].nil?
  query_params[:'filter[value][]'] = @api_client.build_collection_param(opts[:'filter_value'], :csv) if !opts[:'filter_value'].nil?
  query_params[:'filter[operator]'] = opts[:'filter_operator'] if !opts[:'filter_operator'].nil?
  query_params[:'filter[negate]'] = opts[:'filter_negate'] if !opts[:'filter_negate'].nil?
  query_params[:'filter[conditions][]'] = @api_client.build_collection_param(opts[:'filter_conditions'], :csv) if !opts[:'filter_conditions'].nil?
  query_params[:'facets[field]'] = opts[:'facets_field'] if !opts[:'facets_field'].nil?
  query_params[:'facets[name]'] = opts[:'facets_name'] if !opts[:'facets_name'].nil?
  query_params[:'facets[limit]'] = opts[:'facets_limit'] if !opts[:'facets_limit'].nil?
  query_params[:'facets[sort]'] = opts[:'facets_sort'] if !opts[:'facets_sort'].nil?
  query_params[:'facets[filter][]'] = @api_client.build_collection_param(opts[:'facets_filter'], :csv) if !opts[:'facets_filter'].nil?
  query_params[:'facets[interval]'] = opts[:'facets_interval'] if !opts[:'facets_interval'].nil?
  query_params[:'fields[include][]'] = @api_client.build_collection_param(opts[:'fields_include'], :csv) if !opts[:'fields_include'].nil?
  query_params[:'fields[exclude][]'] = @api_client.build_collection_param(opts[:'fields_exclude'], :csv) if !opts[:'fields_exclude'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'sort[]'] = @api_client.build_collection_param(opts[:'sort'], :csv) if !opts[:'sort'].nil?
  query_params[:'profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  query_params[:'preset'] = opts[:'preset'] if !opts[:'preset'].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(['text/plain; charset=utf-8'])

  # 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 => 'Training')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrainingApi#get_training\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
search_training(opts = {}) click to toggle source

List or search humanitarian learning opportunities.

@param [Hash] opts the optional parameters @option opts [PostParams] :fields Returned fields @return [Training]

# File lib/reliefweb-api/api/training_api.rb, line 231
def search_training(opts = {})
  data, _status_code, _headers = search_training_with_http_info(opts)
  data
end
search_training_with_http_info(opts = {}) click to toggle source

List or search humanitarian learning opportunities.

@param [Hash] opts the optional parameters @option opts [PostParams] :fields Returned fields @return [Array<(Training, Fixnum, Hash)>] Training data, response status code and response headers

# File lib/reliefweb-api/api/training_api.rb, line 241
def search_training_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrainingApi.search_training ...'
  end
  # resource path
  local_var_path = '/training'

  # 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(opts[:'fields'])
  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 => 'Training')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrainingApi#search_training\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end