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.10.13 lib/epom/auth.rb
epom-0.10.11 lib/epom/auth.rb
epom-0.10.10 lib/epom/auth.rb
epom-0.10.9 lib/epom/auth.rb
epom-0.10.8 lib/epom/auth.rb
epom-0.10.7 lib/epom/auth.rb
epom-0.10.5 lib/epom/auth.rb
epom-0.10 lib/epom/auth.rb
epom-0.9.9 lib/epom/auth.rb
epom-0.9.8 lib/epom/auth.rb
epom-0.9.7 lib/epom/auth.rb
epom-0.9.6 lib/epom/auth.rb
epom-0.9.4 lib/epom/auth.rb
epom-0.9.2 lib/epom/auth.rb
epom-0.9.1 lib/epom/auth.rb
epom-0.9 lib/epom/auth.rb
epom-0.8.5 lib/epom/auth.rb
epom-0.8.4 lib/epom/auth.rb
epom-0.8.1 lib/epom/auth.rb
epom-0.8 lib/epom/auth.rb