class Pin::Plan

This class models Pins Plans API

Public Class Methods

all(page = nil, pagination = false) click to toggle source

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]

www.pinpayments.com/developers/api-reference/plans

# 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 = {}) click to toggle source

Create a plan given plan details args: options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans

# File lib/pin_up/plan.rb, line 23
def self.create(options = {})
  build_response(make_request(:post, { url: 'plans', options: options }))
end
create_subscription(token, customer_token, card_token = nil) click to toggle source

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

# File lib/pin_up/plan.rb, line 68
def self.create_subscription(token, customer_token, card_token = nil)
  options = 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: options} ))
end
delete(token) click to toggle source

Delete a plan given a token args: token (String) returns: nil www.pinpayments.com/developers/api-reference/plans#delete-plan

# File lib/pin_up/plan.rb, line 50
def self.delete(token)
  build_response(make_request(:delete, { url: "plans/#{token}" } ))
end
find(token) click to toggle source

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

# 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) click to toggle source

List Subscriptions associated with a plan given a token args: token (String) returns: nil

# 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 = {}) click to toggle source

Update a plan given a token args: token (String), options (Hash) returns: a plan object www.pinpayments.com/developers/api-reference/plans#put-plan

# File lib/pin_up/plan.rb, line 41
def self.update(token, options = {})
  build_response(make_request(:put, { url: "plans/#{token}", options: options }))
end