Module: Helio

Extended by:
Gem::Deprecate
Defined in:
lib/helio-ruby.rb,
lib/helio/util.rb,
lib/helio/errors.rb,
lib/helio/version.rb,
lib/helio/list_object.rb,
lib/helio/participant.rb,
lib/helio/api_resource.rb,
lib/helio/helio_client.rb,
lib/helio/helio_object.rb,
lib/helio/customer_list.rb,
lib/helio/helio_response.rb,
lib/helio/api_operations/list.rb,
lib/helio/api_operations/save.rb,
lib/helio/api_operations/create.rb,
lib/helio/api_operations/delete.rb,
lib/helio/api_operations/request.rb,
lib/helio/singleton_api_resource.rb,
lib/helio/api_operations/nested_resource.rb

Defined Under Namespace

Modules: APIOperations, Util Classes: APIConnectionError, APIError, APIResource, AuthenticationError, CustomerList, HelioClient, HelioError, HelioObject, HelioResponse, IdempotencyError, InvalidRequestError, ListObject, Participant, ParticipantError, PermissionError, RateLimitError, SignatureVerificationError, SingletonAPIResource

Constant Summary collapse

DEFAULT_CA_BUNDLE_PATH =
File.dirname(__FILE__) + "/data/ca-certificates.crt"
LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
VERSION =
"0.3.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def api_base
  @api_base
end

.api_idObject

Returns the value of attribute api_id.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def api_id
  @api_id
end

.api_tokenObject

Returns the value of attribute api_token.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def api_token
  @api_token
end

.api_versionObject

Returns the value of attribute api_version.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def api_version
  @api_version
end

.client_idObject

Returns the value of attribute client_id.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def client_id
  @client_id
end

.initial_network_retry_delayObject (readonly)

Returns the value of attribute initial_network_retry_delay.



66
67
68
# File 'lib/helio-ruby.rb', line 66

def initial_network_retry_delay
  @initial_network_retry_delay
end

.max_network_retry_delayObject (readonly)

Returns the value of attribute max_network_retry_delay.



66
67
68
# File 'lib/helio-ruby.rb', line 66

def max_network_retry_delay
  @max_network_retry_delay
end

.open_timeoutObject

Returns the value of attribute open_timeout.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def open_timeout
  @open_timeout
end

.read_timeoutObject

Returns the value of attribute read_timeout.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def read_timeout
  @read_timeout
end

.verify_ssl_certsObject

Returns the value of attribute verify_ssl_certs.



63
64
65
# File 'lib/helio-ruby.rb', line 63

def verify_ssl_certs
  @verify_ssl_certs
end

Class Method Details

.app_infoObject

Gets the application for a plugin that’s identified some. See #set_app_info.



71
72
73
# File 'lib/helio-ruby.rb', line 71

def self.app_info
  @app_info
end

.app_info=(info) ⇒ Object



75
76
77
# File 'lib/helio-ruby.rb', line 75

def self.app_info=(info)
  @app_info = info
end

.ca_bundle_pathObject

The location of a file containing a bundle of CA certificates. By default the library will use an included bundle that can successfully validate Helio certificates.



82
83
84
# File 'lib/helio-ruby.rb', line 82

def self.ca_bundle_path
  @ca_bundle_path
end

.ca_bundle_path=(path) ⇒ Object



86
87
88
89
90
91
# File 'lib/helio-ruby.rb', line 86

def self.ca_bundle_path=(path)
  @ca_bundle_path = path

  # empty this field so a new store is initialized
  @ca_store = nil
end

.ca_storeObject

A certificate store initialized from the the bundle in #ca_bundle_path and which is used to validate TLS on every request.

This was added to the give the gem “pseudo thread safety” in that it seems when initiating many parallel requests marshaling the certificate store is the most likely point of failure (see issue #382). Any program attempting to leverage this pseudo safety should make a call to this method (i.e. ‘Helio.ca_store`) in their initialization code because it marshals lazily and is itself not thread safe.



102
103
104
105
106
107
108
# File 'lib/helio-ruby.rb', line 102

def self.ca_store
  @ca_store ||= begin
    store = OpenSSL::X509::Store.new
    store.add_file(ca_bundle_path)
    store
  end
end

.log_levelObject

When set prompts the library to log some extra information to $stdout and $stderr about what it’s doing. For example, it’ll produce information about requests, responses, and errors that are received. Valid log levels are ‘debug` and `info`, with `debug` being a little more verbose in places.

Use of this configuration is only useful when ‘.logger` is not set. When it is, the decision what levels to print is entirely deferred to the logger.



122
123
124
# File 'lib/helio-ruby.rb', line 122

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/helio-ruby.rb', line 126

def self.log_level=(val)
  # Backwards compatibility for values that we briefly allowed
  if val == "debug"
    val = LEVEL_DEBUG
  elsif val == "info"
    val = LEVEL_INFO
  end

  if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
    raise ArgumentError, "log_level should only be set to `nil`, `debug` or `info`"
  end
  @log_level = val
end

.loggerObject

Sets a logger to which logging output will be sent. The logger should support the same interface as the ‘Logger` class that’s part of Ruby’s standard library (hint, anything in ‘Rails.logger` will likely be suitable).

If ‘.logger` is set, the value of `.log_level` is ignored. The decision on what levels to print is entirely deferred to the logger.



147
148
149
# File 'lib/helio-ruby.rb', line 147

def self.logger
  @logger
end

.logger=(val) ⇒ Object



151
152
153
# File 'lib/helio-ruby.rb', line 151

def self.logger=(val)
  @logger = val
end

.max_network_retriesObject



155
156
157
# File 'lib/helio-ruby.rb', line 155

def self.max_network_retries
  @max_network_retries
end

.max_network_retries=(val) ⇒ Object



159
160
161
# File 'lib/helio-ruby.rb', line 159

def self.max_network_retries=(val)
  @max_network_retries = val.to_i
end

.set_app_info(name, version: nil, url: nil) ⇒ Object

Sets some basic information about the running application that’s sent along with API requests. Useful for plugin authors to identify their plugin when communicating with Helio.

Takes a name and optional version and plugin URL.



168
169
170
171
172
173
174
# File 'lib/helio-ruby.rb', line 168

def self.set_app_info(name, version: nil, url: nil)
  @app_info = {
    name: name,
    url: url,
    version: version,
  }
end