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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# 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 |*args|
audit = args[0] || 'NONE'
options = args[1] || {}
self.class.get "#{url_prefix}/#{send(id_alias)}/customFields",
{
:audit => audit
},
options,
CustomField
end
define_method('add_custom_field') do |*args|
custom_fields = args[0]
user = args[1]
reason = args[2]
= args[3]
options = args[4] || {}
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 |*args|
custom_fields = args[0]
user = args[1]
reason = args[2]
= args[3]
options = args[4] || {}
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
|