Class: Gusto::Companies::DepartmentsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::DepartmentsClient
- Defined in:
- lib/fern_gusto/companies/departments/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#add_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) ⇒ Object
api.companies.departments.add_people(department_uuid: “department_uuid”).
-
#create(company_uuid:, title: nil, request_options: nil) ⇒ Object
api.companies.departments.create(company_uuid: “company_uuid”, title: “Stage Hand”).
-
#delete(department_uuid:, request_options: nil) ⇒ Object
api.companies.departments.delete(department_uuid: “department_uuid”).
-
#get(department_uuid:, request_options: nil) ⇒ Object
api.companies.departments.get(department_uuid: “department_uuid”).
- #initialize(request_client:) ⇒ Gusto::Companies::DepartmentsClient constructor
-
#list(company_uuid:, request_options: nil) ⇒ Object
api.companies.departments.list(company_uuid: “company_uuid”).
-
#remove_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) ⇒ Object
api.companies.departments.remove_people(department_uuid: “department_uuid”).
-
#update(department_uuid:, version:, title: nil, request_options: nil) ⇒ Object
).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::DepartmentsClient
27 28 29 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 27 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
22 23 24 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 22 def request_client @request_client end |
Instance Method Details
#add_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) ⇒ Object
api.companies.departments.add_people(department_uuid: “department_uuid”)
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 235 def add_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) response = @request_client.conn.put 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 || {}), version: version, employees: employees, contractors: contractors }.compact req.url "#{@request_client.get_url(request_options: )}/v1/departments/#{department_uuid}/add" end Gusto::Department.from_json(json_object: response.body) end |
#create(company_uuid:, title: nil, request_options: nil) ⇒ Object
api.companies.departments.create(company_uuid: “company_uuid”, title: “Stage Hand”)
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 84 def create(company_uuid:, title: 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 || {}), title: title }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_uuid}/departments" end Gusto::Department.from_json(json_object: response.body) end |
#delete(department_uuid:, request_options: nil) ⇒ Object
api.companies.departments.delete(department_uuid: “department_uuid”)
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 194 def delete(department_uuid:, request_options: nil) response = @request_client.conn.delete 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/departments/#{department_uuid}" end end |
#get(department_uuid:, request_options: nil) ⇒ Object
api.companies.departments.get(department_uuid: “department_uuid”)
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 117 def get(department_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/departments/#{department_uuid}" end Gusto::Department.from_json(json_object: response.body) end |
#list(company_uuid:, request_options: nil) ⇒ Object
api.companies.departments.list(company_uuid: “company_uuid”)
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 44 def list(company_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/companies/#{company_uuid}/departments" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::Department.from_json(json_object: item) end end |
#remove_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) ⇒ Object
api.companies.departments.remove_people(department_uuid: “department_uuid”)
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 275 def remove_people(department_uuid:, version: nil, employees: nil, contractors: nil, request_options: nil) response = @request_client.conn.put 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 || {}), version: version, employees: employees, contractors: contractors }.compact req.url "#{@request_client.get_url(request_options: )}/v1/departments/#{department_uuid}/remove" end Gusto::Department.from_json(json_object: response.body) end |
#update(department_uuid:, version:, title: nil, request_options: nil) ⇒ Object
)
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/fern_gusto/companies/departments/client.rb', line 160 def update(department_uuid:, version:, title: nil, request_options: nil) response = @request_client.conn.put 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 || {}), version: version, title: title }.compact req.url "#{@request_client.get_url(request_options: )}/v1/departments/#{department_uuid}" end Gusto::Department.from_json(json_object: response.body) end |