Class: RemoveBg::ApiClient
- Inherits:
-
Object
- Object
- RemoveBg::ApiClient
- Includes:
- Api
- Defined in:
- lib/remove_bg/api_client.rb
Constant Summary
Constants included from Api
Instance Method Summary collapse
-
#account_info(options) ⇒ RemoveBg::AccountInfo
Fetches account information.
-
#initialize(connection: RemoveBg::HttpConnection.build) ⇒ ApiClient
constructor
A new instance of ApiClient.
-
#remove_from_file(image_path, options) ⇒ RemoveBg::Result|RemoveBg::CompositeResult
Removes the background from an image on the local file system.
-
#remove_from_url(image_url, options) ⇒ RemoveBg::Result|RemoveBg::CompositeResult
Removes the background from the image at the URL specified.
Constructor Details
#initialize(connection: RemoveBg::HttpConnection.build) ⇒ ApiClient
Returns a new instance of ApiClient.
23 24 25 |
# File 'lib/remove_bg/api_client.rb', line 23 def initialize(connection: RemoveBg::HttpConnection.build) @connection = connection end |
Instance Method Details
#account_info(options) ⇒ RemoveBg::AccountInfo
Fetches account information
55 56 57 |
# File 'lib/remove_bg/api_client.rb', line 55 def account_info() request_account_info(.api_key) end |
#remove_from_file(image_path, options) ⇒ RemoveBg::Result|RemoveBg::CompositeResult
Removes the background from an image on the local file system
33 34 35 36 |
# File 'lib/remove_bg/api_client.rb', line 33 def remove_from_file(image_path, ) data = .data.merge(image_file: Upload.for_file(image_path)) request_remove_bg(data, .api_key) end |
#remove_from_url(image_url, options) ⇒ RemoveBg::Result|RemoveBg::CompositeResult
Removes the background from the image at the URL specified
44 45 46 47 48 |
# File 'lib/remove_bg/api_client.rb', line 44 def remove_from_url(image_url, ) RemoveBg::UrlValidator.validate(image_url) data = .data.merge(image_url:) request_remove_bg(data, .api_key) end |