lib/app_manager/model.rb in app_manager-1.1.0 vs lib/app_manager/model.rb in app_manager-1.1.1

- old
+ new

@@ -5,12 +5,15 @@ def has_plan if !self[AppManager.configuration.plan_id_or_name_field] return false; + end + if self[AppManager.configuration.field_names['grandfathered']] + return true; end - plan_id = self.plan_id + plan_id = self[AppManager.configuration.plan_id_or_name_field] if !plan_id Rails.logger.info "Plan id found nil or not set" return false; end remaining_days = self.get_remaining_days @@ -24,13 +27,13 @@ end def plan_features - plan_id = self.plan_id + plan_id = self[AppManager.configuration.plan_id_or_name_field] if !plan_id - raise "Plan id not found" + raise Error, "Plan id not found" end plan_obj = AppManager::Client.new plans = plan_obj.get_plan(plan_id) if plans && plans['features'].blank? return [] @@ -67,9 +70,30 @@ plan_field = AppManager.configuration.field_names['plan_id'] plan_id = self[plan_field] plan_obj = AppManager::Client.new shop_domain ? plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id) : 0 end + + + def get_plan + if !self[AppManager.configuration.plan_id_or_name_field] + raise Error, "Invalid params, must have charge_id,shop && plan" + end + plan_obj = AppManager::Client.new + return plan_obj.get_plan(self[AppManager.configuration.plan_id_or_name_field]) + end + + def get_charge + begin + shop_domain = self[AppManager.configuration.shopify_domain_field] + plan_obj = AppManager::Client.new + return plan_obj.get_charge(self[AppManager.configuration.shopify_domain_field]) + rescue Exception => e + return "#{e.inspect}" + end + end + + private def casted_value(value,value_type) case value_type \ No newline at end of file