Module: Calculated::RelatableCategoryApiCalls

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

Instance Method Summary collapse

Instance Method Details

#relatable_categories(params = {}) ⇒ Array<Calculated::Models::RelatableCategory>



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

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

#relatable_category(id, params = {}) ⇒ Calculated::Models::RelatableCategory



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

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

this call just beings back a native array with hash of ids and identifiers

Examples:


"4bf42d8a46a95925b5001999" => "timber"


49
50
51
52
53
# File 'lib/calculated/relatable_category_api_calls.rb', line 49

def related_categories_from_relatable_category(id, related_attribute, params = {})
  api_call(:get, "/relatable_categories/#{id}/related_categories", params.merge!(:related_attribute => related_attribute)) do |response|
    response["related_categories"]
  end
end

this call just beings back a native array with hash of ids and identifiers

Examples:


"4bf42d8b46a95925b5001a0c" => "Particle Board"


31
32
33
34
35
36
# File 'lib/calculated/relatable_category_api_calls.rb', line 31

def related_objects_from_relatable_categories(template_name, relatable_category_ids, params = {})
  relatable_category_ids = relatable_category_ids.is_a?(String) ? [relatable_category_ids] : relatable_category_ids
  api_call(:get, "/relatable_categories/related_objects", params.merge!(:template_name => template_name, :relatable_category_ids => relatable_category_ids)) do |response|
    response["related_objects"]
  end
end