fanforce 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ class Fanforce
4
4
  class Error < StandardError
5
5
  attr_accessor :path, :query_params, :request, :response, :request_url, :http_status
6
6
 
7
- def initialize(request, response, path, query_params)
7
+ def initialize(response, request, path, query_params)
8
8
  @query_params = query_params
9
9
  @path = path
10
10
  @request = request
@@ -47,9 +47,9 @@ class Fanforce
47
47
 
48
48
  class UnknownError < Error
49
49
  def code; @http_status ||= 500; 500 end
50
- def initialize(request, response, path, query_params)
50
+ def initialize(response, request, path, query_params)
51
51
  @http_status = response.code
52
- super(request, response, path, query_params)
52
+ super(response, request, path, query_params)
53
53
  end
54
54
  end
55
55
  end
data/lib/fanforce/main.rb CHANGED
@@ -25,8 +25,8 @@ class Fanforce
25
25
 
26
26
  def get(path, req_params={})
27
27
  req_params = apply_auth(req_params)
28
- RestClient.get(url(path, req_params), :accept => :json) do |request, response, result, &block|
29
- Fanforce::Response.new(request, response, complete_url(path), req_params)
28
+ RestClient.get(url(path, req_params), :accept => :json) do |response, request, result, &block|
29
+ Fanforce::Response.new(response, request, complete_url(path), req_params)
30
30
  end
31
31
  end
32
32
 
@@ -43,24 +43,24 @@ class Fanforce
43
43
  def post(path, req_params={})
44
44
  url = complete_url(path)
45
45
  req_params = apply_auth(req_params)
46
- RestClient.post(url, req_params.to_json, :content_type => :json, :accept => :json) do |request, response, result, &block|
47
- Fanforce::Response.new(request, response, url, req_params)
46
+ RestClient.post(url, req_params.to_json, :content_type => :json, :accept => :json) do |response, request, result, &block|
47
+ Fanforce::Response.new(response, request, url, req_params)
48
48
  end
49
49
  end
50
50
 
51
51
  def put(path, req_params={})
52
52
  url = complete_url(path)
53
53
  req_params = apply_auth(req_params)
54
- RestClient.put(url, req_params.to_json, :content_type => :json, :accept => :json) do |request, response, result, &block|
55
- Fanforce::Response.new(request, response, url, req_params)
54
+ RestClient.put(url, req_params.to_json, :content_type => :json, :accept => :json) do |response, request, result, &block|
55
+ Fanforce::Response.new(response, request, url, req_params)
56
56
  end
57
57
  end
58
58
 
59
59
  def delete(path, req_params={})
60
60
  url = complete_url(path)
61
61
  req_params = apply_auth(req_params)
62
- RestClient.delete(url, {:params => to_query_string(req_params), :accept => :json}) do |request, response, result, &block|
63
- Fanforce::Response.new(request, response, url, req_params)
62
+ RestClient.delete(url, {:params => to_query_string(req_params), :accept => :json}) do |response, request, result, &block|
63
+ Fanforce::Response.new(response, request, url, req_params)
64
64
  end
65
65
  end
66
66
 
@@ -1,7 +1,7 @@
1
1
  class Fanforce::Response
2
2
  attr_reader :curl_command, :request_url, :response_body, :response_json
3
3
 
4
- def initialize(request, response, url, req_params)
4
+ def initialize(response, request, url, req_params)
5
5
  case response.code
6
6
  when 200, 201
7
7
  begin
@@ -30,17 +30,17 @@ class Fanforce::Response
30
30
  raise
31
31
  end
32
32
  when 400
33
- raise Fanforce::BadRequestError.new(request, response, url, req_params)
33
+ raise Fanforce::BadRequestError.new(response, request, url, req_params)
34
34
  when 401
35
- raise Fanforce::Unauthorized.new(request, response, url, req_params)
35
+ raise Fanforce::Unauthorized.new(response, request, url, req_params)
36
36
  when 403
37
- raise Fanforce::ForbiddenError.new(request, response, url, req_params)
37
+ raise Fanforce::ForbiddenError.new(response, request, url, req_params)
38
38
  when 404
39
- raise Fanforce::NotFoundError.new(request, response, url, req_params)
39
+ raise Fanforce::NotFoundError.new(response, request, url, req_params)
40
40
  when 422
41
- raise Fanforce::UnprocessableEntityError.new(request, response, url, req_params)
41
+ raise Fanforce::UnprocessableEntityError.new(response, request, url, req_params)
42
42
  else
43
- raise Fanforce::UnknownError.new(request, response, url, req_params)
43
+ raise Fanforce::UnknownError.new(response, request, url, req_params)
44
44
  end
45
45
  response
46
46
  end
@@ -1,3 +1,3 @@
1
1
  class Fanforce
2
- VERSION = '0.5.9'
2
+ VERSION = '0.5.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: