Class: MusicTodayApiWrapper::Resources::Checkout::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/checkout/session.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, address, items = []) ⇒ Session

Returns a new instance of Session.



10
11
12
13
14
# File 'lib/resources/checkout/session.rb', line 10

def initialize(id, address, items = [])
  @id = id
  @address = address
  @items = items
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/resources/checkout/session.rb', line 8

def address
  @address
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/resources/checkout/session.rb', line 8

def id
  @id
end

#itemsObject

Returns the value of attribute items.



8
9
10
# File 'lib/resources/checkout/session.rb', line 8

def items
  @items
end

Class Method Details

.from_hash(session_hash) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/resources/checkout/session.rb', line 16

def self.from_hash(session_hash)
  address = Address.from_hash(session_hash)
  session = Session.new(session_hash['sessionId'], address)
  session_hash['items'].each do |item|
    session.items << Resources::Purchase::Item.from_hash(item)
  end
  session
end