class Omise::Testing::Resource
Public Class Methods
new(url, path, key)
click to toggle source
# File lib/omise/testing/resource.rb, line 8 def initialize(url, path, key) @uri = URI.parse(url) @uri.path = [@uri.path, path].join @key = key end
Public Instance Methods
delete(attributes = {})
click to toggle source
# File lib/omise/testing/resource.rb, line 22 def delete(attributes = {}) Omise::Util.load_response(read_file("delete")) end
get(attributes = {})
click to toggle source
# File lib/omise/testing/resource.rb, line 14 def get(attributes = {}) Omise::Util.load_response(read_file("get", attributes)) end
patch(attributes = {})
click to toggle source
# File lib/omise/testing/resource.rb, line 18 def patch(attributes = {}) Omise::Util.load_response(read_file("patch")) end
post(attributes = {})
click to toggle source
# File lib/omise/testing/resource.rb, line 26 def post(attributes = {}) Omise::Util.load_response(read_file("post")) end
Private Instance Methods
generate_path(verb, attributes)
click to toggle source
# File lib/omise/testing/resource.rb, line 32 def generate_path(verb, attributes) return verb if attributes.empty? params = attributes.to_a.sort { |x,y| x.first.to_s <=> y.first.to_s }.flatten.join("-") [verb, params].compact.join("-") end
read_file(verb, attributes = {})
click to toggle source
# File lib/omise/testing/resource.rb, line 38 def read_file(verb, attributes = {}) path = generate_path(verb, attributes) File.read(File.expand_path(File.join( Omise::LIB_PATH, "..", "test", "fixtures", [@uri.host, @uri.path, "-#{path}.json"].join ))) end