fanforce-api 0.14.9 → 0.15.0
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 +8 -8
- data/lib/fanforce/api/_main.rb +2 -2
- data/lib/fanforce/api/error.rb +1 -1
- data/lib/fanforce/api/response.rb +4 -2
- data/lib/fanforce/api/utils.rb +6 -6
- data/lib/fanforce/api/version.rb +1 -1
- data/test/fanforce_test.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
|
+
Yjk5MjI3MGNlN2FkODk3NzU0OTJlNmFjODUzODU3Njc5YWI4Y2JhMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzBlNTQ2YjlhZTAzNDEzNzc3NzQxNGY4MzQyNDFjN2IxMTY3YWZhOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTlhYzEwMjIzMzM5MjU4YjUyNDBhYjYyYzRkNjRhNmNkNTlmNDdlZDU0MzRl
|
10
|
+
ZDA3ZWUyNWFjYjg1YWIxOGQ5NWUxZmNhNzAyNjg2MmQzYTUyOTQwMWMxZjNj
|
11
|
+
MmY5NTc1YjYzNGY2YTIwYTcwMzM1YWMwODliNzMzMzFhZjVhOGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Zjg1MzU0YWZjZDUyMjlhOTJiYmM1OGRhNWE1M2JmNDZhNDU3Nzc4ODViYTE1
|
14
|
+
YTAzNTFhOTQzYjI3YTE0M2UzNDcyOWNlZjgyMGZkOWFhYmYyYTBhY2Q1MmM4
|
15
|
+
YjA3NGM0NGY0ZTlhMTdjZmI5YWJkMDg1ZmRjZjM4NGJjMzRjNTc=
|
data/lib/fanforce/api/_main.rb
CHANGED
@@ -88,13 +88,13 @@ class Fanforce::API
|
|
88
88
|
@auth_hash ||= {}
|
89
89
|
return @auth_hash if is_blank?(auth_data)
|
90
90
|
auth_data = auth_data.is_a?(Hash) ? symbolize_keys(auth_data) : {api_key: auth_data.to_s}
|
91
|
-
@auth_hash.merge! remove_nil_values(api_key: auth_data[:api_key],
|
91
|
+
@auth_hash.merge! remove_nil_values(api_key: auth_data[:api_key], organization_id: auth_data[:organization_id], organization_slug: auth_data[:organization_slug])
|
92
92
|
params.merge!(@auth_hash)
|
93
93
|
valid_auth?
|
94
94
|
end
|
95
95
|
|
96
96
|
def valid_auth?
|
97
|
-
is_present?(@auth_hash) and is_present?(@auth_hash[:api_key]) and is_present?(@auth_hash[:
|
97
|
+
is_present?(@auth_hash) and is_present?(@auth_hash[:api_key]) and is_present?(@auth_hash[:organization_id])
|
98
98
|
end
|
99
99
|
|
100
100
|
def apply_auth(req_params)
|
data/lib/fanforce/api/error.rb
CHANGED
@@ -53,7 +53,7 @@ end
|
|
53
53
|
class Fanforce::API::DecodingError < Fanforce::API::Error
|
54
54
|
|
55
55
|
def initialize(e, response, request, requested_url, requested_params)
|
56
|
-
@message = "There was a Fanforce gem error while decoding JSON response: #{e.message}"
|
56
|
+
@message = "There was a Fanforce gem error while decoding JSON response: #{e.is_a?(String) ? e : e.message}"
|
57
57
|
@errors = [{message: @message}]
|
58
58
|
super(@message, response, request, requested_url, requested_params)
|
59
59
|
end
|
@@ -5,7 +5,9 @@ class Fanforce::API::Response
|
|
5
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
7
|
rescue Exception => e; raise Fanforce::API::DecodingError.new(e, response, request, requested_url, requested_params) end
|
8
|
-
if response_hash
|
8
|
+
if !response_hash.is_a?(Hash)
|
9
|
+
raise Fanforce::API::DecodingError.new('Server did not send a valid hash.', response, request, requested_url, requested_params)
|
10
|
+
elsif response_hash[:results]
|
9
11
|
Fanforce::API::Results.new(response_hash, response, request, requested_url, requested_params)
|
10
12
|
else
|
11
13
|
Fanforce::API::Result.new(response_hash, response, request, requested_url, requested_params)
|
@@ -71,7 +73,7 @@ class Fanforce::API::Results < Array
|
|
71
73
|
@curl_command ||= Fanforce::Utils.curl_command(@request.method, @requested_url, @requested_params)
|
72
74
|
end
|
73
75
|
|
74
|
-
def body
|
76
|
+
def body
|
75
77
|
@response.to_s
|
76
78
|
end
|
77
79
|
|
data/lib/fanforce/api/utils.rb
CHANGED
@@ -7,20 +7,20 @@ module Fanforce::API::Utils
|
|
7
7
|
|
8
8
|
def valid_fanforce_js_request?(params=@params)
|
9
9
|
return false if !params.is_a?(Hash)
|
10
|
-
return false if is_blank?(params[:
|
10
|
+
return false if is_blank?(params[:organization_id]) or is_blank?(params[:api_key])
|
11
11
|
return true
|
12
12
|
end
|
13
13
|
|
14
14
|
def valid_fanforce_request?(params=@params)
|
15
15
|
return false if !params.is_a?(Hash)
|
16
|
-
return false if is_blank?(params[:
|
16
|
+
return false if is_blank?(params[:organization_id])
|
17
17
|
return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id])
|
18
18
|
return true
|
19
19
|
end
|
20
20
|
|
21
21
|
def valid_install_request?(params=@params)
|
22
22
|
return false if !params.is_a?(Hash)
|
23
|
-
return false if is_blank?(params[:
|
23
|
+
return false if is_blank?(params[:organization_id])
|
24
24
|
return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id])
|
25
25
|
return false if is_blank?(params[:api_key])
|
26
26
|
return true
|
@@ -28,7 +28,7 @@ module Fanforce::API::Utils
|
|
28
28
|
|
29
29
|
def valid_uninstall_request?(params=@params)
|
30
30
|
return false if !params.is_a?(Hash)
|
31
|
-
return false if is_blank?(params[:
|
31
|
+
return false if is_blank?(params[:organization_id])
|
32
32
|
return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id])
|
33
33
|
return false if is_blank?(params[:api_key])
|
34
34
|
return true
|
@@ -53,11 +53,11 @@ module Fanforce::API::Utils
|
|
53
53
|
addon_type = :widget
|
54
54
|
addon_id = params[:widget_id]
|
55
55
|
end
|
56
|
-
remove_nil_values(:"#{addon_type}_id" => params[:"#{addon_type}_id"], addon_type: addon_type, addon_id: addon_id,
|
56
|
+
remove_nil_values(:"#{addon_type}_id" => params[:"#{addon_type}_id"], addon_type: addon_type, addon_id: addon_id, organization_id: params[:organization_id], organization_slug: params[:organization_slug], api_key: params[:api_key], session_id: params[:session_id])
|
57
57
|
end
|
58
58
|
|
59
59
|
def remove_internal_params(params)
|
60
|
-
params.clone.delete_if { |k,v| [:app_id, :behavior_plugin_id, :plugin_id, :widget_id, :addon_type, :addon_id, :
|
60
|
+
params.clone.delete_if { |k,v| [:app_id, :behavior_plugin_id, :plugin_id, :widget_id, :addon_type, :addon_id, :organization_id, :organization_slug, :api_key].include? k }
|
61
61
|
end
|
62
62
|
|
63
63
|
def remove_sensitive_params(params)
|
data/lib/fanforce/api/version.rb
CHANGED
data/test/fanforce_test.rb
CHANGED
@@ -6,7 +6,7 @@ require 'fanforce'
|
|
6
6
|
|
7
7
|
describe Fanforce do
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should test if var is blank' do
|
10
10
|
assert Fanforce.is_blank?(nil)
|
11
11
|
assert !Fanforce.is_blank?("value")
|
12
12
|
|
@@ -15,7 +15,7 @@ describe Fanforce do
|
|
15
15
|
assert !ff.is_blank?("value")
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'should create new instance of fanforce with api_key' do
|
19
19
|
Fanforce.new('13d90b01-6df7-4618-881c-c79320a0dc21')
|
20
20
|
end
|
21
21
|
|