kashflow_soap 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/kashflow_soap.rb +79 -0
  2. metadata +46 -0
@@ -0,0 +1,79 @@
1
+ class KashflowSoap
2
+
3
+ def initialize username, password, options
4
+ raise "missing username/password" unless username and password
5
+ namespaces = {"xmlns:kas" => "KashFlow"}
6
+ @client = Savon.client do |globals|
7
+ globals.wsdl "https://securedwebapp.com/api/service.asmx?wsdl"
8
+ globals.convert_request_keys_to :none
9
+ globals.ssl_version :TLSv1
10
+ globals.ssl_ca_cert_file options[:ssl_ca_cert_file] if options[:ssl_ca_cert_file]
11
+ globals.env_namespace :soapenv
12
+ globals.namespace_identifier :kas
13
+ globals.namespaces namespaces
14
+ globals.log false
15
+ end
16
+ @auth = {UserName: username, Password: password}
17
+ end
18
+
19
+ def call m, message = nil
20
+ if message
21
+ body = {message: message.merge(@auth)}
22
+ response = @client.call(m, body)
23
+ else
24
+ response = @client.call(m, {message: @auth})
25
+ end
26
+ response = response.body["#{m}_response".to_sym]
27
+ result = response["#{m}_result".to_sym]
28
+ status = response[:status]
29
+ result if status != "NO"
30
+ end
31
+
32
+ def insert_customer customer
33
+ result = call :insert_customer, {custr: customer}
34
+ if result
35
+ customer[:CustomerID] = result
36
+ customer
37
+ end
38
+ end
39
+
40
+ def get_customer_by_id id
41
+ call :get_customer_by_id, {CustomerID: id.to_s}
42
+ end
43
+
44
+ def insert_invoice invoice
45
+ result = call :insert_invoice, {Inv: invoice}
46
+ if result
47
+ invoice[:InvoiceNumber] = result
48
+ invoice
49
+ end
50
+ end
51
+
52
+ def get_invoice id
53
+ invoice = call :get_invoice, {InvoiceNumber: id.to_s}
54
+ invoice if invoice[:invoice_dbid] != "0"
55
+ end
56
+
57
+ def get_inv_pay_methods
58
+ result = call :get_inv_pay_methods
59
+ result[:payment_method] if result
60
+ end
61
+
62
+ def get_bank_account
63
+ result = call :get_bank_accounts
64
+ result[:bank_account] if result
65
+ end
66
+
67
+ def insert_invoice_payment payment
68
+ call :insert_invoice_payment, {InvoicePayment: payment}
69
+ end
70
+
71
+ def insert_invoice_line invoice_id, line
72
+ call :insert_invoice_line, {InvoiceID: invoice_id, InvLine: line}
73
+ end
74
+
75
+ def method_missing m, message = nil
76
+ call m, message
77
+ end
78
+
79
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kashflow_soap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ed Clements
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-05-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email: ed.clements@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/kashflow_soap.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.10
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: A Savon wrapper for the KashFlow accounting software API
46
+ test_files: []