Class: Iprocessor::CardProcessor

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/iprocessor.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ CardProcessor

attr_accessor :base_url



15
16
17
18
# File 'lib/iprocessor.rb', line 15

def initialize(username, password)
  @auth = {:username => username, :password => password}
  @base_url = Iprocessor::BASE_URL
end

Instance Method Details

#clean(action) ⇒ Object



30
31
32
# File 'lib/iprocessor.rb', line 30

def clean(action)
  action.present? ? (action.chomp.gsub('/', '').insert(0,'/').insert(-1,'/')) : ''
end

#optionize(filter) ⇒ Object



26
27
28
# File 'lib/iprocessor.rb', line 26

def optionize(filter)
  filter.join('/')
end

#read_license(img_byte, action, filter) ⇒ Object



20
21
22
23
24
# File 'lib/iprocessor.rb', line 20

def read_license(img_byte, action, filter)
  options = {:body => img_byte, :basic_auth => @auth}
  url = @base_url + clean(action) + optionize(filter)
  self.class.post(url, options)
end