fanforce-api 0.14.7 → 0.14.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/fanforce/api/_main.rb +16 -6
- data/lib/fanforce/api/response.rb +0 -11
- data/lib/fanforce/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTZhNzRlNTFmOGNlOGU3YmQ1NzlmYjk5YTM2OWFlNTgxZWY5YjlkNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTViZWRmMDc4NjY2ZTZiMmVjZTQ3MTNmODYwNjI5MWUzMTM0ZTFmYw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUxZjEwMzc5OTIyNGE0ZGY3Njc3ZDdiZGE3ZjNiM2I5NTNiMTg5Y2M2YzMw
|
10
|
+
MGM0YTU1MWIxNTQ5NTIxZDliOGJiNGMwMjUxNjdjYThkN2NhZWEwZjdmYzU3
|
11
|
+
MDZhMTcxMThiZjBmZWIxYzM1YTc0ZTU5YjYzZjE3NzhkYzY5ZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjZmMDIwZGM4OTA5M2RhNjIxODg4ZDVhNDA5ZWY4YTZhNGY4YjJiMTg1MDQ0
|
14
|
+
MmE2N2IxYmQ5YzhhNDVkY2VmNjc4MDE0Njc0ZWU4MTNmODc2ZGE1YjY4NTY2
|
15
|
+
M2Q5ZDlmNDNjN2NkZTFiYTk5OTI2YzY1MTdkMWFlYjUzNGMwN2Q=
|
data/lib/fanforce/api/_main.rb
CHANGED
@@ -40,19 +40,29 @@ class Fanforce::API
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def post(path, req_params={})
|
43
|
+
def post(path, req_params={}, retries=0)
|
44
44
|
url = complete_url(path)
|
45
|
-
req_params = apply_auth(req_params)
|
45
|
+
req_params = apply_auth(req_params) unless retries > 0
|
46
46
|
RestClient.post(url, MultiJson.dump(req_params), :content_type => :json, :accept => :json) do |response, request, result, &block|
|
47
|
-
|
47
|
+
if response.code == 400 and response.body == '{"error":"Invalid JSON"}' and retries <= 2
|
48
|
+
puts "retried #{path} #{retries} times"
|
49
|
+
post(path, req_params, retries+1)
|
50
|
+
else
|
51
|
+
Fanforce::API::Response.process(response, request, url, req_params)
|
52
|
+
end
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
51
|
-
def put(path, req_params={})
|
56
|
+
def put(path, req_params={}, retries=0)
|
52
57
|
url = complete_url(path)
|
53
|
-
req_params = apply_auth(req_params)
|
58
|
+
req_params = apply_auth(req_params) unless retries > 0
|
54
59
|
RestClient.put(url, MultiJson.dump(req_params), :content_type => :json, :accept => :json) do |response, request, result, &block|
|
55
|
-
|
60
|
+
if response.code == 400 and response.body == '{"error":"Invalid JSON"}' and retries <= 2
|
61
|
+
puts "retried #{path} #{retries} times"
|
62
|
+
post(path, req_params, retries+1)
|
63
|
+
else
|
64
|
+
Fanforce::API::Response.process(response, request, url, req_params)
|
65
|
+
end
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
@@ -2,17 +2,6 @@ class Fanforce::API::Response
|
|
2
2
|
attr_reader :curl_command, :requested_url, :requested_params
|
3
3
|
|
4
4
|
def self.process(response, request, requested_url, requested_params)
|
5
|
-
if response.code > 201
|
6
|
-
puts "FANFORCE API CRAPPED OUT: #{response.code}"
|
7
|
-
puts response.args.to_json
|
8
|
-
puts '--------------------------------------'
|
9
|
-
puts response.args[:payload]
|
10
|
-
puts '--------------------------------------'
|
11
|
-
puts response.body
|
12
|
-
puts '--------------------------------------'
|
13
|
-
puts response.net_http_res
|
14
|
-
end
|
15
|
-
|
16
5
|
raise Fanforce::API::ServerError.new(response, request, requested_url, requested_params) if response.code > 201
|
17
6
|
begin response_hash = Fanforce::Utils.decode_json(response)
|
18
7
|
rescue Exception => e; raise Fanforce::API::DecodingError.new(e, response, request, requested_url, requested_params) end
|
data/lib/fanforce/api/version.rb
CHANGED