Class: RecombeeApiClient::Batch

Inherits:
ApiRequest show all
Defined in:
lib/recombee_api_client/api/batch.rb

Overview

Batch processing allows you to submit arbitrary sequence of requests

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_optional

Constructor Details

#initialize(requests, optional = {}) ⇒ Batch

  • *Required arguments*

    • requests -> Array of API requests.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/recombee_api_client/api/batch.rb', line 17

def initialize(requests, optional = {})
  @requests = requests
  optional = normalize_optional(optional)
  @optional = optional
  @body_parameters = requests_to_batch_hash
  @timeout = requests.map{|r| r.timeout}.reduce(:+)
  @ensure_https = true

  @optional.each do |par, _|
    fail UnknownOptionalParameter.new(par) unless ["distinctRecomms"].include? par
  end
end

Instance Attribute Details

#body_parametersObject (readonly)

Values of body parameters as a Hash



36
37
38
# File 'lib/recombee_api_client/api/batch.rb', line 36

def body_parameters
  @body_parameters
end

#ensure_httpsObject

Returns the value of attribute ensure_https.



12
13
14
# File 'lib/recombee_api_client/api/batch.rb', line 12

def ensure_https
  @ensure_https
end

#requestsObject (readonly)

Returns the value of attribute requests.



10
11
12
# File 'lib/recombee_api_client/api/batch.rb', line 10

def requests
  @requests
end

#timeoutObject

Returns the value of attribute timeout.



11
12
13
# File 'lib/recombee_api_client/api/batch.rb', line 11

def timeout
  @timeout
end

Instance Method Details

#methodObject

HTTP method



31
32
33
# File 'lib/recombee_api_client/api/batch.rb', line 31

def method
  :post
end

#pathObject

Relative path to the endpoint



46
47
48
49
# File 'lib/recombee_api_client/api/batch.rb', line 46

def path
  p = '/{databaseId}/batch/'
  p
end

#query_parametersObject

Values of query path parameters as a Hash. name of parameter => value of the parameter



40
41
42
43
# File 'lib/recombee_api_client/api/batch.rb', line 40

def query_parameters
  params = {}
  params
end