Module: KisHttp

Defined in:
lib/kis_http.rb,
lib/kis_http/headers.rb,
lib/kis_http/options.rb,
lib/kis_http/version.rb

Overview

TLD

Defined Under Namespace

Classes: Error, Headers, Options

Constant Summary collapse

VERSION =
'0.2.1'.freeze

Class Method Summary collapse

Class Method Details

.delete(url, **kwargs) ⇒ Object



31
32
33
34
35
# File 'lib/kis_http.rb', line 31

def delete(url, **kwargs)
  request(url, **kwargs) do |uri|
    Net::HTTP::Delete.new(uri)
  end
end

.get(url, **kwargs) ⇒ Object



13
14
15
16
17
# File 'lib/kis_http.rb', line 13

def get(url, **kwargs)
  request(url, **kwargs) do |uri|
    Net::HTTP::Get.new(uri)
  end
end

.Headers(obj) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/kis_http/headers.rb', line 72

def self.Headers(obj)
  if obj.is_a? KisHttp::Headers
    obj
  elsif obj.is_a? Hash
    KisHttp::Headers.new(**obj)
  elsif obj.is_a? Array
    KisHttp::Headers.new(**obj.to_h)
  else
    raise 'Invalid object type for Headers!'
  end
end

.Options(obj) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/kis_http/options.rb', line 137

def self.Options(obj)
  if obj.is_a? KisHttp::Options
    obj
  elsif obj.is_a? Hash
    KisHttp::Options.new(**obj)
  elsif obj.is_a? Array
    KisHttp::Options.new(**obj.to_h)
  else
    raise 'Invalid object type for Options!'
  end
end

.post(url, **kwargs) ⇒ Object



19
20
21
22
23
# File 'lib/kis_http.rb', line 19

def post(url, **kwargs)
  request(url, **kwargs) do |uri|
    Net::HTTP::Post.new(uri)
  end
end

.put(url, **kwargs) ⇒ Object



25
26
27
28
29
# File 'lib/kis_http.rb', line 25

def put(url, **kwargs)
  request(url, **kwargs) do |uri|
    Net::HTTP::Put.new(uri)
  end
end