Class: Pin::Plan
Overview
This class models Pins Plans API
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.all(page = nil, pagination = false) ⇒ Object
Lists all plans for your account args: page (Fixnum), pagination (Boolean) returns: a collection of customer objects.
-
.create(options = {}) ⇒ Object
Create a plan given plan details args: options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans.
-
.create_subscription(token, customer_token, card_token = nil) ⇒ Object
Create a subscription for a plan given a customer_token OR a card_token args: customer_token (String), card (String) see docs.
-
.delete(token) ⇒ Object
Delete a plan given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/plans#delete-plan.
-
.find(token) ⇒ Object
Find a plan for your account given a token args: token (String) returns: a plan object www.pinpayments.com/developers/api-reference/plans#get-plan.
-
.subscriptions(token, page = nil, pagination = false) ⇒ Object
List Subscriptions associated with a plan given a token args: token (String) returns: nil.
-
.update(token, options = {}) ⇒ Object
Update a plan given a token args: token (String), options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans#put-plan.
Methods inherited from Base
#base_uri, build_collection_response, build_response, #initialize, make_request
Constructor Details
This class inherits a constructor from Pin::Base
Class Method Details
.all(page = nil, pagination = false) ⇒ Object
Lists all plans for your account args: page (Fixnum), pagination (Boolean) returns: a collection of customer objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
14 15 16 |
# File 'lib/pin_up/plan.rb', line 14 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, {url: "plans?page=#{page}" } ), pagination) end |
.create(options = {}) ⇒ Object
Create a plan given plan details args: options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans
23 24 25 |
# File 'lib/pin_up/plan.rb', line 23 def self.create( = {}) build_response(make_request(:post, { url: 'plans', options: })) end |
.create_subscription(token, customer_token, card_token = nil) ⇒ Object
Create a subscription for a plan given a customer_token OR a card_token args: customer_token (String), card (String) see docs. returns: a subscription object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pin_up/plan.rb', line 68 def self.create_subscription(token, customer_token, card_token = nil) = if card_token { customer_token: customer_token, card_token: card_token} else { customer_token: customer_token } end build_response(make_request(:post, {url: "plans/#{token}/subscriptions", options: } )) end |
.delete(token) ⇒ Object
Delete a plan given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/plans#delete-plan
50 51 52 |
# File 'lib/pin_up/plan.rb', line 50 def self.delete(token) build_response(make_request(:delete, { url: "plans/#{token}" } )) end |
.find(token) ⇒ Object
Find a plan for your account given a token args: token (String) returns: a plan object www.pinpayments.com/developers/api-reference/plans#get-plan
32 33 34 |
# File 'lib/pin_up/plan.rb', line 32 def self.find(token) build_response(make_request(:get, {url: "plans/#{token}" } )) end |
.subscriptions(token, page = nil, pagination = false) ⇒ Object
List Subscriptions associated with a plan given a token args: token (String) returns: nil
59 60 61 |
# File 'lib/pin_up/plan.rb', line 59 def self.subscriptions(token, page = nil, pagination = false) build_collection_response(make_request(:get, { url: "plans/#{token}/subscriptions" } ), pagination) end |
.update(token, options = {}) ⇒ Object
Update a plan given a token args: token (String), options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans#put-plan
41 42 43 |
# File 'lib/pin_up/plan.rb', line 41 def self.update(token, = {}) build_response(make_request(:put, { url: "plans/#{token}", options: })) end |