Module: XHP::HealthPlanet::Status

Included in:
Client
Defined in:
lib/xhp.rb

Defined Under Namespace

Classes: Tag

Instance Method Summary collapse

Instance Method Details

#format_date(date) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/xhp.rb', line 104

def format_date(date)
  if date.kind_of?(Date)
    date.strftime("%Y%m%d%H%M%s")
  elsif date.kind_of?(String)
    date
  end
end

#innerscan(token, tag = nil, date = 1, from = nil, to = nil) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/xhp.rb', line 89

def innerscan(token, tag = nil, date = 1, from = nil, to = nil)
  url_part = ["https://www.healthplanet.jp/status/innerscan.json?access_token=#{token.access_token}&date=#{date}"]
  url_part << "tag=#{tag.to_s}" if tag
  url_part << "from=#{format_date(from)}" if from
  url_part << "to=#{format_date(to)}" if to

  url = url_part.join('&')
  res = get(url)
  raise "Status API return response code #{res.code}" unless res.code == '200'
  json = JSON.parse(res.body)
  json.extend(ResponseHolder)
  json.http_response = res
  json
end