Class: TimeEase::Adapter::Mite
- Inherits:
-
Object
- Object
- TimeEase::Adapter::Mite
- Defined in:
- lib/adapters/mite.rb
Instance Method Summary collapse
-
#initialize(parsed_output) ⇒ Mite
constructor
A new instance of Mite.
- #post ⇒ Object
- #request_bodies ⇒ Object
Constructor Details
#initialize(parsed_output) ⇒ Mite
Returns a new instance of Mite.
7 8 9 |
# File 'lib/adapters/mite.rb', line 7 def initialize(parsed_output) @parsed = parsed_output end |
Instance Method Details
#post ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/adapters/mite.rb', line 11 def post request_bodies.each do |req_body| RestClient.post "#{ENV['MITE_API_HOST']}/time_entries.json", req_body.to_json, { content_type: :json, accept: :json, "X-MiteApiKey": ENV["MITE_API_KEY"] } end end |
#request_bodies ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/adapters/mite.rb', line 21 def request_bodies @parsed.map do |entry| { time_entry: { date_at: entry.start_at.strftime("%Y-%m-%d"), minutes: ((entry.end_at - entry.start_at) / 60.0).to_i, project_id: project_id(entry), service_id: service_id(entry), note: "#{entry.pj_name} #{entry.task_name}".strip } } end end |