# frozen_string_literal: true module Toggl module Jobcan # Jobcan client class Client attr_accessor :credentials attr_reader :driver attr_reader :toggl include Toggl::Jobcan::TogglSupport DEFAULT_CONFIG = { timezone: 'Asia/Tokyo', day_begin_hour: 6, max_working_interval: 10 }.freeze JOBCAN_URLS = { attendance: 'https://ssl.jobcan.jp/employee/attendance', attendance_modify: 'https://ssl.jobcan.jp/employee/adit/modify/' }.freeze XPATHS = { notice: %(//textarea[@name='notice']), load_button: %(//input[@value='表示']), submit: %(//button[@type='submit']), password_label: %(//label[@for='password']) }.freeze def initialize(credentials: nil, options: Selenium::WebDriver::Chrome::Options.new) @credentials = credentials @config = DEFAULT_CONFIG options.add_argument('--headless') @driver = Selenium::WebDriver.for :chrome, options: options @toggl = Toggl::Worktime::Driver.new( max_working_interval: @config[:max_working_interval] ) end def login @driver.navigate.to JOBCAN_URLS[:attendance] # login if