fanforce 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fanforce/errors.rb +8 -5
- data/lib/fanforce/version.rb +1 -1
- metadata +1 -1
data/lib/fanforce/errors.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
require_relative 'utils'
|
2
|
+
|
1
3
|
class Fanforce
|
2
4
|
class Error < StandardError;
|
5
|
+
include ::Fanforce::Utils
|
3
6
|
attr_accessor :path, :query_params, :request, :response, :request_url
|
4
7
|
|
5
8
|
def initialize(response, request, path, query_params)
|
@@ -11,20 +14,20 @@ class Fanforce
|
|
11
14
|
rescue Exception => e
|
12
15
|
@response = "JSON decode error in Gem: #{e.message}"
|
13
16
|
end
|
14
|
-
@request_url = "#{@path}?#{@query_params
|
17
|
+
@request_url = "#{@path}?#{to_param(@query_params)}"
|
15
18
|
super(@response.is_a?(Hash) ? @response[:msg] : @response)
|
16
19
|
end
|
17
20
|
|
18
21
|
def curl_command
|
19
22
|
case @request.method
|
20
23
|
when :get
|
21
|
-
"curl \"#{@path}?#{@query_params
|
24
|
+
"curl \"#{@path}?#{to_param(@query_params)}\""
|
22
25
|
when :post
|
23
|
-
"curl -X POST -d \"#{@query_params
|
26
|
+
"curl -X POST -d \"#{to_param(@query_params)}\" #{@path}"
|
24
27
|
when :put
|
25
|
-
"curl -X PUT -d \"#{@query_params
|
28
|
+
"curl -X PUT -d \"#{to_param(@query_params)}\" #{@path.to_json}"
|
26
29
|
when :delete
|
27
|
-
"curl --request DELETE \"#{@path}?#{@query_params
|
30
|
+
"curl --request DELETE \"#{@path}?#{to_param(@query_params)}\""
|
28
31
|
else
|
29
32
|
"Could not create curl command because request method was unknown: #{@request.method}"
|
30
33
|
end
|
data/lib/fanforce/version.rb
CHANGED