Sha256: aee5fda988862ff4747ba91ce3e4b4b4600d88bf4b8231f93333efe3369fcf60

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module ThreeScaleToolbox
  module Tasks
    class UpdateServiceSettingsTask
      attr_reader :source, :target, :target_system_name

      def initialize(source:, target:, target_name:)
        @source = source
        @target = target
        @target_system_name = target_name
      end

      def call
        source_obj = source.show_service
        response = target.update_service(target_service_params(source_obj))
        raise ThreeScaleToolbox::Error, "Service has not been saved. Errors: #{response['errors']}" unless response['errors'].nil?

        puts "updated service settings for service id #{source.id}..."
      end

      private

      # system name only included when specified from options
      def target_service_params(source)
        target_svc_obj = ThreeScaleToolbox::Helper.filter_params(Entities::Service::VALID_PARAMS, source)
        target_svc_obj.delete('system_name')
        target_svc_obj.tap do |hash|
          hash['system_name'] = target_system_name unless target_system_name.nil?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
3scale_toolbox-0.7.0 lib/3scale_toolbox/tasks/update_service_settings_task.rb