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.



1074
1075
1076
1077
1078
# File 'lib/webpay/data_types.rb', line 1074

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.



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

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/webpay/data_types.rb', line 1062

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



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

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

Instance Method Details

#cardObject



1104
1105
1106
# File 'lib/webpay/data_types.rb', line 1104

def card
  attributes['card']
end

#card=(value) ⇒ Object



1108
1109
1110
1111
# File 'lib/webpay/data_types.rb', line 1108

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

#descriptionObject



1113
1114
1115
# File 'lib/webpay/data_types.rb', line 1113

def description
  attributes['description']
end

#description=(value) ⇒ Object



1117
1118
1119
# File 'lib/webpay/data_types.rb', line 1117

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

#emailObject



1121
1122
1123
# File 'lib/webpay/data_types.rb', line 1121

def email
  attributes['email']
end

#email=(value) ⇒ Object



1125
1126
1127
# File 'lib/webpay/data_types.rb', line 1125

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

#idObject

attributes accessors



1096
1097
1098
# File 'lib/webpay/data_types.rb', line 1096

def id
  attributes['id']
end

#id=(value) ⇒ Object



1100
1101
1102
# File 'lib/webpay/data_types.rb', line 1100

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

#query_paramsObject



1089
1090
1091
1092
# File 'lib/webpay/data_types.rb', line 1089

def query_params
  result = {}
  return result
end

#request_bodyObject



1081
1082
1083
1084
1085
1086
1087
# File 'lib/webpay/data_types.rb', line 1081

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