Sha256: e78630fe79bdb84ae9b3fb6ede2939ec145897dc662d9220c65a8ab84a5588c1

Contents?: true

Size: 1.04 KB

Versions: 30

Compression:

Stored size: 1.04 KB

Contents

require 'epom/epom_element'

module Epom
  class Auth < EpomElement

    def self.extended_methods
      {
          :get_authentication_token => {
              :url => '/rest-api/auth/token.do',
              :body_parameters => [:username, :password],
              :method => :post
          },
          :register_user => {
              :url => '/rest-api/register-user/KEY/HASH/TIMESTAMP.do',
              :url_parameters => [:key, :hash, :timestamp],
              :body_parameters => [:username, :password, :email, :role, :phone, :firstName, :lastName, :websiteUrl, :company, :country, :state, :enable_market_integration],
              :method => :post
          }
      }
    end

    def self.replace_params_in_url(url, url_params)
      url.gsub!('TOKEN', url_params[:token]) if url.include?('TOKEN')
      url.gsub!('KEY', url_params[:key]) if url.include?('KEY')
      url.gsub!('HASH', url_params[:hash]) if url.include?('HASH')
      url.gsub!('TIMESTAMP', url_params[:timestamp].to_s) if url.include?('TIMESTAMP')
      url
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
epom-0.7.2 lib/epom/auth.rb
epom-0.7 lib/epom/auth.rb
epom-0.6.2 lib/epom/auth.rb
epom-0.6 lib/epom/auth.rb
epom-0.5 lib/epom/auth.rb
epom-0.4.1 lib/epom/auth.rb
epom-0.4 lib/epom/auth.rb
epom-0.3.3 lib/epom/auth.rb
epom-0.3 lib/epom/auth.rb
epom-0.1.0 lib/epom/auth.rb