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/type/boolean.rb,
lib/ledger_sync/type/integer.rb,
lib/ledger_sync/resources/bill.rb,
lib/ledger_sync/util/performer.rb,
lib/ledger_sync/util/validator.rb,
lib/ledger_sync/adaptors/adaptor.rb,
lib/ledger_sync/resources/vendor.rb,
lib/ledger_sync/type/value_mixin.rb,
lib/ledger_sync/adaptors/contract.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/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/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/adaptor_configuration.rb,
lib/ledger_sync/adaptors/test/adaptor.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/util/resources_builder.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/ledger_serializer.rb,
lib/ledger_sync/adaptor_configuration_store.rb,
lib/ledger_sync/resources/deposit_line_item.rb,
lib/ledger_sync/resources/expense_line_item.rb,
lib/ledger_sync/adaptors/test/operation/find.rb,
lib/ledger_sync/resource_attribute/reference.rb,
lib/ledger_sync/adaptors/test/vendor/searcher.rb,
lib/ledger_sync/adaptors/test/account/searcher.rb,
lib/ledger_sync/adaptors/test/operation/create.rb,
lib/ledger_sync/adaptors/test/operation/update.rb,
lib/ledger_sync/resource_attribute/dirty_mixin.rb,
lib/ledger_sync/adaptors/test/customer/searcher.rb,
lib/ledger_sync/adaptors/test/ledger_serializer.rb,
lib/ledger_sync/resource_attribute/reference/one.rb,
lib/ledger_sync/resource_attribute/reference/many.rb,
lib/ledger_sync/resources/journal_entry_line_item.rb,
lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb,
lib/ledger_sync/adaptors/quickbooks_online/searcher.rb,
lib/ledger_sync/adaptors/ledger_serializer_attribute.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation.rb,
lib/ledger_sync/adaptors/test/vendor/operations/find.rb,
lib/ledger_sync/adaptors/test/account/operations/find.rb,
lib/ledger_sync/adaptors/test/expense/operations/find.rb,
lib/ledger_sync/adaptors/test/payment/operations/find.rb,
lib/ledger_sync/adaptors/test/vendor/operations/valid.rb,
lib/ledger_sync/adaptors/test/account/operations/valid.rb,
lib/ledger_sync/adaptors/test/customer/operations/find.rb,
lib/ledger_sync/adaptors/test/transfer/operations/find.rb,
lib/ledger_sync/adaptors/test/vendor/operations/create.rb,
lib/ledger_sync/adaptors/test/vendor/operations/update.rb,
lib/ledger_sync/adaptors/test/account/operations/create.rb,
lib/ledger_sync/adaptors/test/account/operations/update.rb,
lib/ledger_sync/adaptors/test/customer/operations/valid.rb,
lib/ledger_sync/adaptors/test/expense/operations/create.rb,
lib/ledger_sync/adaptors/test/expense/operations/update.rb,
lib/ledger_sync/adaptors/test/payment/operations/create.rb,
lib/ledger_sync/adaptors/test/payment/operations/update.rb,
lib/ledger_sync/adaptors/test/vendor/operations/invalid.rb,
lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/searcher.rb,
lib/ledger_sync/adaptors/test/account/operations/invalid.rb,
lib/ledger_sync/adaptors/test/customer/operations/create.rb,
lib/ledger_sync/adaptors/test/customer/operations/update.rb,
lib/ledger_sync/adaptors/test/transfer/operations/create.rb,
lib/ledger_sync/adaptors/test/transfer/operations/update.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/find.rb,
lib/ledger_sync/adaptors/test/customer/operations/invalid.rb,
lib/ledger_sync/adaptors/ledger_serializer_type/value_type.rb,
lib/ledger_sync/adaptors/quickbooks_online/vendor/searcher.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/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/quickbooks_online/util/error_matcher.rb,
lib/ledger_sync/adaptors/quickbooks_online/bill/operations/find.rb,
lib/ledger_sync/adaptors/quickbooks_online/operation/full_update.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/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/operation/sparse_update.rb,
lib/ledger_sync/adaptors/quickbooks_online/payment/operations/find.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/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/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/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/quickbooks_online/journal_entry/operations/find.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/test/error/adaptor_error/operations/throttle_error.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/ledger_serializer_type/account_sub_type.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/journal_entry_line_item_type.rb

Overview

Defined Under Namespace

Modules: Adaptors, ResultBase, Type, Util, Validatable Classes: Account, AdaptorConfiguration, AdaptorConfigurationStore, Bill, BillLineItem, Customer, Deposit, DepositLineItem, Error, Expense, ExpenseLineItem, JournalEntry, JournalEntryLineItem, OperationResult, Payment, Resource, ResourceAttribute, ResourceAttributeSet, ResourceError, Result, SearchResult, 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.1.3'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adaptorsObject

Returns the value of attribute adaptors.



66
67
68
# File 'lib/ledger_sync.rb', line 66

def adaptors
  @adaptors
end

.resourcesObject

Returns the value of attribute resources.



66
67
68
# File 'lib/ledger_sync.rb', line 66

def resources
  @resources
end

Class Method Details

.log_levelObject



69
70
71
# File 'lib/ledger_sync.rb', line 69

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object

Raises:

  • (ArgumentError)


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

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



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

def self.logger
  @logger
end

.logger=(val) ⇒ Object



83
84
85
# File 'lib/ledger_sync.rb', line 83

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

.register_adaptor(adaptor_key) {|adaptors.send(adaptor_key)| ... } ⇒ Object

Yields:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ledger_sync.rb', line 87

def self.register_adaptor(adaptor_key)
  adaptor_root_path = "ledger_sync/adaptors/#{adaptor_key}"
  require "#{adaptor_root_path}/adaptor"
  self.adaptors ||= LedgerSync::AdaptorConfigurationStore.new
  self.adaptors.register_adaptor(adaptor_key)

  yield(adaptors.send(adaptor_key))

  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



104
105
106
107
108
109
# File 'lib/ledger_sync.rb', line 104

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



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

def self.root
  File.dirname __dir__
end