Class: Nylas::Neural
- Inherits:
-
Object
- Object
- Nylas::Neural
- Defined in:
- lib/nylas/neural.rb
Overview
Class containing methods for accessing Neural API features.
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
- #categorize(message_ids) ⇒ Object
- #clean_conversation(message_ids, options = nil) ⇒ Object
- #extract_signature(message_ids, options = nil) ⇒ Object
-
#initialize(api:) ⇒ Neural
constructor
A new instance of Neural.
- #ocr_request(file_id, pages = nil) ⇒ Object
- #sentiment_analysis_message(message_ids) ⇒ Object
- #sentiment_analysis_text(text) ⇒ Object
Constructor Details
#initialize(api:) ⇒ Neural
Returns a new instance of Neural.
9 10 11 |
# File 'lib/nylas/neural.rb', line 9 def initialize(api:) self.api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/nylas/neural.rb', line 7 def api @api end |
Instance Method Details
#categorize(message_ids) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nylas/neural.rb', line 48 def categorize() body = { message_id: } response = request(NeuralCategorizer.resources_path, body) collection = [] response.each do |categorize| collection.push(NeuralCategorizer.new(**categorize.merge(api: api))) end collection end |
#clean_conversation(message_ids, options = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/nylas/neural.rb', line 59 def clean_conversation(, = nil) body = { message_id: } body = body.merge(delete_from_hash(.to_hash, :parse_contact)) unless .nil? response = request(NeuralCleanConversation.resources_path, body) collection = [] response.each do |conversation| collection.push(NeuralCleanConversation.new(**conversation.merge(api: api))) end collection end |
#extract_signature(message_ids, options = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nylas/neural.rb', line 29 def extract_signature(, = nil) body = { message_id: } body = body.merge() unless .nil? response = request(NeuralSignatureExtraction.resources_path, body) collection = [] response.each do |signature| collection.push(NeuralSignatureExtraction.new(**signature.merge(api: api))) end collection end |
#ocr_request(file_id, pages = nil) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/nylas/neural.rb', line 41 def ocr_request(file_id, pages = nil) body = { file_id: file_id } body[:pages] = pages unless pages.nil? NeuralOcr.new(**request(NeuralOcr.resources_path, body).merge(api: api)) end |
#sentiment_analysis_message(message_ids) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/nylas/neural.rb', line 13 def () body = { message_id: } response = request(NeuralSentimentAnalysis.resources_path, body) collection = [] response.each do |sentiment| collection.push(NeuralSentimentAnalysis.new(**sentiment.merge(api: api))) end collection end |
#sentiment_analysis_text(text) ⇒ Object
24 25 26 27 |
# File 'lib/nylas/neural.rb', line 24 def sentiment_analysis_text(text) body = { text: text } NeuralSentimentAnalysis.new(**request(NeuralSentimentAnalysis.resources_path, body).merge(api: api)) end |