Class: VcrStripeWebhook::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/vcr_stripe_webhook/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, event_hash) ⇒ Event

Returns a new instance of Event.



7
8
9
10
# File 'lib/vcr_stripe_webhook/event.rb', line 7

def initialize(type, event_hash)
  @type = type
  @event_hash = event_hash
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/vcr_stripe_webhook/event.rb', line 5

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object



28
29
30
# File 'lib/vcr_stripe_webhook/event.rb', line 28

def from_hash(hash)
  Event.new(hash["type"], hash["value"])
end

Instance Method Details

#as_hashObject



19
20
21
# File 'lib/vcr_stripe_webhook/event.rb', line 19

def as_hash
  @event_hash
end

#as_jsonObject



23
24
25
# File 'lib/vcr_stripe_webhook/event.rb', line 23

def as_json
  @json = JSON.generate(@event_hash)
end

#to_hObject



12
13
14
15
16
17
# File 'lib/vcr_stripe_webhook/event.rb', line 12

def to_h
  {
    "type" => type,
    "value" => as_hash
  }
end