Sha256: f86724becf3afb527cdad8890d90fcad0f04b8919beb62c0662a69845eb68b7f

Contents?: true

Size: 1.99 KB

Versions: 39

Compression:

Stored size: 1.99 KB

Contents

module Login

  def with_user(ip_address, business_unit_id, options={})
    options.merge!(basic_auth: @auth, headers: @headers)
    response = self.class.get(base_api_endpoint('Web/Session/'), options)
    JSON.parse(response.body)
  end

  def login_using_email(email, password, login_type_id, promotion, session_key, options={})
    parameters =
      {
        'UserName': email,
        'Password': password, 
        'LoginTypeId': login_type_id,
        'PromotionCode': promotion
      }
    options.merge!(basic_auth: @auth, headers: @headers)
    options.merge!(:body => parameters)
    post = self.class.post(base_api_endpoint("Web/Session/#{session_key}/Login"), options)
    post['IsLoggedIn']
  end

  def login_using_external(email, login_type_id, promotion, session_key, options={})
    parameters =
      {
        'UserName': email,
        'LoginTypeId': login_type_id,
        'PromotionCode': promotion
      }
    options.merge!(basic_auth: @auth, headers: @headers)
    options.merge!(:body => parameters.to_json, :headers => {'Content-Type' => 'application/json'})
    post = self.class.post(base_api_endpoint("Web/Session/#{session_key}/Login/External"), options)
    post.success?
  end

  def login_with_token(email, login_type_id, token, promotion, session_key, options={})
    parameters =
      {
        'EmailAddress': email,
        'ForgotLoginToken': token,
        'LoginTypeId': login_type_id,
        'PromotionCode': promotion
      }
    options.merge!(basic_auth: @auth, headers: @headers)
    options.merge!(:body => parameters.to_json, :headers => {'Content-Type' => 'application/json'})
    post = self.class.post(base_api_endpoint("Web/Session/#{session_key}/Login/Token"), options)
    post['IsLoggedIn']
  end

  def logout(session_key, options={})
    options.merge!(basic_auth: @auth, headers: @headers)
    options.merge!(:body => {}, :headers => {'Content-Type' => 'application/json'})
    self.class.post(base_api_endpoint("/Web/Session/#{session_key}/Logout"), options)
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
tessitura_rest-1.1.6 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.5 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.4 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.3 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.2 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.1 lib/tessitura_rest/web/login.rb
tessitura_rest-1.1.0 lib/tessitura_rest/web/login.rb
tessitura_rest-1.0.0 lib/tessitura_rest/web/login.rb
tessitura_rest-0.9.1.3 lib/tessitura_rest/web/login.rb
tessitura_rest-0.9.1.2 lib/tessitura_rest/web/login.rb
tessitura_rest-0.9.1.1 lib/tessitura_rest/web/login.rb
tessitura_rest-0.9.1 lib/tessitura_rest/web/login.rb
tessitura_rest-0.9.0 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.9 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.8 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.7 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.6.9 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.6.8 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.6.7 lib/tessitura_rest/web/login.rb
tessitura_rest-0.8.6.6 lib/tessitura_rest/web/login.rb