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.



1092
1093
1094
1095
1096
# File 'lib/webpay/data_types.rb', line 1092

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.



1073
1074
1075
# File 'lib/webpay/data_types.rb', line 1073

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



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

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



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

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

Instance Method Details

#cardObject



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

def card
  attributes['card']
end

#card=(value) ⇒ Object



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

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

#descriptionObject



1131
1132
1133
# File 'lib/webpay/data_types.rb', line 1131

def description
  attributes['description']
end

#description=(value) ⇒ Object



1135
1136
1137
# File 'lib/webpay/data_types.rb', line 1135

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

#emailObject



1139
1140
1141
# File 'lib/webpay/data_types.rb', line 1139

def email
  attributes['email']
end

#email=(value) ⇒ Object



1143
1144
1145
# File 'lib/webpay/data_types.rb', line 1143

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

#idObject

attributes accessors



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

def id
  attributes['id']
end

#id=(value) ⇒ Object



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

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

#query_paramsObject



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

def query_params
  result = {}
  return result
end

#request_bodyObject



1099
1100
1101
1102
1103
1104
1105
# File 'lib/webpay/data_types.rb', line 1099

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