Sha256: d6d2b70a63af2c5ca8977c885b8d176caeba21b05a2d82dd0b2b165c83831ee5

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

require 'osc_ruby/connect'
require 'osc_ruby/modules/validations_module'
require 'osc_ruby/modules/normalize_module'
require_relative '../../ext/string.rb'

module OSCRuby

	module QueryModule

		class << self

			include ValidationsModule, NormalizeModule
		
			def find(rn_client,resource)

				obj_to_find = OSCRuby::Connect.get(rn_client,resource)

				if obj_to_find.code.to_i == 200 || obj_to_find.code.to_i == 201

					# ValidationsModule::check_obj_for_errors(obj_to_find)

					NormalizeModule::normalize(obj_to_find)
				else

					puts obj_to_find.body

					obj_to_find.body

				end

			end

			def create(rn_client,resource,json_content)

				OSCRuby::Connect.post_or_patch(rn_client,resource,json_content)

			end

			def update(rn_client,resource,json_content)

				OSCRuby::Connect.post_or_patch(rn_client,resource,json_content,true)

			end

			def destroy(rn_client,resource)

				OSCRuby::Connect.delete(rn_client,resource)
				
			end

		end
		
	end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osc_ruby-1.4.0 lib/osc_ruby/modules/query_module.rb
osc_ruby-1.3.2 lib/osc_ruby/modules/query_module.rb
osc_ruby-1.3.1 lib/osc_ruby/modules/query_module.rb