lib/cradlepoint/router.rb in cradlepoint-0.2.4 vs lib/cradlepoint/router.rb in cradlepoint-0.2.5

- old
+ new

@@ -2,11 +2,12 @@ class Router < CradlepointObject attr_accessor :id, :data, :ecm_firmware_uri, :ecm_configuration_uri, :ecm_configuration_manager_uri, :ecm_configuration_manager_data, :mac, :config_status, :description, :full_product_name, :ip_address, - :name, :stream_usage_in, :stream_usage_out, :stream_usage_period + :name, :stream_usage_in, :stream_usage_out, :stream_usage_period, + :group_name def initialize(id = nil, options = {}) self.id = id options.each { |k, v| send("#{ k }=", v) if v } end @@ -71,9 +72,25 @@ def configuration_uri lazy_load_router_data unless self.ecm_configuration_manager_uri lazy_load_configuration_manager_data unless self.ecm_configuration_uri self.ecm_configuration_uri + end + + def group + get unless self.data and self.data.any? + return nil unless self.data[:group] + + group_data = Cradlepoint.make_request(get, build_url(self.data[:group].split('/api/v1').last)) + self.group_name = group_data[:name] + group_data + end + + def group_list + get unless self.data and self.data.any? + return nil unless self.data[:group] + + Cradlepoint.make_request(get, build_url(self.data[:group].split('/api/v1').last + '/routers')) end def lazy_load_router_data get # Grab the data from the api. self.ecm_firmware_uri = self.data[:actual_firmware]