class ThreeScaleToolbox::Commands::PlansCommand::Import::ImportPlanFeaturesStep
Public Instance Methods
call()
click to toggle source
Writes Plan features
# File lib/3scale_toolbox/commands/plans_command/import/import_plan_features_step.rb, line 9 def call missing_features.each do |feature| create_plan_feature(feature) puts "Created plan feature: #{feature}" end end
Private Instance Methods
create_plan_feature(feature_attrs)
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/import_plan_features_step.rb, line 24 def create_plan_feature(feature_attrs) feature = find_feature_by_system_name(feature_attrs['system_name']) || create_service_feature(feature_attrs) plan.create_feature(feature['id']).tap do |resp| if (errors = resp['errors']) raise ThreeScaleToolbox::Error, "Plan feature has not been created. #{errors}" end end end
create_service_feature(feature_attrs)
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/import_plan_features_step.rb, line 34 def create_service_feature(feature_attrs) service.create_feature(feature_attrs).tap do |resp| if (errors = resp['errors']) raise ThreeScaleToolbox::Error, "Service feature has not been created. #{errors}" end end end
missing_features()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/import_plan_features_step.rb, line 18 def missing_features ThreeScaleToolbox::Helper.array_difference(resource_features, plan.features) do |a, b| ThreeScaleToolbox::Helper.compare_hashes(a, b, ['system_name']) end end