Sha256: c5eac0197f3def01436eb13eebc5b2f6fb5f7aac83f2b56644b8ea0e3f80486b

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

module KashflowApi
    class Client
        def initialize(config)
            @config = config
            @url = "https://securedwebapp.com/api/service.asmx?WSDL"
            
            @client = Savon::Client.new @url
        end
        
        def call(api_call)
            result = @client.request("KashFlow/#{api_call.method}") do |soap|
                soap.xml = api_call.xml
            end
            raise "Incorrect username or password" if result.to_hash.first.last[:status_detail] == "Incorrect username or password"
            raise "Your IP Address is not in the access list!" if result.to_hash.first.last[:status_detail] =~ /The IP address of .*? is not in the access list/
            #raise api_call.xml if result.to_hash.first.last[:status] == "NO"
            raise "Kashflow Error: #{result.to_hash.first.last[:status_detail]}" if result.to_hash.first.last[:status] == "NO"
            return result
        end
        
        def client
            @client
        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kashflow_api-0.0.2 lib/kashflow_api/client.rb
kashflow_api-0.0.1 lib/kashflow_api/client.rb
kashflow_api-0.0.1rc1 lib/kashflow_api/client.rb
kashflow_api-0.0.1pre lib/kashflow_api/client.rb