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_off?, 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



49
50
51
52
53
# File 'lib/killbill_client/models/bundle.rb', line 49

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

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

Return the active one



42
43
44
45
46
# File 'lib/killbill_client/models/bundle.rb', line 42

def find_by_external_key(external_key, options = {})
  get "#{KILLBILL_API_BUNDLES_PREFIX}?externalKey=#{external_key}",
      {},
      options
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)



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/killbill_client/models/bundle.rb', line 75

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

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

Resume the bundle (and all its subscription)



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/killbill_client/models/bundle.rb', line 90

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

#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



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/killbill_client/models/bundle.rb', line 58

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.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
                                          to_json,
                                          params,
                                          {
                                              :user    => user,
                                              :reason  => reason,
                                              :comment => comment,
                                          }.merge(options)

  result.refresh(options)
end