Class: Gusto::Companies::AsyncAttachmentsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::AsyncAttachmentsClient
- Defined in:
- lib/fern_gusto/companies/attachments/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_id:, document:, category:, request_options: nil) ⇒ Object
api.companies.attachments.create(company_id: “company_id”, document: my_file.txt).
-
#get(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”).
-
#get_download_url(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get_download_url(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”).
- #initialize(request_client:) ⇒ Gusto::Companies::AsyncAttachmentsClient constructor
-
#list(company_id:, request_options: nil) ⇒ Object
api.companies.attachments.list(company_id: “company_id”).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::AsyncAttachmentsClient
178 179 180 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 178 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::AsyncRequestClient (readonly)
173 174 175 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 173 def request_client @request_client end |
Instance Method Details
#create(company_id:, document:, category:, request_options: nil) ⇒ Object
api.companies.attachments.create(company_id: “company_id”, document: my_file.txt)
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 311 def create(company_id:, document:, category:, request_options: nil) Async do 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 || {}), document: Gusto::FileUtilities.as_faraday_multipart(file_like: document), category: category }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/attachments" end Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: response.body) end end |
#get(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”)
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 194 def get(company_id:, company_attachment_uuid:, request_options: nil) Async do 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_id}/attachments/#{}" end Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: response.body) end end |
#get_download_url(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get_download_url(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”)
231 232 233 234 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/attachments/client.rb', line 231 def get_download_url(company_id:, company_attachment_uuid:, request_options: nil) Async do 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_id}/attachments/#{}/download_url" end Gusto::Companies::Attachments::AttachmentsGetDownloadURLResponse.from_json(json_object: response.body) end end |
#list(company_id:, request_options: nil) ⇒ Object
api.companies.attachments.list(company_id: “company_id”)
267 268 269 270 271 272 273 274 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/attachments/client.rb', line 267 def list(company_id:, request_options: nil) Async do 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_id}/attachments" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: item) end end end |