Class: KillBillClient::Model::Subscription
- Inherits:
-
SubscriptionAttributes
- Object
- Resource
- SubscriptionAttributes
- KillBillClient::Model::Subscription
- Includes:
- 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
Class Method Summary collapse
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, 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.
-
#uncancel(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Uncancel a future cancelled entitlement.
-
#update_bcd(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription BCD.
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
Class Method Details
.find_by_id(subscription_id, options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/killbill_client/models/subscription.rb', line 17 def find_by_id(subscription_id, = {}) get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}", {}, 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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/killbill_client/models/subscription.rb', line 83 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, 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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/killbill_client/models/subscription.rb', line 55 def change_plan(input, user = nil, reason = nil, comment = nil, requested_date = nil, billing_policy = 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 return self.class.put "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{@subscription_id}", input.to_json, params, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#create(user = nil, reason = nil, comment = nil, requested_date = nil, call_completion = false, options = {}) ⇒ Object
Create a new entitlement
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/killbill_client/models/subscription.rb', line 28 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 |
#uncancel(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Uncancel a future cancelled entitlement
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/killbill_client/models/subscription.rb', line 103 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 |
#update_bcd(user = nil, reason = nil, comment = nil, effective_from_date = nil, force_past_effective_date = nil, options = {}) ⇒ Object
Update Subscription BCD
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/killbill_client/models/subscription.rb', line 118 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 |