Class: Drebedengi::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



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

def initialize
  @api_creds = {
    apiId: 'demo_api',
    login: '[email protected]',
    pass:  'demo',
  }
end

Instance Attribute Details

#api_credsObject

Returns the value of attribute api_creds.



13
14
15
# File 'lib/drebedengi/client.rb', line 13

def api_creds
  @api_creds
end

Instance Method Details

#clientObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/drebedengi/client.rb', line 48

def client
  @client ||= ::Savon.client(
    wsdl:       'http://www.drebedengi.ru/soap/dd.wsdl',
    # proxy:      'http://localhost:8888',
    namespaces: {
      'xmlns:ns2' => 'http://xml.apache.org/xml-soap',
      'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
    },
  )
end

#get_balanceObject



23
24
25
26
# File 'lib/drebedengi/client.rb', line 23

def get_balance
  raw_response = client.call(:get_balance, message: api_creds)
  Responses::GetBalance.new(raw_response.body).places
end

#get_place_listObject



28
29
30
31
# File 'lib/drebedengi/client.rb', line 28

def get_place_list
  raw_response = client.call(:get_place_list, message: api_creds)
  Responses::GetPlaceList.new(raw_response.body).places
end

#get_record_list(**kwargs) ⇒ Object

Gets transactions

Parameters:

  • id_list (Array)

    Get specific transactions by id

  • period_from (Date)

    Period from

  • period_to (Date)

    Period to



38
39
40
41
42
43
44
45
46
# File 'lib/drebedengi/client.rb', line 38

def get_record_list(**kwargs)
  raw_response = client.call(
    :get_record_list,
    message:     ParameterBuilders::GetRecordList.new(**kwargs),
    soap_header: { "OpToken" => "secret" },
  )

  Responses::GetRecordList.new(raw_response.body).records
end