Class: Teamsupport::Client

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

Direct Known Subclasses

REST::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Teamsupport::Client

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})

Yields:

  • (_self)

Yield Parameters:



38
39
40
41
42
43
# File 'lib/teamsupport/client.rb', line 38

def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
end

Instance Attribute Details

#api_keyString

Provide api_key and api_secret methods for accessing Client API values

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.api_key
teamsupport_client.api_secret

Returns:

  • (String)


17
18
19
# File 'lib/teamsupport/client.rb', line 17

def api_key
  @api_key
end

#api_secretString

Provide api_key and api_secret methods for accessing Client API values

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.api_key
teamsupport_client.api_secret

Returns:

  • (String)


17
18
19
# File 'lib/teamsupport/client.rb', line 17

def api_secret
  @api_secret
end

#api_urlString

Returns api_url string for the Client

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.api_url

Returns:

  • (String)


54
55
56
# File 'lib/teamsupport/client.rb', line 54

def api_url
  @api_url ||= 'https://app.teamsupport.com'
end

#user_agentString

Returns user agent string for the Client

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.user_agent

Returns:

  • (String)


67
68
69
# File 'lib/teamsupport/client.rb', line 67

def user_agent
  @user_agent ||= "TeamsupportRubyGem/#{Teamsupport::Version}"
end

Instance Method Details

#authHash

Returns authentication hash for the Client

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.auth

Returns:

  • (Hash)


80
81
82
83
84
85
# File 'lib/teamsupport/client.rb', line 80

def auth
  {
    user: api_key,
    password: api_secret,
  }
end

#auth?Boolean

Checks for the existence of an authentication hash on the Client

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_client.auth?

Returns:

  • (Boolean)


96
97
98
# File 'lib/teamsupport/client.rb', line 96

def auth?
  auth.values.all?
end