Programming Language-specific syntax

Passing as a function argument
In addition to the methods above, our client libraries each support passing in settings as function arguments. See the code example below for details.

Using a module variable
This method allows you to specify your API key a single time within a program or once per interpreter session by defining the module variable. This method eliminates the need to specify your API key or private cloud address more than one time and can help keep your code more readable.

require 'indico'

# option 1: pass configuration as a function argument
config = {api_key: "YOUR_API_KEY", cloud: "YOUR_SUBDOMAIN"}
puts(Indico.sentiment("indico is so easy to use!", config))

# option 2: set module variable
Indico.api_key = "YOUR_API_KEY"
Indico.private_cloud = "YOUR_SUBDOMAIN"
puts(Indico.sentiment("indico is so easy to use!"))

# {"Sentiment"=>0.9782025594088044}