class Mollie::Subscription

Constants

STATUS_ACTIVE
STATUS_CANCELED
STATUS_COMPLETED
STATUS_PENDING
STATUS_SUSPENDED

Attributes

amount[RW]
application_fee[RW]
canceled_at[RW]
created_at[RW]
customer_id[RW]
description[RW]
id[RW]
interval[RW]
mandate_id[RW]
metadata[RW]
method[RW]
mode[RW]
next_payment_date[RW]
status[RW]
times[RW]
times_remaining[RW]
webhook_url[RW]

Public Instance Methods

active?() click to toggle source
# File lib/mollie/subscription.rb, line 30
def active?
  status == STATUS_ACTIVE
end
amount=(amount) click to toggle source
# File lib/mollie/subscription.rb, line 66
def amount=(amount)
  @amount = Mollie::Amount.new(amount)
end
application_fee=(application_fee) click to toggle source
# File lib/mollie/subscription.rb, line 97
def application_fee=(application_fee)
  amount      = Amount.new(application_fee['amount'])
  description = application_fee['description']

  @application_fee = OpenStruct.new(
    amount: amount,
    description: description
  )
end
canceled?() click to toggle source
# File lib/mollie/subscription.rb, line 42
def canceled?
  status == STATUS_CANCELED
end
canceled_at=(canceled_at) click to toggle source
# File lib/mollie/subscription.rb, line 58
def canceled_at=(canceled_at)
  @canceled_at = begin
                   Time.parse(canceled_at.to_s)
                 rescue StandardError
                   nil
                 end
end
completed?() click to toggle source
# File lib/mollie/subscription.rb, line 46
def completed?
  status == STATUS_COMPLETED
end
created_at=(created_at) click to toggle source
# File lib/mollie/subscription.rb, line 50
def created_at=(created_at)
  @created_at = begin
                  Time.parse(created_at.to_s)
                rescue StandardError
                  nil
                end
end
customer(options = {}) click to toggle source
# File lib/mollie/subscription.rb, line 82
def customer(options = {})
  Customer.get(customer_id, options)
end
metadata=(metadata) click to toggle source
# File lib/mollie/subscription.rb, line 93
def metadata=(metadata)
  @metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
end
next_payment_date=(next_payment_date) click to toggle source
# File lib/mollie/subscription.rb, line 74
def next_payment_date=(next_payment_date)
  @next_payment_date = begin
                         Date.parse(next_payment_date)
                       rescue StandardError
                         nil
                       end
end
payments(options = {}) click to toggle source
# File lib/mollie/subscription.rb, line 86
def payments(options = {})
  resource_url = Util.extract_url(links, 'payments')
  return if resource_url.nil?
  response = Mollie::Client.instance.perform_http_call('GET', resource_url, nil, {}, options)
  Mollie::List.new(response, Mollie::Payment)
end
pending?() click to toggle source
# File lib/mollie/subscription.rb, line 34
def pending?
  status == STATUS_PENDING
end
suspended?() click to toggle source
# File lib/mollie/subscription.rb, line 38
def suspended?
  status == STATUS_SUSPENDED
end
times=(times) click to toggle source
# File lib/mollie/subscription.rb, line 70
def times=(times)
  @times = times.to_i
end