Class: Scanii::Base
- Inherits:
-
Object
- Object
- Scanii::Base
- Defined in:
- lib/scanii.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#content_length ⇒ Object
Returns the value of attribute content_length.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#findings ⇒ Object
Returns the value of attribute findings.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
- #scan(file) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
44 45 46 47 48 49 |
# File 'lib/scanii.rb', line 44 def initialize(params={}) raise ArgumentError.new(":api_key is a required argument to initialize Scanii") if params.fetch(:api_key).nil? raise ArgumentError.new(":api_secret is a required argument to initialize Scanii") if params.fetch(:api_secret).nil? @api_key = params.fetch(:api_key) @api_secret = params.fetch(:api_secret) end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
38 39 40 |
# File 'lib/scanii.rb', line 38 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
38 39 40 |
# File 'lib/scanii.rb', line 38 def api_secret @api_secret end |
#checksum ⇒ Object
Returns the value of attribute checksum.
38 39 40 |
# File 'lib/scanii.rb', line 38 def checksum @checksum end |
#content_length ⇒ Object
Returns the value of attribute content_length.
38 39 40 |
# File 'lib/scanii.rb', line 38 def content_length @content_length end |
#content_type ⇒ Object
Returns the value of attribute content_type.
38 39 40 |
# File 'lib/scanii.rb', line 38 def content_type @content_type end |
#creation_date ⇒ Object
Returns the value of attribute creation_date.
38 39 40 |
# File 'lib/scanii.rb', line 38 def creation_date @creation_date end |
#findings ⇒ Object
Returns the value of attribute findings.
38 39 40 |
# File 'lib/scanii.rb', line 38 def findings @findings end |
#id ⇒ Object
Returns the value of attribute id.
38 39 40 |
# File 'lib/scanii.rb', line 38 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
38 39 40 |
# File 'lib/scanii.rb', line 38 def @metadata end |
#response ⇒ Object
Returns the value of attribute response.
38 39 40 |
# File 'lib/scanii.rb', line 38 def response @response end |
Class Method Details
.configure {|_self| ... } ⇒ Object
40 41 42 |
# File 'lib/scanii.rb', line 40 def self.configure yield self end |
Instance Method Details
#scan(file) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/scanii.rb', line 51 def scan(file) response = RestClient::Request.execute method: :post, url: 'https://api.scanii.com/v2.1/files', user: @api_key, password: @api_secret, payload: {file: File.new(file)} @response = JSON(response) @id = @response["id"] @checksum = @response["checksum"] @content_length = @response["content_length"] @findings = @response["findings"] @creation_date = @response["creation_date"] @content_type = @response["content_type"] @metadata = @response["metadata"] self end |