Class: Webhookdb::Subscription::Plan

Inherits:
Object
  • Object
show all
Defined in:
lib/webhookdb/subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, stripe_price) ⇒ Plan

Returns a new instance of Plan.



11
12
13
14
15
16
17
# File 'lib/webhookdb/subscription.rb', line 11

def initialize(key, stripe_price)
  @key = key
  @description = stripe_price.nickname
  @price = Money.new(stripe_price.unit_amount)
  @stripe_price_id = stripe_price.id
  @stripe_product_id = stripe_price.product
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/webhookdb/subscription.rb', line 9

def description
  @description
end

#keyObject

Returns the value of attribute key.



9
10
11
# File 'lib/webhookdb/subscription.rb', line 9

def key
  @key
end

#priceObject

Returns the value of attribute price.



9
10
11
# File 'lib/webhookdb/subscription.rb', line 9

def price
  @price
end

#stripe_price_idObject

Returns the value of attribute stripe_price_id.



9
10
11
# File 'lib/webhookdb/subscription.rb', line 9

def stripe_price_id
  @stripe_price_id
end

#stripe_product_idObject

Returns the value of attribute stripe_product_id.



9
10
11
# File 'lib/webhookdb/subscription.rb', line 9

def stripe_product_id
  @stripe_product_id
end

Instance Method Details

#as_jsonObject



19
20
21
# File 'lib/webhookdb/subscription.rb', line 19

def as_json
  return {key:, description:, price:}
end