Class: Gusto::ReportsClient
- Inherits:
-
Object
- Object
- Gusto::ReportsClient
- Defined in:
- lib/fern_gusto/reports/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_uuid:, columns:, groupings:, custom_name: nil, file_type:, with_totals: nil, start_date: nil, end_date: nil, dismissed_start_date: nil, dismissed_end_date: nil, payment_method: nil, employment_type: nil, employment_status: nil, employee_uuids: nil, department_uuids: nil, work_address_uuids: nil, request_options: nil) ⇒ Object
).
-
#get(report_uuid:, request_options: nil) ⇒ Object
api.reports.get(report_uuid: “report_uuid”).
-
#get_template(company_uuid:, report_type:, request_options: nil) ⇒ Object
api.reports.get_template(company_uuid: “company_uuid”, report_type: “report_type”).
- #initialize(request_client:) ⇒ Gusto::ReportsClient constructor
Constructor Details
#initialize(request_client:) ⇒ Gusto::ReportsClient
25 26 27 |
# File 'lib/fern_gusto/reports/client.rb', line 25 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
20 21 22 |
# File 'lib/fern_gusto/reports/client.rb', line 20 def request_client @request_client end |
Instance Method Details
#create(company_uuid:, columns:, groupings:, custom_name: nil, file_type:, with_totals: nil, start_date: nil, end_date: nil, dismissed_start_date: nil, dismissed_end_date: nil, payment_method: nil, employment_type: nil, employment_status: nil, employee_uuids: nil, department_uuids: nil, work_address_uuids: nil, request_options: nil) ⇒ Object
)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fern_gusto/reports/client.rb', line 64 def create(company_uuid:, columns:, groupings:, custom_name: nil, file_type:, with_totals: nil, start_date: nil, end_date: nil, dismissed_start_date: nil, dismissed_end_date: nil, payment_method: nil, employment_type: nil, employment_status: nil, employee_uuids: nil, department_uuids: nil, work_address_uuids: nil, request_options: nil) response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), columns: columns, groupings: groupings, custom_name: custom_name, file_type: file_type, with_totals: with_totals, start_date: start_date, end_date: end_date, dismissed_start_date: dismissed_start_date, dismissed_end_date: dismissed_end_date, payment_method: payment_method, employment_type: employment_type, employment_status: employment_status, employee_uuids: employee_uuids, department_uuids: department_uuids, work_address_uuids: work_address_uuids }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_uuid}/reports" end Gusto::CreateReport.from_json(json_object: response.body) end |
#get(report_uuid:, request_options: nil) ⇒ Object
api.reports.get(report_uuid: “report_uuid”)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/fern_gusto/reports/client.rb', line 98 def get(report_uuid:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/reports/#{report_uuid}" end Gusto::Report.from_json(json_object: response.body) end |
#get_template(company_uuid:, report_type:, request_options: nil) ⇒ Object
api.reports.get_template(company_uuid: “company_uuid”, report_type: “report_type”)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/fern_gusto/reports/client.rb', line 136 def get_template(company_uuid:, report_type:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_uuid}/report_templates/#{report_type}" end Gusto::ReportTemplate.from_json(json_object: response.body) end |