Sha256: babfcafb6b1b7ec5df32588c1a0067f8e793a74c13e271d9dccc1a74add653dd

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'caseblocks_api'
require 'active_support/inflector'

module CaseblocksAPI
  class Finder
    def initialize(client)
      @client = client
    end

    def execute_single(case_type, property_name, value)
      @client.get("/case_blocks/#{case_type}", {query: {search: true, property: property_name, value: value}})
    end

    def execute_multiple(case_type, properties)
      @client.post("/case_blocks/#{case_type}", :body => {search: true, properties: properties}.to_json)
    end
  end

  class Client
    def find_by_property(case_type, property_name, value)
      Finder.new(self.class).execute_single(case_type, property_name, value)
    end

    def find_by_properties(case_type, properties)
      Finder.new(self.class).execute_multiple(case_type, properties)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caseblocks_api-0.2.8 lib/caseblocks_api/finder.rb