Class: Zaikio::Directory::Subscription

Inherits:
Base
  • Object
show all
Defined in:
lib/zaikio/directory/subscription.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Subscription

Returns a new instance of Subscription.



8
9
10
11
12
13
14
15
16
# File 'lib/zaikio/directory/subscription.rb', line 8

def initialize(attributes = {})
  if attributes["subscriber_id"]
    super(attributes.merge(
      "id" => "#{attributes['subscriber_type']}-#{attributes['subscriber_id']}"
    ))
  else
    super
  end
end

Instance Method Details

#activate!Object



18
19
20
# File 'lib/zaikio/directory/subscription.rb', line 18

def activate!
  update(status: "active")
end

#increment_usage_by!(usage, by = 1) ⇒ Object



22
23
24
# File 'lib/zaikio/directory/subscription.rb', line 22

def increment_usage_by!(usage, by = 1)
  update(increment_usages_in_current_billing_period: { usage => by })
end