Module: KillBillClient::Model::TagHelper::ClassMethods

Defined in:
lib/killbill_client/models/helpers/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#has_tags(url_prefix, id_alias) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 66

def has_tags(url_prefix, id_alias)
  define_method('tags') do |included_deleted = false, audit = 'NONE', options = {}|
    self.class.get "#{url_prefix}/#{send(id_alias)}/tags",
                   {
                       :includedDeleted => included_deleted,
                       :audit           => audit
                   },
                   options,
                   Tag
  end

  define_method('add_tags_from_definition_ids') do |tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}|
    created_tag = self.class.post "#{url_prefix}/#{send(id_alias)}/tags",
                                  {},
                                  {
                                      :tagList => tag_definition_ids.join(',')
                                  },
                                  {
                                      :user    => user,
                                      :reason  => reason,
                                      :comment => comment,
                                  }.merge(options),
                                  Tag
    created_tag.refresh(options)
  end

  define_method('remove_tags_from_definition_ids') do |tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}|
    self.class.delete "#{url_prefix}/#{send(id_alias)}/tags",
                      {},
                      {
                          :tagList => tag_definition_ids.join(',')
                      },
                      {
                          :user    => user,
                          :reason  => reason,
                          :comment => comment,
                      }.merge(options)
  end
end