Class: AutotaskApi::Entity
- Inherits:
-
Object
- Object
- AutotaskApi::Entity
show all
- Defined in:
- lib/autotask_api/entity.rb
Direct Known Subclasses
Account, AccountLocation, AccountTeam, AllocationCode, BillingItem, Contact, Contract, ContractBlock, ContractCost, ContractExclusionAllocationCode, ContractExclusionRole, ContractFactor, ContractMilestone, ContractRate, ContractRetainer, ContractRoleCost, ContractService, ContractServiceAdjustment, ContractServiceBundle, ContractServiceBundleAdjustment, ContractServiceBundleUnit, ContractServiceUnit, ContractTicketPurchase, Country, Department, ExpenseItem, ExpenseReport, InstalledProduct, InstalledProductType, InternalLocation, InventoryItem, InventoryLocation, Invoice, Opportunity, PaymentTerm, Phase, Product, Project, ProjectCost, ProjectNote, PurchaseOrderItem, Quote, QuoteItem, QuoteLocation, Resource, ResourceRole, ResourceSkill, Role, SalesOrder, Service, ServiceBundle, ServiceBundleService, ServiceCall, ServiceCallTask, ServiceCallTaskResource, ServiceCallTicket, ServiceCallTicketResource, Skill, Task, TaskPredecessor, TaskSecondaryResource, Tax, TaxCategory, TaxRegion, Ticket, TicketCost, TicketSecondaryResource, TimeEntry
Class Method Summary
collapse
Class Method Details
.all(client = AutotaskApi.client, id = 1) ⇒ Object
.clean_results(results) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/autotask_api/entity.rb', line 40
def self.clean_results(results)
results.each do |record|
record.update(record) { |_k, v| v == { :"@xsi:type" => "xsd:string" } ? nil : v }
.delete('@xsi:type'.to_sym)
end
return results
end
|
.expression(value) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/autotask_api/entity.rb', line 28
def self.expression(value)
case value.class
when TrueClass
1
when FalseClass
0
else
value
end
end
|
.where(condition, client = AutotaskApi.client) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/autotask_api/entity.rb', line 9
def self.where(condition, client = AutotaskApi.client)
query = Query.new(self::NAME, condition, client)
begin
response = query.fetch
rescue RuntimeError => e
raise Error.new(e.message)
end
return EntityCollection.new(self, [], condition, client) if response[:entity_results].nil?
results = response[:entity_results][:entity]
results = [results] unless results.is_a?(Array)
results = clean_results(results)
EntityCollection.new(self, results, condition, client)
end
|