Module: LedgerSync

Defined in:
lib/ledger_sync/resource.rb,
lib/ledger_sync.rb,
lib/ledger_sync/error.rb,
lib/ledger_sync/result.rb,
lib/ledger_sync/type/id.rb,
lib/ledger_sync/version.rb,
lib/ledger_sync/type/date.rb,
lib/ledger_sync/type/float.rb,
lib/ledger_sync/type/value.rb,
lib/ledger_sync/type/string.rb,
lib/ledger_sync/util/signer.rb,
lib/ledger_sync/type/boolean.rb,
lib/ledger_sync/type/integer.rb,
lib/ledger_sync/resources/bill.rb,
lib/ledger_sync/resources/item.rb,
lib/ledger_sync/util/performer.rb,
lib/ledger_sync/util/validator.rb,
lib/ledger_sync/adaptors/adaptor.rb,
lib/ledger_sync/adaptors/request.rb,
lib/ledger_sync/resources/vendor.rb,
lib/ledger_sync/type/value_mixin.rb,
lib/ledger_sync/adaptors/contract.rb,
lib/ledger_sync/adaptors/response.rb,
lib/ledger_sync/adaptors/searcher.rb,
lib/ledger_sync/resources/account.rb,
lib/ledger_sync/resources/deposit.rb,
lib/ledger_sync/resources/expense.rb,
lib/ledger_sync/resources/invoice.rb,
lib/ledger_sync/resources/payment.rb,
lib/ledger_sync/util/hash_helpers.rb,
lib/ledger_sync/adaptors/operation.rb,
lib/ledger_sync/resource_attribute.rb,
lib/ledger_sync/resources/currency.rb,
lib/ledger_sync/resources/customer.rb,
lib/ledger_sync/resources/transfer.rb,
lib/ledger_sync/type/reference_one.rb,
lib/ledger_sync/type/reference_many.rb,
lib/ledger_sync/util/string_helpers.rb,
lib/ledger_sync/concerns/validatable.rb,
lib/ledger_sync/error/adaptor_errors.rb,
lib/ledger_sync/resources/department.rb,
lib/ledger_sync/resources/subsidiary.rb,
lib/ledger_sync/adaptor_configuration.rb,
lib/ledger_sync/error/resource_errors.rb,
lib/ledger_sync/error/operation_errors.rb,
lib/ledger_sync/resource_attribute_set.rb,
lib/ledger_sync/resources/ledger_class.rb,
lib/ledger_sync/util/resources_builder.rb,
lib/ledger_sync/adaptors/netsuite/token.rb,
lib/ledger_sync/adaptors/stripe/adaptor.rb,
lib/ledger_sync/resources/journal_entry.rb,
lib/ledger_sync/resource_attribute/mixin.rb,
lib/ledger_sync/resources/bill_line_item.rb,
lib/ledger_sync/adaptors/netsuite/adaptor.rb,
lib/ledger_sync/adaptors/stripe/operation.rb,
lib/ledger_sync/adaptors/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/searcher.rb,
lib/ledger_sync/adaptor_configuration_store.rb,
lib/ledger_sync/adaptors/netsuite/operation.rb,
lib/ledger_sync/resources/deposit_line_item.rb,
lib/ledger_sync/resources/expense_line_item.rb,
lib/ledger_sync/resources/payment_line_item.rb,
lib/ledger_sync/resource_attribute/reference.rb,
lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb,
lib/ledger_sync/adaptors/stripe/operation/find.rb,
lib/ledger_sync/resource_attribute/dirty_mixin.rb,
lib/ledger_sync/adaptors/test/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/operation/find.rb,
lib/ledger_sync/adaptors/netsuite_soap/operation.rb,
lib/ledger_sync/adaptors/stripe/operation/create.rb,
lib/ledger_sync/adaptors/stripe/operation/delete.rb,
lib/ledger_sync/adaptors/stripe/operation/update.rb,
lib/ledger_sync/resource_attribute/reference/one.rb,
lib/ledger_sync/adaptors/netsuite/record/metadata.rb,
lib/ledger_sync/adaptors/netsuite/record/property.rb,
lib/ledger_sync/resource_attribute/reference/many.rb,
lib/ledger_sync/resources/invoice_sales_line_item.rb,
lib/ledger_sync/resources/journal_entry_line_item.rb,
lib/ledger_sync/adaptors/netsuite/account/searcher.rb,
lib/ledger_sync/adaptors/netsuite/operation/create.rb,
lib/ledger_sync/adaptors/netsuite/operation/delete.rb,
lib/ledger_sync/adaptors/netsuite/operation/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb,
lib/ledger_sync/adaptors/quickbooks_online/request.rb,
lib/ledger_sync/adaptors/quickbooks_online/webhook.rb,
lib/ledger_sync/adaptors/netsuite/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/searcher.rb,
lib/ledger_sync/adaptors/ledger_serializer_attribute.rb,
lib/ledger_sync/adaptors/netsuite/record/http_method.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation.rb,
lib/ledger_sync/adaptors/netsuite_soap/operation/find.rb,
lib/ledger_sync/adaptors/netsuite_soap/operation/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb,
lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb,
lib/ledger_sync/adaptors/netsuite/vendor/operations/find.rb,
lib/ledger_sync/adaptors/netsuite_soap/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/webhook_event.rb,
lib/ledger_sync/adaptors/stripe/customer/operations/find.rb,
lib/ledger_sync/adaptors/test/customer/ledger_serializer.rb,
lib/ledger_sync/adaptors/mixins/infer_adaptor_class_mixin.rb,
lib/ledger_sync/adaptors/netsuite/account/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/find.rb,
lib/ledger_sync/adaptors/ledger_serializer_type/value_type.rb,
lib/ledger_sync/adaptors/mixins/infer_resource_class_mixin.rb,
lib/ledger_sync/adaptors/netsuite/currency/operations/find.rb,
lib/ledger_sync/adaptors/netsuite/customer/operations/find.rb,
lib/ledger_sync/adaptors/netsuite/vendor/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/vendor/operations/create.rb,
lib/ledger_sync/adaptors/netsuite/vendor/operations/delete.rb,
lib/ledger_sync/adaptors/netsuite/vendor/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/searcher.rb,
lib/ledger_sync/adaptors/stripe/customer/operations/create.rb,
lib/ledger_sync/adaptors/stripe/customer/operations/delete.rb,
lib/ledger_sync/adaptors/stripe/customer/operations/update.rb,
lib/ledger_sync/adaptors/netsuite/account/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/account/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/account/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/create.rb,
lib/ledger_sync/adaptors/ledger_serializer_type/mapping_type.rb,
lib/ledger_sync/adaptors/netsuite/currency/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/currency/operations/create.rb,
lib/ledger_sync/adaptors/netsuite/currency/operations/delete.rb,
lib/ledger_sync/adaptors/netsuite/currency/operations/update.rb,
lib/ledger_sync/adaptors/netsuite/customer/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/customer/operations/create.rb,
lib/ledger_sync/adaptors/netsuite/customer/operations/delete.rb,
lib/ledger_sync/adaptors/netsuite/customer/operations/update.rb,
lib/ledger_sync/adaptors/netsuite/vendor/ledger_deserializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/customer/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/util/error_parser.rb,
lib/ledger_sync/adaptors/mixins/infer_ledger_serializer_mixin.rb,
lib/ledger_sync/adaptors/netsuite/account/ledger_deserializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb,
lib/ledger_sync/adaptors/netsuite/currency/deledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite/customer/ledger_deserializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/department/searcher.rb,
lib/ledger_sync/adaptors/mixins/infer_validation_contract_mixin.rb,
lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/dashboard_url_helper.rb,
lib/ledger_sync/adaptors/quickbooks_online/webhook_notification.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_class/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/full_update.rb,
lib/ledger_sync/adaptors/netsuite_soap/customer/ledger_serializer.rb,
lib/ledger_sync/adaptors/netsuite_soap/customer/operations/create.rb,
lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry/searcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/account/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/sparse_update.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment/operations/find.rb,
lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb,
lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/customer/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/transfer/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/update.rb,
lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/account/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/account/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/account/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/invoice/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/util/adaptor_error_parser.rb,
lib/ledger_sync/adaptors/quickbooks_online/currency/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/customer/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/customer/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/customer/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/department/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/transfer/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/transfer/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/transfer/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/util/operation_error_parser.rb,
lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/reference_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/department/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/department/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/department/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/find.rb,
lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/subsidiary_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_class/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/update.rb,
lib/ledger_sync/adaptors/mixins/offset_and_limit_pagination_searcher_mixin.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry/operations/create.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/date_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/amount_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/deposit_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/expense_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/account_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/payment_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/account_sub_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/invoice_sales_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/journal_entry_line_item/ledger_serializer.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/classification_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/entity_reference_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/transaction_reference_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/journal_entry_line_item_type.rb

Overview

Defined Under Namespace

Modules: Adaptors, ResultBase, Type, Util, Validatable Classes: Account, AdaptorConfiguration, AdaptorConfigurationStore, Bill, BillLineItem, Currency, Customer, Department, Deposit, DepositLineItem, Error, Expense, ExpenseLineItem, Invoice, InvoiceSalesLineItem, Item, JournalEntry, JournalEntryLineItem, LedgerClass, OperationResult, Payment, PaymentLineItem, Resource, ResourceAttribute, ResourceAttributeSet, ResourceError, Result, SearchResult, Subsidiary, Transfer, ValidationResult, Vendor

Constant Summary collapse

LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
VERSION =
'1.3.3'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adaptorsObject

Returns the value of attribute adaptors.



72
73
74
# File 'lib/ledger_sync.rb', line 72

def adaptors
  @adaptors
end

.resourcesObject

Returns the value of attribute resources.



72
73
74
# File 'lib/ledger_sync.rb', line 72

def resources
  @resources
end

Class Method Details

.log_levelObject



75
76
77
# File 'lib/ledger_sync.rb', line 75

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object

Raises:

  • (ArgumentError)


79
80
81
82
83
# File 'lib/ledger_sync.rb', line 79

def self.log_level=(val)
  raise ArgumentError, 'log_level should only be set to `nil`, `debug` or `info`' if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)

  @log_level = val
end

.loggerObject



85
86
87
# File 'lib/ledger_sync.rb', line 85

def self.logger
  @logger
end

.logger=(val) ⇒ Object



89
90
91
# File 'lib/ledger_sync.rb', line 89

def self.logger=(val)
  @logger = val
end

.register_adaptor(adaptor_key, module_string: nil) {|adaptor_config| ... } ⇒ Object

Yields:

  • (adaptor_config)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ledger_sync.rb', line 93

def self.register_adaptor(adaptor_key, module_string: nil)
  adaptor_root_path = "ledger_sync/adaptors/#{adaptor_key}"
  require "#{adaptor_root_path}/adaptor"
  self.adaptors ||= LedgerSync::AdaptorConfigurationStore.new
  adaptor_config = LedgerSync::AdaptorConfiguration.new(adaptor_key, module_string: module_string)
  yield(adaptor_config)
  self.adaptors.register_adaptor(adaptor_config: adaptor_config)

  adaptor_files = Gem.find_files("#{adaptor_root_path}/**/*.rb")
  # Sort the files to include BFS-style as most dependencies are in parent folders
  adaptor_files.sort { |a, b| a.count('/') <=> b.count('/') }.each do |path|
    next if path.include?('config.rb')

    require path
  end
end

.register_resource(resource:) ⇒ Object



110
111
112
113
114
115
# File 'lib/ledger_sync.rb', line 110

def self.register_resource(resource:)
  self.resources ||= {}
  raise "Resource key #{resource.resource_type} already exists." if resources.key?(resource.resource_type)

  self.resources[resource.resource_type] = resource
end

.rootObject



117
118
119
# File 'lib/ledger_sync.rb', line 117

def self.root
  File.dirname __dir__
end