kashflow_api 0.0.2 → 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.markdown +2 -14
- data/Rakefile +7 -0
- data/kashflow_api.gemspec +3 -4
- data/lib/kashflow_api/api.rb +1 -1
- data/lib/kashflow_api/api_call.rb +2 -1
- data/lib/kashflow_api/client.rb +5 -5
- data/lib/kashflow_api/config.rb +2 -2
- data/lib/kashflow_api/models/customer.rb +11 -10
- data/lib/kashflow_api/models/customer_balance.rb +2 -2
- data/lib/kashflow_api/models/invoice.rb +1 -1
- data/lib/kashflow_api/models/nominal_code.rb +1 -1
- data/lib/kashflow_api/models/quote.rb +1 -1
- data/lib/kashflow_api/models/receipt.rb +1 -1
- data/lib/kashflow_api/models/supplier.rb +3 -3
- data/lib/kashflow_api/version.rb +1 -1
- data/spec/kashflow_api_customer_balance_spec.rb +1 -3
- data/spec/kashflow_api_customer_spec.rb +18 -12
- data/spec/kashflow_api_nominal_codes_spec.rb +1 -3
- data/spec/kashflow_api_quote_spec.rb +1 -3
- data/spec/kashflow_api_spec.rb +1 -3
- data/spec/kashflow_api_supplier_spec.rb +3 -4
- data/spec/spec_helper.rb +4 -1
- data/spec/test_data.example.yml +7 -0
- metadata +31 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80713598b9cc6087bc6f5c8fb1e8dddbc08b8638
|
4
|
+
data.tar.gz: 6028013836e547246697247fc46c2158c6f285af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 444553516b639eb4b7b8df00a8bdedc21c27f53361c03f1c9ca2f4c9ca3a78f5230665e35f7baf651d57e4dca2cf2d3dffb0ecba5962bbc6887b3d40963c4443
|
7
|
+
data.tar.gz: 91b2b8e5790b87199677dfe67b5b436a8424d591995917f8538c93f7d8fa70a3976d35dddf04ca27b355dd5a4b6abd1d4d0624d33d93aa8476023da41b4b6fd4
|
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -18,18 +18,6 @@ You can now call methods on the models e.g.
|
|
18
18
|
|
19
19
|
KashflowApi::Customer.all
|
20
20
|
|
21
|
-
#
|
21
|
+
# More Info
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
## Customers
|
26
|
-
|
27
|
-
* GetCustomersModifiedSince
|
28
|
-
* GetCustomerSources
|
29
|
-
* GetCustomerVATNumber
|
30
|
-
* SetCustomerVATNumber
|
31
|
-
* GetCustomerCurrency
|
32
|
-
* SetCustomerCurrency
|
33
|
-
* GetCustomerAdvancePayments
|
34
|
-
|
35
|
-
## Quotes
|
23
|
+
For more info head over to the [wiki][https://github.com/Ed-ITSolutions/KashflowAPI/wiki]
|
data/Rakefile
CHANGED
data/kashflow_api.gemspec
CHANGED
@@ -7,12 +7,10 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = KashflowApi::VERSION
|
8
8
|
s.authors = ["Adam \"Arcath\" Laycock"]
|
9
9
|
s.email = ["gems@arcath.net"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "http://ed-itsolutions.github.io/KashflowAPI"
|
11
11
|
s.summary = %q{Provides an interface for the Kashflow API}
|
12
12
|
s.description = s.summary
|
13
13
|
|
14
|
-
s.rubyforge_project = "kashflow_api"
|
15
|
-
|
16
14
|
s.files = `git ls-files`.split("\n")
|
17
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -20,7 +18,8 @@ Gem::Specification.new do |s|
|
|
20
18
|
|
21
19
|
# Development Dependencies
|
22
20
|
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "simplecov"
|
23
22
|
|
24
23
|
# Runtime Dependencies
|
25
|
-
s.add_runtime_dependency "savon", "
|
24
|
+
s.add_runtime_dependency "savon", "~> 2.3"
|
26
25
|
end
|
data/lib/kashflow_api/api.rb
CHANGED
data/lib/kashflow_api/client.rb
CHANGED
@@ -3,14 +3,14 @@ module KashflowApi
|
|
3
3
|
def initialize(config)
|
4
4
|
@config = config
|
5
5
|
@url = "https://securedwebapp.com/api/service.asmx?WSDL"
|
6
|
-
|
7
|
-
@client = Savon
|
6
|
+
|
7
|
+
@client = Savon.client(wsdl: @url, log: @config.loggers)
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(api_call)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
#"KashFlow/#{api_call.method}"
|
12
|
+
#result = @client.xml_call(api_call.method_sym, api_call)
|
13
|
+
result = @client.call(api_call.method_sym, xml: api_call.xml)
|
14
14
|
raise "Incorrect username or password" if result.to_hash.first.last[:status_detail] == "Incorrect username or password"
|
15
15
|
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/
|
16
16
|
#raise api_call.xml if result.to_hash.first.last[:status] == "NO"
|
data/lib/kashflow_api/config.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module KashflowApi
|
2
2
|
class Config
|
3
|
-
attr_accessor :username, :password
|
3
|
+
attr_accessor :username, :password, :loggers
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@loggers = true
|
7
7
|
end
|
8
8
|
|
9
9
|
def loggers=(i)
|
10
|
+
@loggers = i
|
10
11
|
HTTPI.log = i
|
11
|
-
Savon.log = i
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -6,35 +6,35 @@ module KashflowApi
|
|
6
6
|
|
7
7
|
def self.find_by_customer_code(search)
|
8
8
|
result = KashflowApi.api.get_customer(search)
|
9
|
-
self.build_from_soap(result.
|
9
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_customer_response][:get_customer_result])
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.find_by_customer_id(search)
|
13
13
|
result = KashflowApi.api.get_customer_by_id(search)
|
14
|
-
self.build_from_soap(result.
|
14
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_customer_by_id_response][:get_customer_by_id_result])
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.find_by_customer_email(search)
|
18
18
|
result = KashflowApi.api.get_customer_by_email(search)
|
19
|
-
self.build_from_soap(result.
|
19
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_customer_by_email_response][:get_customer_by_email_result])
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.find_by_postcode(search)
|
23
23
|
result = KashflowApi.api.get_customers_by_postcode(search)
|
24
|
-
self.build_from_soap(result.
|
24
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_customers_by_postcode_response][:get_customers_by_postcode])
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.all
|
28
28
|
result = KashflowApi.api.get_customers
|
29
29
|
customers = []
|
30
|
-
result.
|
30
|
+
result.hash[:envelope][:body][:get_customers_response][:get_customers_result][:customer].each do |customer|
|
31
31
|
customers.push self.build_from_soap customer
|
32
32
|
end
|
33
33
|
customers
|
34
34
|
end
|
35
35
|
|
36
36
|
def save
|
37
|
-
if @hash[
|
37
|
+
if @hash[:customer_id] == "0"
|
38
38
|
insert_customer
|
39
39
|
else
|
40
40
|
update_customer
|
@@ -42,7 +42,7 @@ module KashflowApi
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def destroy
|
45
|
-
KashflowApi.api.delete_customer(self.
|
45
|
+
KashflowApi.api.delete_customer(self.customer_id)
|
46
46
|
end
|
47
47
|
|
48
48
|
def balance
|
@@ -53,10 +53,11 @@ module KashflowApi
|
|
53
53
|
xml = []
|
54
54
|
id_line = ""
|
55
55
|
@hash.keys.each do |key|
|
56
|
-
if key ==
|
57
|
-
id_line = "
|
56
|
+
if key == :customer_id
|
57
|
+
id_line = "<CustomerID>#{@hash[key]}</CustomerID>" unless @hash[key] == "0"
|
58
58
|
else
|
59
|
-
|
59
|
+
key_name = key.to_s.split('_').map{|e| e.capitalize}.join
|
60
|
+
xml.push("<#{key_name}>#{@hash[key]}</#{key_name}>")
|
60
61
|
end
|
61
62
|
end
|
62
63
|
[id_line, xml.join].join
|
@@ -5,8 +5,8 @@ module KashflowApi
|
|
5
5
|
def initialize(customer)
|
6
6
|
result = KashflowApi.api.get_customer_balance(customer.code)
|
7
7
|
@customer = customer
|
8
|
-
@value = result.
|
9
|
-
@balance = result.
|
8
|
+
@value = result.hash[:envelope][:body][:get_customer_balance_response][:get_customer_balance_result][:value].to_f
|
9
|
+
@balance = result.hash[:envelope][:body][:get_customer_balance_response][:get_customer_balance_result][:balance].to_f
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -2,7 +2,7 @@ module KashflowApi
|
|
2
2
|
class Invoice < KashflowApi::SoapObject
|
3
3
|
def self.find(search)
|
4
4
|
result = KashflowApi.api.get_invoice(search)
|
5
|
-
self.build_from_soap(result.
|
5
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_invoice_response][:get_invoice_result])
|
6
6
|
end
|
7
7
|
|
8
8
|
def customer
|
@@ -3,7 +3,7 @@ module KashflowApi
|
|
3
3
|
def self.all
|
4
4
|
result = KashflowApi.api.get_nominal_codes
|
5
5
|
codes = []
|
6
|
-
result.
|
6
|
+
result.hash[:envelope][:body][:get_nominal_codes_response][:get_nominal_codes_result][:nominal_code].each do |code|
|
7
7
|
codes.push(self.build_from_soap(code))
|
8
8
|
end
|
9
9
|
codes
|
@@ -2,7 +2,7 @@ module KashflowApi
|
|
2
2
|
class Quote < KashflowApi::Invoice
|
3
3
|
def self.find_by_id(search)
|
4
4
|
result = KashflowApi.api.get_quote_by_id(search)
|
5
|
-
self.build_from_soap(result.
|
5
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_quote_by_id_response][:get_quote_by_id_result])
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -2,7 +2,7 @@ module KashflowApi
|
|
2
2
|
class Receipt < KashflowApi::SoapObject
|
3
3
|
def self.find(search)
|
4
4
|
result = KashflowApi.api.get_receipt(search)
|
5
|
-
self.build_from_soap(result.
|
5
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_receipt_response][:get_receipt_result])
|
6
6
|
end
|
7
7
|
|
8
8
|
def save
|
@@ -6,18 +6,18 @@ module KashflowApi
|
|
6
6
|
|
7
7
|
def self.find_by_supplier_code(search)
|
8
8
|
result = KashflowApi.api.get_supplier(search)
|
9
|
-
self.build_from_soap(result.
|
9
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_supplier_response][:get_supplier_result])
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.find_by_supplier_id(search)
|
13
13
|
result = KashflowApi.api.get_supplier_by_id(search)
|
14
|
-
self.build_from_soap(result.
|
14
|
+
self.build_from_soap(result.hash[:envelope][:body][:get_supplier_by_id_response][:get_supplier_by_id_result])
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.all
|
18
18
|
result = KashflowApi.api.get_suppliers
|
19
19
|
suppliers = []
|
20
|
-
result.
|
20
|
+
result.hash[:envelope][:body][:get_suppliers_response][:get_suppliers_result][:supplier].each do |supplier|
|
21
21
|
suppliers.push self.build_from_soap supplier
|
22
22
|
end
|
23
23
|
suppliers.sort { |x, y| x.name <=> y.name }
|
data/lib/kashflow_api/version.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
# Require the gem
|
3
|
-
require 'lib/kashflow_api'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe KashflowApi::Customer do
|
6
4
|
before :each do
|
@@ -23,7 +21,8 @@ describe KashflowApi::Customer do
|
|
23
21
|
end
|
24
22
|
|
25
23
|
it "should find a customer by kashflowid" do
|
26
|
-
KashflowApi::Customer.
|
24
|
+
id = KashflowApi::Customer.find(test_data("customer_code")).customer_id
|
25
|
+
KashflowApi::Customer.find_by_customer_id(id).should be_a KashflowApi::Customer
|
27
26
|
end
|
28
27
|
|
29
28
|
it "should find a customer by email" do
|
@@ -48,14 +47,21 @@ describe KashflowApi::Customer do
|
|
48
47
|
end
|
49
48
|
|
50
49
|
it "should update a customer" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
customer = KashflowApi::Customer.new
|
51
|
+
customer.code = "RSPEC"
|
52
|
+
customer.name = "Rspec Test School"
|
53
|
+
customer.save
|
54
|
+
search = KashflowApi::Customer.find("RSPEC")
|
55
|
+
search.name.should eq "Rspec Test School"
|
56
|
+
search.address1.should be_nil
|
57
|
+
search.address1 = "rspec"
|
58
|
+
search.save
|
59
|
+
search = KashflowApi::Customer.find("RSPEC")
|
60
|
+
search.name.should eq "Rspec Test School"
|
61
|
+
search.address1.should eq "rspec"
|
62
|
+
search = KashflowApi::Customer.find("RSPEC")
|
63
|
+
search.name.should eq "Rspec Test School"
|
64
|
+
search.destroy
|
59
65
|
end
|
60
66
|
|
61
67
|
it "should create a new customer and then destroy it" do
|
data/spec/kashflow_api_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
# Require the gem
|
3
|
-
require 'lib/kashflow_api'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe KashflowApi::Supplier do
|
6
4
|
before :each do
|
@@ -19,6 +17,7 @@ describe KashflowApi::Supplier do
|
|
19
17
|
end
|
20
18
|
|
21
19
|
it "should find a supplier by kashflowid" do
|
22
|
-
KashflowApi::Supplier.
|
20
|
+
id = KashflowApi::Supplier.find(test_data("supplier_code")).supplier_id
|
21
|
+
KashflowApi::Supplier.find_by_supplier_id(id).should be_a KashflowApi::Supplier
|
23
22
|
end
|
24
23
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kashflow_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam "Arcath" Laycock
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '0'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: savon
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - ~>
|
36
46
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
47
|
+
version: '2.3'
|
38
48
|
type: :runtime
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - ~>
|
44
53
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
54
|
+
version: '2.3'
|
46
55
|
description: Provides an interface for the Kashflow API
|
47
56
|
email:
|
48
57
|
- gems@arcath.net
|
@@ -78,29 +87,29 @@ files:
|
|
78
87
|
- spec/kashflow_api_spec.rb
|
79
88
|
- spec/kashflow_api_supplier_spec.rb
|
80
89
|
- spec/spec_helper.rb
|
81
|
-
|
90
|
+
- spec/test_data.example.yml
|
91
|
+
homepage: http://ed-itsolutions.github.io/KashflowAPI
|
82
92
|
licenses: []
|
93
|
+
metadata: {}
|
83
94
|
post_install_message:
|
84
95
|
rdoc_options: []
|
85
96
|
require_paths:
|
86
97
|
- lib
|
87
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
99
|
requirements:
|
90
|
-
- -
|
100
|
+
- - '>='
|
91
101
|
- !ruby/object:Gem::Version
|
92
102
|
version: '0'
|
93
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
104
|
requirements:
|
96
|
-
- -
|
105
|
+
- - '>='
|
97
106
|
- !ruby/object:Gem::Version
|
98
107
|
version: '0'
|
99
108
|
requirements: []
|
100
|
-
rubyforge_project:
|
101
|
-
rubygems_version:
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.0.0
|
102
111
|
signing_key:
|
103
|
-
specification_version:
|
112
|
+
specification_version: 4
|
104
113
|
summary: Provides an interface for the Kashflow API
|
105
114
|
test_files:
|
106
115
|
- spec/kashflow_api_customer_balance_spec.rb
|
@@ -111,4 +120,5 @@ test_files:
|
|
111
120
|
- spec/kashflow_api_spec.rb
|
112
121
|
- spec/kashflow_api_supplier_spec.rb
|
113
122
|
- spec/spec_helper.rb
|
123
|
+
- spec/test_data.example.yml
|
114
124
|
has_rdoc:
|