Class: Sense::Client
- Inherits:
-
Object
- Object
- Sense::Client
- Includes:
- Account, Alarms, Alerts, App, Devices, Expansions, Firmware, Insights, Notifications, Questions, Sensors, Session, Sharing, SleepSounds, Speech, Stats, Store, Support, Timeline, Trends
- Defined in:
- lib/hello_sense/client.rb
Constant Summary collapse
- API_HOST =
'https://api.hello.is'.freeze
Constants included from Account
Account::EMAIL_PATTERN, Account::MIN_PASSWORD_LENGTH
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#delete(path) ⇒ Object
XXX.
-
#get(path) ⇒ Object
XXX.
-
#initialize(options = {}) ⇒ Client
constructor
XXX.
-
#patch(path, data) ⇒ Object
XXX.
-
#post(path, data) ⇒ Object
XXX.
- #put(path, data) ⇒ Object
Methods included from Trends
Methods included from Timeline
#create_timeline_event, #remove_timeline_event, #timeline, #update_timeline_event
Methods included from Support
Methods included from Store
Methods included from Stats
Methods included from Speech
Methods included from SleepSounds
#play_sound, #sound_durations, #sounds, #sounds_combined_state, #sounds_status, #stop_sounds
Methods included from Sharing
Methods included from Session
#authorize_with_password!, #destroy_token
Methods included from Sensors
#sensors, #sensors_historical, #update_sensors
Methods included from Questions
#questions, #skip_question, #update_questions
Methods included from Notifications
#create_notification, #notifications, #update_notifications
Methods included from Insights
Methods included from Firmware
#firmware_update_status, #request_firmware_update
Methods included from Expansions
#expansion, #expansion_configurations, #expansions, #update_expansion, #update_expansion_configurations
Methods included from Devices
#devices, #devices_info, #remove_device, #remove_pill, #remove_sense, #swap_device, #update_voice, #voice
Methods included from App
Methods included from Alerts
Methods included from Alarms
#alarm_sounds, #alarms, #update_alarm
Methods included from Account
#account, #create_account, #current_timezone, #delete_profile_picture, #preferences, #update_account, #update_email, #update_password, #update_photo, #update_preferences, #update_timezone
Constructor Details
#initialize(options = {}) ⇒ Client
XXX
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hello_sense/client.rb', line 41 def initialize( = {}) @access_token = [:access_token] @client_id = [:client_id] @client_secret = [:client_secret] @password = [:password] @username = [:username] @access_token = if @access_token.nil? puts "** Using #{@access_token} as Sense access token" end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
31 32 33 |
# File 'lib/hello_sense/client.rb', line 31 def access_token @access_token end |
Instance Method Details
#delete(path) ⇒ Object
XXX
55 56 57 58 |
# File 'lib/hello_sense/client.rb', line 55 def delete(path) response = connection.delete(path, headers) data_or_error(response) end |
#get(path) ⇒ Object
XXX
63 64 65 66 |
# File 'lib/hello_sense/client.rb', line 63 def get(path) response = connection.get(path, headers) data_or_error(response) end |
#patch(path, data) ⇒ Object
XXX
72 73 74 75 76 |
# File 'lib/hello_sense/client.rb', line 72 def patch(path, data) # XXX may need +set_form_data+ response = connection.patch(path, data, headers) data_or_error(response) end |
#post(path, data) ⇒ Object
XXX
82 83 84 85 86 87 |
# File 'lib/hello_sense/client.rb', line 82 def post(path, data) request = Net::HTTP::Post.new(path, headers) request.set_form_data(data) response = connection.request(request) data_or_error(response) end |
#put(path, data) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/hello_sense/client.rb', line 91 def put(path, data) request = Net::HTTP::Put.new(path, headers) request.set_form_data(data) response = connection.request(request) data_or_error(response) end |