Class: BusinessCentral::Base
- Inherits:
-
Object
- Object
- BusinessCentral::Base
- Includes:
- ApiMethods
- Defined in:
- lib/business_central/base.rb
Direct Known Subclasses
Account, AgedAccountsPayable, AgedAccountsReceivable, BalanceSheet, CashFlowStatement, Company, CompanyInformation, CountriesRegion, Currency, Customer, CustomerFinancialDetails, CustomerPayment, CustomerPaymentsJournal, CustomerSales, Dimension, DimensionLine, Employee, GeneralLedgerEntry, IncomeStatement, Irs1099Code, Item, ItemCategory, Journal, JournalLine, PaymentMethod, PaymentTerm, Picture, PurchaseInvoice, PurchaseInvoiceLine, RetainedEarningsStatement, SalesCreditMemo, SalesCreditMemoLine, SalesInvoice, SalesInvoiceLine, SalesOrder, SalesOrderLine, SalesQuote, SalesQuoteLine, ShipmentMethod, Subscription, TaxArea, TaxGroup, TrialBalance, UnitOfMeasure, Vendor, VendorPurchase
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#build_url(parent_id, child_id = nil) ⇒ Object
Use the BusinessCentral::URLBuilder to create the URL to query the API.
-
#initialize(client) ⇒ Base
constructor
The
Base
class used to provide functionality to subclasses. -
#process(response) ⇒ Object
Use a BusinessCentral::Response::ResponseHandler to proces the results from the API query.
Methods included from ApiMethods
#create, #delete, #get, #get_child, #method_missing, #query, #query_child, #update
Constructor Details
#initialize(client) ⇒ Base
The Base
class used to provide functionality to subclasses
15 16 17 |
# File 'lib/business_central/base.rb', line 15 def initialize(client) @client = client.nil? ? BusinessCentral::Client.new() : client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BusinessCentral::ApiMethods
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/business_central/base.rb', line 9 def client @client end |
Instance Method Details
#build_url(parent_id, child_id = nil) ⇒ Object
Use the BusinessCentral::URLBuilder to create the URL to query the API
35 36 37 38 39 40 41 42 43 |
# File 'lib/business_central/base.rb', line 35 def build_url(parent_id, child_id = nil) = { child_path: api_object } if !child_id.nil? [:child_id] = child_id end BusinessCentral::URLBuilder.new(api_object_parent, parent_id, ).url end |
#process(response) ⇒ Object
Use a BusinessCentral::Response::ResponseHandler to proces the results from the API query
24 25 26 27 28 |
# File 'lib/business_central/base.rb', line 24 def process(response) BusinessCentral::Response::ResponseHandler. new(@client.dataset(response)). compiled_data end |