module QboApi::Entity
Public Instance Methods
entity_path(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 15 def entity_path(entity) "#{realm_id}/#{singular(entity).downcase}" end
extract_entity_from_query(query, to_sym: false)
click to toggle source
# File lib/qbo_api/entity.rb, line 96 def extract_entity_from_query(query, to_sym: false) if m = query.match(/from\s+(\w+)(?:$|\s)/i) (to_sym ? underscore(m[1]).to_sym : m[1]) if m[1] end end
is_name_list_entity?(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 60 def is_name_list_entity?(entity) name_list_entities.include?(singular(entity)) end
is_transaction_entity?(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 36 def is_transaction_entity?(entity) transaction_entities.include?(singular(entity)) end
is_voidable_transaction_entity?(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 23 def is_voidable_transaction_entity?(entity) voidable_transaction_entities.include?(singular(entity)) end
name_list_entities()
click to toggle source
# File lib/qbo_api/entity.rb, line 64 def name_list_entities %w{ Account Budget Class CompanyCurrency Customer Department Employee Item JournalCode PaymentMethod TaxAgency TaxCode TaxRate TaxService Term Vendor } end
singular(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 3 def singular(entity) e = snake_to_camel(entity) case e when 'Classes', 'Class' 'Class' when 'Entitlements', 'Preferences' e else e.chomp('s') end end
snake_to_camel(sym)
click to toggle source
# File lib/qbo_api/entity.rb, line 19 def snake_to_camel(sym) sym.to_s.split('_').collect(&:capitalize).join end
supporting_entities()
click to toggle source
# File lib/qbo_api/entity.rb, line 85 def supporting_entities %w{ Attachable Batch CompanyInfo Entitlements ExchangeRate Preferences } end
transaction_entities()
click to toggle source
# File lib/qbo_api/entity.rb, line 40 def transaction_entities %w{ Bill BillPayment CreditMemo Deposit Estimate Invoice JournalEntry Payment Purchase PurchaseOrder RefundReceipt SalesReceipt TimeActivity Transfer VendorCredit } end
voidable_transaction_entities()
click to toggle source
# File lib/qbo_api/entity.rb, line 27 def voidable_transaction_entities %w{ BillPayment Invoice Payment SalesReceipt } end
Private Instance Methods
underscore(entity)
click to toggle source
# File lib/qbo_api/entity.rb, line 104 def underscore(entity) entity.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase end