Class: Podio::Widget

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/widget.rb

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes, #error_code, #error_message, #error_parameters, #error_propagate

Class Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, handle_api_errors_for, has_many, has_one, #hash, #initialize, #initialize_attributes, list, member, #new_record?, output_attribute_as_json, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.create(ref_type, ref_id, attributes) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/podio/models/widget.rb', line 13

def create(ref_type, ref_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/widget/#{ref_type}/#{ref_id}/"
    req.body = attributes
  end

  response.body['widget_id']
end

.delete(id) ⇒ Object



31
32
33
# File 'lib/podio/models/widget.rb', line 31

def delete(id)
  Podio.connection.delete("/widget/#{id}").status
end

.find(id) ⇒ Object



44
45
46
# File 'lib/podio/models/widget.rb', line 44

def find(id)
  member Podio.connection.get("/widget/#{id}").body
end

.find_all_for_reference(ref_type, ref_id) ⇒ Object



48
49
50
# File 'lib/podio/models/widget.rb', line 48

def find_all_for_reference(ref_type, ref_id)
  list Podio.connection.get("/widget/#{ref_type}/#{ref_id}/display/").body
end

.update(id, attributes) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/podio/models/widget.rb', line 22

def update(id, attributes)
  response = Podio.connection.put do |req|
    req.url "/widget/#{id}"
    req.body = attributes
  end

  response.status
end

.update_order(ref_type, ref_id, widget_list) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/podio/models/widget.rb', line 35

def update_order(ref_type, ref_id, widget_list)
  response = Podio.connection.put do |req|
    req.url "/widget/#{ref_type}/#{ref_id}/order"
    req.body = widget_list
  end

  response.status
end