Class: SimpleClient::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



10
11
12
13
# File 'lib/simple-client/simple-client.rb', line 10

def initialize
  @response = nil
  @response_headers = {}
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



8
9
10
# File 'lib/simple-client/simple-client.rb', line 8

def body
  @body
end

#request_headersObject

Returns the value of attribute request_headers.



8
9
10
# File 'lib/simple-client/simple-client.rb', line 8

def request_headers
  @request_headers
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/simple-client/simple-client.rb', line 7

def response
  @response
end

#response_bodyObject (readonly)

Returns the value of attribute response_body.



7
8
9
# File 'lib/simple-client/simple-client.rb', line 7

def response_body
  @response_body
end

#response_codeObject (readonly)

Returns the value of attribute response_code.



7
8
9
# File 'lib/simple-client/simple-client.rb', line 7

def response_code
  @response_code
end

#response_headersObject (readonly)

Returns the value of attribute response_headers.



7
8
9
# File 'lib/simple-client/simple-client.rb', line 7

def response_headers
  @response_headers
end

#ssl_client_certObject

Returns the value of attribute ssl_client_cert.



8
9
10
# File 'lib/simple-client/simple-client.rb', line 8

def ssl_client_cert
  @ssl_client_cert
end

Instance Method Details

#delete(url, params = {}) ⇒ SimpleClient::Client

Wrapper for Net::HTTP Delete

=> ‘bar, ’User-Agent’ => ‘Firefox’}

Parameters:

  • url (String)

    The full request URL

  • params (Hash) (defaults to: {})

    Optional parameters format e.g. {:headers =>

Returns:



62
63
64
65
# File 'lib/simple-client/simple-client.rb', line 62

def delete(url, params = {})
  delete = DeleteRequest.new
  do_request(delete, url, params)
end

#get(url, params = {}) ⇒ SimpleClient::Client

Wrapper for Net::HTTP Get

=> ‘bar, ’User-Agent’ => ‘Firefox’}

Parameters:

  • url (String)

    The full request URL

  • params (Hash) (defaults to: {})

    Optional parameters format e.g. {:headers =>

Returns:



23
24
25
26
# File 'lib/simple-client/simple-client.rb', line 23

def get(url, params = {})
  get = GetRequest.new
  do_request(get, url, params)
end

#post(url, params = {}) ⇒ SimpleClient::Client

Wrapper for Net::HTTP Post

=> ‘bar, ’User-Agent’ => ‘Firefox’, :body => ‘abc’}

Parameters:

  • url (String)

    The full request URL

  • params (Hash) (defaults to: {})

    Optional parameters format e.g. {:headers =>

Returns:



36
37
38
39
# File 'lib/simple-client/simple-client.rb', line 36

def post(url, params = {})
  post = PostRequest.new
  do_request(post, url, params)
end

#put(url, params = {}) ⇒ SimpleClient::Client

Wrapper for Net::HTTP Put

=> ‘bar, ’User-Agent’ => ‘Firefox’, :body => ‘abc’}

Parameters:

  • url (String)

    The full request URL

  • params (Hash) (defaults to: {})

    Optional parameters format e.g. {:headers =>

Returns:



49
50
51
52
# File 'lib/simple-client/simple-client.rb', line 49

def put(url, params = {})
  put = PutRequest.new
  do_request(put, url, params)
end