Class: Geti::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/geti/client.rb

Direct Known Subclasses

AppClient, AuthClient

Instance Method Summary collapse

Constructor Details

#initialize(auth, terminal_opts = {}, env = 'test') ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
# File 'lib/geti/client.rb', line 5

def initialize(auth, terminal_opts={}, env='test')
  @user = auth['user']
  @pass = auth['pass']
  @env = env
end

Instance Method Details

#certification?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/geti/client.rb', line 39

def certification?
  @env != 'production'
end

#data_packet {|xml| ... } ⇒ Object

Yields:

  • (xml)


15
16
17
18
19
20
21
# File 'lib/geti/client.rb', line 15

def data_packet
  xml = Builder::XmlMarkup.new
  xml.instruct!
  yield xml
  content = xml.target!
  {"DataPacket" => content}
end

#domainObject



43
44
45
46
47
48
49
# File 'lib/geti/client.rb', line 43

def domain
  if certification?
    'demo.eftchecks.com'
  else
    'getigateway.eftchecks.com'
  end
end

#soap_clientObject



11
12
13
# File 'lib/geti/client.rb', line 11

def soap_client
  @soap_client ||= Savon.client(service_address)
end

#soap_request(operation, op_key = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/geti/client.rb', line 23

def soap_request(operation, op_key=nil)
  operation.sub!('Certification','') unless certification?
  response = soap_client.request operation do
    http.headers.delete('SOAPAction')
    config.soap_header = soap_header
    soap.body = (yield if block_given?)
  end

  op_key ||= operation.gsub(/(.)([A-Z])/, '\1_\2').downcase
  op_key.sub!('_certification','') unless certification?
  response_key = (op_key+'_response').to_sym
  result_key = (op_key+'_result').to_sym

  xml_parser.parse(response.body[response_key][result_key])
end

#xml_parserObject



51
52
53
# File 'lib/geti/client.rb', line 51

def xml_parser
  @xml_parser or Nori
end