Class: KillBillClient::Model::Bundle

Inherits:
BundleAttributes show all
Defined in:
lib/killbill_client/models/bundle.rb

Constant Summary collapse

KILLBILL_API_BUNDLES_PREFIX =
"#{KILLBILL_API_PREFIX}/bundles"

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 inherited from Resource

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

Class Method Details

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

Return active and inactive ones



25
26
27
28
29
# File 'lib/killbill_client/models/bundle.rb', line 25

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

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

Return the active one



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

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



11
12
13
14
15
# File 'lib/killbill_client/models/bundle.rb', line 11

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

Instance Method Details

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

Pause the bundle (and all its subscription)



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/killbill_client/models/bundle.rb', line 54

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)



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/killbill_client/models/bundle.rb', line 70

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(bundle_id, 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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/killbill_client/models/bundle.rb', line 35

def transfer(bundle_id, 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