Class: KillBillClient::Model::Subscription
- Inherits:
-
SubscriptionAttributes
- Object
- Resource
- SubscriptionAttributes
- KillBillClient::Model::Subscription
- Includes:
- AuditLogWithHistoryHelper, CustomFieldHelper, TagHelper
- Defined in:
- lib/killbill_client/models/subscription.rb
Constant Summary collapse
- KILLBILL_API_ENTITLEMENT_PREFIX =
"#{KILLBILL_API_PREFIX}/subscriptions"
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
- .event_audit_logs_with_history(event_id, options = {}) ⇒ Object
- .find_by_external_key(external_key, audit = "NONE", options = {}) ⇒ Object
- .find_by_id(subscription_id, audit = "NONE", options = {}) ⇒ Object
-
.find_raw_by_id(subscription_id, audit = "NONE", options = {}) ⇒ Object
Returns the raw JSON response body from Kill Bill for the given subscription, without any model parsing or re-serialization.
Instance Method Summary collapse
-
#cancel(user = nil, reason = nil, comment = nil, requested_date = nil, entitlementPolicy = nil, billing_policy = nil, use_requested_date_for_billing = nil, options = {}) ⇒ Object
Cancel the entitlement at the requested date.
-
#change_plan(input, user = nil, reason = nil, comment = nil, requested_date = nil, billing_policy = nil, target_phase_type = nil, call_completion = false, options = {}) ⇒ Object
Change the plan of the existing Entitlement.
-
#create(user = nil, reason = nil, comment = nil, requested_date = nil, call_completion = false, options = {}) ⇒ Object
Create a new entitlement.
-
#create_entitlement_with_add_on(entitlements, entitlement_date, billing_date, migrated = false, rename_key_if_exists_and_unused = true, call_completion_sec = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Create an entitlement with addOn products.
-
#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
Block a Subscription.
-
#uncancel(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Uncancel a future cancelled entitlement.
-
#undo_change_plan(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Undo a pending change plan on an entitlement.
-
#update_bcd(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription BCD.
-
#update_quantity(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_new_quantity_with_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription Quantity.
Methods included from AuditLogWithHistoryHelper
Methods included from CustomFieldHelper
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, raw_get, #refresh, require_multi_tenant_options!, #to_hash, #to_json
Constructor Details
This class inherits a constructor from KillBillClient::Model::Resource
Class Method Details
.event_audit_logs_with_history(event_id, options = {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/killbill_client/models/subscription.rb', line 49 def event_audit_logs_with_history(event_id, = {}) get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/events/#{event_id}/auditLogsWithHistory", {}, , AuditLog end |
.find_by_external_key(external_key, audit = "NONE", options = {}) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/killbill_client/models/subscription.rb', line 39 def find_by_external_key(external_key, audit = "NONE", = {}) get "#{KILLBILL_API_ENTITLEMENT_PREFIX}", { :externalKey => external_key, :audit => audit }, end |
.find_by_id(subscription_id, audit = "NONE", options = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/killbill_client/models/subscription.rb', line 21 def find_by_id(subscription_id, audit = "NONE", = {}) get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}", { :audit => audit }, end |
.find_raw_by_id(subscription_id, audit = "NONE", options = {}) ⇒ Object
Returns the raw JSON response body from Kill Bill for the given subscription, without any model parsing or re-serialization.
31 32 33 34 35 36 37 |
# File 'lib/killbill_client/models/subscription.rb', line 31 def find_raw_by_id(subscription_id, audit = "NONE", = {}) raw_get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}", { :audit => audit }, end |
Instance Method Details
#cancel(user = nil, reason = nil, comment = nil, requested_date = nil, entitlementPolicy = nil, billing_policy = nil, use_requested_date_for_billing = nil, options = {}) ⇒ Object
Cancel the entitlement at the requested date
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/killbill_client/models/subscription.rb', line 119 def cancel(user = nil, reason = nil, comment = nil, requested_date = nil, entitlementPolicy = nil, billing_policy = nil, use_requested_date_for_billing = nil, = {}) params = {} params[:requestedDate] = requested_date unless requested_date.nil? params[:billingPolicy] = billing_policy unless billing_policy.nil? params[:entitlementPolicy] = entitlementPolicy unless entitlementPolicy.nil? params[:useRequestedDateForBilling] = use_requested_date_for_billing unless use_requested_date_for_billing.nil? self.class.delete "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}", {}, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#change_plan(input, user = nil, reason = nil, comment = nil, requested_date = nil, billing_policy = nil, target_phase_type = nil, call_completion = false, options = {}) ⇒ Object
Change the plan of the existing Entitlement
@ call_completion : whether the call should wait for invoice/payment to be completed before calls return
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/killbill_client/models/subscription.rb', line 89 def change_plan(input, user = nil, reason = nil, comment = nil, requested_date = nil, billing_policy = nil, target_phase_type = nil, call_completion = false, = {}) params = {} params[:callCompletion] = call_completion params[:requestedDate] = requested_date unless requested_date.nil? params[:billingPolicy] = billing_policy unless billing_policy.nil? # Make sure account_id is set input[:accountId] = @account_id input[:productCategory] = @product_category input[:phaseType] = target_phase_type self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{@subscription_id}", input.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() self.class.find_by_id(@subscription_id, "NONE", ) end |
#create(user = nil, reason = nil, comment = nil, requested_date = nil, call_completion = false, options = {}) ⇒ Object
Create a new entitlement
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/killbill_client/models/subscription.rb', line 62 def create(user = nil, reason = nil, comment = nil, requested_date = nil, call_completion = false, = {}) params = {} params[:callCompletion] = call_completion params[:entitlementDate] = requested_date unless requested_date.nil? params[:billingDate] = requested_date unless requested_date.nil? created_entitlement = self.class.post KILLBILL_API_ENTITLEMENT_PREFIX, to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() created_entitlement.refresh() end |
#create_entitlement_with_add_on(entitlements, entitlement_date, billing_date, migrated = false, rename_key_if_exists_and_unused = true, call_completion_sec = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Create an entitlement with addOn products
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/killbill_client/models/subscription.rb', line 200 def create_entitlement_with_add_on(entitlements, entitlement_date, billing_date, migrated = false, rename_key_if_exists_and_unused = true, call_completion_sec = nil, user = nil, reason = nil, comment = nil, = {}) params = {} params[:entitlementDate] = entitlement_date if entitlement_date params[:billingDate] = billing_date if billing_date params[:migrated] = migrated params[:renameKeyIfExistsAndUnused] = rename_key_if_exists_and_unused params[:callCompletion] = true unless call_completion_sec.nil? params[:callTimeoutSec] = call_completion_sec unless call_completion_sec.nil? self.class.post "#{KILLBILL_API_ENTITLEMENT_PREFIX}/createSubscriptionWithAddOns", entitlements.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() 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
Block a Subscription
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/killbill_client/models/subscription.rb', line 174 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, = {}) 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 body.type = "SUBSCRIPTION" params = {} params[:requestedDate] = requested_date unless requested_date.nil? self.class.post "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}/block", body.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#uncancel(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Uncancel a future cancelled entitlement
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/killbill_client/models/subscription.rb', line 139 def uncancel(user = nil, reason = nil, comment = nil, = {}) params = {} self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}/uncancel", nil, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#undo_change_plan(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Undo a pending change plan on an entitlement
222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/killbill_client/models/subscription.rb', line 222 def undo_change_plan(user = nil, reason = nil, comment = nil, = {}) self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}/undoChangePlan", {}, {}, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#update_bcd(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription BCD
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/killbill_client/models/subscription.rb', line 154 def update_bcd(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_past_effective_date = nil, = {}) params = {} params[:effectiveFromDate] = effective_from_date unless effective_from_date.nil? params[:forceNewBcdWithPastEffectiveDate] = force_past_effective_date unless force_past_effective_date.nil? return self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}/bcd", self.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#update_quantity(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_new_quantity_with_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription Quantity
237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/killbill_client/models/subscription.rb', line 237 def update_quantity(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_new_quantity_with_past_effective_date = nil, = {}) params = {} params[:effectiveFromDate] = effective_from_date unless effective_from_date.nil? params[:forceNewQuantityWithPastEffectiveDate] = force_new_quantity_with_past_effective_date unless force_new_quantity_with_past_effective_date.nil? return self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}/quantity", self.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |