Class: XSR::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/xsr/client.rb

Overview

XSR Client class, holding methods to handle HTTP requests

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/xsr/client.rb', line 7

def initialize(options = {})
  @base_url = options[:base_url]
  @base_header = options[:header]
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/xsr/client.rb', line 4

def base_url
  @base_url
end

#default_headerObject

Returns the value of attribute default_header.



5
6
7
# File 'lib/xsr/client.rb', line 5

def default_header
  @default_header
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



16
17
18
# File 'lib/xsr/client.rb', line 16

def delete(path, options = {})
  request_with_data(path, options) { |uri| Net::HTTP::Delete.new(uri.to_s) }
end

#get(path, options = {}) ⇒ Object



24
25
26
# File 'lib/xsr/client.rb', line 24

def get(path, options = {})
  request_with_data(path, options) { |uri| Net::HTTP::Get.new(uri.to_s) }
end

#post(path, options = {}) ⇒ Object



12
13
14
# File 'lib/xsr/client.rb', line 12

def post(path, options = {})
  request_with_data(path, options) { |uri| Net::HTTP::Post.new(uri.to_s) }
end

#put(path, options = {}) ⇒ Object



20
21
22
# File 'lib/xsr/client.rb', line 20

def put(path, options = {})
  request_with_data(path, options) { |uri| Net::HTTP::Put.new(uri.to_s) }
end