Class: Braspag::Sale

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag/api/sale.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(merchant_order_id) ⇒ Sale

Returns a new instance of Sale.



7
8
9
# File 'lib/braspag/api/sale.rb', line 7

def initialize(merchant_order_id)
    @merchant_order_id = merchant_order_id
end

Instance Attribute Details

#customerObject

Returns the value of attribute customer.



3
4
5
# File 'lib/braspag/api/sale.rb', line 3

def customer
  @customer
end

#merchant_order_idObject

Returns the value of attribute merchant_order_id.



3
4
5
# File 'lib/braspag/api/sale.rb', line 3

def merchant_order_id
  @merchant_order_id
end

#paymentObject

Returns the value of attribute payment.



3
4
5
# File 'lib/braspag/api/sale.rb', line 3

def payment
  @payment
end

Class Method Details

.from_json(data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/braspag/api/sale.rb', line 17

def self.from_json(data)
    if (data != nil)
        sale = Sale.new(data["MerchantOrderId"] || nil)

        sale.customer = Customer.from_json(data["Customer"] || nil)
        sale.payment = Payment.from_json(data["Payment"] || nil)

        return sale
    end
end

Instance Method Details

#to_json(*options) ⇒ Object



11
12
13
14
15
# File 'lib/braspag/api/sale.rb', line 11

def to_json(*options)
    hash = as_json(*options)
    hash.reject! {|k,v| v.nil?}
    hash.to_json(*options)
end