Class: Pin::Subscription
Overview
This class models Pins Subscription API
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.all(page = nil, pagination = false) ⇒ Object
Lists all subscriptions for your account args: page (Fixnum), pagination (Boolean) returns: a collection of subscription objects.
-
.create(options = {}) ⇒ Object
Create a subscription given subscription details args: options (Hash) returns: a subscription object www.pinpayments.com/developers/api-reference/subscriptions#post-subscriptions.
-
.delete(token) ⇒ Object
Delete (cancel) a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#delete-subscription.
-
.find(token) ⇒ Object
Find a subscription for your account given a token args: token (String) returns: a subscription object www.pinpayments.com/developers/api-reference/subscriptions#get-subscription.
-
.history(token, page = nil, pagination = false) ⇒ Object
Fetch all History for a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#history-subscription.
-
.reactivate(token) ⇒ Object
Reactivate a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#reactivate-subscription.
-
.update(token, card_token = nil) ⇒ Object
Update a subscription for your account given a token and any of: email, card (hash),card_token args: token (String), options (Hash) returns: a subscription object pinpayments.com/developers/api-reference/subscriptions#put-subscription NB: When providing a card (hash), you need to specify the full list of details.
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 subscriptions for your account args: page (Fixnum), pagination (Boolean) returns: a collection of subscription objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
www.pinpayments.com/developers/api-reference/subscriptions#get-subscriptions
14 15 16 |
# File 'lib/pin_up/subscription.rb', line 14 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, { url: "subscriptions?page=#{page}" }), pagination) end |
.create(options = {}) ⇒ Object
Create a subscription given subscription details args: options (Hash) returns: a subscription object www.pinpayments.com/developers/api-reference/subscriptions#post-subscriptions
23 24 25 |
# File 'lib/pin_up/subscription.rb', line 23 def self.create( = {}) build_response(make_request(:post, { url: 'subscriptions', options: })) end |
.delete(token) ⇒ Object
Delete (cancel) a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#delete-subscription
58 59 60 |
# File 'lib/pin_up/subscription.rb', line 58 def self.delete(token) build_response(make_request(:delete, { url: "subscriptions/#{token}" })) end |
.find(token) ⇒ Object
Find a subscription for your account given a token args: token (String) returns: a subscription object www.pinpayments.com/developers/api-reference/subscriptions#get-subscription
32 33 34 |
# File 'lib/pin_up/subscription.rb', line 32 def self.find(token) build_response(make_request(:get, { url: "subscriptions/#{token}" })) end |
.history(token, page = nil, pagination = false) ⇒ Object
Fetch all History for a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#history-subscription
76 77 78 |
# File 'lib/pin_up/subscription.rb', line 76 def self.history(token, page = nil, pagination = false) build_collection_response(make_request(:get, { url: "subscriptions/#{token}/history?page=#{page}" }), pagination) end |
.reactivate(token) ⇒ Object
Reactivate a subscription given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/subscriptions#reactivate-subscription
67 68 69 |
# File 'lib/pin_up/subscription.rb', line 67 def self.reactivate(token) build_response(make_request(:put, { url: "subscriptions/#{token}/reactivate" })) end |
.update(token, card_token = nil) ⇒ Object
Update a subscription for your account given a token and any of: email, card (hash),card_token args: token (String), options (Hash) returns: a subscription object pinpayments.com/developers/api-reference/subscriptions#put-subscription NB: When providing a card (hash), you need to specify the full list of details.
44 45 46 47 48 49 50 51 |
# File 'lib/pin_up/subscription.rb', line 44 def self.update(token, card_token = nil) = unless card_token.empty? { card_token: card_token } else card_token end build_response(make_request(:put, { url: "subscriptions/#{token}", options: })) end |