class PayPal::SDK::REST::DataTypes::Agreement

Public Class Methods

find(resource_id) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2272
def find(resource_id)
  raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
  path = "v1/payments/billing-agreements/#{resource_id}"
  self.new(api.get(path))
end
load_members() click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2236
def self.load_members
      object_of :id, String
      object_of :state, String
      object_of :name, String
      object_of :description, String
      object_of :start_date, String
      object_of :agreement_details, AgreementDetails
      object_of :payer, Payer
      object_of :shipping_address, Address
      object_of :override_merchant_preferences, MerchantPreferences
    array_of  :override_charge_models, OverrideChargeModel
      object_of :plan, Plan
      object_of :create_time, String
      object_of :update_time, String
    array_of  :links, Links
      object_of :token, String
end
transactions(agreement_id, start_date, end_date, options = {}) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2331
def transactions(agreement_id, start_date, end_date, options = {})
  path = "v1/payments/billing-agreements/#{agreement_id}/transactions" #?start-date=#{start_date}&end-date=#{end_date}"
  options = { :start_date => start_date, :end_date => end_date }
  AgreementTransactions.new(api.get(path, options))
end

Public Instance Methods

bill_balance(agreement_state_descriptor) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2311
def bill_balance(agreement_state_descriptor)
  agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
  path = "v1/payments/billing-agreements/#{self.id}/bill-balance"
  response = api.post(path, agreement_state_descriptor.to_hash, http_header)
  self.merge!(response)
  success?
end
cancel(agreement_state_descriptor) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2303
def cancel(agreement_state_descriptor)
  agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
  path = "v1/payments/billing-agreements/#{self.id}/cancel"
  response = api.post(path, agreement_state_descriptor.to_hash, http_header)
  self.merge!(response)
  success?
end
create() click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2256
def create()
  path = "v1/payments/billing-agreements/"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  self.get_token(self.links)
  success?
end
execute() click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2264
def execute()
  path = "v1/payments/billing-agreements/#{self.token}/agreement-execute"
  response = api.post(path, {}, http_header)
  self.merge!(response)
  success?
end
get_token(links) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2338
def get_token(links)
  links.each do |link|
    if link.rel.eql? "approval_url"
      uri = URI.parse(link.href)
      params = CGI.parse(uri.query)
      self.token = params['token'][0]
      return
    end
  end
end
re_activate(agreement_state_descriptor) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2295
def re_activate(agreement_state_descriptor)
  agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
  path = "v1/payments/billing-agreements/#{self.id}/re-activate"
  response = api.post(path, agreement_state_descriptor.to_hash, http_header)
  self.merge!(response)
  success?
end
set_balance(currency) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2319
def set_balance(currency)
  currency = Currency.new(currency) unless currency.is_a? Currency
  path = "v1/payments/billing-agreements/#{self.id}/set-balance"
  response = api.post(path, currency.to_hash, http_header)
  self.merge!(response)
  success?
end
suspend(agreement_state_descriptor) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2287
def suspend(agreement_state_descriptor)
  agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
  path = "v1/payments/billing-agreements/#{self.id}/suspend"
  response = api.post(path, agreement_state_descriptor.to_hash, http_header)
  self.merge!(response)
  success?
end
update(patch) click to toggle source
# File lib/paypal-sdk/rest/data_types.rb, line 2279
def update(patch)
  patch = Patch.new(patch) unless patch.is_a? Patch
  path = "v1/payments/billing-agreements/#{self.id}"
  response = api.patch(path, [patch.to_hash], http_header)
  self.merge!(response)
  success?
end