Module: Blend::Client
- Defined in:
- lib/blend/client.rb,
lib/blend/client/juice_client.rb,
lib/blend/client/github_client.rb,
lib/blend/client/heroku_client.rb,
lib/blend/client/hipchat_client.rb
Defined Under Namespace
Classes: GithubClient, HerokuClient, HipchatClient, JuiceClient
Class Method Summary
collapse
Class Method Details
.get_token(type) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/blend/client.rb', line 35
def get_token( type )
token = case type
when :hipchat
ENV['HIPCHAT_API_TOKEN'] || juice_client.hipchat_api
when :github
ENV['GITHUB_API_TOKEN'] || juice_client.auth( "github" )
when :heroku
ENV['HEROKU_API_TOKEN'] || juice_client.heroku_api
else
throw "Unknown token type #{type}".red
end
throw "Token not found for #{type}" if token.nil? || token == ""
token
end
|
.github_client ⇒ Object
13
14
15
|
# File 'lib/blend/client.rb', line 13
def github_client
@github_client ||= Blend::Client::GithubClient.new( Github.new( oauth_token: get_token( :github ) ) )
end
|
.heroku_client ⇒ Object
31
32
33
|
# File 'lib/blend/client.rb', line 31
def heroku_client
@heroku_client ||= Blend::Client::HerokuClient.new( Heroku::API.new( api_key: get_token( :heroku ) ) )
end
|
.hipchat_client ⇒ Object
9
10
11
|
# File 'lib/blend/client.rb', line 9
def hipchat_client
@hipchat_client ||= Blend::Client::HipchatClient.new( HipChat::API.new( get_token( :hipchat ) ) )
end
|
.juice_client(options = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/blend/client.rb', line 17
def juice_client( options = {} )
if( options[:auth_token] )
if( @juice_client && @juice_client.auth_token != options[:auth_token] )
@juice_client = nil
@hipchat_client = nil
@github_client = nil
end
@juice_client ||= Blend::Client::JuiceClient.new options
end
@juice_client ||= Blend::Client::JuiceClient.new
end
|