driftrock-service 0.3.1 → 0.3.2
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/driftrock-service.rb +5 -1
- data/lib/driftrock-service/api/admin.rb +2 -14
- data/lib/driftrock-service/api/data.rb +5 -1
- data/lib/driftrock-service/api/website.rb +12 -8
- data/lib/driftrock-service/config.rb +14 -9
- data/lib/driftrock-service/driftrock_app.rb +2 -6
- data/lib/driftrock-service/version.rb +1 -1
- data/spec/administrative_api_spec.rb +4 -2
- data/spec/models/administrative_api_test.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
data/lib/driftrock-service.rb
CHANGED
@@ -18,7 +18,6 @@ module Driftrock
|
|
18
18
|
def acts_as_driftrock_app
|
19
19
|
if respond_to?(:before_filter)
|
20
20
|
include Driftrock::Service::DriftrockApp
|
21
|
-
before_filter :add_p3p_header
|
22
21
|
before_filter :authorise, except: :driftrock_app_status
|
23
22
|
end
|
24
23
|
include Driftrock::Service::Api::Data
|
@@ -33,6 +32,11 @@ module Driftrock
|
|
33
32
|
include Driftrock::Service::Api::Website
|
34
33
|
end
|
35
34
|
|
35
|
+
def acts_as_driftrock_website_model
|
36
|
+
include Driftrock::Service::Api::Website
|
37
|
+
extend Driftrock::Service::Api::Website
|
38
|
+
end
|
39
|
+
|
36
40
|
def acts_as_driftrock_admin
|
37
41
|
include Driftrock::Service::Api::Admin
|
38
42
|
end
|
@@ -13,20 +13,8 @@ module Driftrock
|
|
13
13
|
get(URLs::APPS)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
put(URLs::APPS+"/#{
|
18
|
-
end
|
19
|
-
|
20
|
-
def make_invisible(app_id)
|
21
|
-
put(URLs::APPS+"/#{app_id}/make_invisible")
|
22
|
-
end
|
23
|
-
|
24
|
-
def activate(app_id)
|
25
|
-
put(URLs::APPS+"/#{app_id}/activate")
|
26
|
-
end
|
27
|
-
|
28
|
-
def deactivate(app_id)
|
29
|
-
put(URLs::APPS+"/#{app_id}/deactivate")
|
16
|
+
def update_app(id, app_data)
|
17
|
+
put(URLs::APPS + "/#{id}", app_data)
|
30
18
|
end
|
31
19
|
|
32
20
|
end
|
@@ -11,26 +11,30 @@ module Driftrock
|
|
11
11
|
APPS = BASE+'/driftrock_app'
|
12
12
|
end
|
13
13
|
|
14
|
-
def list_apps
|
15
|
-
get(URLs::APPS+"/")
|
14
|
+
def list_apps(opts = {})
|
15
|
+
get(URLs::APPS+"/", opts)
|
16
16
|
end
|
17
17
|
|
18
|
-
def get_app(app_id)
|
19
|
-
get(URLs::APPS+"/#{app_id}")
|
18
|
+
def get_app(app_id, opts ={})
|
19
|
+
get(URLs::APPS+"/#{app_id}", opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_app_by_string_app_id(app_id, opts ={})
|
23
|
+
get(URLs::APPS+"/#{app_id}/by_app_id", opts)
|
20
24
|
end
|
21
25
|
|
22
26
|
def add_twitter_details(username, password)
|
23
27
|
post(URLs::CHANNELS+"/temp/connect_twitter", {username: username, password: password})
|
24
28
|
end
|
25
29
|
|
26
|
-
def auth_token(app_id, timestamp,
|
30
|
+
def auth_token(app_id, timestamp, opts={})
|
27
31
|
response = post(URLs::APPS+"/#{app_id}/auth_token",
|
28
|
-
{
|
32
|
+
{timestamp: timestamp}.merge(opts))
|
29
33
|
response['token']
|
30
34
|
end
|
31
35
|
|
32
|
-
def activate_app(app_id)
|
33
|
-
post(URLs::APPS+"/#{app_id}/activate")
|
36
|
+
def activate_app(app_id, opts={})
|
37
|
+
post(URLs::APPS+"/#{app_id}/activate", opts)
|
34
38
|
end
|
35
39
|
|
36
40
|
def channel_types
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Driftrock
|
2
2
|
module Service
|
3
|
-
class Config < Struct.new(:salt
|
4
|
-
:
|
3
|
+
class Config < Struct.new(:salt, :website_location, :status_location,
|
4
|
+
:status_action,
|
5
|
+
:logout_action, :log_location,:log_level,:base_url,
|
6
|
+
:app_id,:api_token)
|
5
7
|
private_class_method :new
|
6
8
|
|
7
9
|
def self.base_url
|
@@ -16,10 +18,6 @@ module Driftrock
|
|
16
18
|
@config.api_token
|
17
19
|
end
|
18
20
|
|
19
|
-
def self.unauthorised_path
|
20
|
-
@config.unauthorised_path
|
21
|
-
end
|
22
|
-
|
23
21
|
def self.app_id
|
24
22
|
@config.app_id
|
25
23
|
end
|
@@ -31,17 +29,24 @@ module Driftrock
|
|
31
29
|
def self.log_location
|
32
30
|
@config.log_location
|
33
31
|
end
|
32
|
+
|
33
|
+
def self.website_location
|
34
|
+
@config.website_location
|
35
|
+
end
|
34
36
|
|
35
37
|
def self.init
|
36
38
|
config = new
|
37
39
|
config.log_level = DriftrockLogger::Levels::ALL
|
38
40
|
config.log_location = STDOUT
|
41
|
+
config.website_location = "http://www.driftrock.com"
|
42
|
+
config.status_action = "application#driftrock_app_status"
|
43
|
+
config.logout_action = "application#driftrock_logout"
|
39
44
|
yield(config)
|
40
45
|
config.base_url.gsub(/\/$/, "") if config.base_url
|
41
|
-
|
42
|
-
if Rails && config.app_id
|
46
|
+
if defined?(Rails) && config.app_id
|
43
47
|
Rails.application.routes.prepend do
|
44
|
-
get 'driftrock_app_status' =>
|
48
|
+
get 'driftrock_app_status' => config.status_action
|
49
|
+
get 'driftrock_logout' => config.logout_action
|
45
50
|
end
|
46
51
|
end
|
47
52
|
@config = config
|
@@ -1,10 +1,5 @@
|
|
1
1
|
module Driftrock::Service
|
2
2
|
module DriftrockApp
|
3
|
-
|
4
|
-
|
5
|
-
def add_p3p_header
|
6
|
-
response.headers["p3p"] = "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
|
7
|
-
end
|
8
3
|
|
9
4
|
def authorise
|
10
5
|
return if session && session[:user_id] && session[:company_id]
|
@@ -13,7 +8,8 @@ module Driftrock::Service
|
|
13
8
|
token = params[:token]
|
14
9
|
expected_token = token_for(timestamp, company_id)
|
15
10
|
if token != expected_token
|
16
|
-
redirect_to Driftrock::Service::Config.
|
11
|
+
redirect_to Driftrock::Service::Config.website_location+
|
12
|
+
"?unauthorised=true"
|
17
13
|
else
|
18
14
|
session[:user_id] = params[:user_id]
|
19
15
|
session[:company_id] = params[:company_id]
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AdministrativeApiTest do
|
4
|
-
it "should
|
4
|
+
it "should error without a user and session id" do
|
5
5
|
#Assume for the sake of testing there's at least one app
|
6
|
-
|
6
|
+
lambda{
|
7
|
+
AdministrativeApiTest.new.list_apps
|
8
|
+
}.should raise_error(Driftrock::Errors::DriftrockError)
|
7
9
|
end
|
8
10
|
|
9
11
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: driftrock-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|