almapi 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb6918b7e7c9f7ebd49f2255ce6d447e9b3ac8608a2847790b9bde4434325622
4
- data.tar.gz: 0b3fe11572d763268e2ae1be8c2b42a77a816d8ea4687855389ba93fb654624e
3
+ metadata.gz: 8b5ba5d80ae25614a6560df36126d04a5ab3eb574ce5026ca5b5c8cacddf3a70
4
+ data.tar.gz: 26cad93394125cbaa1bfc11c6a9ef20e4dd38366815d59a4a43d21b744e31115
5
5
  SHA512:
6
- metadata.gz: 94f9e303a9ccd2fa37fe182c8b1b1d5039cda9f5f9c551fee3706dc9f6520aee4567f8600f8148b48179a9818583687be6de25555b773d6b2d4021c39501a2ae
7
- data.tar.gz: cee651945fb60c85d80b364782d8485c06305a805ebcc16e3e6b3e53f6684da98695844196a3ea43edd09cf389dc3ef013323766594a9d6e4743c72a4c64a3d1
6
+ metadata.gz: ebef23941dbf9a8b0fc8dbbc1b1ab1496f3bc341aab56329a7f39ca9817270a714feb57adf02a204b97231d70f5a23217d9344a8f1f99ddaadcd469e4c2d7b28
7
+ data.tar.gz: aa8a1ec97ab087310cd1c5f428db752ca7f76504bc0b90fdfe07cacba3006337829532c17b36d60d6b8ec71dbb4377e9de6de1e862852921b8e394282e1ec2a7
data/lib/almapi/almapi.rb CHANGED
@@ -61,6 +61,7 @@ module Almapi
61
61
  "#{@uri_base}#{resource}" # All other cases
62
62
  end
63
63
 
64
+ puts "[Almapi::Api.get] INFO URL #{url_api}"
64
65
  handle_response(@conn.get(url_api))
65
66
  end
66
67
 
@@ -72,6 +73,7 @@ module Almapi
72
73
  # @return [Response] : the resulting response
73
74
  def post(resource, data)
74
75
  url_api = "#{@uri_base}#{resource}"
76
+ puts "[Almapi::Api.post] INFO URL #{url_api}"
75
77
  handle_response(@conn.post(url_api, data.to_s))
76
78
  end
77
79
 
@@ -83,12 +85,8 @@ module Almapi
83
85
  # @return [Response] : the resulting response. If error occurs, raises an AlmapiError
84
86
  def put(resource, data)
85
87
  url_api = "#{@uri_base}#{resource}"
86
- puts url_api
87
- begin
88
- handle_response(@conn.put(url_api, data.to_s, "Content-Type" => "application/xml"))
89
- rescue StandardError => e
90
- puts e
91
- end
88
+ puts "[Almapi::Api.put] INFO URL #{url_api}"
89
+ handle_response(@conn.put(url_api, data.to_s))
92
90
  end
93
91
 
94
92
  # Handles a DELETE request creating the complete URI.
@@ -98,7 +96,8 @@ module Almapi
98
96
  # @param data [String] : an XML string containing data to put.
99
97
  # @return [Response] : the resulting response. If error occurs, raises an AlmapiError
100
98
  def delete(resource, _data)
101
- url_api = resource.to_s
99
+ url_api = "#{@uri_base}#{resource}"
100
+ puts "[Almapi::Api.delete] INFO URL #{url_api}"
102
101
  handle_response(@conn.delete(url_api))
103
102
  end
104
103
 
@@ -107,16 +106,16 @@ module Almapi
107
106
  # [Private] handles the response and decides to raise AlmapiError if necessary
108
107
  #
109
108
  # @param response [Response] mandatory : the response of the API call
109
+ # @param method [String] mandatory the called HTTP method
110
110
  # @return [Response || AlmapiError] : the resulting response if the API call succeeded, else AlmapiError
111
- def handle_response(response)
111
+ def handle_response(response, method)
112
112
  case response.status
113
113
  when 200
114
114
  # Success
115
115
  response
116
116
  else
117
117
  # Request has been correctly handled but cannot succeed
118
- raise Almapi::AlmapiError, "AlmapiError : #{response.status} -> #{response.body}"
119
- p @conn
118
+ raise Almapi::AlmapiError, "[Almapi::Api.handle_response] AlmapiError : for method #{method}, #{response.status} -> #{response.body}"
120
119
  end
121
120
  end
122
121
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Almapi
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - jszenb