Class: HiEnergyAi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hi_energy_ai/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, bearer_token: nil, base_url: nil, app_origin: nil, timeout: nil, user_agent: nil, dry_run: nil) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hi_energy_ai/client.rb', line 20

def initialize(api_key: nil, bearer_token: nil, base_url: nil, app_origin: nil, timeout: nil, user_agent: nil, dry_run: nil)
  @config = self.class.configuration.dup
  @config.api_key = api_key if api_key
  @config.bearer_token = bearer_token if bearer_token
  @config.base_url = base_url if base_url
  @config.app_origin = app_origin if app_origin
  @config.timeout = timeout if timeout
  @config.user_agent = user_agent if user_agent
  @config.dry_run = dry_run unless dry_run.nil?

  raise ArgumentError, "api_key or bearer_token is required" unless @config.credentials_present?
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/hi_energy_ai/client.rb', line 9

def config
  @config
end

Class Method Details

.configurationObject



16
17
18
# File 'lib/hi_energy_ai/client.rb', line 16

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



11
12
13
14
# File 'lib/hi_energy_ai/client.rb', line 11

def self.configure
  yield(configuration)
  configuration
end

Instance Method Details

#advertisersObject



81
82
83
# File 'lib/hi_energy_ai/client.rb', line 81

def advertisers
  @advertisers ||= Resources::Advertisers.new(self)
end

#agenciesObject



113
114
115
# File 'lib/hi_energy_ai/client.rb', line 113

def agencies
  @agencies ||= Resources::Agencies.new(self)
end

#app_get(path, params: {}) ⇒ Object



49
50
51
# File 'lib/hi_energy_ai/client.rb', line 49

def app_get(path, params: {})
  app_request(:get, path, params: params)
end

#app_post(path, params: {}, body: nil) ⇒ Object



53
54
55
# File 'lib/hi_energy_ai/client.rb', line 53

def app_post(path, params: {}, body: nil)
  app_request(:post, path, params: params, body: body)
end

#app_request(method, path, params: {}, body: nil) ⇒ Object



61
62
63
# File 'lib/hi_energy_ai/client.rb', line 61

def app_request(method, path, params: {}, body: nil)
  perform_request(app_connection, method, path, params: params, body: body)
end

#clicksObject



97
98
99
# File 'lib/hi_energy_ai/client.rb', line 97

def clicks
  @clicks ||= Resources::Clicks.new(self)
end

#contactsObject



89
90
91
# File 'lib/hi_energy_ai/client.rb', line 89

def contacts
  @contacts ||= Resources::Contacts.new(self)
end

#dealsObject



85
86
87
# File 'lib/hi_energy_ai/client.rb', line 85

def deals
  @deals ||= Resources::Deals.new(self)
end


141
142
143
# File 'lib/hi_energy_ai/client.rb', line 141

def deeplinks
  @deeplinks ||= Resources::Deeplinks.new(self)
end

#delete(path, params: {}) ⇒ Object



45
46
47
# File 'lib/hi_energy_ai/client.rb', line 45

def delete(path, params: {})
  request(:delete, path, params: params)
end

#domainsObject



137
138
139
# File 'lib/hi_energy_ai/client.rb', line 137

def domains
  @domains ||= Resources::Domains.new(self)
end

#exportsObject



145
146
147
# File 'lib/hi_energy_ai/client.rb', line 145

def exports
  @exports ||= Resources::Exports.new(self)
end

#get(path, params: {}) ⇒ Object



33
34
35
# File 'lib/hi_energy_ai/client.rb', line 33

def get(path, params: {})
  request(:get, path, params: params)
end

#mcpObject



149
150
151
# File 'lib/hi_energy_ai/client.rb', line 149

def mcp
  @mcp ||= Resources::Mcp.new(self)
end

#networksObject



117
118
119
# File 'lib/hi_energy_ai/client.rb', line 117

def networks
  @networks ||= Resources::Networks.new(self)
end

#opportunitiesObject



101
102
103
# File 'lib/hi_energy_ai/client.rb', line 101

def opportunities
  @opportunities ||= Resources::Opportunities.new(self)
end

#paginate(path, params: {}) ⇒ Object



65
66
67
# File 'lib/hi_energy_ai/client.rb', line 65

def paginate(path, params: {})
  Paginator.new(client: self, path: path, params: params)
end

#patch(path, params: {}, body: nil) ⇒ Object



41
42
43
# File 'lib/hi_energy_ai/client.rb', line 41

def patch(path, params: {}, body: nil)
  request(:patch, path, params: params, body: body)
end

#post(path, params: {}, body: nil) ⇒ Object



37
38
39
# File 'lib/hi_energy_ai/client.rb', line 37

def post(path, params: {}, body: nil)
  request(:post, path, params: params, body: body)
end

#publishersObject



109
110
111
# File 'lib/hi_energy_ai/client.rb', line 109

def publishers
  @publishers ||= Resources::Publishers.new(self)
end

#reportsObject



105
106
107
# File 'lib/hi_energy_ai/client.rb', line 105

def reports
  @reports ||= Resources::Reports.new(self)
end

#request(method, path, params: {}, body: nil) ⇒ Object



57
58
59
# File 'lib/hi_energy_ai/client.rb', line 57

def request(method, path, params: {}, body: nil)
  perform_request(api_connection, method, path, params: params, body: body)
end

#schemaObject



73
74
75
# File 'lib/hi_energy_ai/client.rb', line 73

def schema
  @schema ||= Resources::Schema.new(self)
end

#searchObject



77
78
79
# File 'lib/hi_energy_ai/client.rb', line 77

def search
  @search ||= Resources::Search.new(self)
end

#status_changesObject



121
122
123
# File 'lib/hi_energy_ai/client.rb', line 121

def status_changes
  @status_changes ||= Resources::StatusChanges.new(self)
end

#tagsObject



125
126
127
# File 'lib/hi_energy_ai/client.rb', line 125

def tags
  @tags ||= Resources::Tags.new(self)
end

#toolsObject



69
70
71
# File 'lib/hi_energy_ai/client.rb', line 69

def tools
  @tools ||= Resources::Tools.new(self)
end

#transactionsObject



93
94
95
# File 'lib/hi_energy_ai/client.rb', line 93

def transactions
  @transactions ||= Resources::Transactions.new(self)
end

#usersObject



129
130
131
# File 'lib/hi_energy_ai/client.rb', line 129

def users
  @users ||= Resources::Users.new(self)
end

#verticalsObject



133
134
135
# File 'lib/hi_energy_ai/client.rb', line 133

def verticals
  @verticals ||= Resources::Verticals.new(self)
end