Sha256: a692875cf75fb5dc93f8c37d6ee9e479c02c7a98cf9ac740f128214ebd1aa932

Contents?: true

Size: 1.15 KB

Versions: 22

Compression:

Stored size: 1.15 KB

Contents

# -*- encoding : utf-8 -*-
class SklikApi::Access

  #set credentials
  def self.set args = {}
    args.symbolize_keys!
    #check required arguments
    raise ArgumentError, "email is required" unless args[:email]
    raise ArgumentError, "password is required" unless args[:password]
    
    #save argument to right places
    @args = args
    
    #return this object!
    return self
  end

  def self.get
    Marshal.load( Marshal.dump (@args )) 
  end
  
  #return email
  def self.email
    @args[:email].to_s
  end

  #for login take first part of email "name@seznam.cz" -> "name"
  def self.login
    @args[:email].to_s.split("@").first
  end

  #return customer_id
  def self.customer_id    
    @args.has_key?(:customer_id) && @args[:customer_id] ? @args[:customer_id] : nil
  end

  #return password
  def self.password
    @args[:password].to_s
  end
    
  #if you change Access credentials change uniq identifier -> 
  #used for stroing sessions for multiple logins
  def self.uniq_identifier 
    "#{@args[:email]}:#{@args[:password]}"
  end
  
  #to prevent changes in settings dump it
  def self.access
    Marshal.load( Marshal.dump( @args ))
  end
  
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sklik-api-0.1.5 lib/sklik-api/access.rb
sklik-api-0.1.4 lib/sklik-api/access.rb
sklik-api-0.1.3 lib/sklik-api/access.rb
sklik-api-0.1.2 lib/sklik-api/access.rb
sklik-api-0.1.1 lib/sklik-api/access.rb
sklik-api-0.1.0 lib/sklik-api/access.rb
sklik-api-0.0.16 lib/sklik-api/access.rb
sklik-api-0.0.15 lib/sklik-api/access.rb
sklik-api-0.0.14 lib/sklik-api/access.rb
sklik-api-0.0.13 lib/sklik-api/access.rb
sklik-api-0.0.12 lib/sklik-api/access.rb
sklik-api-0.0.11 lib/sklik-api/access.rb
sklik-api-0.0.10 lib/sklik-api/access.rb
sklik-api-0.0.9 lib/sklik-api/access.rb
sklik-api-0.0.8 lib/sklik-api/access.rb
sklik-api-0.0.7 lib/sklik-api/access.rb
sklik-api-0.0.6 lib/sklik-api/access.rb
sklik-api-0.0.5 lib/sklik-api/access.rb
sklik-api-0.0.4 lib/sklik-api/access.rb
sklik-api-0.0.3 lib/sklik-api/access.rb