Class: Thron::Gateway::Dashboard

Inherits:
Session show all
Defined in:
lib/thron/gateway/dashboard.rb

Constant Summary collapse

PACKAGE =
Package.new(:xadmin, :resources, self.service_name)

Constants inherited from Base

Base::NO_ACTIVE_SESSION

Instance Attribute Summary

Attributes inherited from Base

#token_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Session

#initialize

Methods included from Pageable

included

Methods inherited from Base

#check_session, client_id, #client_id, service_name

Methods included from Routable

included, info, #route

Constructor Details

This class inherits a constructor from Thron::Gateway::Session

Class Method Details

.routesObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/thron/gateway/dashboard.rb', line 9

def self.routes
  @routes ||= {
    change_contents_owner: Route::factory(name: 'changeContentsOwner', package: PACKAGE),
    download_source_file: Route::factory(name: 'downloadSourceFile', package: PACKAGE, verb: Route::Verbs::GET),
    migrate_user_stuff: Route::factory(name: 'migrateUserStuff', package: PACKAGE),
    propagate_acl_to_sub_categories: Route::factory(name: 'propagateAclToSubCategories', package: PACKAGE),
    replace_source_files: Route::factory(name: 'replaceSourceFiles', package: PACKAGE),
    reset_content_user_preferences: Route::factory(name: 'resetUserPreferences', package: PACKAGE),
    trash_contents: Route::factory(name: 'trashContent', package: PACKAGE),
    untrash_contents: Route::factory(name: 'untrashContent', package: PACKAGE)
  }
end

Instance Method Details

#change_contents_owner(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/thron/gateway/dashboard.rb', line 22

def change_contents_owner(options = {})
  contents = options[:contents]
  body = { 
    clientId: client_id,
    contents: contents
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#download_source_file(options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/thron/gateway/dashboard.rb', line 31

def download_source_file(options = {})
  content_id = options[:content_id]
  save_as = options[:save_as]
  query = { 
    clientId: client_id,
    tokenId: token_id,
    xcontentId: content_id,
    saveAs: save_as
  }
  route(to: __callee__, query: query, token_id: token_id)
end

#migrate_user_stuff(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/thron/gateway/dashboard.rb', line 43

def migrate_user_stuff(options = {})
  user_id1 = options[:user_id1]
  user_id2 = options[:user_id2]
  remove_user_id1 = options.fetch(:remove_user_id1) { false }
  body = { 
    clientId: client_id,
    userId1: user_id1,
    userId2: user_id2,
    removeUserId1: remove_user_id1
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#propagate_acl_to_sub_categories(options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/thron/gateway/dashboard.rb', line 56

def propagate_acl_to_sub_categories(options = {})
  category_id = options[:category_id]
  acls = options[:acls]
  force = options.fetch(:force) { false }
  body = { 
    clientId: client_id,
    categoryId: category_id,
    acls: acls,
    force: force
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#replace_source_files(options = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/thron/gateway/dashboard.rb', line 69

def replace_source_files(options = {})
  media_content_id = options[:media_content_id]
  content_id = options[:content_id]
  file_ids = options[:file_ids]
  remove_original_files = options.fetch(:remove_original_files) { false }
  body = { 
    clientId: client_id,
    mediaContentId: media_content_id,
    xcontentId: content_id,
    sourceFiles: { repositoryFileIds: file_ids },
    removeOriginalFiles: remove_original_files
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#reset_content_user_preferences(options = {}) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/thron/gateway/dashboard.rb', line 84

def reset_content_user_preferences(options = {})
  content_id = options[:content_id]
  body = { 
    clientId: client_id,
    xcontentId: content_id
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#trash_contents(options = {}) ⇒ Object



93
94
95
96
97
98
99
100
101
102
# File 'lib/thron/gateway/dashboard.rb', line 93

def trash_contents(options = {})
  contents = options[:contents]
  body = { 
    clientId: client_id,
    contentList: { contentsToTrash: contents.map(&:payload) }
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.extra(attribute: 'contentsInIssue')
  end
end

#untrash_contents(options = {}) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/thron/gateway/dashboard.rb', line 104

def untrash_contents(options = {})
  new_user_id = options[:new_user_id]
  content_ids = options[:content_ids]
  body = { 
    clientId: client_id,
    contentList: { 
      newUserId: new_user_id,
      xcontentIds: content_ids
    }
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.extra(attribute: 'contentsInIssue')
  end
end