Class: PapierkramApi::V1::Endpoints::Tracker::TimeEntries
- Defined in:
- lib/papierkram_api/v1/endpoints/tracker/time_entries.rb
Overview
This class is responsible for all the API calls related to tracker time entries connections.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(page: 1, page_size: 100, order_by: nil, order_direction: nil, project_id: nil, task_id: nil, invoice_id: nil, user_id: nil, billing_state: nil, start_time_range_start: nil, start_time_range_end: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists.
- #archive_by(id:) ⇒ Object
- #create(entry_date:, started_at_time:, ended_at_time:, task_id:, user_id:, comments: nil, billable_duration: nil, unbillable: nil) ⇒ Object
- #delete_by(id:) ⇒ Object
- #find_by(id:) ⇒ Object
- #unarchive_by(id:) ⇒ Object
-
#update_by(id:, entry_date: nil, started_at_time: nil, ended_at_time: nil, task_id: nil, user_id: nil, comments: nil, billable_duration: nil, unbillable: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Methods inherited from Base
#http_delete, #http_get, #http_patch, #http_post, #http_put, #initialize, #remaining_quota
Constructor Details
This class inherits a constructor from PapierkramApi::V1::Endpoints::Base
Instance Method Details
#all(page: 1, page_size: 100, order_by: nil, order_direction: nil, project_id: nil, task_id: nil, invoice_id: nil, user_id: nil, billing_state: nil, start_time_range_start: nil, start_time_range_end: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 13 def all(page: 1, # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists page_size: 100, order_by: nil, order_direction: nil, project_id: nil, task_id: nil, invoice_id: nil, user_id: nil, billing_state: nil, start_time_range_start: nil, start_time_range_end: nil) validate!(billing_state: billing_state, start_time_range_start: start_time_range_start, start_time_range_end: start_time_range_end) query = { page: page, page_size: page_size } query[:order_by] = order_by if order_by query[:order_direction] = order_direction if order_direction query[:project_id] = project_id if project_id query[:task_id] = task_id if task_id query[:invoice_id] = invoice_id if invoice_id query[:user_id] = user_id if user_id query[:billing_state] = billing_state if billing_state query[:start_time_range_start] = start_time_range_start if start_time_range_start query[:start_time_range_end] = start_time_range_end if start_time_range_end http_get("#{@url_api_path}/tracker/time_entries", query) end |
#archive_by(id:) ⇒ Object
96 97 98 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 96 def archive_by(id:) http_post("#{@url_api_path}/tracker/time_entries/#{id}/archive") end |
#create(entry_date:, started_at_time:, ended_at_time:, task_id:, user_id:, comments: nil, billable_duration: nil, unbillable: nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 45 def create( entry_date:, started_at_time:, ended_at_time:, task_id:, user_id:, comments: nil, billable_duration: nil, unbillable: nil ) body = {} body[:entry_date] = entry_date body[:started_at_time] = started_at_time body[:ended_at_time] = ended_at_time body[:task] = { id: task_id } body[:user] = { id: user_id } body[:comments] = comments if comments body[:billable_duration] = billable_duration if billable_duration body[:unbillable] = unbillable if unbillable http_post("#{@url_api_path}/tracker/time_entries", body) end |
#delete_by(id:) ⇒ Object
92 93 94 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 92 def delete_by(id:) http_delete("#{@url_api_path}/tracker/time_entries/#{id}") end |
#find_by(id:) ⇒ Object
9 10 11 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 9 def find_by(id:) http_get("#{@url_api_path}/tracker/time_entries/#{id}") end |
#unarchive_by(id:) ⇒ Object
100 101 102 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 100 def unarchive_by(id:) http_post("#{@url_api_path}/tracker/time_entries/#{id}/unarchive") end |
#update_by(id:, entry_date: nil, started_at_time: nil, ended_at_time: nil, task_id: nil, user_id: nil, comments: nil, billable_duration: nil, unbillable: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/papierkram_api/v1/endpoints/tracker/time_entries.rb', line 68 def update_by( # rubocop:disable Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity id:, entry_date: nil, started_at_time: nil, ended_at_time: nil, task_id: nil, user_id: nil, comments: nil, billable_duration: nil, unbillable: nil ) body = {} body[:entry_date] = entry_date if entry_date body[:started_at_time] = started_at_time if started_at_time body[:ended_at_time] = ended_at_time if ended_at_time body[:task] = { id: task_id } if task_id body[:user] = { id: user_id } if user_id body[:comments] = comments if comments body[:billable_duration] = billable_duration if billable_duration body[:unbillable] = unbillable if unbillable http_put("#{@url_api_path}/tracker/time_entries/#{id}", body) end |