Class: PayPal::SDK::REST::DataTypes::CreditCard

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

.find(resource_id) ⇒ Object

Raises:

  • (ArgumentError)


339
340
341
342
343
# File 'lib/paypal-sdk/rest/data_types.rb', line 339

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

.load_membersObject



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/paypal-sdk/rest/data_types.rb', line 311

def self.load_members
  object_of :id, String
  object_of :number, String
  object_of :type, String
  object_of :expire_month, Integer
  object_of :expire_year, Integer
  object_of :cvv2, String
  object_of :first_name, String
  object_of :last_name, String
  object_of :billing_address, Address
  object_of :external_customer_id, String
  object_of :state, String
  object_of :valid_until, String
  object_of :create_time, String
  object_of :update_time, String
  array_of :links, Links
end

Instance Method Details

#createObject



331
332
333
334
335
336
# File 'lib/paypal-sdk/rest/data_types.rb', line 331

def create()
  path = "v1/vault/credit-cards"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  success?
end

#deleteObject



346
347
348
349
350
351
# File 'lib/paypal-sdk/rest/data_types.rb', line 346

def delete()
  path = "v1/vault/credit-cards/#{self.id}"
  response = api.delete(path, {})
  self.merge!(response)
  success?
end

#update(patch_requests) ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
# File 'lib/paypal-sdk/rest/data_types.rb', line 353

def update(patch_requests)
  patch_request_array = []
  patch_requests.each do |patch_request|
    patch_request = Patch.new(patch_request) unless patch_request.is_a? Patch
    patch_request_array << patch_request.to_hash
  end
  path = "v1/vault/credit-cards/#{self.id}"
  response = api.patch(path, patch_request_array, http_header)
  self.merge!(response)
  success?
end