Module: KillBillClient::Model::TagHelper
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- AUTO_PAY_OFF_ID =
'00000000-0000-0000-0000-000000000001'
- AUTO_INVOICING_OFF_ID =
'00000000-0000-0000-0000-000000000002'
- OVERDUE_ENFORCEMENT_OFF_ID =
'00000000-0000-0000-0000-000000000003'
- WRITTEN_OFF_ID =
'00000000-0000-0000-0000-000000000004'
- MANUAL_PAY_ID =
'00000000-0000-0000-0000-000000000005'
- TEST_ID =
'00000000-0000-0000-0000-000000000006'
Class Method Summary collapse
Instance Method Summary collapse
- #add_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #add_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #control_tag_off?(control_tag_definition_id, options) ⇒ Boolean
- #remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #remove_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #set_tags(tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
107 108 109 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 107 def self.included(klass) klass.extend ClassMethods end |
Instance Method Details
#add_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 12 def add_tag(tag_name, user = nil, reason = nil, comment = nil, = {}) tag_definition = TagDefinition.find_by_name(tag_name, 'NONE', ) if tag_definition.nil? tag_definition = TagDefinition.new tag_definition.name = tag_name tag_definition.description = 'TagDefinition automatically created by the Kill Bill Ruby client library' tag_definition = TagDefinition.create(user, ) end add_tag_from_definition_id(tag_definition.id, user, reason, comment, ) end |
#add_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
50 51 52 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 50 def add_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, = {}) ([tag_definition_id], user, reason, comment, ) end |
#control_tag_off?(control_tag_definition_id, options) ⇒ Boolean
58 59 60 61 62 63 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 58 def control_tag_off?(control_tag_definition_id, ) res = ('NONE', ) !((res || []).select do |t| t.tag_definition_id == control_tag_definition_id end.first.nil?) end |
#remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 24 def remove_tag(tag_name, user = nil, reason = nil, comment = nil, = {}) tag_definition = TagDefinition.find_by_name(tag_name, 'NONE', ) return nil if tag_definition.nil? remove_tag_from_definition_id(tag_definition.id, user, reason, comment, ) end |
#remove_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
54 55 56 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 54 def remove_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, = {}) ([tag_definition_id], user, reason, comment, ) end |
#set_tags(tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/killbill_client/models/helpers/tag_helper.rb', line 31 def (tag_definition_ids, user = nil, reason = nil, comment = nil, = {}) current_tag_definition_ids = (false, 'NONE', ).map { |tag| tag.tag_definition_id } # Find tags to remove = Set.new current_tag_definition_ids.each do |current_tag_definition_id| << current_tag_definition_id unless tag_definition_ids.include?(current_tag_definition_id) end # Find tags to add = Set.new tag_definition_ids.each do |new_tag_definition_id| << new_tag_definition_id unless current_tag_definition_ids.include?(new_tag_definition_id) end (.to_a, user, reason, comment, ) unless .empty? (.to_a, user, reason, comment, ) unless .empty? end |