Class: HerokuAddonProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_addon_provider.rb,
lib/heroku_addon_provider/version.rb

Constant Summary collapse

VERSION =
'0.0.1'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.manifest_pathObject

Returns the value of attribute manifest_path.



11
12
13
# File 'lib/heroku_addon_provider.rb', line 11

def manifest_path
  @manifest_path
end

Class Method Details

.application_info(heroku_id) ⇒ Object



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

def application_info(heroku_id)
  faraday.get("/vendor/apps/#{heroku_id}").body
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



59
60
61
# File 'lib/heroku_addon_provider.rb', line 59

def configure(&block)
  yield self
end

.installed_applicationsObject



40
41
42
# File 'lib/heroku_addon_provider.rb', line 40

def installed_applications
  faraday.get('/vendor/apps').body
end

.manifestObject



13
14
15
16
17
18
19
20
21
# File 'lib/heroku_addon_provider.rb', line 13

def manifest
  if manifest_path
    @manifest ||= JSON.load(File.read(manifest_path))
  elsif (defined?(Rails) && File.exists?("#{Rails.root}/addon-manifest.json"))
    @manifest ||= JSON.load(File.read("#{Rails.root}/addon-manifest.json"))
  else
    raise 'Addon manifest not found'
  end
end

.owner_email(heroku_id) ⇒ Object



48
49
50
51
# File 'lib/heroku_addon_provider.rb', line 48

def owner_email(heroku_id)
  info = application_info(heroku_id)
  info['owner_email']
end

.owner_emailsObject



53
54
55
56
57
# File 'lib/heroku_addon_provider.rb', line 53

def owner_emails
  installed_applications.map do |app|
    owner_email(app['heroku_id'])
  end
end

.passwordObject



27
28
29
# File 'lib/heroku_addon_provider.rb', line 27

def password
  manifest['api']['password']
end

.provider_idObject



23
24
25
# File 'lib/heroku_addon_provider.rb', line 23

def provider_id
  manifest['id']
end

.sso_saltObject



31
32
33
# File 'lib/heroku_addon_provider.rb', line 31

def sso_salt
  manifest['api']['sso_salt']
end

.sso_token(user_id, timestamp) ⇒ Object



35
36
37
38
# File 'lib/heroku_addon_provider.rb', line 35

def sso_token(user_id, timestamp)
  pre_token = "#{user_id}:#{sso_salt}:#{timestamp}"
  Digest::SHA1.hexdigest(pre_token).to_s
end