Class: Driftrock::Service::DriftrockModel::DriftrockApp
Class Method Summary
collapse
Instance Method Summary
collapse
#get_from_api_method, included, #initialize, #post_to_api_method, #put_to_api_method
Class Method Details
.all_for_current_user ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 64
def self.all_for_current_user
array_of_app_hashes = get_from_api_method.call("/apps_for_current_user")
array_of_app_hashes.map do |app_hash|
app_hash.symbolize_keys!
new(app_hash)
end
end
|
Instance Method Details
#activate ⇒ Object
22
23
24
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 22
def activate
post_to_api_method.call("/#{id}/activate")
end
|
#auth_token(timestamp) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 26
def auth_token(timestamp)
response = post_to_api_method.call(
"/#{id}/auth_token",
{timestamp: timestamp})
response['token']
end
|
#logout_url ⇒ Object
45
46
47
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 45
def logout_url
url+"/driftrock_logout"
end
|
#show_url ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 33
def show_url
timestamp = DateTime.now
token = auth_token(timestamp)
query_str = {
timestamp: timestamp,
company_id: ::Driftrock::Service::DriftrockApi.instance.current_company_id,
token: token,
user_id: ::Driftrock::Service::DriftrockApi.instance.current_user_id
}.to_query
url+"?"+query_str
end
|
#status_check(http_method = HTTParty.public_method(:get)) ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 53
def status_check(http_method = HTTParty.public_method(:get))
status = :ok
begin
status_text = http_method.call(status_url)
status = :not_ok if status_text.strip != "OK"
rescue Errno::ECONNREFUSED => e
status = :not_available
end
status
end
|
#status_url ⇒ Object
49
50
51
|
# File 'lib/driftrock-service/driftrock_model/driftrock_app.rb', line 49
def status_url
url+"/driftrock_app_status"
end
|