Module: Driftrock::Service::Api::Administrative

Includes:
Driftrock::Service::Api
Defined in:
lib/driftrock-service/api/administrative.rb

Defined Under Namespace

Modules: URLs

Instance Method Summary collapse

Methods included from Driftrock::Service::Api

#get, #post, #put

Instance Method Details

#activate_app(app_id) ⇒ Object



32
33
34
# File 'lib/driftrock-service/api/administrative.rb', line 32

def activate_app(app_id)
  post(URLs::APPS+"/#{app_id}/activate")
end

#add_channel(channel_name, channel_data) ⇒ Object



40
41
42
# File 'lib/driftrock-service/api/administrative.rb', line 40

def add_channel(channel_name, channel_data)
  post(URLs::CHANNELS+"/#{channel_name}", channel_data) 
end

#add_company(company_data) ⇒ Object



64
65
66
# File 'lib/driftrock-service/api/administrative.rb', line 64

def add_company(company_data)
  post(URLs::USERS+"/company", company_data)
end

#add_profile_for_channel(channel_name, profile_id) ⇒ Object



48
49
50
# File 'lib/driftrock-service/api/administrative.rb', line 48

def add_profile_for_channel(channel_name, profile_id)
  post(URLs::CHANNELS+"/#{channel_name}/profile", {profile_id: profile_id}) 
end

#add_twitter_details(username, password) ⇒ Object



22
23
24
# File 'lib/driftrock-service/api/administrative.rb', line 22

def add_twitter_details(username, password)
  post(URLs::CHANNELS+"/temp/connect_twitter", {username: username, password: password})
end

#auth_token(app_id, timestamp, company_id) ⇒ Object



26
27
28
29
30
# File 'lib/driftrock-service/api/administrative.rb', line 26

def auth_token(app_id, timestamp, company_id)
  response = post(URLs::APPS+"/#{app_id}/auth_token", 
       {company_id: company_id, timestamp: timestamp})
  response['token']
end

#channel_typesObject



36
37
38
# File 'lib/driftrock-service/api/administrative.rb', line 36

def channel_types
  get(URLs::CHANNELS+"/types")
end

#driftrock_login(validation_data) ⇒ Object



56
57
58
# File 'lib/driftrock-service/api/administrative.rb', line 56

def (validation_data)
  post(URLs::USERS+"/login", validation_data) 
end

#get_app(app_id) ⇒ Object



18
19
20
# File 'lib/driftrock-service/api/administrative.rb', line 18

def get_app(app_id)
  get(URLs::APPS+"/#{app_id}")
end

#get_channel(channel_name) ⇒ Object



44
45
46
# File 'lib/driftrock-service/api/administrative.rb', line 44

def get_channel(channel_name)
  get(URLs::CHANNELS+"/#{channel_name}") 
end

#get_companiesObject



76
77
78
# File 'lib/driftrock-service/api/administrative.rb', line 76

def get_companies
  get(URLs::USERS+"/companies") 
end

#get_company(company_id) ⇒ Object



72
73
74
# File 'lib/driftrock-service/api/administrative.rb', line 72

def get_company(company_id)
  get(URLs::USERS+"/company/#{company_id}") 
end

#get_user(user_session_id) ⇒ Object



68
69
70
# File 'lib/driftrock-service/api/administrative.rb', line 68

def get_user(user_session_id)
  get(URLs::USERS+"/#{user_session_id}") 
end

#list_appsObject



14
15
16
# File 'lib/driftrock-service/api/administrative.rb', line 14

def list_apps
  get(URLs::APPS+"/")
end

#new_account(user_data) ⇒ Object



60
61
62
# File 'lib/driftrock-service/api/administrative.rb', line 60

def (user_data)
  post(URLs::USERS+"/new", user_data) 
end

#new_company(company_data) ⇒ Object



85
86
87
# File 'lib/driftrock-service/api/administrative.rb', line 85

def new_company(company_data)
  post(URLs::COMPANIES+"/new", company_data) 
end

#new_token_for_channel(channel_name, token) ⇒ Object



52
53
54
# File 'lib/driftrock-service/api/administrative.rb', line 52

def new_token_for_channel(channel_name, token)
  put(URLs::CHANNELS+"/#{channel_name}/profile", token) 
end

#user_admin?(user_session_id) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
83
# File 'lib/driftrock-service/api/administrative.rb', line 80

def user_admin?(user_session_id)
  response = get(URLs::USERS+"/#{user_session_id}/is_admin") 
  response['is_admin'] =~ /true/
end