Class: RestPki::RestPkiClient
- Inherits:
-
Object
- Object
- RestPki::RestPkiClient
- Defined in:
- lib/rest_pki/restpki_client.rb
Instance Method Summary collapse
- #get(url, object_model) ⇒ Object
- #get_authentication ⇒ Object
-
#initialize(endpoint_url, access_token) ⇒ RestPkiClient
constructor
A new instance of RestPkiClient.
- #post(url, data, object_model) ⇒ Object
Constructor Details
#initialize(endpoint_url, access_token) ⇒ RestPkiClient
Returns a new instance of RestPkiClient.
8 9 10 11 |
# File 'lib/rest_pki/restpki_client.rb', line 8 def initialize(endpoint_url, access_token) @endpoint_url = endpoint_url @access_token = access_token end |
Instance Method Details
#get(url, object_model) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rest_pki/restpki_client.rb', line 13 def get(url, object_model) verb = 'GET' params = get_rest_params(verb, url) begin response = RestClient::Request.execute params rescue RestClient::Exception => ex response = RestPkiObject.convert({ :code => ex.http_code, :body => ex.response }, 'response_model') rescue Exception => ex raise RestUnreachableError.new(verb, url, ex.) end check_response(verb, url, response) RestPkiObject.convert(MultiJson.decode(response.body), object_model) end |
#get_authentication ⇒ Object
51 52 53 |
# File 'lib/rest_pki/restpki_client.rb', line 51 def get_authentication Authentication.new(self) end |
#post(url, data, object_model) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rest_pki/restpki_client.rb', line 32 def post(url, data, object_model) verb = 'POST' params = get_rest_params(verb, url, data) begin response = RestClient::Request.execute params rescue RestClient::Exception => ex response = RestPkiObject.convert({ :code => ex.http_code, :body => ex.response }, 'response_model') rescue Exception => ex raise RestUnreachableError.new(verb, url, ex.) end check_response(verb, url, response) RestPkiObject.convert(MultiJson.decode(response.body), object_model) end |