Module: Alula::ApiOperations::List
- Included in:
- BillingProgram, Dealer, DealerAccountTransfer, DealerAddress, DealerPhone, DealerProgram, DealerSuspensionLog, Device, DeviceAlias, DeviceCellularStatus, DeviceCharge, DeviceCredit, DeviceEventLog, DeviceNotification, DeviceProgram, DeviceUser, EventTrigger, EventWebhook, FeatureBySubject, FeaturePlan, FeaturePlanVideo, FeaturePrice, HelixUser, OAuthClient, ReceiverConnection, ReceiverDisabled, ReceiverGroup, Revision, Station, User, UserAddress, UserPhone, UserPreferences, UserPushtoken, UserVideoProfile, VideoVerificationCamera
- Defined in:
- lib/alula/api_operations/list.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
8
9
10
|
# File 'lib/alula/api_operations/list.rb', line 8
def method_missing(method, *args, &block)
QueryInterface.new(self).send(method, *args, &block)
end
|
Class Method Details
.extended(base) ⇒ Object
4
5
6
|
# File 'lib/alula/api_operations/list.rb', line 4
def self.extended(base)
base.include(InstanceMethods)
end
|
Instance Method Details
#build_and_merge_list_relationships(collection, relations) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/alula/api_operations/list.rb', line 24
def build_and_merge_list_relationships(collection, relations)
relations.each do |relation|
model = Alula.class_from_resource_type(relation['type'])
model = model.new.construct_from(relation)
key = { type: model.get_type, id: model.id }.freeze
unless get_relationship(model.get_type).nil?
collection.select{ |m| m.link_matchers.include?(key) }
.each { |m| m.add_model_to_relationship(model) }
end
end
collection
end
|
#list(filters = {}, opts = {}) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/alula/api_operations/list.rb', line 12
def list(filters = {}, opts = {})
response = Alula::Client.request(:get, resource_url, filters, opts)
if response.ok?
list = ListObject.construct_from_response(self, response, opts)
list = build_and_merge_list_relationships(list, response.data['included']) if response.data['included']
list
else
error_class = AlulaError.for_response(response)
raise error_class
end
end
|