fanforce-api 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/fanforce-api.gemspec +1 -1
- data/lib/fanforce.rb +2 -2
- data/lib/fanforce/api.rb +1 -1
- data/lib/fanforce/api/_main.rb +6 -6
- data/lib/fanforce/api/error.rb +4 -4
- data/lib/fanforce/api/response.rb +7 -7
- data/lib/fanforce/api/utils.rb +2 -2
- data/lib/fanforce/api/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWJmMmYxYjk3ZjlkNDZkZDM4NTA5ZWJmZDk0YmE0OWIyZmNhOTQ3Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjIxYmQxM2FlMjFjMDYwZDkwZmZiNzZjNDY0MTAxNWJkYzMyOWJhYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjgxODVmOTMzZWVkNWUxOTlkMjZmYTUxMzY0NDI2MmFhYzdiNTVmYjgyY2Ix
|
10
|
+
YTBkNDdmNmNiMGI0ODA3NmFkZWI5YmFkMjM0NzlhNmMyYjIzODQ4NDk3ODk3
|
11
|
+
ZDY4NTQyMmM0MWU4YzVmZTljNmNmMTE1YmI2ZjQxMGI5Mjk4ODc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDBmYWY4YzBiNDY1M2RiY2NkN2ExNmU1ZGY3OWVhOTljNTA3ODY2NGE4ODBl
|
14
|
+
N2EwYjFlYjI3OGE3YTQ2ZGJkNmZiMDgxZjE3OWMwY2I0YmM1NzQ2NmIzNzA5
|
15
|
+
NzkwMmU0ZDdhMDZiNWRkNDg2YmFiMjMwMzA3NmFjZDM0MWI2ODI=
|
data/fanforce-api.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'fanforce/api/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = 'fanforce-api'
|
8
|
-
gem.version = Fanforce::
|
8
|
+
gem.version = Fanforce::API::VERSION
|
9
9
|
gem.date = '2012-10-19'
|
10
10
|
gem.summary = %q{Ruby API wrapper for Fanforce}
|
11
11
|
gem.description = %q{Ruby API wrapper that interfaces with all six Fanforce APIs.}
|
data/lib/fanforce.rb
CHANGED
data/lib/fanforce/api.rb
CHANGED
data/lib/fanforce/api/_main.rb
CHANGED
@@ -2,8 +2,8 @@ require 'rest-client'
|
|
2
2
|
require_relative 'utils'
|
3
3
|
require_relative 'response'
|
4
4
|
|
5
|
-
class Fanforce::
|
6
|
-
include Fanforce::
|
5
|
+
class Fanforce::API
|
6
|
+
include Fanforce::API::Utils
|
7
7
|
include Fanforce::Errors
|
8
8
|
|
9
9
|
def initialize(arg={})
|
@@ -36,7 +36,7 @@ class Fanforce::Api
|
|
36
36
|
def get(path, req_params={})
|
37
37
|
req_params = apply_auth(req_params)
|
38
38
|
RestClient.get(url(path, req_params), :accept => :json) do |response, request, result, &block|
|
39
|
-
Fanforce::
|
39
|
+
Fanforce::API::Response.process(response, request, complete_url(path), req_params)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,7 +44,7 @@ class Fanforce::Api
|
|
44
44
|
url = complete_url(path)
|
45
45
|
req_params = apply_auth(req_params)
|
46
46
|
RestClient.post(url, req_params.to_json, :content_type => :json, :accept => :json) do |response, request, result, &block|
|
47
|
-
Fanforce::
|
47
|
+
Fanforce::API::Response.process(response, request, url, req_params)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -52,7 +52,7 @@ class Fanforce::Api
|
|
52
52
|
url = complete_url(path)
|
53
53
|
req_params = apply_auth(req_params)
|
54
54
|
RestClient.put(url, req_params.to_json, :content_type => :json, :accept => :json) do |response, request, result, &block|
|
55
|
-
Fanforce::
|
55
|
+
Fanforce::API::Response.process(response, request, url, req_params)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -60,7 +60,7 @@ class Fanforce::Api
|
|
60
60
|
url = complete_url(path)
|
61
61
|
req_params = apply_auth(req_params)
|
62
62
|
RestClient.delete(url(path, req_params), :accept => :json) do |response, request, result, &block|
|
63
|
-
Fanforce::
|
63
|
+
Fanforce::API::Response.process(response, request, url, req_params)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/lib/fanforce/api/error.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'utils'
|
2
2
|
|
3
|
-
class Fanforce::
|
3
|
+
class Fanforce::API::Error < StandardError
|
4
4
|
attr_accessor :response, :request, :requested_url, :requested_params, :errors
|
5
5
|
|
6
6
|
def initialize(message, response, request, requested_url, requested_params)
|
@@ -22,7 +22,7 @@ class Fanforce::Api::Error < StandardError
|
|
22
22
|
def to_hash; {} end
|
23
23
|
end
|
24
24
|
|
25
|
-
class Fanforce::
|
25
|
+
class Fanforce::API::ServerError < Fanforce::API::Error
|
26
26
|
|
27
27
|
def initialize(response, request, requested_url, requested_params)
|
28
28
|
@response_body = response.to_s
|
@@ -31,7 +31,7 @@ class Fanforce::Api::ServerError < Fanforce::Api::Error
|
|
31
31
|
@response_hash = Fanforce::Utils.decode_json(response)
|
32
32
|
@errors = @response_hash[:errors]
|
33
33
|
rescue Exception => e
|
34
|
-
raise Fanforce::
|
34
|
+
raise Fanforce::API::DecodingError.new(e, response, request, requested_url, requested_params)
|
35
35
|
end
|
36
36
|
|
37
37
|
super(response.to_s, response, request, requested_url, requested_params)
|
@@ -50,7 +50,7 @@ class Fanforce::Api::ServerError < Fanforce::Api::Error
|
|
50
50
|
|
51
51
|
end
|
52
52
|
|
53
|
-
class Fanforce::
|
53
|
+
class Fanforce::API::DecodingError < Fanforce::API::Error
|
54
54
|
|
55
55
|
def initialize(e, response, request, requested_url, requested_params)
|
56
56
|
@message = "There was a Fanforce gem error while decoding JSON response: #{e.message}"
|
@@ -1,20 +1,20 @@
|
|
1
|
-
class Fanforce::
|
1
|
+
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
|
-
raise Fanforce::
|
5
|
+
raise Fanforce::API::ServerError.new(response, request, requested_url, requested_params) if response.code > 201
|
6
6
|
begin response_hash = Fanforce::Utils.decode_json(response)
|
7
|
-
rescue Exception => e; raise Fanforce::
|
7
|
+
rescue Exception => e; raise Fanforce::API::DecodingError.new(e, response, request, requested_url, requested_params) end
|
8
8
|
if response_hash[:results]
|
9
|
-
Fanforce::
|
9
|
+
Fanforce::API::Results.new(response_hash, response, request, requested_url, requested_params)
|
10
10
|
else
|
11
|
-
Fanforce::
|
11
|
+
Fanforce::API::Result.new(response_hash, response, request, requested_url, requested_params)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
16
16
|
|
17
|
-
class Fanforce::
|
17
|
+
class Fanforce::API::Result < Hash
|
18
18
|
attr_reader :requested_url, :requested_params
|
19
19
|
|
20
20
|
def initialize(response_hash, response, request, requested_url, requested_params)
|
@@ -50,7 +50,7 @@ class Fanforce::Api::Result < Hash
|
|
50
50
|
def code; @response.code end
|
51
51
|
end
|
52
52
|
|
53
|
-
class Fanforce::
|
53
|
+
class Fanforce::API::Results < Array
|
54
54
|
attr_reader :requested_url, :requested_params
|
55
55
|
|
56
56
|
def initialize(response_hash, response, request, requested_url, requested_params)
|
data/lib/fanforce/api/utils.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'fanforce/utils'
|
2
2
|
|
3
|
-
module Fanforce::
|
3
|
+
module Fanforce::API::Utils
|
4
4
|
include Fanforce::Utils
|
5
|
-
extend Fanforce::
|
5
|
+
extend Fanforce::API::Utils
|
6
6
|
def self.included(base) base.extend(self) end
|
7
7
|
|
8
8
|
def valid_fanforce_js_request?(params=@params)
|
data/lib/fanforce/api/version.rb
CHANGED