class Freee::Pigmon::Client

Attributes

client_id[RW]
client_secret[RW]

Public Class Methods

new(client_id, client_secret) click to toggle source
# File lib/freee/pigmon/client.rb, line 9
def initialize(client_id, client_secret)
  self.client_id = client_id
  self.client_secret = client_secret
end

Public Instance Methods

break_begin(access_token, employee_id, company_id) click to toggle source
# File lib/freee/pigmon/client.rb, line 55
def break_begin(access_token, employee_id, company_id)
  api_client(access_token).post_time_clock(
    employee_id,
    company_id,
    'break_begin'
  )
end
break_end(access_token, employee_id, company_id) click to toggle source
# File lib/freee/pigmon/client.rb, line 63
def break_end(access_token, employee_id, company_id)
  api_client(access_token).post_time_clock(
    employee_id,
    company_id,
    'break_end'
  )
end
clock_in(access_token, employee_id, company_id) click to toggle source
# File lib/freee/pigmon/client.rb, line 38
def clock_in(access_token, employee_id, company_id)
  api_client(access_token).post_time_clock(
    employee_id,
    company_id,
    'clock_in'
  )
end
clock_out(access_token, employee_id, company_id) click to toggle source
# File lib/freee/pigmon/client.rb, line 71
def clock_out(access_token, employee_id, company_id)
  api_client(access_token).post_time_clock(
    employee_id,
    company_id,
    'clock_out'
  )
end
clocked_in?(access_token, employee_id, company_id) click to toggle source
# File lib/freee/pigmon/client.rb, line 46
def clocked_in?(access_token, employee_id, company_id)
  available_types = api_client(access_token)
                    .check_available_time_clock_types(
                      employee_id,
                      company_id
                    )
  available_types.include? 'clock_out'
end
fetch_freee_user_info_hash(access_token) click to toggle source
# File lib/freee/pigmon/client.rb, line 32
def fetch_freee_user_info_hash(access_token)
  api_client(access_token).fetch_user_info_hash
end
fetch_token_hash(authorize_code) click to toggle source
# File lib/freee/pigmon/client.rb, line 18
def fetch_token_hash(authorize_code)
  token_info_hash = Freee::Pigmon.fetch_token_from_code(client_id, client_secret, authorize_code)
  token_info_hash
end
get_clocks(access_token, employee_id, company_id, from_date: nil, to_date: nil, per: nil, page: nil) click to toggle source
# File lib/freee/pigmon/client.rb, line 79
def get_clocks(access_token, employee_id, company_id, from_date: nil, to_date: nil, per: nil, page: nil)
  api_client(access_token).get_time_clocks(
    employee_id,
    company_id,
    from_date: from_date,
    to_date: to_date,
    per: per,
    page: page
  )
end
refresh_access_token(access_token, refresh_token, expires_at) click to toggle source
# File lib/freee/pigmon/client.rb, line 23
def refresh_access_token(access_token, refresh_token, expires_at)
  token_info_hash = Freee::Pigmon.token_refresh(
    access_token,
    refresh_token,
    expires_at
  )
  token_info_hash
end
url_to_generate_code() click to toggle source
# File lib/freee/pigmon/client.rb, line 14
def url_to_generate_code
  Freee::Pigmon.url_to_generate_code(self.client_id)
end

Private Instance Methods

api_client(access_token) click to toggle source
# File lib/freee/pigmon/client.rb, line 92
def api_client(access_token)
  Freee::Pigmon::APIClient.new(access_token)
end