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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTY5NDllN2IwOTFiNTQ0MGFjZjgxYTIxNDY0OGY2ZDEwZTNlZjkxNA==
4
+ Yjk5MjI3MGNlN2FkODk3NzU0OTJlNmFjODUzODU3Njc5YWI4Y2JhMQ==
5
5
  data.tar.gz: !binary |-
6
- YzQ1OGY0OGY4OTU0OGIyYjdjNTc3NWYxNjNlNGNmYjNmMWI5YWVhMg==
6
+ MzBlNTQ2YjlhZTAzNDEzNzc3NzQxNGY4MzQyNDFjN2IxMTY3YWZhOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2ZkY2Q1MDljZjdiMjJkM2RkNzU1MGZjZjliMGIwYTg2OTM5MmQ3OTkxODgz
10
- OTJlYzljODEwMmQwZjBlNWNkOTE4ZmJjZDNmOGM3NDljMDM2YjIzNjEwYmE0
11
- YzE2OTMwNTMxNzNmZDRkOGVlYTk5MzEzY2JhY2UwNTVlZjYxYjg=
9
+ NTlhYzEwMjIzMzM5MjU4YjUyNDBhYjYyYzRkNjRhNmNkNTlmNDdlZDU0MzRl
10
+ ZDA3ZWUyNWFjYjg1YWIxOGQ5NWUxZmNhNzAyNjg2MmQzYTUyOTQwMWMxZjNj
11
+ MmY5NTc1YjYzNGY2YTIwYTcwMzM1YWMwODliNzMzMzFhZjVhOGE=
12
12
  data.tar.gz: !binary |-
13
- ZDdmMGRkMjcxZmVlN2FjYzA2NmM0NjY0YzQ4MTk0NGQxMjhhMjIxYTYyNGFj
14
- NzkyYmRhMTFjMGRhZjYyZjAxMzYxYzYzMmQ3NjUwNzNjNzFjMTYwZDJkYTBl
15
- ZjZkMDkwNGViNjVhOWE3YzRmM2U1Y2RhODJhZDEyYWZkODgyYjY=
13
+ Zjg1MzU0YWZjZDUyMjlhOTJiYmM1OGRhNWE1M2JmNDZhNDU3Nzc4ODViYTE1
14
+ YTAzNTFhOTQzYjI3YTE0M2UzNDcyOWNlZjgyMGZkOWFhYmYyYTBhY2Q1MmM4
15
+ YjA3NGM0NGY0ZTlhMTdjZmI5YWJkMDg1ZmRjZjM4NGJjMzRjNTc=
@@ -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], fanforce_id: auth_data[:fanforce_id], fanforce_slug: auth_data[:fanforce_slug])
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[:fanforce_id])
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)
@@ -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[:results]
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
 
@@ -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[:fanforce_id]) or is_blank?(params[:api_key])
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[:fanforce_id])
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[:fanforce_id])
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[:fanforce_id])
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, fanforce_id: params[:fanforce_id], fanforce_slug: params[:fanforce_slug], api_key: params[:api_key], session_id: params[:session_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, :fanforce_id, :fanforce_slug, :api_key].include? k }
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)
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class API
3
- VERSION = '0.14.9'
3
+ VERSION = '0.15.0'
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ require 'fanforce'
6
6
 
7
7
  describe Fanforce do
8
8
 
9
- it "should test if var is blank" do
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 "should create new instance of fanforce with api_key" do
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.9
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark