Method: Adapi::BudgetOrder#update

Defined in:
lib/adapi/budget_order.rb

#update(params = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/adapi/budget_order.rb', line 62

def update(params = {})
  return false unless self.valid?      
  
  operand = {
    :id => self.send(:id),
    :billing_account_id => self.send(:billing_account_id),
    :start_date_time => fix_time(self.send(:start_date_time)),
    :end_date_time => fix_time(self.send(:end_date_time))
  }

  if self.send(:spending_limit).is_a?(Hash)
    operand[:spending_limit] = self.send(:spending_limit)
  else
    operand[:spending_limit] = { micro_amount: Api.to_micro_units(self.send(:spending_limit)) }
  end

  response = self.mutate(
    operator: 'SET', 
    operand: operand
  )      

  check_for_errors(self)
end