Module: Alula::ApiOperations::Request
- Included in:
- BillingProgram, Dealer, DealerAccountTransfer, DealerAddress, DealerBranding, DealerPhone, DealerProgram, DealerSuspensionLog, Device, DeviceAlias, DeviceCellularStatus, DeviceCharge, DeviceCredit, DeviceEventLog, DeviceNotification, DeviceProgram, EventTrigger, EventWebhook, FeatureBySubject, FeaturePlan, FeaturePlanVideo, FeaturePrice, OAuthClient, ReceiverDisabled, ReceiverGroup, Revision, Station, User, UserAddress, UserPhone, UserPreferences, UserPushtoken, UserVideoProfile, Video::Device, VideoVerificationCamera
- Defined in:
- lib/alula/api_operations/request.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
Instance Method Summary collapse
- #build_and_merge_item_relationships(item, relations) ⇒ Object
-
#retrieve(id, built_filters = {}) ⇒ Object
Load a single model by ID.
Class Method Details
.extended(base) ⇒ Object
4 5 6 |
# File 'lib/alula/api_operations/request.rb', line 4 def self.extended(base) base.include(InstanceMethods) end |
Instance Method Details
#build_and_merge_item_relationships(item, relations) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/alula/api_operations/request.rb', line 22 def build_and_merge_item_relationships(item, relations) relations.each do |relation| model = Alula.class_from_resource_type(relation['type']) model = model.new.construct_from(relation) # # TODO: Remove this line. This makes us ignore unknown relationships unless get_relationship(model.get_type).nil? item.add_model_to_relationship(model) end end item end |
#retrieve(id, built_filters = {}) ⇒ Object
Load a single model by ID
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/alula/api_operations/request.rb', line 9 def retrieve(id, built_filters = {}) response = Alula::Client.request(:get, self.resource_url(id), built_filters, {}) if response.ok? item = self.new.construct_from(response.data['data']) item = build_and_merge_item_relationships(item, response.data['included']) if response.data['included'] item.rate_limit = response.rate_limit item else error_class = AlulaError.for_response(response) raise error_class end end |