Class: ZuoraConnect::AppInstance

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/zuora_connect/app_instance.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loginsObject

Returns the value of attribute logins.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def logins
  @logins
end

#modeObject

Returns the value of attribute mode.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def mode
  @mode
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def options
  @options
end

#passObject

Returns the value of attribute pass.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def pass
  @pass
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def user
  @user
end

#validObject

Returns the value of attribute valid.



3
4
5
# File 'app/models/zuora_connect/app_instance.rb', line 3

def valid
  @valid
end

Class Method Details

.decrypt_response(resp) ⇒ Object



37
38
39
# File 'app/models/zuora_connect/app_instance.rb', line 37

def self.decrypt_response(resp)
  OpenSSL::PKey::RSA.new(ZuoraConnect.configuration.private_key).private_decrypt(resp)
end

Instance Method Details

#new_session(user, password) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/zuora_connect/app_instance.rb', line 5

def new_session(user, password)
  @user = user
  @password = password
  response = JSON.parse(HTTParty.get(ZuoraConnect.configuration.url + "/api/v1/tools/tasks/#{self.id}.json",:basic_auth => auth = {:username => user, :password => password}).body)
  @mode = response["mode"]
  @options = Hash.new
  @logins = Hash.new
  response.each do |k,v|
    if k.match(/^(.*)_login$/)
      @logins[k] = v
    elsif k == "options"
      v.each do |opt|
        @options[opt["config_name"]] = opt
      end
    end
  end
  @valid = true
end

#send_emailObject



33
34
35
# File 'app/models/zuora_connect/app_instance.rb', line 33

def send_email

end

#updateOption(optionId, value) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/models/zuora_connect/app_instance.rb', line 24

def updateOption(optionId, value)
  if @user && @pass
    return HTTParty.get(ZuoraConnect.configuration.url + "/api/v1/tools/application_options/#{optionId}/edit?value=#{value}",:basic_auth => auth = {:username => user, :password => password})
  else
    puts "Username or password is nil"
    return false
  end
end