Class: PayPal::SDK::REST::DataTypes::Plan

Inherits:
Base show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/rest/data_types.rb

Constant Summary

Constants inherited from Core::API::DataTypes::Base

Core::API::DataTypes::Base::ContentKey, Core::API::DataTypes::Base::HashOptions

Instance Attribute Summary

Attributes inherited from Base

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, #error=, included

Methods included from SetAPI

#client_id=, #client_secret=, #set_config, #token=

Methods inherited from Base

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

Methods inherited from Core::API::DataTypes::Base

add_attribute, add_member, array_of, #convert_array, #convert_object, define_alias_methods, #hash_key, #initialize, #member_names, members, #members, #merge!, object_of, #set, #skip_value?, snakecase, #to_hash, #value_to_hash

Methods included from Core::Logging

#log_event, #logger, logger, logger=

Constructor Details

This class inherits a constructor from PayPal::SDK::Core::API::DataTypes::Base

Class Method Details

.all(options = {}) ⇒ Object



2117
2118
2119
2120
# File 'lib/paypal-sdk/rest/data_types.rb', line 2117

def all(options = {})
  path = "v1/payments/billing-plans/"
  PlanList.new(api.get(path, options))
end

.find(resource_id) ⇒ Object

Raises:

  • (ArgumentError)


2111
2112
2113
2114
2115
# File 'lib/paypal-sdk/rest/data_types.rb', line 2111

def find(resource_id)
  raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
  path = "v1/payments/billing-plans/#{resource_id}"
  self.new(api.get(path))
end

.load_membersObject



2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
# File 'lib/paypal-sdk/rest/data_types.rb', line 2076

def self.load_members
  object_of :id, String
  object_of :name, String
  object_of :description, String
  object_of :type, String
  object_of :state, String
  object_of :create_time, String
  object_of :update_time, String
  array_of  :payment_definitions, PaymentDefinition
  array_of  :terms, Terms
  object_of :merchant_preferences, MerchantPreferences
  array_of  :links, Links
end

Instance Method Details

#createObject



2092
2093
2094
2095
2096
2097
# File 'lib/paypal-sdk/rest/data_types.rb', line 2092

def create()
  path = "v1/payments/billing-plans/"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  success?
end

#update(patch) ⇒ Object



2099
2100
2101
2102
2103
2104
2105
2106
# File 'lib/paypal-sdk/rest/data_types.rb', line 2099

def update(patch)
  patch = Patch.new(patch) unless patch.is_a? Patch
  patch_request = Array.new(1, patch.to_hash)
  path = "v1/payments/billing-plans/#{self.id}"
  response = api.patch(path, patch_request, http_header)
  self.merge!(response)
  success?
end