fanforce 0.3.12 → 0.3.13

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.
data/lib/fanforce/main.rb CHANGED
@@ -8,7 +8,7 @@ class Fanforce
8
8
  def initialize(arg={})
9
9
  if arg.is_a?(Hash)
10
10
  add_params(arg)
11
- auth(params) if params.length > 0
11
+ auth(@params) if @params.length > 0
12
12
  elsif arg.is_a?(String)
13
13
  auth(arg)
14
14
  end
@@ -18,76 +18,76 @@ class Fanforce
18
18
  @params ||= {}
19
19
  end
20
20
 
21
- def add_params(params)
22
- params.merge!(collect_known_params params)
21
+ def add_params(params_to_add)
22
+ params.merge!(collect_known_params params_to_add)
23
23
  end
24
24
 
25
- def get(path, params={})
25
+ def get(path, req_params={})
26
26
  url = complete_url(path)
27
- params = apply_auth(params)
28
- RestClient.get(url, {:params => params, :accept => :json}) do |response, request, result, &block|
29
- handle_response(response, request, url, params)
27
+ req_params = apply_auth(req_params)
28
+ RestClient.get(url, {:params => req_params, :accept => :json}) do |response, request, result, &block|
29
+ handle_response(response, request, url, req_params)
30
30
  end
31
31
  end
32
32
 
33
- def get_url(path, params={})
33
+ def get_url(path, req_params={})
34
34
  url = complete_url(path)
35
- params = apply_auth(params)
36
- "#{url}?#{to_query_string(params)}"
35
+ req_params = apply_auth(req_params)
36
+ "#{url}?#{to_query_string(req_params)}"
37
37
  end
38
38
 
39
- def post(path, params={})
39
+ def post(path, req_params={})
40
40
  url = complete_url(path)
41
- params = apply_auth(params)
42
- RestClient.post(url, params, {:accept => :json}) do |response, request, result, &block|
43
- handle_response(response, request, url, params)
41
+ req_params = apply_auth(req_params)
42
+ RestClient.post(url, req_params, {:accept => :json}) do |response, request, result, &block|
43
+ handle_response(response, request, url, req_params)
44
44
  end
45
45
  end
46
46
 
47
- def put(path, params={})
47
+ def put(path, req_params={})
48
48
  url = complete_url(path)
49
- params = apply_auth(params)
50
- RestClient.put(url, params, {:accept => :json}) do |response, request, result, &block|
51
- handle_response(response, request, url, params)
49
+ req_params = apply_auth(req_params)
50
+ RestClient.put(url, req_params, {:accept => :json}) do |response, request, result, &block|
51
+ handle_response(response, request, url, req_params)
52
52
  end
53
53
  end
54
54
 
55
- def delete(path, params={})
55
+ def delete(path, req_params={})
56
56
  url = complete_url(path)
57
- params = apply_auth(params)
58
- RestClient.delete(url, {:params => params, :accept => :json}) do |response, request, result, &block|
59
- handle_response(response, request, url, params)
57
+ req_params = apply_auth(req_params)
58
+ RestClient.delete(url, {:params => req_params, :accept => :json}) do |response, request, result, &block|
59
+ handle_response(response, request, url, req_params)
60
60
  end
61
61
  end
62
62
 
63
- def identify(params)
64
- post '/bie/identify', params
63
+ def identify(req_params)
64
+ post '/bie/identify', req_params
65
65
  {success: true}
66
66
  end
67
67
 
68
- def track(behavior_id, params)
69
- post '/bie/track', params.merge(behavior_id: behavior_id)
68
+ def track(behavior_id, req_params)
69
+ post '/bie/track', req_params.merge(behavior_id: behavior_id)
70
70
  {success: true}
71
71
  end
72
72
 
73
- def handle_response(response, request, url, params)
73
+ def handle_response(response, request, url, req_params)
74
74
  case response.code
75
75
  when 200, 201
76
76
  begin
77
77
  response = decode_json(response)
78
78
  rescue
79
- raise UnknownError.new(response, request, url, params)
79
+ raise UnknownError.new(response, request, url, req_params)
80
80
  end
81
81
  when 400
82
- raise BadRequestError.new(response, request, url, params)
82
+ raise BadRequestError.new(response, request, url, req_params)
83
83
  when 403
84
- raise ForbiddenError.new(response, request, url, params)
84
+ raise ForbiddenError.new(response, request, url, req_params)
85
85
  when 404
86
- raise NotFoundError.new(response, request, url, params)
86
+ raise NotFoundError.new(response, request, url, req_params)
87
87
  when 422
88
- raise UnprocessableEntityError.new(response, request, url, params)
88
+ raise UnprocessableEntityError.new(response, request, url, req_params)
89
89
  else
90
- raise UnknownError.new(response, request, url, params)
90
+ raise UnknownError.new(response, request, url, req_params)
91
91
  end
92
92
  response
93
93
  end
@@ -105,8 +105,8 @@ class Fanforce
105
105
  is_present?(@auth_hash) and is_present?(@auth_hash[:api_key]) and is_present?(@auth_hash[:fanforce_id])
106
106
  end
107
107
 
108
- def apply_auth(params)
109
- params.merge(@auth_hash || {})
108
+ def apply_auth(req_params)
109
+ req_params.merge(@auth_hash || {})
110
110
  end
111
111
 
112
112
  def complete_url(path)
@@ -1,3 +1,3 @@
1
1
  class Fanforce
2
- VERSION = "0.3.12"
2
+ VERSION = "0.3.13"
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.3.12
4
+ version: 0.3.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: