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
- #format_timestamp(timestamp) ⇒ Object
-
#initialize(name:, payload:, timestamp: nil) ⇒ Event
constructor
A new instance of Event.
- #object_classes ⇒ Object
- #serializable_hash ⇒ Object
- #transaction ⇒ Object
Constructor Details
#initialize(name:, payload:, timestamp: nil) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 11 12 |
# File 'lib/ravelin/event.rb', line 5 def initialize(name:, payload:, timestamp: nil) @internal_name = name @name = convert_event_name(name) @payload = convert_to_ravelin_objects(payload) @timestamp = .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 @timestamp end |
Instance Method Details
#format_timestamp(timestamp) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ravelin/event.rb', line 60 def () case @internal_name when :ato_login * 1000 when :ato_reclaim Time.at().utc.to_datetime.to_s else end end |
#object_classes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ravelin/event.rb', line 28 def object_classes { ato_login: AtoLogin, authentication_mechanism: AuthenticationMechanism, chargeback: Chargeback, customer: Customer, ato_reclaim: AtoReclaim, device: Device, location: Location, login: Login, order: Order, password: Password, payment_method: PaymentMethod, supplier: Supplier, voucher_redemption: VoucherRedemption, transaction: transaction, label: Label, voucher: Voucher, } end |
#serializable_hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ravelin/event.rb', line 14 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 |
#transaction ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ravelin/event.rb', line 49 def transaction case name when :pretransaction PreTransaction when :checkout CheckoutTransaction else Transaction end end |