Class: Plagiarism::Balance

Inherits:
Request
  • Object
show all
Defined in:
lib/plagiarism/balance.rb

Instance Attribute Summary

Attributes inherited from Request

#params, #response

Class Method Summary collapse

Methods inherited from Request

#initialize

Constructor Details

This class inherits a constructor from Plagiarism::Request

Class Method Details

.amountObject

Return the amount (in cents) of your remaining Copyscape account balance



11
12
13
14
15
16
17
18
# File 'lib/plagiarism/balance.rb', line 11

def amount
  response = Request.new(:get, o: 'balance').response
  if response.success?
    Money.parse(response.doc.css('value').text).cents
  else
    raise "An error occurred while attempting to retrieve your account balance"
  end
end

.creditsObject

Return search credits remaining for your Copyscape account



23
24
25
26
27
28
29
30
# File 'lib/plagiarism/balance.rb', line 23

def credits
  response = Request.new(:get, o: 'balance').response
  if response.success?
    response.doc.css('total').text.to_i
  else
    raise "An error occurred while attempting to retrieve your account balance"
  end
end