Sha256: 37d684bc16c906cb5c18c36d1ba04512036043ea237e0013e7b8b0aca3e7920d

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'uri'

module Voucherify
  module Service
    class ValidationRules
      attr_reader :client

      def initialize(client)
        @client = client
      end

      def create(validation_rules)
        @client.post('/validation-rules', validation_rules.to_json)
      end

      def list(query)
        @client.get('/validation-rules', query)
      end

      def get(id)
        @client.get("/validation-rules/#{URI.encode(id)}")
      end

      def update(validation_rules)
        @client.put("/validation-rules/#{URI.encode(validation_rules['id'] || validation_rules[:id])}", validation_rules.to_json)
      end

      def delete(id)
        @client.delete("/validation-rules/#{URI.encode(id)}")
      end

      def createAssignment(id, assignment)
        @client.post("/validation-rules/#{URI.encode(id)}/assignments", assignment.to_json)
      end

      def deleteAssignment(rule_id, assignment_id)
        @client.delete("/validation-rules/#{URI.encode(rule_id)}/assignments/#{URI.encode(assignment_id)}")
      end

      def listAssignments(id, query)
        @client.get("/validation-rules/#{URI.encode(id)}/assignments", query)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
voucherify-2.1.1 lib/voucherify/service/validation_rules.rb
voucherify-2.1.0 lib/voucherify/service/validation_rules.rb
voucherify-2.0.0 lib/voucherify/service/validation_rules.rb