Module: Mode::Sdk

Defined in:
lib/mode/sdk.rb,
lib/mode/sdk/cli.rb,
lib/mode/sdk/table.rb,
lib/mode/sdk/column.rb,
lib/mode/sdk/upload.rb,
lib/mode/sdk/client.rb,
lib/mode/sdk/version.rb,
lib/mode/sdk/csv_file.rb,
lib/mode/sdk/hash_util.rb,
lib/mode/sdk/column_set.rb,
lib/mode/sdk/table_import.rb,
lib/mode/sdk/configuration.rb,
lib/mode/sdk/client/request.rb,
lib/mode/sdk/warehouse_util.rb,
lib/mode/sdk/client/response.rb,
lib/mode/sdk/actions/table_upsert.rb

Overview

Official Mode Analytics Ruby SDK

Defined Under Namespace

Modules: Actions, HashUtil, WarehouseUtil Classes: Cli, Client, Column, ColumnSet, Configuration, CsvFile, Table, TableImport, Upload

Constant Summary collapse

VERSION =

Current version of this SDK

'0.1.0'

Class Method Summary collapse

Class Method Details

.accountHash

The Mode API representation of the authenticated account

Returns:

  • (Hash)

    the account representation


36
37
38
# File 'lib/mode/sdk.rb', line 36

def 
  @account ||= Mode::Sdk::Client.
end

.authenticated?Boolean

Returns:

  • (Boolean)

See Also:


50
51
52
# File 'lib/mode/sdk.rb', line 50

def authenticated?
  Mode::Sdk::Client.authenticated?
end

.configMode::Sdk::Configuration

The Mode configuration instance

Returns:


28
29
30
# File 'lib/mode/sdk.rb', line 28

def config
  @config ||= Mode::Sdk::Configuration.new
end

.configure {|Mode::Sdk::Configuration| ... } ⇒ Object

Set Mode configuration values

Examples:

Mode.configure do |config|
  config.token  = "token"
  config.secret = "secret"
end

Yields:


20
21
22
# File 'lib/mode/sdk.rb', line 20

def configure
  yield config
end

.resetObject

Un-memoize everything


56
57
58
59
60
61
62
# File 'lib/mode/sdk.rb', line 56

def reset
  %w(config account).each do |name|
    next unless instance_variable_defined?(:"@#{name}")

    remove_instance_variable(:"@#{name}")
  end
end

.usernameString

The username of the authenticated account

Returns:

  • (String)

    the username


44
45
46
# File 'lib/mode/sdk.rb', line 44

def username
  .fetch('username')
end