Module: Calculated::ObjectTemplateApiCalls

Included in:
Session
Defined in:
lib/calculated/object_template_api_calls.rb

Instance Method Summary collapse

Instance Method Details

#generic_objects_for_object_template(name, params = {}) ⇒ Calculated::Models::ObjectTemplate

this request will have loaded generic objects for the ready basically

Parameters:

  • name (String)
  • params (Hash) (defaults to: {})

Returns:



27
28
29
30
31
# File 'lib/calculated/object_template_api_calls.rb', line 27

def generic_objects_for_object_template(name, params = {})
  api_call(:get, "/object_templates/#{name}/generic_objects", params) do |response|
     Calculated::Models::ObjectTemplate.new(response["object_template"])
  end
end

#generic_objects_for_object_template_with_filter(name, filter, params = {}) ⇒ Calculated::Models::GeneriObject

This will filter the results of the generic objects from a simple text search note this is not an expancive text search so limit to 1 word searches for best results

this request will have loaded relatable categories for the object template

Examples:

generic_objects_for_object_template_with_filter('airport', 'london')

There is also the usuage of relatable_category_values with the params
this will allow further filtering on the search its an AND Filter not an OR filter
searching for ford diesel cars for example

generic_objects_for_object_template_with_filter('car', 'diesel', :relatable_category_values => ["ford"])

Parameters:

  • name (String)
  • filter (String)
  • params (Hash) (defaults to: {})

Returns:

  • (Calculated::Models::GeneriObject)


64
65
66
67
68
# File 'lib/calculated/object_template_api_calls.rb', line 64

def generic_objects_for_object_template_with_filter(name, filter, params = {})
  api_call(:get, "/object_templates/#{name}/generic_objects/filter", params.merge!(:filter => filter)) do |response|
     Calculated::Models::ObjectTemplate.new(response["object_template"])
  end
end

#object_template(id, params = {}) ⇒ Calculated::Models::ObjectTemplate

Parameters:

  • id (String)
  • params (Hash) (defaults to: {})

Returns:



8
9
10
11
12
# File 'lib/calculated/object_template_api_calls.rb', line 8

def object_template(id, params = {})
  api_call(:get, "/object_templates/#{id}", params) do |response|
     Calculated::Models::ObjectTemplate.new(response["object_template"])
  end
end

#object_templates(params = {}) ⇒ Array<Calculated::Models::ObjectTemplate>

Parameters:

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

Returns:



16
17
18
19
20
# File 'lib/calculated/object_template_api_calls.rb', line 16

def object_templates(params = {})
  api_call(:get, "/object_templates", params) do |response|
    response["object_templates"].map{|object_template| Calculated::Models::ObjectTemplate.new(object_template)}
  end
end

#relatable_categories_for_object_template(name, related_attribute, params = {}) ⇒ Calculated::Models::ObjectTemplate

this request will have loaded relatable categories for the object template

Parameters:

  • related_attribute (String)
  • name (String)
  • params (Hash) (defaults to: {})

Returns:



38
39
40
41
42
# File 'lib/calculated/object_template_api_calls.rb', line 38

def relatable_categories_for_object_template(name, related_attribute, params = {})
  api_call(:get, "/object_templates/#{name}/relatable_categories", params.merge!(:related_attribute => related_attribute)) do |response|
     Calculated::Models::ObjectTemplate.new(response["object_template"])
  end
end