Class: RS::BaseRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/rs/requests/base.rb

Overview

This class is the base for other request classes.

Constant Summary collapse

WAYBILL_SERVICE_URL =

Waybill service WSDL location.

'http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL'
INVOICE_SERVICE_URL =

Invoice service WSDL location.

'http://www.revenue.mof.ge/ntosservice/ntosservice.asmx?WSDL'
DEFAULTS =

Defaults

{su: 'DIMITRI1979:206322102', sp: '123456', payer_id: 731937, user_id: 783}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_error_codeObject

Last error code.



17
18
19
# File 'lib/rs/requests/base.rb', line 17

def last_error_code
  @last_error_code
end

Instance Method Details

#format_date(dt) ⇒ Object



42
43
44
# File 'lib/rs/requests/base.rb', line 42

def format_date(dt)
  dt.strftime('%Y-%m-%dT%H:%M:%S')
end

#invoice_clientObject

Getting waybill SOAP client.



25
26
27
# File 'lib/rs/requests/base.rb', line 25

def invoice_client
  Savon::Client.new { wsdl.document = INVOICE_SERVICE_URL }
end

#validate_presence_of(params, *keys) ⇒ Object

Validates presence of specified keys in the #params hash.

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rs/requests/base.rb', line 30

def validate_presence_of(params, *keys)
  # XXX: do we always need this replacement???
  [:su, :sp, :user_id, :payer_id].each do |sym|
    if keys.include?(sym) and params[sym].blank?
      params[sym] = RS.config.send(sym)
    end
  end
  # <-- XXX
  diff = keys - params.keys
  raise ArgumentError, "The following parameter(s) not specified: #{diff.to_s[1..-2]}" unless diff.empty?
end

#waybill_clientObject

Getting waybill SOAP client.



20
21
22
# File 'lib/rs/requests/base.rb', line 20

def waybill_client
  Savon::Client.new { wsdl.document = WAYBILL_SERVICE_URL }
end