Class: DexcomShareApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dexcom_share_api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, password:, server:) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/dexcom_share_api/client.rb', line 10

def initialize(username:, password:, server:)
  @dexcom_api ||= HttpApi.new(username:, password:, server:)
end

Instance Attribute Details

#dexcom_apiObject (readonly)

Returns the value of attribute dexcom_api.



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

def dexcom_api
  @dexcom_api
end

Instance Method Details

#estimated_glucose(last: 10) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/dexcom_share_api/client.rb', line 14

def estimated_glucose(last: 10)
  result = dexcom_api.fetch_estimated_glucose!(last:)

  result
    .map { |entry| Glucose.new(entry) }
    .reverse
end

#last_estimated_glucoseObject



22
23
24
25
26
# File 'lib/dexcom_share_api/client.rb', line 22

def last_estimated_glucose
  result = dexcom_api.fetch_estimated_glucose!(last: 1)

  Glucose.new(result[0])
end