Class: BillForward::Subscription
Overview
This entity exposes the following child entities via method_missing:
PricingComponentValue[] .pricingComponentValues PricingComponentValueChange[] .pricingComponentValueChanges
Instance Attribute Summary
#_client
Class Method Summary
collapse
Instance Method Summary
collapse
#delete, #initialize, #save
create, #initialize
#[], #[]=, #_dump, _load, build_entity, build_entity_array, #camel_case_lower, get_all, get_by_id, #initialize, #method_missing, request_ambiguous, request_first_heterotyped, request_many_heterotyped, #serialize, #serialize_field, singleton_client, #state_params, #to_json, #to_ordered_hash, #to_s, #to_unordered_hash
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class BillForward::BillingEntity
Class Method Details
.add_charge(id, request_object = {}, custom_client = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/bill_forward/entities/subscription.rb', line 30
def add_charge(id, request_object = {}, custom_client = nil)
raise ArgumentError.new("id cannot be nil") if id.nil?
endpoint = sprintf('%s/charge',
ERB::Util.url_encode(id)
)
request_entity = BillForward::GenericEntity.new(
request_object
)
self.request_many_heterotyped(BillForward::SubscriptionCharge, 'post', endpoint, request_entity, nil, custom_client)
end
|
.get_by_account_id(id, query_params = {}, custom_client = nil) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/bill_forward/entities/subscription.rb', line 10
def get_by_account_id(id, query_params = {}, custom_client = nil)
raise ArgumentError.new("id cannot be nil") if id.nil?
endpoint = sprintf('account/%s',
ERB::Util.url_encode(id)
)
self.request_many('get', endpoint, query_params, custom_client)
end
|
.get_by_version_id(id, query_params = {}, custom_client = nil) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/bill_forward/entities/subscription.rb', line 20
def get_by_version_id(id, query_params = {}, custom_client = nil)
raise ArgumentError.new("id cannot be nil") if id.nil?
endpoint = sprintf('version/%s',
ERB::Util.url_encode(id)
)
self.request_first('get', endpoint, query_params, custom_client)
end
|
Instance Method Details
#activate ⇒ Object
63
64
65
66
67
|
# File 'lib/bill_forward/entities/subscription.rb', line 63
def activate
set_state_param('state', 'AwaitingPayment')
response = save
response
end
|
#add_charge(request_object = {}, custom_client = nil) ⇒ Object
45
46
47
|
# File 'lib/bill_forward/entities/subscription.rb', line 45
def add_charge(request_object = {}, custom_client = nil)
self.class.add_charge(self.id, request_object, custom_client)
end
|
#add_payment_method(id) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/bill_forward/entities/subscription.rb', line 69
def add_payment_method(id)
raise ArgumentError.new("id cannot be nil") if id.nil?
endpoint = sprintf('%s/payment-methods',
ERB::Util.url_encode(self.id)
)
request_entity = BillForward::GenericEntity.new({
'id' => id
})
self.class.request_first('post', endpoint, request_entity, nil, custom_client)
end
|
#get_payment_methods(query_params = {}, custom_client = nil) ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/bill_forward/entities/subscription.rb', line 94
def get_payment_methods(query_params = {}, custom_client = nil)
endpoint = sprintf('%s/payment-methods',
ERB::Util.url_encode(self.id)
)
self.class.request_many_heterotyped(BillForward::PaymentMethod, 'get', endpoint, query_params, custom_client)
end
|
#migrate_plan(names_to_values = Hash.new, new_plan_id = nil, invoicing_type = 'Aggregated', new_plan = nil) ⇒ self
Migrates subscription to new plan, with PricingComponentValue values corresponding to named PricingComponents. This works only for ‘arrears’ or ‘in advance’ pricing components.
Note: pricing component mapping is not yet implemented, so currently the ‘names_to_values’ parameter is ignored.
115
116
117
118
119
120
121
122
|
# File 'lib/bill_forward/entities/subscription.rb', line 115
def migrate_plan(names_to_values = Hash.new, new_plan_id = nil, invoicing_type = 'Aggregated', new_plan = nil)
migrate_plan_simple(new_plan_id, invoicing_type)
end
|
#product ⇒ Object
56
57
58
59
60
61
|
# File 'lib/bill_forward/entities/subscription.rb', line 56
def product
if (super.nil?)
self.product = BillForward::Product::get_by_id self.productID
end
super
end
|
#productRatePlan ⇒ Object
49
50
51
52
53
54
|
# File 'lib/bill_forward/entities/subscription.rb', line 49
def productRatePlan
if (super.nil?)
self.productRatePlan = BillForward::ProductRatePlan::get_by_id self.productRatePlanID
end
super
end
|
#remove_payment_method(id) ⇒ Object
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/bill_forward/entities/subscription.rb', line 83
def remove_payment_method(id)
raise ArgumentError.new("id cannot be nil") if id.nil?
endpoint = sprintf('%s/payment-methods/%s',
ERB::Util.url_encode(self.id),
ERB::Util.url_encode(id)
)
self.class.request_first('delete', endpoint, nil, custom_client)
end
|