class Podio::Item

@see developers.podio.com/doc/items

Protected Class Methods

bulk_delete(app_id, attributes) click to toggle source

@see developers.podio.com/doc/items/bulk-delete-items-19406111

# File lib/podio/models/item.rb, line 237
def bulk_delete(app_id, attributes)
  response = Podio.connection.post do |req|
    req.url("/item/app/#{app_id}/delete")
    req.body = attributes
  end

  response.body
end
calculate(app_id, config) click to toggle source

@see developers.podio.com/doc/items/calculate-67633

# File lib/podio/models/item.rb, line 174
def calculate(app_id, config)
  response = Podio.connection.post do |req|
    req.url "/item/app/#{app_id}/calculate"
    req.body = config
  end

  response.body
end
cleanup_field_values(app_id) click to toggle source
# File lib/podio/models/item.rb, line 278
def cleanup_field_values(app_id)
  Podio.connection.post("/item/app/#{app_id}/cleanup_field_values").body
end
clone(item_id, options={}) click to toggle source

@see developers.podio.com/doc/items/clone-item-37722742

# File lib/podio/models/item.rb, line 261
def clone(item_id, options={})
  response = Podio.connection.post do |req|
    req.url("/item/#{item_id}/clone", options)
  end

  response.body['item_id']
end
create(app_id, attributes, options={}) click to toggle source

@see developers.podio.com/doc/items/add-new-item-22362

# File lib/podio/models/item.rb, line 218
def create(app_id, attributes, options={})
  response = Podio.connection.post do |req|
    req.url("/item/app/#{app_id}/", options)
    req.body = attributes
  end

  member response.body
end
delete(id, options={}) click to toggle source

@see developers.podio.com/doc/items/delete-item-22364

# File lib/podio/models/item.rb, line 247
def delete(id, options={})
  response = Podio.connection.delete do |req|
    req.url("/item/#{id}", options)
  end

  response.body
end
delete_ref(id) click to toggle source

@see developers.podio.com/doc/items/delete-item-reference-7302326

# File lib/podio/models/item.rb, line 256
def delete_ref(id)
  Podio.connection.delete("/item/#{id}/ref").body
end
export(app_id, exporter, options={}) click to toggle source

@see developers.podio.com/doc/items/export-items-4235696

# File lib/podio/models/item.rb, line 203
def export(app_id, exporter, options={})
  response = Podio.connection.post { |req|
    req.url "/item/app/#{app_id}/export/#{exporter}"
    req.body = options
  }.body
end
find(id, options = {}) click to toggle source

@see developers.podio.com/doc/items/get-item-22360

# File lib/podio/models/item.rb, line 93
def find(id, options = {})
  member Podio.connection.get { |req|
    req.url("/item/#{id}", options)
  }.body
end
find_all(app_id, options={}) click to toggle source

@see developers.podio.com/doc/items/get-items-27803

# File lib/podio/models/item.rb, line 127
def find_all(app_id, options={})
  collection Podio.connection.get { |req|
    req.url("/item/app/#{app_id}/", options)
  }.body
end
find_all_by_external_id(app_id, external_id) click to toggle source
# File lib/podio/models/item.rb, line 122
def find_all_by_external_id(app_id, external_id)
  collection Podio.connection.get("/item/app/#{app_id}/v2/?external_id=#{external_id}").body
end
find_app_values(app_id) click to toggle source

@see developers.podio.com/doc/items/get-app-values-22455

# File lib/podio/models/item.rb, line 151
def find_app_values(app_id)
  response = Podio.connection.get { |req|
    req.url("/item/app/#{app_id}/values")
  }
  response.body
end
find_basic(id, options={}) click to toggle source

@see developers.podio.com/doc/items/get-item-basic-61768

# File lib/podio/models/item.rb, line 104
def find_basic(id, options={})
  member Podio.connection.get { |req|
    req.url("/item/#{id}/basic", options)
  }.body
end
find_basic_by_field(item_id, field_id) click to toggle source
# File lib/podio/models/item.rb, line 110
def find_basic_by_field(item_id, field_id)
  member Podio.connection.get("/item/#{item_id}/reference/#{field_id}/preview").body
end
find_basic_hash_by_field(item_id, field_id) click to toggle source
# File lib/podio/models/item.rb, line 114
def find_basic_hash_by_field(item_id, field_id)
  Podio.connection.get("/item/#{item_id}/reference/#{field_id}/preview").body
end
find_by_app_item_id(app_id, app_item_id) click to toggle source
# File lib/podio/models/item.rb, line 99
def find_by_app_item_id(app_id, app_item_id)
  member Podio.connection.get("/app/#{app_id}/item/#{app_item_id}").body
end
find_by_external_id(app_id, external_id) click to toggle source
# File lib/podio/models/item.rb, line 118
def find_by_external_id(app_id, external_id)
  member Podio.connection.get("/item/app/#{app_id}/external_id/#{external_id}").body
end
find_by_filter_id(app_id, filter_id, attributes, options={}) click to toggle source

@see developers.podio.com/doc/items/filter-items-by-view-4540284

# File lib/podio/models/item.rb, line 134
def find_by_filter_id(app_id, filter_id, attributes, options={})
  collection Podio.connection.post { |req|
    req.url("/item/app/#{app_id}/filter/#{filter_id}/", options)
    req.body = attributes
  }.body
end
find_by_filter_values(app_id, filter_values, attributes={}, options={}) click to toggle source

@see developers.podio.com/doc/items/filter-items-4496747

# File lib/podio/models/item.rb, line 142
def find_by_filter_values(app_id, filter_values, attributes={}, options={})
  attributes[:filters] = filter_values
  collection Podio.connection.post { |req|
    req.url("/item/app/#{app_id}/filter/", options)
    req.body = attributes
  }.body
end
find_field_top(field_id, options={:limit => 8}) click to toggle source
# File lib/podio/models/item.rb, line 183
def find_field_top(field_id, options={:limit => 8})
  list Podio.connection.get { |req|
    req.url("/item/field/#{field_id}/top/", options)
  }.body
end
find_meeting_url(id) click to toggle source

@see developers.podio.com/doc/items/get-meeting-url-14763260

# File lib/podio/models/item.rb, line 292
def find_meeting_url(id)
  response = Podio.connection.get { |req|
    req.url("/item/#{id}/meeting/url")
  }
  response.body
end
find_next_or_previous(operation, current_item_id, time) click to toggle source
# File lib/podio/models/item.rb, line 305
def find_next_or_previous(operation, current_item_id, time)
  member Podio.connection.get { |req|
    req.url("/item/#{current_item_id}/#{operation}", time_options(time))
  }.body
end
find_references(item_id) click to toggle source

@see developers.podio.com/doc/items/get-item-references-22439

# File lib/podio/models/item.rb, line 159
def find_references(item_id)
  response = Podio.connection.get { |req|
    req.url("/item/#{item_id}/reference/")
  }
  response.body
end
find_references_by_field(item_id, field_id, options = {}) click to toggle source

@see developers.podio.com/doc/items/get-references-to-item-by-field-7403920

# File lib/podio/models/item.rb, line 167
def find_references_by_field(item_id, field_id, options = {})
  list Podio.connection.get { |req|
    req.url("/item/#{item_id}/reference/field/#{field_id}", options)
  }.body
end
item_count(app_id) click to toggle source

@see developers.podio.com/doc/items/get-item-count-34819997

# File lib/podio/models/item.rb, line 190
def item_count(app_id)
  Podio.connection.get("/item/app/#{app_id}/count/").body
end
rearrange(id, attributes, options = {}) click to toggle source
# File lib/podio/models/item.rb, line 282
def rearrange(id, attributes, options = {})
  response = Podio.connection.post do |req|
    req.url("/item/#{id}/rearrange", options)
    req.body = attributes
  end

  member response.body
end
search_field(field_id, options={}) click to toggle source

@see developers.podio.com/doc/items/find-items-by-field-and-title-22485

# File lib/podio/models/item.rb, line 211
def search_field(field_id, options={})
  list Podio.connection.get { |req|
    req.url("/item/field/#{field_id}/find", options)
  }.body
end
set_participation(id, status) click to toggle source

@see developers.podio.com/doc/items/set-participation-7156154

# File lib/podio/models/item.rb, line 270
def set_participation(id, status)
  response = Podio.connection.put do |req|
    req.url "/item/#{id}/participation"
    req.body = { :status => status }
  end
  response.status
end
time_options(time) click to toggle source
# File lib/podio/models/item.rb, line 301
def time_options(time)
  time.present? ? { 'time' => (time.is_a?(String) ? time : time.to_s(:db)) } : {}
end
update(id, attributes, options={}) click to toggle source

@see developers.podio.com/doc/items/update-item-22363

# File lib/podio/models/item.rb, line 228
def update(id, attributes, options={})
  response = Podio.connection.put do |req|
    req.url("/item/#{id}", options)
    req.body = attributes
  end
  response.status
end
xlsx(app_id, options={}) click to toggle source

@see developers.podio.com/doc/items/get-items-as-xlsx-63233

# File lib/podio/models/item.rb, line 195
def xlsx(app_id, options={})
  response = Podio.connection.get { |req|
    req.url("/item/app/#{app_id}/xlsx/", options)
  }
  response.body
end

Public Instance Methods

create() click to toggle source

@see developers.podio.com/doc/items/add-new-item-22362

# File lib/podio/models/item.rb, line 66
def create
  model = self.class.create(self.app_id, prepare_item_values(self))
  self.attributes = model.attributes
  self
end
destroy() click to toggle source

@see developers.podio.com/doc/items/delete-item-22364

# File lib/podio/models/item.rb, line 73
def destroy
  self.class.delete(self.id)
end
update() click to toggle source

@see developers.podio.com/doc/items/update-item-22363

# File lib/podio/models/item.rb, line 78
def update
  self.class.update(self.id, prepare_item_values(self))
end

Protected Instance Methods

prepare_item_values(item) click to toggle source
# File lib/podio/models/item.rb, line 83
def prepare_item_values(item)
  fields = item.fields.collect { |field| field.values.nil? ? nil : { :external_id => field.external_id, :values => field.values } }.compact
  file_ids = item[:file_ids]
  tags = item.tags.collect(&:presence).compact

  {:fields => fields, :file_ids => file_ids, :tags => tags }
end