Sha256: c7987ec3c3980b631a8ec514e5e6946880d1b4320bc4d06504b771a2796aaa0d

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

require 'stripe'

module Aptible
  module Billing
    class BillingDetail < Resource
      field :id
      field :created_at, type: Time
      field :updated_at, type: Time
      field :stripe_customer_id
      field :stripe_subscription_id
      field :stripe_subscription_status
      field :plan
      field :billing_contact_id

      def stripe_customer
        return nil if stripe_customer_id.nil?
        @stripe_customer ||= Stripe::Customer.retrieve(stripe_customer_id)
      end

      def can_manage_compliance?
        %w(production pilot).include?(plan)
      end

      def subscription
        return nil if stripe_subscription_id.nil?
        subscriptions = stripe_customer.subscriptions
        @subscription ||= subscriptions.retrieve(stripe_subscription_id)
      end

      def subscribed?
        !!stripe_subscription_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aptible-billing-0.1.0 lib/aptible/billing/billing_detail.rb