fanforce-api 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e817a09166ee9f545d0cbef8e66eac06d1564813
4
- data.tar.gz: 6423c94330ee17be6fda05f32133806261bf65aa
3
+ metadata.gz: c9b535f477646e92ddfa34e2e36a462e68ee2ec0
4
+ data.tar.gz: 5b85e380606cf373c51327c648013b46537fb108
5
5
  SHA512:
6
- metadata.gz: 3c158ba89daf5186daf1271cb8e29fbc559f22f1d2e509272349ff8326cf4055c4ed0f47c23a29fb1b6d386b9746a9816c60ccb9d9030f7ce35b5c2377b97383
7
- data.tar.gz: f195a6913fb4f975061327fbb51af96213ce389640a5ada01b06959a1f7494e098cb44756996658845ac3c5ee34f7e96e54c90c43cd49d7c0c157d15cb87f8de
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(response.to_s, response, request, requested_url, requested_params)
17
+ super(@errors[0][:message], response, request, requested_url, requested_params)
18
18
  end
19
19
 
20
20
  def to_hash
@@ -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, complete_url(path), params)
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(url(path, params), :accept => :json) do |response, request, result, &block|
39
- Fanforce::API::Response.process(response, request, complete_url(path), params)
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 = complete_url(path)
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 = complete_url(path)
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 = complete_url(path)
73
+ url = request_url(path)
83
74
  params = inject_auth_params(params)
84
- RestClient.delete(url(path, params), :accept => :json) do |response, request, result, &block|
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 complete_url(path)
127
- 'http://' + Fanforce.api_domain + path
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
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class API
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
5
5
  end
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.3
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-26 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client