onvo 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 967e133975c31fcc061cd6acad2440e9e0073f9d7d7aaaec3ab68bdf2799dd2e
4
- data.tar.gz: 41ee50ef105dc3cbd744aaf62c039852d0b9d49d11f1b650bf86c056e94fc0e0
3
+ metadata.gz: e6937ab93049efd3a44da1312af5d9958cafb32f925bb15fbf163d70517c4b3c
4
+ data.tar.gz: f8b85f21bf26fd0c3f0e5145d4502e746d49ca9912e208f8a1c4fc6a935f1490
5
5
  SHA512:
6
- metadata.gz: 3eb80f26a62ed5935cd42981af88fa01d827a10de2cd0b6c21028ef3fe344020dc34592c4018db3f68487ae8b33b34e17b3825874d25cbd5ee9e7bc5643ef0c5
7
- data.tar.gz: 25820519a2f95207f9571935d5c4a388d2fd5e8fc2de0f0a1f6dd61d959a16cbf5188e676cb5094c94bc95a348322de684aa42d19db43106575300c72c6255e3
6
+ metadata.gz: 45dc7961d1bad2ef7c7d4d73ba5971ce55a392e701f8cd4baa95633e5abbd05a788e3194e133e4994d3ddacd8821a86c232e79271cde7477e948b9f1ab587dd2
7
+ data.tar.gz: 2ee18add6d5a2d5a6668e32205fb792b5f776b1ece527ef797bc010006b97cfe6464d3d5f375b0ee6ade32c2a1a3b86e43f718698321862dd08c24746f76c12b
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Account endpoints
6
+ class Accounts < Resource
7
+ def list
8
+ base_get('/accounts')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/accounts/#{id}")
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Automation endpoints
6
+ class Automations < Resource
7
+ def list
8
+ base_get('/automations')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/automations/#{id}")
13
+ end
14
+
15
+ def delete(id)
16
+ base_delete("/automations/#{id}")
17
+ end
18
+
19
+ def update(id, body)
20
+ base_post("/automations/#{id}", body)
21
+ end
22
+
23
+ def create(body)
24
+ base_put('/automations', body)
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../resource'
4
+
5
+ # The default template for an Onvo Dashboard Resource
6
+ class DashboardResource < Resource
7
+ include HTTParty
8
+
9
+ attr_accessor :dashboard_id
10
+
11
+ def initialize(dashboard_id, endpoint, api_key)
12
+ @dashboard_id = dashboard_id
13
+ @endpoint = endpoint
14
+ super(endpoint, api_key)
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require_relative './dashboard_resource'
5
+
6
+ # Dashboard Widget endpoints
7
+ class DashboardDatasources < DashboardResource
8
+ def list
9
+ base_get("/dashboards/#{@dashboard_id}/datasources")
10
+ end
11
+
12
+ def link(datasource_id)
13
+ base_put("/dashboards/#{@dashboard_id}/datasources", datasourceId: datasource_id) #TODO: check if not "datasourceId"
14
+ end
15
+
16
+ def unlink(datasource_id)
17
+ base_delete("/dashboards/#{@dashboard_id}/datasources/#{datasource_id}")
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require_relative './dashboard_resource'
5
+
6
+ # Dashboard Question endpoints
7
+ class DashboardQuestions < DashboardResource
8
+ def list
9
+ base_get("/dashboards/#{@dashboard_id}/questions")
10
+ end
11
+
12
+ # TODO: ask?
13
+ def create(query)
14
+ processed_query = URI.encode_www_form_component(query)
15
+ base_put("/dashboards/#{@dashboard_id}/questions?query=#{processed_query}")
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './dashboard_resource'
4
+
5
+ # Dashboard session endpoints
6
+ class DashboardSessions < DashboardResource
7
+ def list
8
+ base_get("/dashboards/#{@dashboard_id}/sessions")
9
+ end
10
+
11
+ # TODO: check if rename to delete_all
12
+ def delete
13
+ base_delete("/dashboards/#{@dashboard_id}/sessions")
14
+ end
15
+
16
+ def upsert(user_id, parameters = {})
17
+ session_data = base_post(
18
+ "/dashboards/#{@dashboard_id}/sessions",
19
+ user: user_id,
20
+ parameters: parameters
21
+ )
22
+ session_data.merge({ 'url': "#{@endpoint}#{session_data['url']}" })
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require_relative './dashboard_resource'
5
+
6
+ # Dashboard Widget endpoints
7
+ class DashboardWidgets < DashboardResource
8
+ def list
9
+ base_get("/dashboards/#{@dashboard_id}/widgets")
10
+ end
11
+
12
+ def get(widget_id)
13
+ base_get("/dashboards/#{@dashboard_id}/widgets/#{widget_id}")
14
+ end
15
+
16
+ def delete(widget_id)
17
+ base_delete("/dashboards/#{@dashboard_id}/widgets/#{widget_id}")
18
+ end
19
+
20
+ def update(widget_id, body)
21
+ base_post("/dashboards/#{@dashboard_id}/widgets/#{widget_id}", body)
22
+ end
23
+
24
+ def create(query)
25
+ processed_query = URI.encode_www_form_component(query)
26
+ base_put("/dashboards/#{@dashboard_id}/widgets?query=#{processed_query}")
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './dashboard/datasources'
4
+ require_relative './dashboard/widgets'
5
+ require_relative './dashboard/questions'
6
+ require_relative './dashboard/sessions'
7
+
8
+ # The Dashboard API
9
+ class Dashboard
10
+ attr_accessor :datasources, :widgets, :questions, :sessions
11
+
12
+ def initialize(dashboard_id, endpoint, api_key)
13
+ params = [dashboard_id, endpoint, api_key]
14
+
15
+ @datasources = DashboardDatasources.new(*params)
16
+ @widgets = DashboardWidgets.new(*params)
17
+ @questions = DashboardQuestions.new(*params)
18
+ @sessions = DashboardSessions.new(*params)
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Dashboard endpoints
6
+ class Dashboards < Resource
7
+ def list
8
+ base_get('/dashboards')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/dashboards/#{id}")
13
+ end
14
+
15
+ def delete(id)
16
+ base_delete("/dashboards/#{id}")
17
+ end
18
+
19
+ def update(id, body)
20
+ base_post("/dashboards/#{id}", body)
21
+ end
22
+
23
+ def create(body)
24
+ base_put('/dashboards', body)
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Datasource endpoints
6
+ class Datasources < Resource
7
+ def list
8
+ base_get('/datasources')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/datasources/#{id}")
13
+ end
14
+
15
+ def get_data(id)
16
+ base_get("/datasources/#{id}/data")
17
+ end
18
+
19
+ def fetch_column_descriptions(id)
20
+ base_post("/datasources/#{id}/populate-columns")
21
+ end
22
+
23
+ def delete(id)
24
+ base_delete("/datasources/#{id}")
25
+ end
26
+
27
+ def update(id, body)
28
+ base_post("/datasources/#{id}", body)
29
+ end
30
+
31
+ def create(body)
32
+ base_put('/datasources', body)
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Embed user endpoints
6
+ class EmbedUsers < Resource
7
+ def list
8
+ base_get('/embed-users')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/embed-users/#{id}")
13
+ end
14
+
15
+ def delete(id)
16
+ base_delete("/embed-users/#{id}")
17
+ end
18
+
19
+ def upsert(id, name, email, metadata = {})
20
+ base_post(
21
+ '/embed-users',
22
+ {
23
+ 'id': id,
24
+ 'name': name,
25
+ 'email': email,
26
+ 'metadata': metadata
27
+ }
28
+ )
29
+ end
30
+
31
+ def get_access_token(id)
32
+ base_get("/embed-users/#{id}/token")
33
+ end
34
+ end
data/lib/onvo/teams.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../resource'
4
+
5
+ # Team endpoints
6
+ class Teams < Resource
7
+ def list
8
+ base_get('/teams')
9
+ end
10
+
11
+ def get(id)
12
+ base_get("/teams/#{id}")
13
+ end
14
+ end
data/lib/onvo.rb CHANGED
@@ -1,7 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative './onvo/accounts'
4
+ require_relative './onvo/teams'
5
+ require_relative './onvo/embed_users'
6
+ require_relative './onvo/datasources'
7
+ require_relative './onvo/automations'
8
+ require_relative './onvo/dashboards'
9
+
10
+ require_relative './onvo/dashboard'
11
+
12
+ # The Onvo Ruby SDK
3
13
  class Onvo
4
- def self.hello
5
- puts "Hello world!"
14
+ attr_reader :accounts, :teams, :embed_users, :datasources, :automations, :dashboards
15
+ attr_accessor :endpoint, :api_key
16
+
17
+ def initialize(endpoint = ENV['ONVO_API_ENDPOINT'], api_key = ENV['ONVO_API_KEY'])
18
+ @endpoint = endpoint
19
+ @api_key = api_key
20
+ params = [@endpoint, @api_key]
21
+
22
+ @accounts = Accounts.new(*params)
23
+ @teams = Teams.new(*params)
24
+ @embed_users = EmbedUsers.new(*params)
25
+ @datasources = Datasources.new(*params)
26
+ @automations = Automations.new(*params)
27
+ @dashboards = Dashboards.new(*params)
28
+ end
29
+
30
+ def dashboard(dashboard_id)
31
+ Dashboard.new(dashboard_id, @endpoint, @api_key)
6
32
  end
7
- end
33
+ end
data/lib/resource.rb ADDED
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'json'
5
+ require 'uri'
6
+
7
+ # The default template for an Onvo Resource
8
+ class Resource
9
+ include HTTParty
10
+
11
+ attr_accessor :options
12
+
13
+ def initialize(endpoint, api_key)
14
+ self.class.base_uri endpoint
15
+ @options = {
16
+ headers: {
17
+ 'x-api-key': api_key,
18
+ 'Content-Type': 'application/json'
19
+ }
20
+ }
21
+ end
22
+
23
+ def base_request
24
+ response = yield
25
+ body = JSON.parse(response.body)
26
+ # TODO: Replace Runtime w/ custom errors
27
+ raise "#{response.code} Error : #{body['message']}" if response.code >= 400
28
+
29
+ body
30
+ rescue JSON::ParserError, TypeError
31
+ response.body
32
+ end
33
+
34
+ def base_get(subdirectory)
35
+ base_request { self.class.get(subdirectory, options) }
36
+ end
37
+
38
+ def base_put(subdirectory, body = nil)
39
+ params = body ? options.merge({ body: body.to_json }) : options
40
+ base_request { self.class.put(subdirectory, params) }
41
+ end
42
+
43
+ def base_post(subdirectory, body = nil)
44
+ params = body ? options.merge({ body: body.to_json }) : options
45
+ base_request { self.class.post(subdirectory, params) }
46
+ end
47
+
48
+ def base_delete(subdirectory)
49
+ base_request { self.class.delete(subdirectory, options) }
50
+ end
51
+ end
metadata CHANGED
@@ -1,23 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onvo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Ronnel Davis
8
7
  - Bryan Davis
8
+ - Ronnel Davis
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-12 00:00:00.000000000 Z
13
- dependencies: []
14
- description:
12
+ date: 2024-02-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.13.7
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.13.7
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.8'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.8'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest-hooks
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 1.5.1
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 1.5.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: uri
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.13.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.13.0
70
+ description: A gem to provide utilities to seamlessly communicate with the Onvo platform,
71
+ allowing developers to integrate AI-powered dashboards into their products.
15
72
  email:
73
+ - bryandavis999.dev@gmail.com
16
74
  executables: []
17
75
  extensions: []
18
76
  extra_rdoc_files: []
19
77
  files:
20
78
  - lib/onvo.rb
79
+ - lib/onvo/accounts.rb
80
+ - lib/onvo/automations.rb
81
+ - lib/onvo/dashboard.rb
82
+ - lib/onvo/dashboard/dashboard_resource.rb
83
+ - lib/onvo/dashboard/datasources.rb
84
+ - lib/onvo/dashboard/questions.rb
85
+ - lib/onvo/dashboard/sessions.rb
86
+ - lib/onvo/dashboard/widgets.rb
87
+ - lib/onvo/dashboards.rb
88
+ - lib/onvo/datasources.rb
89
+ - lib/onvo/embed_users.rb
90
+ - lib/onvo/teams.rb
91
+ - lib/resource.rb
21
92
  homepage:
22
93
  licenses: []
23
94
  metadata: {}
@@ -25,6 +96,7 @@ post_install_message:
25
96
  rdoc_options: []
26
97
  require_paths:
27
98
  - lib
99
+ - lib/onvo
28
100
  required_ruby_version: !ruby/object:Gem::Requirement
29
101
  requirements:
30
102
  - - ">="
@@ -39,6 +111,5 @@ requirements: []
39
111
  rubygems_version: 3.3.7
40
112
  signing_key:
41
113
  specification_version: 4
42
- summary: A gem to provide utilities to seamlessly communicate with the Onvo platform,
43
- allowing developers to integrate AI-powered dashboards into their products.
114
+ summary: Communicate with the Onvo platform.
44
115
  test_files: []