lib/3scale_toolbox/entities/method.rb in 3scale_toolbox-0.19.2 vs lib/3scale_toolbox/entities/method.rb in 3scale_toolbox-0.19.3

- old
+ new

@@ -1,10 +1,12 @@ module ThreeScaleToolbox module Entities class Method include CRD::MethodSerializer + METHOD_BLACKLIST = %w[id links created_at updated_at parent_id].freeze + class << self def create(service:, attrs:) method_attrs = service.remote.create_method service.id, service.hits.id, attrs if (errors = method_attrs['errors']) raise ThreeScaleToolbox::ThreeScaleApiError.new('Method has not been created', errors) @@ -72,9 +74,18 @@ def delete remote.delete_method service.id, hits_id, id end + # enriched_key returns a metric key that will be unique for all + # metrics/methods from products and backends + def enriched_key + "product.#{service.id}.#{id}" + end + + def to_hash + attrs.reject { |key, _| METHOD_BLACKLIST.include? key } + end private def hits_id service.hits.id