Class: Salesforce::Einstein::Base
- Inherits:
-
Object
- Object
- Salesforce::Einstein::Base
- Defined in:
- lib/salesforce/einstein/base.rb
Direct Known Subclasses
Constant Summary collapse
- BASE_URI =
'https://api.einstein.ai/v2'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#boundary ⇒ Object
Returns the value of attribute boundary.
-
#email ⇒ Object
Returns the value of attribute email.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #delete_reflesh_token(token) ⇒ Object
- #get_api_usage ⇒ Object
-
#initialize(cert: nil, private_key: nil, password: nil, email:, timeout: 3600) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(cert: nil, private_key: nil, password: nil, email:, timeout: 3600) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/salesforce/einstein/base.rb', line 15 def initialize(cert: nil, private_key: nil, password: nil, email:, timeout: 3600) if cert.nil? && private_key.nil? raise ArgumentError, 'At least one parameter must be specified: cert or private_key' end if cert cert_contents = File.read(File.(cert)) pkcs12 = OpenSSL::PKCS12.new(cert_contents, password) @private_key = pkcs12.key else private_key_contents = File.read(File.(private_key)) @private_key = OpenSSL::PKey::RSA.new(private_key_contents, password) end @email = email @boundary = SecureRandom.hex(10) @timeout = 3600 end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
13 14 15 |
# File 'lib/salesforce/einstein/base.rb', line 13 def access_token @access_token end |
#boundary ⇒ Object
Returns the value of attribute boundary.
13 14 15 |
# File 'lib/salesforce/einstein/base.rb', line 13 def boundary @boundary end |
#email ⇒ Object
Returns the value of attribute email.
13 14 15 |
# File 'lib/salesforce/einstein/base.rb', line 13 def email @email end |
#private_key ⇒ Object
Returns the value of attribute private_key.
13 14 15 |
# File 'lib/salesforce/einstein/base.rb', line 13 def private_key @private_key end |
#timeout ⇒ Object
Returns the value of attribute timeout.
13 14 15 |
# File 'lib/salesforce/einstein/base.rb', line 13 def timeout @timeout end |
Instance Method Details
#delete_reflesh_token(token) ⇒ Object
42 43 44 |
# File 'lib/salesforce/einstein/base.rb', line 42 def delete_reflesh_token(token) delete "/oauth2/token/#{token}" end |
#get_api_usage ⇒ Object
38 39 40 |
# File 'lib/salesforce/einstein/base.rb', line 38 def get_api_usage get '/apiusage' end |