Sha256: 7fd9bab8dfcce97c2966d5181d9c8939629e55653d6a14609b13672c31f36987

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 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
      field :organization

      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.1 lib/aptible/billing/billing_detail.rb