iron_bank 0.1.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env.example +7 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +20 -0
- data/.gitignore +6 -1
- data/.reek +95 -0
- data/.rspec +1 -2
- data/.rubocop.yml +55 -0
- data/.travis.yml +22 -3
- data/Gemfile +3 -3
- data/LICENSE +176 -0
- data/README.md +133 -0
- data/Rakefile +39 -3
- data/bin/console +13 -1
- data/bin/setup +1 -0
- data/iron_bank.gemspec +34 -10
- data/lib/generators/iron_bank/install/install_generator.rb +20 -0
- data/lib/generators/iron_bank/install/templates/README +16 -0
- data/lib/generators/iron_bank/install/templates/iron_bank.rb +29 -0
- data/lib/iron_bank/action.rb +39 -0
- data/lib/iron_bank/actions/amend.rb +16 -0
- data/lib/iron_bank/actions/create.rb +19 -0
- data/lib/iron_bank/actions/delete.rb +19 -0
- data/lib/iron_bank/actions/execute.rb +21 -0
- data/lib/iron_bank/actions/generate.rb +19 -0
- data/lib/iron_bank/actions/query.rb +16 -0
- data/lib/iron_bank/actions/query_more.rb +21 -0
- data/lib/iron_bank/actions/subscribe.rb +32 -0
- data/lib/iron_bank/actions/update.rb +19 -0
- data/lib/iron_bank/associations.rb +73 -0
- data/lib/iron_bank/authentication.rb +37 -0
- data/lib/iron_bank/authentications/cookie.rb +80 -0
- data/lib/iron_bank/authentications/token.rb +82 -0
- data/lib/iron_bank/cacheable.rb +52 -0
- data/lib/iron_bank/client.rb +96 -0
- data/lib/iron_bank/collection.rb +31 -0
- data/lib/iron_bank/configuration.rb +86 -0
- data/lib/iron_bank/csv.rb +29 -0
- data/lib/iron_bank/describe/field.rb +65 -0
- data/lib/iron_bank/describe/object.rb +81 -0
- data/lib/iron_bank/describe/related.rb +40 -0
- data/lib/iron_bank/describe/tenant.rb +50 -0
- data/lib/iron_bank/endpoint.rb +36 -0
- data/lib/iron_bank/error.rb +45 -0
- data/lib/iron_bank/instrumentation.rb +14 -0
- data/lib/iron_bank/local.rb +72 -0
- data/lib/iron_bank/local_records.rb +52 -0
- data/lib/iron_bank/logger.rb +23 -0
- data/lib/iron_bank/metadata.rb +36 -0
- data/lib/iron_bank/object.rb +89 -0
- data/lib/iron_bank/open_tracing.rb +17 -0
- data/lib/iron_bank/operation.rb +33 -0
- data/lib/iron_bank/operations/billing_preview.rb +16 -0
- data/lib/iron_bank/query_builder.rb +72 -0
- data/lib/iron_bank/queryable.rb +55 -0
- data/lib/iron_bank/resource.rb +70 -0
- data/lib/iron_bank/resources/account.rb +62 -0
- data/lib/iron_bank/resources/amendment.rb +13 -0
- data/lib/iron_bank/resources/catalog_tiers/discount_amount.rb +26 -0
- data/lib/iron_bank/resources/catalog_tiers/discount_percentage.rb +26 -0
- data/lib/iron_bank/resources/catalog_tiers/price.rb +26 -0
- data/lib/iron_bank/resources/contact.rb +13 -0
- data/lib/iron_bank/resources/export.rb +11 -0
- data/lib/iron_bank/resources/import.rb +12 -0
- data/lib/iron_bank/resources/invoice.rb +37 -0
- data/lib/iron_bank/resources/invoice_adjustment.rb +13 -0
- data/lib/iron_bank/resources/invoice_item.rb +25 -0
- data/lib/iron_bank/resources/invoice_payment.rb +13 -0
- data/lib/iron_bank/resources/payment.rb +17 -0
- data/lib/iron_bank/resources/payment_method.rb +14 -0
- data/lib/iron_bank/resources/product.rb +14 -0
- data/lib/iron_bank/resources/product_rate_plan.rb +32 -0
- data/lib/iron_bank/resources/product_rate_plan_charge.rb +27 -0
- data/lib/iron_bank/resources/product_rate_plan_charge_tier.rb +60 -0
- data/lib/iron_bank/resources/rate_plan.rb +21 -0
- data/lib/iron_bank/resources/rate_plan_charge.rb +30 -0
- data/lib/iron_bank/resources/rate_plan_charge_tier.rb +26 -0
- data/lib/iron_bank/resources/subscription.rb +28 -0
- data/lib/iron_bank/resources/usage.rb +16 -0
- data/lib/iron_bank/response/raise_error.rb +16 -0
- data/lib/iron_bank/schema.rb +58 -0
- data/lib/iron_bank/utils.rb +59 -0
- data/lib/iron_bank/version.rb +4 -1
- data/lib/iron_bank.rb +152 -2
- metadata +300 -12
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A payment belongs to an account and is applied against one or many
|
6
|
+
# invoices and/or the account credit balance.
|
7
|
+
#
|
8
|
+
class Payment < Resource
|
9
|
+
with_schema
|
10
|
+
|
11
|
+
with_one :account
|
12
|
+
with_one :payment_method
|
13
|
+
|
14
|
+
with_many :invoice_payments
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# An electronic payment method, belongs to an account, can be set as the
|
6
|
+
# default payment method on an account to enable auto-pay through payment
|
7
|
+
# runs.
|
8
|
+
#
|
9
|
+
class PaymentMethod < Resource
|
10
|
+
with_schema
|
11
|
+
with_one :account
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A Zuora product holds many product rate plans.
|
6
|
+
#
|
7
|
+
class Product < Resource
|
8
|
+
with_schema
|
9
|
+
with_local_records
|
10
|
+
with_cache
|
11
|
+
with_many :product_rate_plans, aka: :plans
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A product rate plan belongs to a product and holds many product rate plan
|
6
|
+
# charges. It represents what a customer is subscribing to.
|
7
|
+
#
|
8
|
+
class ProductRatePlan < Resource
|
9
|
+
# Zuora limitation: we cannot query for `ActiveCurrencies` with any other
|
10
|
+
# fields, so instead we define a separate `#active_currencies` method.
|
11
|
+
def self.exclude_fields
|
12
|
+
%w[ActiveCurrencies]
|
13
|
+
end
|
14
|
+
with_schema
|
15
|
+
with_local_records
|
16
|
+
with_cache
|
17
|
+
|
18
|
+
with_one :product
|
19
|
+
with_many :product_rate_plan_charges, aka: :charges
|
20
|
+
|
21
|
+
def active_currencies
|
22
|
+
query_string = IronBank::QueryBuilder.zoql(
|
23
|
+
self.class.object_name,
|
24
|
+
['ActiveCurrencies'],
|
25
|
+
id: id
|
26
|
+
)
|
27
|
+
|
28
|
+
IronBank.client.query(query_string)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A product rate plan charge can be a one-time, recurring or usage-based
|
6
|
+
# charge. It belongs to a product rate plan and can have many tiers when
|
7
|
+
# using a Volume or Tiered pricing model.
|
8
|
+
#
|
9
|
+
# NOTE: if multiple currencies are enabled for your Zuora tenant, then there
|
10
|
+
# is *at least* one tier per active currency.
|
11
|
+
#
|
12
|
+
class ProductRatePlanCharge < Resource
|
13
|
+
# `DiscountClass` seems to not be a queryable field, despite the result
|
14
|
+
# from the describe call for product rate plan charge.
|
15
|
+
def self.exclude_fields
|
16
|
+
%w[DiscountClass]
|
17
|
+
end
|
18
|
+
with_schema
|
19
|
+
with_local_records
|
20
|
+
with_cache
|
21
|
+
|
22
|
+
with_one :product_rate_plan, aka: :plan
|
23
|
+
|
24
|
+
with_many :product_rate_plan_charge_tiers, aka: :tiers
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A tier holds an amount (cost) and a currency for a given product rate plan
|
6
|
+
# charge.
|
7
|
+
#
|
8
|
+
class ProductRatePlanChargeTier < Resource
|
9
|
+
with_schema
|
10
|
+
with_local_records
|
11
|
+
with_cache
|
12
|
+
|
13
|
+
with_one :product_rate_plan_charge, aka: :charge
|
14
|
+
|
15
|
+
def self.where(conditions)
|
16
|
+
# If we are coming from a subclass, defer to Queryable#all
|
17
|
+
return super unless name.end_with?('ProductRatePlanChargeTier')
|
18
|
+
|
19
|
+
CatalogTiers.constants.map do |tier_klass|
|
20
|
+
CatalogTiers.const_get(tier_klass).where(conditions)
|
21
|
+
end.flatten
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_each
|
25
|
+
return enum_for(:find_each) unless block_given?
|
26
|
+
return super unless name.end_with?('ProductRatePlanChargeTier')
|
27
|
+
|
28
|
+
CatalogTiers.constants.each do |tier_klass|
|
29
|
+
# Pass the block to each subclasses
|
30
|
+
CatalogTiers.const_get(tier_klass).find_each(&Proc.new)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# We want to store all fields to the CSV, not just the ones that can be
|
35
|
+
# queried through Zuora, for all the different tiers (discount-percentage,
|
36
|
+
# discount-fixed amount and regular pricing).
|
37
|
+
def to_csv_row
|
38
|
+
ProductRatePlanChargeTier.fields.each.with_object([]) do |field, row|
|
39
|
+
row << remote[field]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.load_records
|
44
|
+
CSV.foreach(file_path, csv_options).with_object({}) do |row, store|
|
45
|
+
remote = row.to_h.reject { |_, value| value.nil? }
|
46
|
+
|
47
|
+
record = if remote['DiscountAmount']
|
48
|
+
CatalogTiers::DiscountAmount.new(remote)
|
49
|
+
elsif remote['DiscountPercentage']
|
50
|
+
CatalogTiers::DiscountPercentage.new(remote)
|
51
|
+
else
|
52
|
+
CatalogTiers::Price.new(remote)
|
53
|
+
end
|
54
|
+
|
55
|
+
store[row['Id']] = record
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A rate plan belongs to a subscription and is a copy of the associated
|
6
|
+
# product rate plan from the catalog at the time of the subscription.
|
7
|
+
#
|
8
|
+
class RatePlan < Resource
|
9
|
+
with_schema
|
10
|
+
with_cache
|
11
|
+
|
12
|
+
with_one :amendment
|
13
|
+
with_one :product_rate_plan, aka: :catalog_plan
|
14
|
+
with_one :subscription
|
15
|
+
|
16
|
+
with_many :rate_plan_charges,
|
17
|
+
aka: :charges,
|
18
|
+
conditions: { is_last_segment: true }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A rate plan charge belongs to a subscription rate plan.
|
6
|
+
#
|
7
|
+
class RatePlanCharge < Resource
|
8
|
+
def self.exclude_fields
|
9
|
+
%w[
|
10
|
+
DiscountAmount
|
11
|
+
DiscountClass
|
12
|
+
DiscountPercentage
|
13
|
+
IncludedUnits
|
14
|
+
OveragePrice
|
15
|
+
Price
|
16
|
+
RevenueRecognitionRuleName
|
17
|
+
RolloverBalance
|
18
|
+
]
|
19
|
+
end
|
20
|
+
with_schema
|
21
|
+
with_cache
|
22
|
+
|
23
|
+
with_one :original, resource_name: 'RatePlanCharge'
|
24
|
+
with_one :product_rate_plan_charge, aka: :catalog_charge
|
25
|
+
with_one :rate_plan, aka: :plan
|
26
|
+
|
27
|
+
with_many :rate_plan_charge_tiers, aka: :tiers
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A rate plan charge tier hold the price per unit the customer will be
|
6
|
+
# billed for, in his/her currency.
|
7
|
+
#
|
8
|
+
class RatePlanChargeTier < Resource
|
9
|
+
# Excluding 'DiscountAmount' & 'DiscountPercentage', as Zuora stores these
|
10
|
+
# values in the 'Price' field.
|
11
|
+
def self.exclude_fields
|
12
|
+
%w[
|
13
|
+
Currency
|
14
|
+
DiscountAmount
|
15
|
+
DiscountPercentage
|
16
|
+
IncludedUnits
|
17
|
+
OveragePrice
|
18
|
+
]
|
19
|
+
end
|
20
|
+
with_schema
|
21
|
+
with_cache
|
22
|
+
|
23
|
+
with_one :rate_plan_charge, aka: :charge
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# A Zuora subscription, belongs to an account, holds rate plans and is
|
6
|
+
# versioned through each amendment.
|
7
|
+
#
|
8
|
+
class Subscription < Resource
|
9
|
+
with_schema
|
10
|
+
with_cache
|
11
|
+
|
12
|
+
with_one :account
|
13
|
+
with_one :invoice_owner, resource_name: 'Account'
|
14
|
+
|
15
|
+
with_one :original, resource_name: 'Subscription'
|
16
|
+
with_one :previous,
|
17
|
+
resource_name: 'Subscription',
|
18
|
+
foreign_key: 'previous_subscription_id'
|
19
|
+
|
20
|
+
with_many :rate_plans, aka: :plans
|
21
|
+
with_many :usages
|
22
|
+
|
23
|
+
# FIXME: a subscription can only have at most one amendment (no amendment
|
24
|
+
# for the last version) but there are no `AmendmentId` on a subscription.
|
25
|
+
with_many :amendments
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
module Resources
|
5
|
+
# Usage is consumed by usage-based charges during the bill run.
|
6
|
+
#
|
7
|
+
class Usage < Resource
|
8
|
+
with_schema
|
9
|
+
|
10
|
+
with_one :account
|
11
|
+
with_one :charge, resource_name: 'RatePlanCharge'
|
12
|
+
with_one :import
|
13
|
+
with_one :subscription
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
# Faraday response middleware
|
5
|
+
module Response
|
6
|
+
# This class raises an exception based on the HTTP status code and the
|
7
|
+
# `success` flag (if present in the response) from Zuora.
|
8
|
+
class RaiseError < Faraday::Response::Middleware
|
9
|
+
private
|
10
|
+
|
11
|
+
def on_complete(response)
|
12
|
+
(error = IronBank::Error.from_response(response)) && raise(error)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
# Representation of all Zuora objects and their fields for a Zuora tenant,
|
5
|
+
# with import/export capabilities.
|
6
|
+
#
|
7
|
+
class Schema
|
8
|
+
private_class_method :new
|
9
|
+
|
10
|
+
def self.directory
|
11
|
+
IronBank.configuration.schema_directory
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.export
|
15
|
+
FileUtils.mkdir_p(directory) unless Dir.exist?(directory)
|
16
|
+
new(IronBank.client).export
|
17
|
+
reset
|
18
|
+
import
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.for(object_name)
|
22
|
+
import[object_name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.import
|
26
|
+
@import ||= Dir["#{directory}/*.xml"].each.with_object({}) do |name, data|
|
27
|
+
doc = File.open(name) { |file| Nokogiri::XML(file) }
|
28
|
+
object = IronBank::Describe::Object.from_xml(doc)
|
29
|
+
data[object.name] = object
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.reset
|
34
|
+
@import = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def export
|
38
|
+
tenant.objects.compact.each do |object|
|
39
|
+
begin
|
40
|
+
object.export
|
41
|
+
rescue IronBank::Describe::Object::InvalidXML
|
42
|
+
# TODO: log the object error
|
43
|
+
next
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
attr_reader :client
|
49
|
+
|
50
|
+
def initialize(client)
|
51
|
+
@client = client
|
52
|
+
end
|
53
|
+
|
54
|
+
def tenant
|
55
|
+
@tenant ||= IronBank::Describe::Tenant.from_connection(client.connection)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IronBank
|
4
|
+
# A few helper methods for interacting with Zuora
|
5
|
+
#
|
6
|
+
module Utils
|
7
|
+
module_function
|
8
|
+
|
9
|
+
# Inspired from ActiveSupport
|
10
|
+
def underscore(camel_cased_word)
|
11
|
+
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
|
12
|
+
|
13
|
+
word = camel_cased_word.to_s.gsub(/::/, '/')
|
14
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
15
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
16
|
+
word.tr!('-', '_')
|
17
|
+
word.downcase
|
18
|
+
end
|
19
|
+
|
20
|
+
def camelize(term, type: :upper)
|
21
|
+
# Preserve custom field term postfix, in the '__c' or the '__NS' format
|
22
|
+
custom_field = (term.to_s =~ /__c$/i)
|
23
|
+
netsuite_field = (term.to_s =~ /__NS$/i)
|
24
|
+
lower_camelize = type == :lower
|
25
|
+
|
26
|
+
output = term.to_s.dup.tap do |copy|
|
27
|
+
copy.gsub!(/^_*/, '')
|
28
|
+
copy.gsub!(/__(NS|c)$/i, '') if custom_field || netsuite_field
|
29
|
+
|
30
|
+
lower_camelize ? lower_camelize(copy) : upper_camelize(copy)
|
31
|
+
end
|
32
|
+
|
33
|
+
if custom_field
|
34
|
+
"#{output}__c"
|
35
|
+
elsif netsuite_field
|
36
|
+
"#{output}__NS"
|
37
|
+
else
|
38
|
+
output
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def kebab(term)
|
43
|
+
underscore(term).tr!('_', '-')
|
44
|
+
end
|
45
|
+
|
46
|
+
def lower_camelize(term)
|
47
|
+
term.gsub!(/(^|_)(.)/) do
|
48
|
+
match = Regexp.last_match
|
49
|
+
char = match[2]
|
50
|
+
|
51
|
+
match.begin(2).zero? ? char : char.upcase
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def upper_camelize(term)
|
56
|
+
term.gsub!(/(^|_)(.)/) { Regexp.last_match(2).upcase }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/iron_bank/version.rb
CHANGED
data/lib/iron_bank.rb
CHANGED
@@ -1,5 +1,155 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# External librairies
|
4
|
+
require 'csv'
|
5
|
+
require 'faraday'
|
6
|
+
require 'faraday_middleware'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'json'
|
9
|
+
require 'nokogiri'
|
10
|
+
require 'ddtrace'
|
2
11
|
|
12
|
+
# An opinionated Ruby interface to the Zuora REST API
|
3
13
|
module IronBank
|
4
|
-
|
14
|
+
class << self
|
15
|
+
# Holds an instance of IronBank::Client which becomes the default for many
|
16
|
+
# query and other actions requiring a connection to Zuora.
|
17
|
+
attr_accessor :client
|
18
|
+
|
19
|
+
# Configurable options such as schema directory.
|
20
|
+
attr_accessor :configuration
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configure
|
24
|
+
self.configuration ||= Configuration.new
|
25
|
+
yield(configuration)
|
26
|
+
|
27
|
+
return unless configuration.credentials?
|
28
|
+
|
29
|
+
self.client ||= IronBank::Client.new(configuration.credentials)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.logger
|
33
|
+
self.configuration.logger
|
34
|
+
end
|
35
|
+
|
36
|
+
# Zuora actions, e.g., subscribe, amend, etc.
|
37
|
+
module Actions; end
|
38
|
+
|
39
|
+
# Metadata describe
|
40
|
+
module Describe; end
|
41
|
+
|
42
|
+
# Zuora resources
|
43
|
+
module Resources; end
|
44
|
+
|
45
|
+
# Zuora operations, e.g., billing-preview
|
46
|
+
module Operations; end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Utilities
|
50
|
+
require 'iron_bank/logger'
|
51
|
+
require 'iron_bank/cacheable'
|
52
|
+
require 'iron_bank/configuration'
|
53
|
+
require 'iron_bank/endpoint'
|
54
|
+
require 'iron_bank/local_records'
|
55
|
+
require 'iron_bank/local'
|
56
|
+
require 'iron_bank/utils'
|
57
|
+
require 'iron_bank/version'
|
58
|
+
require 'iron_bank/csv'
|
59
|
+
require 'iron_bank/error'
|
60
|
+
require 'iron_bank/response/raise_error'
|
61
|
+
|
62
|
+
# Helpers
|
63
|
+
require 'iron_bank/open_tracing'
|
64
|
+
require 'iron_bank/instrumentation'
|
65
|
+
|
66
|
+
# Use default configuration
|
67
|
+
IronBank.configure {}
|
68
|
+
|
69
|
+
# Actions
|
70
|
+
require 'iron_bank/action'
|
71
|
+
require 'iron_bank/actions/amend'
|
72
|
+
require 'iron_bank/actions/create'
|
73
|
+
require 'iron_bank/actions/delete'
|
74
|
+
require 'iron_bank/actions/execute'
|
75
|
+
require 'iron_bank/actions/generate'
|
76
|
+
require 'iron_bank/actions/subscribe'
|
77
|
+
require 'iron_bank/actions/update'
|
78
|
+
require 'iron_bank/actions/query'
|
79
|
+
require 'iron_bank/actions/query_more'
|
80
|
+
|
81
|
+
# Client and schema (describe)
|
82
|
+
require 'iron_bank/authentication'
|
83
|
+
require 'iron_bank/authentications/cookie'
|
84
|
+
require 'iron_bank/authentications/token'
|
85
|
+
require 'iron_bank/client'
|
86
|
+
require 'iron_bank/describe/field'
|
87
|
+
require 'iron_bank/describe/object'
|
88
|
+
require 'iron_bank/describe/related'
|
89
|
+
require 'iron_bank/describe/tenant'
|
90
|
+
require 'iron_bank/object'
|
91
|
+
require 'iron_bank/schema'
|
92
|
+
require 'iron_bank/query_builder'
|
93
|
+
|
94
|
+
# Operations
|
95
|
+
require 'iron_bank/operation'
|
96
|
+
require 'iron_bank/operations/billing_preview'
|
97
|
+
|
98
|
+
# Resources
|
99
|
+
require 'iron_bank/associations'
|
100
|
+
require 'iron_bank/metadata'
|
101
|
+
require 'iron_bank/queryable'
|
102
|
+
require 'iron_bank/resource'
|
103
|
+
require 'iron_bank/collection'
|
104
|
+
require 'iron_bank/resources/account'
|
105
|
+
require 'iron_bank/resources/amendment'
|
106
|
+
require 'iron_bank/resources/contact'
|
107
|
+
require 'iron_bank/resources/export'
|
108
|
+
require 'iron_bank/resources/import'
|
109
|
+
require 'iron_bank/resources/invoice_adjustment'
|
110
|
+
require 'iron_bank/resources/invoice_item'
|
111
|
+
require 'iron_bank/resources/invoice_payment'
|
112
|
+
require 'iron_bank/resources/invoice'
|
113
|
+
require 'iron_bank/resources/payment_method'
|
114
|
+
require 'iron_bank/resources/payment'
|
115
|
+
require 'iron_bank/resources/product_rate_plan_charge_tier'
|
116
|
+
require 'iron_bank/resources/product_rate_plan_charge'
|
117
|
+
require 'iron_bank/resources/product_rate_plan'
|
118
|
+
require 'iron_bank/resources/product'
|
119
|
+
require 'iron_bank/resources/rate_plan_charge_tier'
|
120
|
+
require 'iron_bank/resources/rate_plan_charge'
|
121
|
+
require 'iron_bank/resources/rate_plan'
|
122
|
+
require 'iron_bank/resources/subscription'
|
123
|
+
require 'iron_bank/resources/usage'
|
124
|
+
require 'iron_bank/resources/catalog_tiers/discount_amount'
|
125
|
+
require 'iron_bank/resources/catalog_tiers/discount_percentage'
|
126
|
+
require 'iron_bank/resources/catalog_tiers/price'
|
127
|
+
|
128
|
+
# Aliasing IronBank::Actions::* to IronBank::*
|
129
|
+
IronBank::Actions.constants.each do |action|
|
130
|
+
IronBank.const_set(action, IronBank::Actions.const_get(action))
|
131
|
+
end
|
132
|
+
|
133
|
+
# Aliasing IronBank::Resources::* to IronBank::*
|
134
|
+
IronBank::Resources.constants.each do |resource|
|
135
|
+
IronBank.const_set(resource, IronBank::Resources.const_get(resource))
|
136
|
+
end
|
137
|
+
|
138
|
+
# Aliasing catalog-related objects
|
139
|
+
IronBank::CatalogPlan = IronBank::Resources::ProductRatePlan
|
140
|
+
IronBank::CatalogCharge = IronBank::Resources::ProductRatePlanCharge
|
141
|
+
IronBank::CatalogTier = IronBank::Resources::ProductRatePlanChargeTier
|
142
|
+
|
143
|
+
# Aliasing subscription-related objects
|
144
|
+
IronBank::Plan = IronBank::Resources::RatePlan
|
145
|
+
IronBank::Charge = IronBank::Resources::RatePlanCharge
|
146
|
+
IronBank::Tier = IronBank::Resources::RatePlanChargeTier
|
147
|
+
|
148
|
+
Datadog.configure do |config|
|
149
|
+
config.tracer(
|
150
|
+
enabled: IronBank.configuration.open_tracing_enabled
|
151
|
+
)
|
152
|
+
# registers the tracing middleware.
|
153
|
+
config.use :faraday,
|
154
|
+
service_name: IronBank.configuration.open_tracing_service_name
|
5
155
|
end
|