Sha256: ddf06c09d88282cb820646bec2fe14dbc4494e82af740267452673fbc3eb01d1

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

module Moneta
  module Api
    class Service
      DEMO = 'https://demo.moneta.ru/services.wsdl'
      PRODUCTION = 'https://www.moneta.ru/services.wsdl'
      NAMESPACE = 'http://www.moneta.ru/schemas/messages.xsd'

      include ServiceMethods
      attr_reader :client

      def initialize(username, password, params = {})
        @client = Savon.client(prepare_params(username, password, params))
      end

      private

      def prepare_params(username, password, params)
        demo_mode = params.delete(:demo_mode)

        {
          wsse_auth: [ username, password ],
          wsdl: wsdl_url(demo_mode),
          namespace: NAMESPACE
        }.merge(params)
      end

      def wsdl_url(demo_mode)
        demo_mode ? DEMO : PRODUCTION
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
moneta-api-1.13.0 lib/moneta/api/service.rb
moneta-api-1.12.8 lib/moneta/api/service.rb