Class: Ravelin::Event
- Inherits:
-
Object
- Object
- Ravelin::Event
- Defined in:
- lib/ravelin/event.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(name:, payload:, timestamp: nil) ⇒ Event
constructor
A new instance of Event.
- #object_classes ⇒ Object
- #serializable_hash ⇒ Object
Constructor Details
#initialize(name:, payload:, timestamp: nil) ⇒ Event
5 6 7 8 9 10 11 |
# File 'lib/ravelin/event.rb', line 5 def initialize(name:, payload:, timestamp: nil) @name = convert_event_name(name) @payload = convert_to_ravelin_objects(payload) = .nil? ? Time.now.to_i : convert_to_epoch() validate_top_level_payload_params end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ravelin/event.rb', line 3 def name @name end |
#payload ⇒ Object
Returns the value of attribute payload.
3 4 5 |
# File 'lib/ravelin/event.rb', line 3 def payload @payload end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/ravelin/event.rb', line 3 def end |
Instance Method Details
#object_classes ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ravelin/event.rb', line 27 def object_classes { chargeback: Chargeback, customer: Customer, device: Device, location: Location, order: Order, payment_method: PaymentMethod, voucher_redemption: VoucherRedemption, transaction: name == :pretransaction ? PreTransaction : Transaction, label: Label, voucher: Voucher, } end |
#serializable_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ravelin/event.rb', line 13 def serializable_hash payload_hash = hash_map(payload) do |k, v| k = Ravelin.camelize(k) if v.is_a?(Ravelin::RavelinObject) [k, v.serializable_hash] else [k, v] end end payload_hash.merge('timestamp' => ) end |