fanforce-api 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fanforce/api/errors/server.rb +1 -1
- data/lib/fanforce/api/main.rb +10 -18
- data/lib/fanforce/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b535f477646e92ddfa34e2e36a462e68ee2ec0
|
4
|
+
data.tar.gz: 5b85e380606cf373c51327c648013b46537fb108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2eef5909f1c911e5f8315bc260a774a35ff8a6ab3a5c6c4200941052299a1df50459b532b81f4df84a655f9d2b31a1677bff54ce0837eb6a62c9f8f447eef10
|
7
|
+
data.tar.gz: 80042227d65414eeded7a377c51defa749ba220e8f17b61d6184b0ed77832370bc4593438a6707a18c89aab410dd2e62449a0037164f51d0373cc642bd4d0cb2
|
@@ -14,7 +14,7 @@ class Fanforce::API::Error::Server < Fanforce::API::Error
|
|
14
14
|
@errors = [{message: "(Response body from #{response.code} error was empty: #{response.body})"}]
|
15
15
|
end
|
16
16
|
|
17
|
-
super(
|
17
|
+
super(@errors[0][:message], response, request, requested_url, requested_params)
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_hash
|
data/lib/fanforce/api/main.rb
CHANGED
@@ -10,15 +10,6 @@ class Fanforce::API
|
|
10
10
|
set_auth(auth_data) if auth_data
|
11
11
|
end
|
12
12
|
|
13
|
-
# Get the raw url for a request
|
14
|
-
# @param path [String]
|
15
|
-
# @param req_params [Hash]
|
16
|
-
# @return [String] url
|
17
|
-
def raw_url(path, req_params={})
|
18
|
-
req_params = inject_auth_params(req_params)
|
19
|
-
"#{complete_url(path)}?#{to_query_string(req_params) if req_params.size > 0}"
|
20
|
-
end
|
21
|
-
|
22
13
|
# Get the CURL command for a request
|
23
14
|
# @param method [Symbol] (get/post/put/delete)
|
24
15
|
# @param path [String]
|
@@ -26,7 +17,7 @@ class Fanforce::API
|
|
26
17
|
# @return [String] curl command
|
27
18
|
def curl_command(method, path, params={})
|
28
19
|
params = inject_auth_params(params)
|
29
|
-
Fanforce.curl_command(method,
|
20
|
+
Fanforce.curl_command(method, request_url(path), params)
|
30
21
|
end
|
31
22
|
|
32
23
|
# Handles a GET request for Fanforce API
|
@@ -35,8 +26,8 @@ class Fanforce::API
|
|
35
26
|
# @return [Fanforce::API::Response]
|
36
27
|
def get(path, params={})
|
37
28
|
params = inject_auth_params(params)
|
38
|
-
RestClient.get(
|
39
|
-
Fanforce::API::Response.process(response, request,
|
29
|
+
RestClient.get(request_url(path, params), :accept => :json) do |response, request, result, &block|
|
30
|
+
Fanforce::API::Response.process(response, request, request_url(path), params)
|
40
31
|
end
|
41
32
|
end
|
42
33
|
|
@@ -45,7 +36,7 @@ class Fanforce::API
|
|
45
36
|
# @param params [Hash]
|
46
37
|
# @return [Fanforce::API::Response]
|
47
38
|
def post(path, params={}, retries=0)
|
48
|
-
url =
|
39
|
+
url = request_url(path)
|
49
40
|
params = inject_auth_params(params) unless retries > 0
|
50
41
|
RestClient.post(url, MultiJson.dump(params), :content_type => :json, :accept => :json) do |response, request, result, &block|
|
51
42
|
if response.code == 400 and response.body == '{"error":"Invalid JSON"}' and retries <= 2
|
@@ -62,7 +53,7 @@ class Fanforce::API
|
|
62
53
|
# @param params [Hash]
|
63
54
|
# @return [Fanforce::API::Response]
|
64
55
|
def put(path, params={}, retries=0)
|
65
|
-
url =
|
56
|
+
url = request_url(path)
|
66
57
|
params = inject_auth_params(params) unless retries > 0
|
67
58
|
RestClient.put(url, MultiJson.dump(params), :content_type => :json, :accept => :json) do |response, request, result, &block|
|
68
59
|
if response.code == 400 and response.body == '{"error":"Invalid JSON"}' and retries <= 2
|
@@ -79,9 +70,9 @@ class Fanforce::API
|
|
79
70
|
# @param params [Hash]
|
80
71
|
# @return [Fanforce::API::Response]
|
81
72
|
def delete(path, params={})
|
82
|
-
url =
|
73
|
+
url = request_url(path)
|
83
74
|
params = inject_auth_params(params)
|
84
|
-
RestClient.delete(
|
75
|
+
RestClient.delete(request_url(path, params), :accept => :json) do |response, request, result, &block|
|
85
76
|
Fanforce::API::Response.process(response, request, url, params)
|
86
77
|
end
|
87
78
|
end
|
@@ -123,8 +114,9 @@ class Fanforce::API
|
|
123
114
|
params.merge(@auth_params || {})
|
124
115
|
end
|
125
116
|
|
126
|
-
def
|
127
|
-
|
117
|
+
def request_url(path, params={})
|
118
|
+
params = inject_auth_params(params)
|
119
|
+
"http://#{Fanforce.api_domain}#{path}#{'?'+to_query_string(params) if params.size > 0}"
|
128
120
|
end
|
129
121
|
|
130
122
|
end
|
data/lib/fanforce/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fanforce-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|