Class: PayPal::SDK::Subscriptions::Plan

Inherits:
RequestBase show all
Defined in:
lib/paypal-sdk/subscriptions/plan.rb

Overview

v1/billing/plans

Defined Under Namespace

Classes: BillingCycle, Page, PaymentPreferences, Taxes

Instance Attribute Summary

Attributes inherited from RequestAPIBase

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RequestBase

#commit, #create, create!, find, #path

Methods inherited from RequestAPIBase

#http_header, #merge!, #raise_error!, raise_on_api_error, #success?

Methods included from RequestDataType

#api, api, #error=, included

Class Method Details

.all(options = {}) ⇒ Object

options include ‘page’, ‘page_size’, and ‘total_required’



85
86
87
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 85

def all(options = {})
  Page.new(api.get(path, options))
end

.path(resource_id = nil) ⇒ Object



80
81
82
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 80

def path(resource_id = nil)
  "v1/billing/plans/#{resource_id}"
end

Instance Method Details

#activateObject



51
52
53
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 51

def activate
  commit("#{path(id)}/activate")
end

#deactivateObject



56
57
58
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 56

def deactivate
  commit("#{path(id)}/deactivate")
end

#reloadObject



90
91
92
93
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 90

def reload
  merge! api.get(self.class.path id)
  success?
end

#update(patch) ⇒ Object

developer.paypal.com/docs/api/subscriptions/v1/#plans_patch patch [Hash] { op: ‘replace’, path: , value: } path = [description|payment_preferences.auto_bill_outstanding|taxes.percentage|payment_preferences.payment_failure_threshold]



41
42
43
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 41

def update(patch)
  super
end

#update_pricing(*schemes) ⇒ Object



45
46
47
48
# File 'lib/paypal-sdk/subscriptions/plan.rb', line 45

def update_pricing(*schemes)
  payload = { pricing_schemes: schemes.map(&:to_hash) }
  commit("#{path(id)}/update-pricing-schemes", payload)
end