Class: Simplify::Subscription
- Inherits:
-
Hash
- Object
- Hash
- Simplify::Subscription
- Defined in:
- lib/simplify/subscription.rb
Overview
A Subscription object.
Instance Attribute Summary collapse
-
#private_key ⇒ Object
Private key used to access the API.
-
#public_key ⇒ Object
Public key used to access the API.
Class Method Summary collapse
-
.create(parms, public_key = nil, private_key = nil) ⇒ Object
Creates an Subscription object.
-
.find(id, public_key = nil, private_key = nil) ⇒ Object
Retrieve a Subscription object from the API.
-
.list(criteria = nil, public_key = nil, private_key = nil) ⇒ Object
Retrieve Subscription objects.
Instance Method Summary collapse
-
#delete ⇒ Object
Delete this object.
-
#update ⇒ Object
-
coupon
Coupon being assigned to this subscription *currency
Currency code (ISO-4217).
-
Instance Attribute Details
#private_key ⇒ Object
Private key used to access the API.
40 41 42 |
# File 'lib/simplify/subscription.rb', line 40 def private_key @private_key end |
#public_key ⇒ Object
Public key used to access the API.
37 38 39 |
# File 'lib/simplify/subscription.rb', line 37 def public_key @public_key end |
Class Method Details
.create(parms, public_key = nil, private_key = nil) ⇒ Object
Creates an Subscription object
- parms
-
a hash of parameters; valid keys are:
-
amount
Amount of the payment (minor units). Example: 1000 = 10.00 -
coupon
Coupon ID associated with the subscription -
currency
Currency code (ISO-4217). Must match the currency associated with your account. default:USD -
customer
Customer that is enrolling in the subscription. -
frequency
Frequency of payment for the plan. Example: Monthly -
name
Name describing subscription -
plan
The ID of the plan that should be used for the subscription. -
quantity
Quantity of the plan for the subscription.
- public_key
-
Public to use for the API call. If nil, the value of Simplify::public_key will be used.
- private_key
-
Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
Returns a Subscription object.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/simplify/subscription.rb', line 58 def self.create(parms, public_key = nil, private_key = nil) if public_key == nil then public_key = Simplify::public_key end if private_key == nil then private_key = Simplify::private_key end h = Simplify::PaymentsApi.execute("subscription", 'create', parms, public_key, private_key) obj = Subscription.new() obj.public_key = public_key obj.private_key = private_key obj = obj.merge(h) obj end |
.find(id, public_key = nil, private_key = nil) ⇒ Object
Retrieve a Subscription object from the API
- id
-
ID of object to retrieve
- public_key
-
Public to use for the API call. If nil, the value of Simplify::public_key will be used.
- private_key
-
Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
Returns a Subscription object.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/simplify/subscription.rb', line 115 def self.find(id, public_key = nil, private_key = nil) if public_key == nil then public_key = Simplify::public_key end if private_key == nil then private_key = Simplify::private_key end h = Simplify::PaymentsApi.execute("subscription", 'show', {"id" => id}, public_key, private_key) obj = Subscription.new() obj.public_key = public_key obj.private_key = private_key obj = obj.merge(h) obj end |
.list(criteria = nil, public_key = nil, private_key = nil) ⇒ Object
Retrieve Subscription objects.
- criteria
-
a hash of parameters; valid keys are:
-
filter
Filters to apply to the list. -
max
Allows up to a max of 50 list items to return. default:20 -
offset
Used in paging of the list. This is the start offset of the page. default:0 -
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (eitherasc
for ascending ordesc
for descending). Sortable properties are:id plan
.
- public_key
-
Public to use for the API call. If nil, the value of Simplify::public_key will be used.
- private_key
-
Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
Returns an object where the list
property contains the list of Subscription objects and the total
property contains the total number of Subscription objects available for the given criteria.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/simplify/subscription.rb', line 91 def self.list(criteria = nil, public_key = nil, private_key = nil) if public_key == nil then public_key = Simplify::public_key end if private_key == nil then private_key = Simplify::private_key end h = Simplify::PaymentsApi.execute("subscription", 'list', criteria, public_key, private_key) obj = Subscription.new() obj.public_key = public_key obj.private_key = private_key obj = obj.merge(h) obj end |
Instance Method Details
#delete ⇒ Object
Delete this object
75 76 77 78 79 |
# File 'lib/simplify/subscription.rb', line 75 def delete() h = Simplify::PaymentsApi.execute("subscription", 'delete', self, self.public_key, self.private_key) self.merge!(h) self end |
#update ⇒ Object
-
coupon
Coupon being assigned to this subscription -
currency
Currency code (ISO-4217). Must match the currency associated with your account. -
frequency
Frequency of payment for the plan. Example: Monthly -
name
Name describing subscription -
plan
Plan that should be used for the subscription. -
prorate
Whether to prorate existing subscription. (required) -
quantity
Quantity of the plan for the subscription.
142 143 144 145 146 |
# File 'lib/simplify/subscription.rb', line 142 def update() h = Simplify::PaymentsApi.execute("subscription", 'update', self, self.public_key, self.private_key) self.merge!(h) self end |