Class: KillBillClient::Model::Bundle

Inherits:
BundleAttributes show all
Includes:
CustomFieldHelper, TagHelper
Defined in:
lib/killbill_client/models/bundle.rb

Constant Summary collapse

KILLBILL_API_BUNDLES_PREFIX =
"#{KILLBILL_API_PREFIX}/bundles"

Constants included from TagHelper

TagHelper::AUTO_INVOICING_OFF_ID, TagHelper::AUTO_PAY_OFF_ID, TagHelper::MANUAL_PAY_ID, TagHelper::OVERDUE_ENFORCEMENT_OFF_ID, TagHelper::TEST_ID, TagHelper::WRITTEN_OFF_ID

Constants inherited from Resource

Resource::KILLBILL_API_PAGINATION_PREFIX, Resource::KILLBILL_API_PREFIX

Instance Attribute Summary

Attributes inherited from Resource

#clazz, #etag, #response, #session_id, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CustomFieldHelper

included

Methods included from TagHelper

#add_tag, #add_tag_from_definition_id, #control_tag?, included, #remove_tag, #remove_tag_from_definition_id, #set_tags

Methods inherited from Resource

#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, #initialize, instantiate_record_from_json, post, put, #refresh, require_multi_tenant_options!, #to_hash, #to_json

Constructor Details

This class inherits a constructor from KillBillClient::Model::Resource

Class Method Details

.find_all_by_account_id_and_external_key(account_id, external_key, options = {}) ⇒ Object

Return active and inactive ones



54
55
56
57
58
# File 'lib/killbill_client/models/bundle.rb', line 54

def (, external_key, options = {})
  get "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/bundles?externalKey=#{external_key}",
      {},
      options
end

.find_by_external_key(external_key, included_deleted, options = {}) ⇒ Object

Return the active one



42
43
44
45
46
47
48
49
50
51
# File 'lib/killbill_client/models/bundle.rb', line 42

def find_by_external_key(external_key, included_deleted, options = {})
  params = {}
  params[:externalKey] = external_key
  params[:includedDeleted] = included_deleted if included_deleted

  result  = get "#{KILLBILL_API_BUNDLES_PREFIX}",
      params,
      options
  return included_deleted ? result : result[0]
end

.find_by_id(bundle_id, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/killbill_client/models/bundle.rb', line 35

def find_by_id(bundle_id, options = {})
  get "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
      {},
      options
end

.find_in_batches(offset = 0, limit = 100, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/killbill_client/models/bundle.rb', line 17

def find_in_batches(offset = 0, limit = 100, options = {})
  get "#{KILLBILL_API_BUNDLES_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
      {
          :offset => offset,
          :limit  => limit
      },
      options
end

.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/killbill_client/models/bundle.rb', line 26

def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {})
  get "#{KILLBILL_API_BUNDLES_PREFIX}/search/#{search_key}",
      {
          :offset => offset,
          :limit  => limit
      },
      options
end

Instance Method Details

#pause(requested_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object

Pause the bundle (and all its subscription)



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/killbill_client/models/bundle.rb', line 81

def pause(requested_date = nil, user = nil, reason = nil, comment = nil, options = {})

  params                 = {}
  params[:requestedDate] = requested_date unless requested_date.nil?
  self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{@bundle_id}/pause",
                 {},
                 params,
                 {
                     :user    => user,
                     :reason  => reason,
                     :comment => comment,
                 }.merge(options)
end

#rename_external_key(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
# File 'lib/killbill_client/models/bundle.rb', line 135

def rename_external_key(user = nil, reason = nil, comment = nil, options = {})

  self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{@bundle_id}/renameKey",
                 to_json,
                 {},
                 {
                     :user    => user,
                     :reason  => reason,
                     :comment => comment,
                 }.merge(options)
end

#resume(requested_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object

Resume the bundle (and all its subscription)



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/killbill_client/models/bundle.rb', line 96

def resume(requested_date = nil, user = nil, reason = nil, comment = nil, options = {})

  params                 = {}
  params[:requestedDate] = requested_date unless requested_date.nil?
  self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{@bundle_id}/resume",
                 {},
                 params,
                 {
                     :user    => user,
                     :reason  => reason,
                     :comment => comment,
                 }.merge(options)
end

#set_blocking_state(state_name, service, is_block_change, is_block_entitlement, is_block_billing, requested_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object

Low level api to block/unblock a given subscription/bundle/account



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/killbill_client/models/bundle.rb', line 113

def set_blocking_state(state_name, service, is_block_change, is_block_entitlement, is_block_billing, requested_date = nil, user = nil, reason = nil, comment = nil, options = {})

  params                 = {}
  params[:requestedDate] = requested_date unless requested_date.nil?

  body = KillBillClient::Model::BlockingStateAttributes.new
  body.state_name = state_name
  body.service = service
  body.is_block_change = is_block_change
  body.is_block_entitlement = is_block_entitlement
  body.is_block_billing = is_block_billing

  self.class.post "#{KILLBILL_API_BUNDLES_PREFIX}/#{@bundle_id}/block",
                 body.to_json,
                 params,
                 {
                     :user    => user,
                     :reason  => reason,
                     :comment => comment,
                 }.merge(options)
end

#transfer(requested_date = nil, billing_policy = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object

Transfer the bundle to the new account. The new account_id should be set in this object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/killbill_client/models/bundle.rb', line 63

def transfer(requested_date = nil, billing_policy = nil, user = nil, reason = nil, comment = nil, options = {})
  params                 = {}
  params[:requestedDate] = requested_date unless requested_date.nil?
  params[:billingPolicy] = billing_policy unless billing_policy.nil?

  result                 = self.class.post "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
                                          to_json,
                                          params,
                                          {
                                              :user    => user,
                                              :reason  => reason,
                                              :comment => comment,
                                          }.merge(options)

  result.refresh(options)
end