class Podio::Contract

Public Class Methods

block(contract_id) click to toggle source
# File lib/podio/models/contract.rb, line 196
def block(contract_id)
  response = Podio.connection.post("/contract/#{contract_id}/block")
  response.status
end
calculate_price(contract_id, attributes) click to toggle source
# File lib/podio/models/contract.rb, line 164
def calculate_price(contract_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/contract/#{contract_id}/price"
    req.body = attributes
  end

  response.body
end
change_to_fixed(contract_id, attributes) click to toggle source
# File lib/podio/models/contract.rb, line 182
def change_to_fixed(contract_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/contract/#{contract_id}/change_to/fixed"
    req.body = attributes
  end

  response.status
end
change_to_variable(contract_id) click to toggle source
# File lib/podio/models/contract.rb, line 191
def change_to_variable(contract_id)
  response = Podio.connection.post("/contract/#{contract_id}/change_to/variable")
  response.status
end
create(attributes) click to toggle source
# File lib/podio/models/contract.rb, line 130
def create(attributes)
  response = Podio.connection.post do |req|
    req.url "/contract/"
    req.body = attributes
  end

  member response.body
end
create_payment(contract_id, query_string) click to toggle source
# File lib/podio/models/contract.rb, line 173
def create_payment(contract_id, query_string)
  response = Podio.connection.post do |req|
    req.url "/contract/#{contract_id}/payment"
    req.body = {:query_string => query_string}
  end

  response.body
end
delete(id) click to toggle source
# File lib/podio/models/contract.rb, line 160
def delete(id)
  Podio.connection.delete("/contract/#{id}").body
end
end(contract_id, attributes) click to toggle source
# File lib/podio/models/contract.rb, line 151
def end(contract_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/contract/#{contract_id}/end"
    req.body = attributes
  end

  response.body
end
find(contract_id, options={}) click to toggle source
# File lib/podio/models/contract.rb, line 106
def find(contract_id, options={})
  member Podio.connection.get("/contract/#{contract_id}", options).body
end
find_all_mine() click to toggle source
# File lib/podio/models/contract.rb, line 110
def find_all_mine
  list Podio.connection.get("/contract/").body
end
find_all_my_offers() click to toggle source
# File lib/podio/models/contract.rb, line 114
def find_all_my_offers
  list Podio.connection.get("/contract/offered/").body
end
find_all_unpaid() click to toggle source
# File lib/podio/models/contract.rb, line 126
def find_all_unpaid
  list Podio.connection.get("/contract/unpaid/").body
end
find_for_org(org_id) click to toggle source
# File lib/podio/models/contract.rb, line 118
def find_for_org(org_id)
  list Podio.connection.get("/contract/org/#{org_id}/").body
end
find_users_for_org(org_id) click to toggle source
# File lib/podio/models/contract.rb, line 122
def find_users_for_org(org_id)
  member Podio.connection.get("/contract/org/#{org_id}/user").body
end
get_list_prices() click to toggle source
# File lib/podio/models/contract.rb, line 210
def get_list_prices
  Podio.connection.get('/contract/price/').body
end
get_tier_prices(contract_id) click to toggle source
# File lib/podio/models/contract.rb, line 206
def get_tier_prices(contract_id)
  Podio.connection.get("/contract/#{contract_id}/price/tier").body
end
start(contract_id) click to toggle source
# File lib/podio/models/contract.rb, line 147
def start(contract_id)
  Podio.connection.post("/contract/#{contract_id}/start").body
end
unblock(contract_id) click to toggle source
# File lib/podio/models/contract.rb, line 201
def unblock(contract_id)
  response = Podio.connection.post("/contract/#{contract_id}/unblock")
  response.status
end
update(contract_id, attributes) click to toggle source
# File lib/podio/models/contract.rb, line 139
def update(contract_id, attributes)
  response = Podio.connection.put do |req|
    req.url "/contract/#{contract_id}"
    req.body = attributes
  end
  response.status
end

Public Instance Methods

block() click to toggle source
# File lib/podio/models/contract.rb, line 93
def block
  self.class.block(self.contract_id)
end
calculate_price() click to toggle source
# File lib/podio/models/contract.rb, line 61
def calculate_price
  pricing = self.class.calculate_price(self.contract_id, self.attributes.slice(:full, :premium_emp_network, :premium_space_ids))
  self.clear_price
  self["price"] = pricing
end
change_to_fixed() click to toggle source
# File lib/podio/models/contract.rb, line 79
def change_to_fixed
  self.class.change_to_fixed(self.contract_id,
    :item_limits => {
      :employee => self.item_limits['employee'],
      :external => self.item_limits['external']
    },
    :invoice_interval => self.invoice_interval
  )
end
change_to_variable() click to toggle source
# File lib/podio/models/contract.rb, line 89
def change_to_variable
  self.class.change_to_variable(self.contract_id)
end
create_payment(query_string) click to toggle source
# File lib/podio/models/contract.rb, line 67
def create_payment(query_string)
  self.class.create_payment(self.contract_id, query_string)
end
delete() click to toggle source
# File lib/podio/models/contract.rb, line 71
def delete
  self.class.delete(self.id)
end
end(attributes) click to toggle source
# File lib/podio/models/contract.rb, line 75
def end(attributes)
  self.class.end(self.id, attributes)
end
premium_space_ids=(values) click to toggle source
# File lib/podio/models/contract.rb, line 53
def premium_space_ids=(values)
  self[:premium_space_ids] = (values || []).map(&:to_i)
end
price=(attributes) click to toggle source
# File lib/podio/models/contract.rb, line 49
def price=(attributes)
  self[:price] = attributes
end
tier_prices() click to toggle source
# File lib/podio/models/contract.rb, line 101
def tier_prices
  self.class.get_tier_prices(self.contract_id)
end
unblock() click to toggle source
# File lib/podio/models/contract.rb, line 97
def unblock
  self.class.unblock(self.contract_id)
end
update() click to toggle source
# File lib/podio/models/contract.rb, line 57
def update
  self.class.update(self.contract_id, self.attributes.except(:premium_spaces))
end