Class: EwayRapid::InternalModels::ShippingAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/models/internal_models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cityObject

Returns the value of attribute city.



269
270
271
# File 'lib/eway_rapid/models/internal_models.rb', line 269

def city
  @city
end

#countryObject

Returns the value of attribute country.



271
272
273
# File 'lib/eway_rapid/models/internal_models.rb', line 271

def country
  @country
end

#emailObject

Returns the value of attribute email.



273
274
275
# File 'lib/eway_rapid/models/internal_models.rb', line 273

def email
  @email
end

#faxObject

Returns the value of attribute fax.



275
276
277
# File 'lib/eway_rapid/models/internal_models.rb', line 275

def fax
  @fax
end

#first_nameObject

Returns the value of attribute first_name.



265
266
267
# File 'lib/eway_rapid/models/internal_models.rb', line 265

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



266
267
268
# File 'lib/eway_rapid/models/internal_models.rb', line 266

def last_name
  @last_name
end

#phoneObject

Returns the value of attribute phone.



274
275
276
# File 'lib/eway_rapid/models/internal_models.rb', line 274

def phone
  @phone
end

#postal_codeObject

Returns the value of attribute postal_code.



272
273
274
# File 'lib/eway_rapid/models/internal_models.rb', line 272

def postal_code
  @postal_code
end

#shipping_methodObject

Returns the value of attribute shipping_method.



276
277
278
# File 'lib/eway_rapid/models/internal_models.rb', line 276

def shipping_method
  @shipping_method
end

#stateObject

Returns the value of attribute state.



270
271
272
# File 'lib/eway_rapid/models/internal_models.rb', line 270

def state
  @state
end

#street1Object

Returns the value of attribute street1.



267
268
269
# File 'lib/eway_rapid/models/internal_models.rb', line 267

def street1
  @street1
end

#street2Object

Returns the value of attribute street2.



268
269
270
# File 'lib/eway_rapid/models/internal_models.rb', line 268

def street2
  @street2
end

Class Method Details

.from_hash(hash) ⇒ Object



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/eway_rapid/models/internal_models.rb', line 302

def self.from_hash(hash)
  shipping_address = ShippingAddress.new
  shipping_address.first_name = hash[Constants::FIRST_NAME]
  shipping_address.last_name = hash[Constants::LAST_NAME]
  shipping_address.street1 = hash[Constants::STREET1]
  shipping_address.street2 = hash[Constants::STREET2]
  shipping_address.city = hash[Constants::CITY]
  shipping_address.state = hash[Constants::STATE]
  shipping_address.country = hash[Constants::COUNTRY]
  shipping_address.postal_code = hash[Constants::POSTAL_CODE]
  shipping_address.email = hash[Constants::EMAIL]
  shipping_address.phone = hash[Constants::PHONE]
  shipping_address.fax = hash[Constants::FAX]
  shipping_address.shipping_method = hash[Constants::SHIPPING_METHOD]
  shipping_address
end

.from_json(json) ⇒ Object



297
298
299
300
# File 'lib/eway_rapid/models/internal_models.rb', line 297

def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end

.to_hash(shipping_address) ⇒ Object



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/eway_rapid/models/internal_models.rb', line 278

def self.to_hash(shipping_address)
  hash = {}
  if shipping_address
   hash[Constants::FIRST_NAME] = shipping_address.first_name if shipping_address.first_name
   hash[Constants::LAST_NAME] = shipping_address.last_name if shipping_address.last_name
   hash[Constants::STREET1] = shipping_address.street1 if shipping_address.street1
   hash[Constants::STREET2] = shipping_address.street2 if shipping_address.street2
   hash[Constants::CITY] = shipping_address.city if shipping_address.city
   hash[Constants::STATE] = shipping_address.state if shipping_address.state
   hash[Constants::COUNTRY] = shipping_address.country if shipping_address.country
   hash[Constants::POSTAL_CODE] = shipping_address.postal_code if shipping_address.postal_code
   hash[Constants::EMAIL] = shipping_address.email if shipping_address.email
   hash[Constants::PHONE] = shipping_address.phone if shipping_address.phone
   hash[Constants::FAX] = shipping_address.fax if shipping_address.fax
   hash[Constants::SHIPPING_METHOD] = shipping_address.shipping_method if shipping_address.shipping_method
  end
  hash
end