fanforce-api 0.14.7 → 0.14.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDY5YTdjYjM2MWUwMzU5NmM5YWFlZTE1MDNkZWJlMTkwZDkwODY1Mw==
4
+ OTZhNzRlNTFmOGNlOGU3YmQ1NzlmYjk5YTM2OWFlNTgxZWY5YjlkNg==
5
5
  data.tar.gz: !binary |-
6
- OTEyYjBiZmNiYjEzMWJiMGQ3NmQwODI5ZGYyZGM0ZDk5NjNmOGVkYQ==
6
+ ZTViZWRmMDc4NjY2ZTZiMmVjZTQ3MTNmODYwNjI5MWUzMTM0ZTFmYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDVlNzEzMzQyNjFhODgzZTZmMGE4MDgxYWUzYjk3MzAzZDViZGU0M2UyMzMx
10
- NDllNjliOGEzZThlNzFlZjM4MGFmODMwYmJhZmQ4Yjk1YjUxMzQ4YmM4MzBj
11
- NDgwMzY1MGY0ZjQ3NDk4MWU1ZWM2ZmQyMTVkMDE0ZmMzY2M2YzU=
9
+ MWUxZjEwMzc5OTIyNGE0ZGY3Njc3ZDdiZGE3ZjNiM2I5NTNiMTg5Y2M2YzMw
10
+ MGM0YTU1MWIxNTQ5NTIxZDliOGJiNGMwMjUxNjdjYThkN2NhZWEwZjdmYzU3
11
+ MDZhMTcxMThiZjBmZWIxYzM1YTc0ZTU5YjYzZjE3NzhkYzY5ZWQ=
12
12
  data.tar.gz: !binary |-
13
- ZjU1NWRlYzUxYTM0OWFiMzEwMTZkNjEzNzJhMWQwOWNkMTM0MTdmMDFmOTU5
14
- NDA1MmU2N2Y4YjQ4NTU5MzBiZDYxMTZkYjI2OTlmYTAwNWE4ZTBhZTc1Y2Qx
15
- NDBmODRjM2RkZjBjM2I2MTVhNWZlYmY4NmE0NGZjNjRiYjY4ZjQ=
13
+ MjZmMDIwZGM4OTA5M2RhNjIxODg4ZDVhNDA5ZWY4YTZhNGY4YjJiMTg1MDQ0
14
+ MmE2N2IxYmQ5YzhhNDVkY2VmNjc4MDE0Njc0ZWU4MTNmODc2ZGE1YjY4NTY2
15
+ M2Q5ZDlmNDNjN2NkZTFiYTk5OTI2YzY1MTdkMWFlYjUzNGMwN2Q=
@@ -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
- Fanforce::API::Response.process(response, request, url, req_params)
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
- Fanforce::API::Response.process(response, request, url, req_params)
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
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class API
3
- VERSION = '0.14.7'
3
+ VERSION = '0.14.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.7
4
+ version: 0.14.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark