almapi 0.1.7 → 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: e2595f89d0085997b7725770d054dcdbd80f56dc3c57fbd3c28a6655f70def3e
4
- data.tar.gz: edb1857f61ab8d66c891c7e201e7cd269f3617e193e6aa184d4c341fe167816f
3
+ metadata.gz: 8b5ba5d80ae25614a6560df36126d04a5ab3eb574ce5026ca5b5c8cacddf3a70
4
+ data.tar.gz: 26cad93394125cbaa1bfc11c6a9ef20e4dd38366815d59a4a43d21b744e31115
5
5
  SHA512:
6
- metadata.gz: 2c7b704e6e58e721c1ab6c6bb531fd60096c928adca37451e79615352d6b10bcce87bf85464a84e4ba6fcefe03fb99645f52c7fd2cc97e7e73921f0ee88941e2
7
- data.tar.gz: 619689dd130c5c710c17278e117f596b2d807652de3cf212bc9e81150b2a190ab3449acf462a501ce3a9efc65a62319968e385f6f6dfa19cede7de550ba20e23
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
 
@@ -71,7 +72,8 @@ module Almapi
71
72
  # @param data [String] : an XML string containing data to post.
72
73
  # @return [Response] : the resulting response
73
74
  def post(resource, data)
74
- url_api = resource.to_s
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
 
@@ -82,13 +84,9 @@ module Almapi
82
84
  # @param data [String] : an XML string containing data to put.
83
85
  # @return [Response] : the resulting response. If error occurs, raises an AlmapiError
84
86
  def put(resource, data)
85
- url_api = resource.to_s
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
87
+ url_api = "#{@uri_base}#{resource}"
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.7"
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.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - jszenb