Class: NewDemoApiClient::AsyncFileClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::AsyncFileClient
- Defined in:
- lib/test_sdk/file/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create_file_entry(deal_id:, group_id:, name:, type: nil, request_options: nil) ⇒ NewDemoApiClient::CreateFileForSignedURLResponse
Create a new file entry for a specific group and deal.
-
#delete(file_id:, group_id:, deal_id:, archive: nil, request_options: nil) ⇒ Object
Delete a file by its ID for a specific group and deal.
-
#download(deal_id:, file_id:, group_id:, request_options: nil) ⇒ Object
Download a file by its ID for a specific group and deal.
-
#get(deal_id:, file_id:, group_id:, request_options: nil) ⇒ NewDemoApiClient::FileResponse
Get a file by its ID for a specific group and deal.
- #initialize(request_client:) ⇒ NewDemoApiClient::AsyncFileClient constructor
-
#list(deal_id:, group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseFileResponse
Get all files for a specific group and deal.
-
#read_url(deal_id:, file_id:, group_id:, content_type: nil, download: nil, request_options: nil) ⇒ NewDemoApiClient::GcsSignedURLResponse
Get a signed URL to read a file by its ID for a specific group and deal.
-
#update(file_id:, group_id:, deal_id:, type: nil, request_options: nil) ⇒ NewDemoApiClient::FileResponse
Update a file by its ID for a specific group and deal.
-
#upload(deal_id:, group_id:, file:, name:, filetype:, request_options: nil) ⇒ NewDemoApiClient::CreateFileResponse
Upload a file for a specific group and deal.
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::AsyncFileClient
351 352 353 |
# File 'lib/test_sdk/file/client.rb', line 351 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::AsyncRequestClient (readonly)
347 348 349 |
# File 'lib/test_sdk/file/client.rb', line 347 def request_client @request_client end |
Instance Method Details
#create_file_entry(deal_id:, group_id:, name:, type: nil, request_options: nil) ⇒ NewDemoApiClient::CreateFileForSignedURLResponse
Create a new file entry for a specific group and deal. Requires the contents to
be uploaded separately via signed-url.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/test_sdk/file/client.rb', line 423 def create_file_entry(deal_id:, group_id:, name:, type: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? 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 || {}), name: name, type: type }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{deal_id}/deal/#{group_id}/file/entry" end NewDemoApiClient::CreateFileForSignedURLResponse.from_json(json_object: response.body) end end |
#delete(file_id:, group_id:, deal_id:, archive: nil, request_options: nil) ⇒ Object
Delete a file by its ID for a specific group and deal.
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/test_sdk/file/client.rb', line 584 def delete(file_id:, group_id:, deal_id:, archive: nil, request_options: nil) Async do response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "archive": archive }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{file_id}/deal/#{group_id}/file/#{deal_id}" end parsed_json = JSON.parse(response.body) parsed_json end end |
#download(deal_id:, file_id:, group_id:, request_options: nil) ⇒ Object
Download a file by its ID for a specific group and deal.
NOTE: Downloads are limited to 10 GB. For larger file downloads use the
signed-url download endpoint.
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/test_sdk/file/client.rb', line 625 def download(deal_id:, file_id:, group_id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? 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: )}/api/v1/group/#{deal_id}/deal/#{file_id}/file/#{group_id}/download" end parsed_json = JSON.parse(response.body) parsed_json end end |
#get(deal_id:, file_id:, group_id:, request_options: nil) ⇒ NewDemoApiClient::FileResponse
Get a file by its ID for a specific group and deal.
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/test_sdk/file/client.rb', line 504 def get(deal_id:, file_id:, group_id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? 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: )}/api/v1/group/#{deal_id}/deal/#{file_id}/file/#{group_id}" end NewDemoApiClient::FileResponse.from_json(json_object: response.body) end end |
#list(deal_id:, group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseFileResponse
Get all files for a specific group and deal.
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
# File 'lib/test_sdk/file/client.rb', line 460 def list(deal_id:, group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "sort_by": sort_by, "sort_order": sort_order, "page": page, "page_size": page_size }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{deal_id}/deal/#{group_id}/file/all" end NewDemoApiClient::PaginatedResponseFileResponse.from_json(json_object: response.body) end end |
#read_url(deal_id:, file_id:, group_id:, content_type: nil, download: nil, request_options: nil) ⇒ NewDemoApiClient::GcsSignedURLResponse
Get a signed URL to read a file by its ID for a specific group and deal.
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/test_sdk/file/client.rb', line 668 def read_url(deal_id:, file_id:, group_id:, content_type: nil, download: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "content_type": content_type, "download": download }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{deal_id}/deal/#{file_id}/file/#{group_id}/signed-url" end NewDemoApiClient::GcsSignedURLResponse.from_json(json_object: response.body) end end |
#update(file_id:, group_id:, deal_id:, type: nil, request_options: nil) ⇒ NewDemoApiClient::FileResponse
Update a file by its ID for a specific group and deal.
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/test_sdk/file/client.rb', line 545 def update(file_id:, group_id:, deal_id:, type: nil, request_options: nil) Async do response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? 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 || {}), type: type }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{file_id}/deal/#{group_id}/file/#{deal_id}" end NewDemoApiClient::FileResponse.from_json(json_object: response.body) end end |
#upload(deal_id:, group_id:, file:, name:, filetype:, request_options: nil) ⇒ NewDemoApiClient::CreateFileResponse
Upload a file for a specific group and deal. Creates a file entry as well as
uploads its contents.
NOTE: Uploads are limited to 10 GB. For larger file uploads use the signed-url
upload endpoint.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/test_sdk/file/client.rb', line 378 def upload(deal_id:, group_id:, file:, name:, filetype:, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? 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 || {}), file: NewDemoApiClient::FileUtilities.as_faraday_multipart(file_like: file), name: name, filetype: filetype }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{deal_id}/deal/#{group_id}/file" end NewDemoApiClient::CreateFileResponse.from_json(json_object: response.body) end end |