6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/killbill_client/models/helpers/custom_field_helper.rb', line 6
def has_custom_fields(url_prefix, id_alias)
define_method('custom_fields') do |audit = 'NONE', options = {}|
self.class.get "#{url_prefix}/#{send(id_alias)}/customFields",
{
:audit => audit
},
options,
CustomField
end
define_method('add_custom_field') do |custom_fields, user = nil, reason = nil, = nil, options = {}|
body = custom_fields.is_a?(Enumerable) ? custom_fields : [custom_fields]
custom_field = self.class.post "#{url_prefix}/#{send(id_alias)}/customFields",
body.to_json,
{},
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options),
CustomField
custom_field.refresh(options)
end
define_method('remove_custom_field') do |custom_fields, user = nil, reason = nil, = nil, options = {}|
custom_fields_param = custom_fields.is_a?(Enumerable) ? custom_fields.join(",") : custom_fields
self.class.delete "#{url_prefix}/#{send(id_alias)}/customFields",
{},
{
:customFieldList => custom_fields_param
},
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options)
end
end
|