Sha256: 96755a8db06d5e9cc7616e4fee21a65439a2d4a03be645c772ceab6a10fe4f42
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
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 def organization Aptible::Auth::Organization.find_by_url( links['organization'].href, token: token, headers: headers ) rescue nil end def billing_contact Aptible::Auth::User.find_by_url( links['billing_contact'].href, token: token, headers: headers ) rescue nil end 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
4 entries across 4 versions & 1 rubygems