Class: MyZeo

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/my_zeo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, opts = {}) ⇒ MyZeo

Returns a new instance of MyZeo.



11
12
13
14
15
16
# File 'lib/my_zeo.rb', line 11

def initialize(api_key,opts={})
  @api_key = api_key
  @user_id = opts[:user_id] ? opts[:user_id] : nil 
  MyZeo.basic_auth opts[:login], opts[:password] if (opts[:login] && opts[:password])
  MyZeo.base_uri opts[:base_url] if opts[:base_url] 
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/my_zeo.rb', line 8

def api_key
  @api_key
end

#user_idObject (readonly)

Returns the value of attribute user_id.



9
10
11
# File 'lib/my_zeo.rb', line 9

def user_id
  @user_id
end

Instance Method Details

#get_all_dates_with_sleep_dataObject



65
66
67
# File 'lib/my_zeo.rb', line 65

def get_all_dates_with_sleep_data
  MyZeo.get("/getAllDatesWithSleepData?key=#{@api_key}").recursive_symbolize_keys!
end

#get_bulk_sleep_records_since_date(opts = {}) ⇒ Object



37
38
39
40
# File 'lib/my_zeo.rb', line 37

def get_bulk_sleep_records_since_date(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getBulkSleepRecordsSinceDate?key=#{@api_key}", :query => {:userid => @user_id, :date => date }).recursive_symbolize_keys!
end

#get_bulk_sleep_stats_since_date(opts = {}) ⇒ Object



32
33
34
35
# File 'lib/my_zeo.rb', line 32

def get_bulk_sleep_stats_since_date(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getBulkSleepStatsSinceDate?key=#{@api_key}", :query => {:userid => @user_id, :date => date }).recursive_symbolize_keys!
end

#get_dates_with_sleep_data_in_range(opts = {}) ⇒ Object



69
70
71
72
73
# File 'lib/my_zeo.rb', line 69

def get_dates_with_sleep_data_in_range(opts={})
  date_from = opts[:date_from] ? opts[:date_from] : ""
  date_to = opts[:date_to] ? opts[:date_to] : ""
  MyZeo.get("/getDatesWithSleepDataInRange?key=#{@api_key}", :query => {:dateFrom => date_from, :dateTo => date_to}).recursive_symbolize_keys!
end

#get_earliest_sleep_recordObject



109
110
111
# File 'lib/my_zeo.rb', line 109

def get_earliest_sleep_record
  MyZeo.get("/getEarliestSleepRecord?key=#{@api_key}").recursive_symbolize_keys!
end

#get_earliest_sleep_statsObject



105
106
107
# File 'lib/my_zeo.rb', line 105

def get_earliest_sleep_stats
  MyZeo.get("/getEarliestSleepStats?key=#{@api_key}").recursive_symbolize_keys!
end

#get_latest_sleep_recordObject



117
118
119
# File 'lib/my_zeo.rb', line 117

def get_latest_sleep_record
  MyZeo.get("/getLatestSleepRecord?key=#{@api_key}").recursive_symbolize_keys!
end

#get_latest_sleep_statsObject



113
114
115
# File 'lib/my_zeo.rb', line 113

def get_latest_sleep_stats
  MyZeo.get("/getLatestSleepStats?key=#{@api_key}").recursive_symbolize_keys!
end

#get_next_sleep_record(opts = {}) ⇒ Object



100
101
102
103
# File 'lib/my_zeo.rb', line 100

def get_next_sleep_record(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getNextSleepRecord?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#get_next_sleep_stats(opts = {}) ⇒ Object



95
96
97
98
# File 'lib/my_zeo.rb', line 95

def get_next_sleep_stats(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getNextSleepStats?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#get_overall_average_day_feel_scoreObject



53
54
55
# File 'lib/my_zeo.rb', line 53

def get_overall_average_day_feel_score
  MyZeo.get("/getOverallAverageDayFeelScore?key=#{@api_key}").recursive_symbolize_keys!
end

#get_overall_average_morning_feel_scoreObject



57
58
59
# File 'lib/my_zeo.rb', line 57

def get_overall_average_morning_feel_score
  MyZeo.get("/getOverallAverageMorningFeelScore?key=#{@api_key}").recursive_symbolize_keys!
end

#get_overall_average_sleep_stealer_scoreObject



61
62
63
# File 'lib/my_zeo.rb', line 61

def get_overall_average_sleep_stealer_score
  MyZeo.get("/getOverallAverageSleepStealerScore?key=#{@api_key}").recursive_symbolize_keys!
end

#get_overall_average_zq_scoreObject

*************************************************************************************************************************************



49
50
51
# File 'lib/my_zeo.rb', line 49

def get_overall_average_zq_score
  MyZeo.get("/getOverallAverageZQScore?key=#{@api_key}").recursive_symbolize_keys!
end

#get_previous_sleep_record(opts = {}) ⇒ Object



90
91
92
93
# File 'lib/my_zeo.rb', line 90

def get_previous_sleep_record(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getPreviousSleepRecord?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#get_previous_sleep_stats(opts = {}) ⇒ Object



85
86
87
88
# File 'lib/my_zeo.rb', line 85

def get_previous_sleep_stats(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getPreviousSleepStats?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#get_sleep_record_for_date(opts = {}) ⇒ Object



80
81
82
83
# File 'lib/my_zeo.rb', line 80

def get_sleep_record_for_date(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getSleepRecordForDate?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#get_sleep_stats_for_date(opts = {}) ⇒ Object



75
76
77
78
# File 'lib/my_zeo.rb', line 75

def get_sleep_stats_for_date(opts={})
  date = opts[:date] ? opts[:date] : ""
  MyZeo.get("/getSleepStatsForDate?key=#{@api_key}", :query => {:date => date }).recursive_symbolize_keys!
end

#j_spring_security_logoutObject



42
43
44
45
# File 'lib/my_zeo.rb', line 42

def j_spring_security_logout
  logout_url_base = self.base_uri.split('/api/').first
  get("#{logout_url_base}/j_spring_security_logout")
end

#logoutObject



121
122
123
# File 'lib/my_zeo.rb', line 121

def logout
  MyZeo.get("/logout?key=#{@api_key}")
end

#secure_logoutObject



125
126
127
# File 'lib/my_zeo.rb', line 125

def secure_logout
  MyZeo.get("#{self.class.base_uri.split('/api/').first}/j_spring_security_logout")
end

BULK API *************************************************************************************************************************************



20
21
22
# File 'lib/my_zeo.rb', line 20

def subscribe_to_notify_link(callback_url)
  "#{self.class.base_uri}/subscribeToNotify?key=#{@api_key}&userid=#{@user_id}&callback=#{callback_url}"
end

#unsubscribe_from_notifyObject



28
29
30
# File 'lib/my_zeo.rb', line 28

def unsubscribe_from_notify
  MyZeo.get("/unsubscribeFromNotify?key=#{@api_key}", :query => {:userid => @user_id}).recursive_symbolize_keys!
end


24
25
26
# File 'lib/my_zeo.rb', line 24

def unsubscribe_from_notify_link
  "#{self.class.base_uri}/unsubscribeFromNotify?key=#{@api_key}&userid=#{@user_id}"
end