This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Communication class safer by not storing state inside some singl…
…eton Move specs around
- Loading branch information
1 parent
f272590
commit 6d1f239
Showing
14 changed files
with
979 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,30 @@ | ||
module WeTransfer | ||
class Client | ||
class Error < StandardError; end | ||
include Communication | ||
|
||
NullLogger = Logger.new(nil) | ||
|
||
attr_reader :transfer | ||
|
||
# Initialize a WeTransfer::Client | ||
# | ||
# @param api_key [String] The API key you want to authenticate with | ||
# @param logger [Logger] (NullLogger) your custom logger | ||
# | ||
# @return [WeTransfer::Client] | ||
def initialize(api_key:, logger: NullLogger) | ||
Communication.reset_authentication! | ||
Communication.api_key = api_key | ||
Communication.logger = logger | ||
def initialize(api_key:) | ||
@communicator = Communication.new(api_key) | ||
end | ||
|
||
def create_transfer(**args, &block) | ||
transfer = WeTransfer::Transfer.new(args) | ||
transfer = WeTransfer::Transfer.new(args.merge(communicator: @communicator)) | ||
transfer.persist(&block) | ||
@transfer = transfer | ||
|
||
self | ||
end | ||
|
||
def create_transfer_and_upload_files(**args, &block) | ||
create_transfer(args, &block) | ||
@transfer.upload_files | ||
@transfer.complete_files | ||
@transfer.finalize | ||
|
||
self | ||
transfer = create_transfer(args, &block) | ||
transfer.upload_files | ||
transfer.complete_files | ||
transfer.finalize | ||
end | ||
|
||
def find_transfer(transfer_id) | ||
@transfer = WeTransfer::Transfer.find(transfer_id) | ||
@communicator.find_transfer(transfer_id) | ||
end | ||
end | ||
end |
Oops, something went wrong.