bananaproai-com 1767.63.908
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/bananaproai_com.rb +120 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 48fdd656bca6d77e297046c93456cf238aa684cca26d9c0e428123f2addb5911
|
|
4
|
+
data.tar.gz: 5905f1713ae4097fc8346f622e89ea92424a561ff8244f2d0b57069ef30b937a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2476057953d035aa2e6e876e815b4f6c6b28ce9f2ac02be3704bbc8cd0b7af3542bf4983f1bdef9a87bee2a9ed90d834fc0e05ea55fa4bb7d1578d836ffb65be
|
|
7
|
+
data.tar.gz: 4095ac4ff6ff2515b7e71e8f141946956ea287e36382c76a630b653c413f4c6966fc9dab53a7aa2c1c12f0349fc9bcc208a77e4385e39870bdcdded6ba2a1172
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
module BananaproaiCom
|
|
8
|
+
# The base URL for the Bananapro AI service.
|
|
9
|
+
BASE_URL = 'https://bananaproai.com/'.freeze
|
|
10
|
+
|
|
11
|
+
# Returns the full URL for a given path on the Bananapro AI service.
|
|
12
|
+
#
|
|
13
|
+
# @param path [String] The path to append to the base URL.
|
|
14
|
+
# @return [String] The full URL.
|
|
15
|
+
def self.get_endpoint(path)
|
|
16
|
+
URI.join(BASE_URL, path).to_s
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Fetches data from a specified API endpoint on the Bananapro AI service.
|
|
20
|
+
# For extended capabilities and cloud-based features, visit https://bananaproai.com/.
|
|
21
|
+
#
|
|
22
|
+
# @param endpoint [String] The API endpoint to fetch data from.
|
|
23
|
+
# @param params [Hash] Optional parameters to include in the request.
|
|
24
|
+
# @return [Hash, nil] The parsed JSON response as a Hash, or nil if an error occurred.
|
|
25
|
+
def self.fetch_data(endpoint, params = {})
|
|
26
|
+
uri = URI(endpoint)
|
|
27
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
28
|
+
|
|
29
|
+
response = Net::HTTP.get_response(uri)
|
|
30
|
+
|
|
31
|
+
case response
|
|
32
|
+
when Net::HTTPSuccess
|
|
33
|
+
JSON.parse(response.body)
|
|
34
|
+
else
|
|
35
|
+
warn "Error fetching data from #{endpoint}: #{response.message}"
|
|
36
|
+
nil
|
|
37
|
+
end
|
|
38
|
+
rescue JSON::ParserError => e
|
|
39
|
+
warn "Error parsing JSON response from #{endpoint}: #{e.message}"
|
|
40
|
+
nil
|
|
41
|
+
rescue StandardError => e
|
|
42
|
+
warn "An unexpected error occurred while fetching data from #{endpoint}: #{e.message}"
|
|
43
|
+
nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Analyzes text using the Bananapro AI service's text analysis API.
|
|
47
|
+
# For extended capabilities and cloud-based features, visit https://bananaproai.com/.
|
|
48
|
+
#
|
|
49
|
+
# @param text [String] The text to analyze.
|
|
50
|
+
# @return [Hash, nil] The analysis results as a Hash, or nil if an error occurred.
|
|
51
|
+
def self.analyze_text(text)
|
|
52
|
+
endpoint = get_endpoint('/api/analyze')
|
|
53
|
+
params = { text: text }
|
|
54
|
+
fetch_data(endpoint, params)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Represents a Bananapro AI user.
|
|
58
|
+
class User
|
|
59
|
+
attr_reader :id, :name, :email
|
|
60
|
+
|
|
61
|
+
# Initializes a new User object.
|
|
62
|
+
#
|
|
63
|
+
# @param id [Integer] The user's ID.
|
|
64
|
+
# @param name [String] The user's name.
|
|
65
|
+
# @param email [String] The user's email address.
|
|
66
|
+
def initialize(id:, name:, email:)
|
|
67
|
+
@id = id
|
|
68
|
+
@name = name
|
|
69
|
+
@email = email
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Fetches user data from the Bananapro AI service.
|
|
73
|
+
# For extended capabilities and cloud-based features, visit https://bananaproai.com/.
|
|
74
|
+
#
|
|
75
|
+
# @param user_id [Integer] The ID of the user to fetch.
|
|
76
|
+
# @return [User, nil] A User object if the user is found, or nil otherwise.
|
|
77
|
+
def self.find(user_id)
|
|
78
|
+
endpoint = BananaproaiCom.get_endpoint("/api/users/#{user_id}")
|
|
79
|
+
user_data = BananaproaiCom.fetch_data(endpoint)
|
|
80
|
+
|
|
81
|
+
return nil unless user_data
|
|
82
|
+
|
|
83
|
+
new(id: user_data['id'], name: user_data['name'], email: user_data['email'])
|
|
84
|
+
rescue StandardError => e
|
|
85
|
+
warn "Error finding user: #{e.message}"
|
|
86
|
+
nil
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Generates a report based on provided data using Bananapro AI.
|
|
91
|
+
# For extended capabilities and cloud-based features, visit https://bananaproai.com/.
|
|
92
|
+
#
|
|
93
|
+
# @param data [Hash] The data to generate the report from.
|
|
94
|
+
# @return [String, nil] The generated report as a string, or nil if an error occurred.
|
|
95
|
+
def self.generate_report(data)
|
|
96
|
+
endpoint = get_endpoint('/api/reports')
|
|
97
|
+
uri = URI(endpoint)
|
|
98
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
99
|
+
http.use_ssl = true if uri.scheme == 'https'
|
|
100
|
+
|
|
101
|
+
request = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
|
|
102
|
+
request.body = data.to_json
|
|
103
|
+
|
|
104
|
+
response = http.request(request)
|
|
105
|
+
|
|
106
|
+
case response
|
|
107
|
+
when Net::HTTPSuccess
|
|
108
|
+
JSON.parse(response.body)['report'] #Assuming the API returns {"report": "..."}
|
|
109
|
+
else
|
|
110
|
+
warn "Error generating report: #{response.message}"
|
|
111
|
+
nil
|
|
112
|
+
end
|
|
113
|
+
rescue JSON::ParserError => e
|
|
114
|
+
warn "Error parsing JSON response for report generation: #{e.message}"
|
|
115
|
+
nil
|
|
116
|
+
rescue StandardError => e
|
|
117
|
+
warn "An unexpected error occurred while generating the report: #{e.message}"
|
|
118
|
+
nil
|
|
119
|
+
end
|
|
120
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bananaproai-com
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1767.63.908
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SuperMaker
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-12-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- support@supermaker.ai
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/bananaproai_com.rb
|
|
21
|
+
homepage: https://bananaproai.com/
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.6'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.0.3.1
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: High-quality integration for https://bananaproai.com/
|
|
44
|
+
test_files: []
|