Files
ubicloud/model/billing_info.rb
Jeremy Evans 30247a3800 Include model annotations at the bottom of all model files
This makes it easier for developers new to the codebase to
easily get important information on the model's table in the
same file as the model code.

To ensure the model annotations stay accurate, run them on
test_up/test_down.  In CI, regenerate the annotations, and
check for no changes, similar to how the linters work.
2024-11-13 09:13:30 -08:00

37 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require_relative "../model"
require "stripe"
class BillingInfo < Sequel::Model
one_to_many :payment_methods
one_to_one :project
include ResourceMethods
def stripe_data
if (Stripe.api_key = Config.stripe_secret_key)
@stripe_data ||= Stripe::Customer.retrieve(stripe_id)
end
end
def after_destroy
if (Stripe.api_key = Config.stripe_secret_key)
Stripe::Customer.delete(stripe_id)
end
super
end
end
# Table: billing_info
# Columns:
# id | uuid | PRIMARY KEY
# stripe_id | text | NOT NULL
# created_at | timestamp with time zone | NOT NULL DEFAULT now()
# Indexes:
# billing_info_pkey | PRIMARY KEY btree (id)
# billing_info_stripe_id_key | UNIQUE btree (stripe_id)
# Referenced By:
# payment_method | payment_method_billing_info_id_fkey | (billing_info_id) REFERENCES billing_info(id)
# project | project_billing_info_id_fkey | (billing_info_id) REFERENCES billing_info(id)