Sha256: 31f4425cffb1fc0a20f99615c979bafd81489290d960b296261a1846a9cc04f8
Contents?: true
Size: 1018 Bytes
Versions: 1
Compression:
Stored size: 1018 Bytes
Contents
# frozen_string_literal: true require 'thor' require 'httparty' module StudyLine class CLI < Thor class Sender include HTTParty BASE_URI = 'http://localhost:3000/dashboards' end desc "start", "Record the start time of study" def start start_time = Time.now response = Sender.post( "#{Sender::BASE_URI}/start", body: { start_time: start_time }.to_json, headers: headers ) # Handle the response... end desc "finish", "Record the finish time of study" def finish end_time = Time.now response = Sender.post( "#{Sender::BASE_URI}/finish", body: { end_time: end_time }.to_json, headers: headers ) # Handle the response... end private def user_token ENV['CUSTOM_TOKEN'] || (raise "Error: Token not found.") end def headers { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{user_token}" } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
study_line-0.1.0 | lib/study_line.rb |