hi_energy_ai 0.1.0

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.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +13 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +339 -0
  5. data/lib/hi_energy_ai/client.rb +229 -0
  6. data/lib/hi_energy_ai/configuration.rb +24 -0
  7. data/lib/hi_energy_ai/error.rb +44 -0
  8. data/lib/hi_energy_ai/paginator.rb +27 -0
  9. data/lib/hi_energy_ai/resource.rb +37 -0
  10. data/lib/hi_energy_ai/resources/advertisers.rb +39 -0
  11. data/lib/hi_energy_ai/resources/agencies.rb +15 -0
  12. data/lib/hi_energy_ai/resources/clicks.rb +11 -0
  13. data/lib/hi_energy_ai/resources/contacts.rb +19 -0
  14. data/lib/hi_energy_ai/resources/deals.rb +23 -0
  15. data/lib/hi_energy_ai/resources/deeplinks.rb +11 -0
  16. data/lib/hi_energy_ai/resources/domains.rb +11 -0
  17. data/lib/hi_energy_ai/resources/exports.rb +19 -0
  18. data/lib/hi_energy_ai/resources/mcp.rb +41 -0
  19. data/lib/hi_energy_ai/resources/networks.rb +15 -0
  20. data/lib/hi_energy_ai/resources/opportunities.rb +11 -0
  21. data/lib/hi_energy_ai/resources/publishers.rb +27 -0
  22. data/lib/hi_energy_ai/resources/reports.rb +15 -0
  23. data/lib/hi_energy_ai/resources/schema.rb +11 -0
  24. data/lib/hi_energy_ai/resources/search.rb +11 -0
  25. data/lib/hi_energy_ai/resources/status_changes.rb +11 -0
  26. data/lib/hi_energy_ai/resources/tags.rb +17 -0
  27. data/lib/hi_energy_ai/resources/tools.rb +11 -0
  28. data/lib/hi_energy_ai/resources/transactions.rb +15 -0
  29. data/lib/hi_energy_ai/resources/users.rb +31 -0
  30. data/lib/hi_energy_ai/resources/verticals.rb +11 -0
  31. data/lib/hi_energy_ai/response.rb +56 -0
  32. data/lib/hi_energy_ai/version.rb +5 -0
  33. data/lib/hi_energy_ai.rb +29 -0
  34. metadata +164 -0
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ class Paginator
5
+ include Enumerable
6
+
7
+ def initialize(client:, path:, params: {}, first_response: nil)
8
+ @client = client
9
+ @path = path
10
+ @params = params
11
+ @first_response = first_response
12
+ end
13
+
14
+ def each
15
+ response = @first_response || @client.get(@path, params: @params)
16
+
17
+ loop do
18
+ yield response
19
+
20
+ break unless response.has_more?
21
+
22
+ next_params = @params.merge(response.next_page_params)
23
+ response = @client.get(@path, params: next_params)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ class Resource
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ private
10
+
11
+ attr_reader :client
12
+
13
+ def get(path, params: {})
14
+ client.get(path, params: params)
15
+ end
16
+
17
+ def post(path, params: {}, body: nil)
18
+ client.post(path, params: params, body: body)
19
+ end
20
+
21
+ def patch(path, params: {}, body: nil)
22
+ client.patch(path, params: params, body: body)
23
+ end
24
+
25
+ def delete(path, params: {})
26
+ client.delete(path, params: params)
27
+ end
28
+
29
+ def app_get(path, params: {})
30
+ client.app_get(path, params: params)
31
+ end
32
+
33
+ def app_post(path, params: {}, body: nil)
34
+ client.app_post(path, params: params, body: body)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Advertisers < Resource
6
+ def list(**params)
7
+ get("/advertisers", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/advertisers/#{id}", params: params)
12
+ end
13
+
14
+ def search_by_domain(domain:, **params)
15
+ get("/advertisers/search_by_domain", params: params.merge(domain: domain))
16
+ end
17
+
18
+ def by_domain(domain:, **params)
19
+ list(domain: domain, **params)
20
+ end
21
+
22
+ def contacts(id, **params)
23
+ get("/advertisers/#{id}/contacts", params: params)
24
+ end
25
+
26
+ def similar(id, **params)
27
+ get("/advertisers/#{id}/similar_advertisers", params: params)
28
+ end
29
+
30
+ def related(id, **params)
31
+ get("/advertisers/#{id}/related_advertisers", params: params)
32
+ end
33
+
34
+ def find_more_contacts(id, **params)
35
+ post("/advertisers/#{id}/find_more_contacts", params: params)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Agencies < Resource
6
+ def list(**params)
7
+ get("/agencies", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/agencies/#{id}", params: params)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Clicks < Resource
6
+ def list(start_date:, end_date:, **params)
7
+ get("/clicks", params: params.merge(start_date: start_date, end_date: end_date))
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Contacts < Resource
6
+ def list(**params)
7
+ get("/contacts", params: params)
8
+ end
9
+
10
+ def create(attributes, **params)
11
+ post("/contacts", params: params, body: { contact: attributes })
12
+ end
13
+
14
+ def add(attributes, **params)
15
+ post("/contacts/add", params: params, body: { contact: attributes })
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Deals < Resource
6
+ def list(**params)
7
+ get("/deals", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/deals/#{id}", params: params)
12
+ end
13
+
14
+ def types(**params)
15
+ get("/deals/types", params: params)
16
+ end
17
+
18
+ def translate(id, **params)
19
+ post("/deals/#{id}/translate", params: params)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Deeplinks < Resource
6
+ def generate(attributes, **params)
7
+ post("/deeplinks/generate", params: params, body: attributes)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Domains < Resource
6
+ def search(domain:, **params)
7
+ get("/domains/search", params: params.merge(domain: domain))
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Exports < Resource
6
+ def list(**params)
7
+ get("/exports", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/exports/#{id}", params: params)
12
+ end
13
+
14
+ def create(attributes, **params)
15
+ post("/exports", params: params, body: attributes)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Mcp < Resource
6
+ def bootstrap(**params)
7
+ app_get("mcp", params: params)
8
+ end
9
+
10
+ def integration(**params)
11
+ app_get("mcp/integration.json", params: params)
12
+ end
13
+
14
+ def initialize_session(protocol_version: "2025-11-25", id: 1, **params)
15
+ app_post(
16
+ "mcp",
17
+ params: params,
18
+ body: {
19
+ jsonrpc: "2.0",
20
+ id: id,
21
+ method: "initialize",
22
+ params: { protocolVersion: protocol_version }
23
+ }
24
+ )
25
+ end
26
+
27
+ def call(method, params: {}, id: 1, **query)
28
+ app_post(
29
+ "mcp",
30
+ params: query,
31
+ body: {
32
+ jsonrpc: "2.0",
33
+ id: id,
34
+ method: method,
35
+ params: params
36
+ }
37
+ )
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Networks < Resource
6
+ def list(**params)
7
+ get("/networks", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/networks/#{id}", params: params)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Opportunities < Resource
6
+ def list(**params)
7
+ get("/opportunities", params: params)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Publishers < Resource
6
+ def list(**params)
7
+ get("/publishers", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/publishers/#{id}", params: params)
12
+ end
13
+
14
+ def create(attributes, **params)
15
+ post("/publishers", params: params, body: { publisher: attributes })
16
+ end
17
+
18
+ def update(id, attributes, **params)
19
+ patch("/publishers/#{id}", params: params, body: { publisher: attributes })
20
+ end
21
+
22
+ def find_linkedin_users(id, **params)
23
+ post("/publishers/#{id}/find_linkedin_users", params: params)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Reports < Resource
6
+ def list(**params)
7
+ get("/reports", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/reports/#{id}", params: params)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Schema < Resource
6
+ def fetch(**params)
7
+ get("/schema", params: params)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Search < Resource
6
+ def query(q:, **params)
7
+ get("/search", params: params.merge(q: q))
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class StatusChanges < Resource
6
+ def list(**params)
7
+ get("/status_changes", params: params)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Tags < Resource
6
+ def list(**params)
7
+ get("/tags", params: params)
8
+ end
9
+
10
+ alias search list
11
+
12
+ def advertisers(id, **params)
13
+ get("/tags/#{id}/advertisers", params: params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Tools < Resource
6
+ def list(**params)
7
+ get("/tools", params: params)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Transactions < Resource
6
+ def list(**params)
7
+ get("/transactions", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/transactions/#{id}", params: params)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Users < Resource
6
+ def list(**params)
7
+ get("/users", params: params)
8
+ end
9
+
10
+ def find(id, **params)
11
+ get("/users/#{id}", params: params)
12
+ end
13
+
14
+ def create(attributes, **params)
15
+ post("/users", params: params, body: { user: attributes })
16
+ end
17
+
18
+ def update(id, attributes, **params)
19
+ patch("/users/#{id}", params: params, body: { user: attributes })
20
+ end
21
+
22
+ def resend_invitation(id, **params)
23
+ post("/users/#{id}/resend_invitation", params: params)
24
+ end
25
+
26
+ def rotate_api_key(id, **params)
27
+ post("/users/#{id}/rotate_api_key", params: params)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ module Resources
5
+ class Verticals < Resource
6
+ def list(**params)
7
+ get("/verticals", params: params)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ class Response
5
+ attr_reader :status, :headers, :body, :data, :meta, :raw
6
+
7
+ def initialize(status:, headers:, body:)
8
+ @status = status
9
+ @headers = headers
10
+ @body = body
11
+ @raw = body
12
+ @data = body.is_a?(Hash) ? (body["data"] || body[:data]) : body
13
+ @meta = body.is_a?(Hash) ? (body["meta"] || body[:meta]) : nil
14
+ end
15
+
16
+ def success?
17
+ status >= 200 && status < 300
18
+ end
19
+
20
+ def [](key)
21
+ return body[key] if body.is_a?(Hash)
22
+
23
+ nil
24
+ end
25
+
26
+ def to_h
27
+ body.is_a?(Hash) ? body : { "data" => body }
28
+ end
29
+
30
+ def pagination
31
+ return meta if meta.is_a?(Hash) && meta.key?("pagination")
32
+
33
+ body.is_a?(Hash) ? (body["pagination"] || body[:pagination]) : nil
34
+ end
35
+
36
+ def next_page
37
+ return nil unless meta.is_a?(Hash)
38
+
39
+ meta["next_page"] || meta[:next_page]
40
+ end
41
+
42
+ def has_more?
43
+ return meta["has_more"] if meta.is_a?(Hash) && meta.key?("has_more")
44
+ return meta[:has_more] if meta.is_a?(Hash) && meta.key?(:has_more)
45
+
46
+ !next_page.nil?
47
+ end
48
+
49
+ def next_page_params
50
+ page = next_page
51
+ return nil if page.nil?
52
+
53
+ { page: page }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiEnergyAi
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ require_relative "hi_energy_ai/version"
6
+ require_relative "hi_energy_ai/error"
7
+ require_relative "hi_energy_ai/configuration"
8
+ require_relative "hi_energy_ai/response"
9
+ require_relative "hi_energy_ai/paginator"
10
+ require_relative "hi_energy_ai/resource"
11
+ require_relative "hi_energy_ai/client"
12
+
13
+ Dir[File.join(__dir__, "hi_energy_ai/resources", "*.rb")].sort.each { |file| require file }
14
+
15
+ module HiEnergyAi
16
+ class << self
17
+ def new(**options)
18
+ Client.new(**options)
19
+ end
20
+
21
+ def configure(&block)
22
+ Client.configure(&block)
23
+ end
24
+
25
+ def documentation_url
26
+ Configuration::DOCUMENTATION_URL
27
+ end
28
+ end
29
+ end