Class: WebPay::CustomerRequestUpdate

Inherits:
Entity
  • Object
show all
Defined in:
lib/webpay/data_types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#normalize_hash, #to_h, #to_s

Constructor Details

#initialize(hash = {}) ⇒ CustomerRequestUpdate

Returns a new instance of CustomerRequestUpdate.



1009
1010
1011
1012
1013
# File 'lib/webpay/data_types.rb', line 1009

def initialize(hash = {})
  hash = normalize_hash(hash)
  hash['card'] = hash['card'].is_a?(Hash) ? WebPay::CardRequest.new(hash['card']) : hash['card']
  @attributes = hash
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



990
991
992
# File 'lib/webpay/data_types.rb', line 990

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'lib/webpay/data_types.rb', line 997

def self.create(params)
  return params if params.is_a?(self)
  hash = case params
    when Hash; params
    when WebPay::CustomerResponse; {'id' => params.id}
    when String; {'id' => params}
    else
      raise WebPay::InvalidRequestError.new("#{self} does not accept the given value", params)
    end
  self.new(hash)
end

.fieldsObject



992
993
994
# File 'lib/webpay/data_types.rb', line 992

def self.fields
  ['id', 'card', 'description', 'email']
end

Instance Method Details

#cardObject



1039
1040
1041
# File 'lib/webpay/data_types.rb', line 1039

def card
  attributes['card']
end

#card=(value) ⇒ Object



1043
1044
1045
1046
# File 'lib/webpay/data_types.rb', line 1043

def card=(value)
  value = value.is_a?(Hash) ? WebPay::CardRequest.new(value) : value
  attributes['card'] = value
end

#descriptionObject



1048
1049
1050
# File 'lib/webpay/data_types.rb', line 1048

def description
  attributes['description']
end

#description=(value) ⇒ Object



1052
1053
1054
# File 'lib/webpay/data_types.rb', line 1052

def description=(value)
  attributes['description'] = value
end

#emailObject



1056
1057
1058
# File 'lib/webpay/data_types.rb', line 1056

def email
  attributes['email']
end

#email=(value) ⇒ Object



1060
1061
1062
# File 'lib/webpay/data_types.rb', line 1060

def email=(value)
  attributes['email'] = value
end

#idObject

attributes accessors



1031
1032
1033
# File 'lib/webpay/data_types.rb', line 1031

def id
  attributes['id']
end

#id=(value) ⇒ Object



1035
1036
1037
# File 'lib/webpay/data_types.rb', line 1035

def id=(value)
  attributes['id'] = value
end

#query_paramsObject



1024
1025
1026
1027
# File 'lib/webpay/data_types.rb', line 1024

def query_params
  result = {}
  return result
end

#request_bodyObject



1016
1017
1018
1019
1020
1021
1022
# File 'lib/webpay/data_types.rb', line 1016

def request_body
  result = {}
  copy_if_exists(@attributes, result, 'card', 'request_body');
  copy_if_exists(@attributes, result, 'description', 'request_body');
  copy_if_exists(@attributes, result, 'email', 'request_body');
  result
end