37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/adapi/budget_order.rb', line 37
def create
return false unless self.valid?
operand = {
: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: 'ADD',
operand: operand
)
check_for_errors(self)
self.id = response[:value].first[:id] rescue nil
end
|