kashflow_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  spec/test_data.yml
6
+ coverage/*
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
- # Unimplemented Methods
21
+ # More Info
22
22
 
23
- Some of the methods in the Kashflow API have not been implemented in this gem (yet)
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
@@ -1,2 +1,9 @@
1
1
  require 'rubygems'
2
2
  require "bundler/gem_tasks"
3
+ require 'savon'
4
+
5
+ desc "List API Operations"
6
+ task :list_api_operations do
7
+ client = Savon.client(wsdl: "https://securedwebapp.com/api/service.asmx?WSDL")
8
+ puts client.operations
9
+ end
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", "0.9.2"
24
+ s.add_runtime_dependency "savon", "~> 2.3"
26
25
  end
@@ -23,7 +23,7 @@ module KashflowApi
23
23
  private
24
24
 
25
25
  def self.generate_method_list
26
- KashflowApi.client.client.wsdl.soap_actions
26
+ KashflowApi.client.client.operations
27
27
  end
28
28
  end
29
29
  end
@@ -1,8 +1,9 @@
1
1
  module KashflowApi
2
2
  class ApiCall
3
- attr_reader :result, :xml, :method
3
+ attr_reader :result, :xml, :method, :method_sym
4
4
 
5
5
  def initialize(method, argument)
6
+ @method_sym = method.to_sym
6
7
  set_method(method)
7
8
  build_xml(argument)
8
9
  raise xml if @raise
@@ -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::Client.new @url
6
+
7
+ @client = Savon.client(wsdl: @url, log: @config.loggers)
8
8
  end
9
9
 
10
10
  def call(api_call)
11
- result = @client.request("KashFlow/#{api_call.method}") do |soap|
12
- soap.xml = api_call.xml
13
- end
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"
@@ -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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomerResponse"]["GetCustomerResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomerByIDResponse"]["GetCustomerByIDResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomerByEmailResponse"]["GetCustomerByEmailResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomersByPostcodeResponse"]["GetCustomersByPostcode"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomersResponse"]["GetCustomersResult"]["Customer"].each do |customer|
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["CustomerID"] == "0"
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.customerid)
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 == "CustomerID"
57
- id_line = "<#{key}>#{@hash[key]}</#{key}>" unless @hash[key] == "0"
56
+ if key == :customer_id
57
+ id_line = "<CustomerID>#{@hash[key]}</CustomerID>" unless @hash[key] == "0"
58
58
  else
59
- xml.push("<#{key}>#{@hash[key]}</#{key}>")
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.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomerBalanceResponse"]["GetCustomerBalanceResult"]["Value"].to_f
9
- @balance = result.basic_hash["soap:Envelope"]["soap:Body"]["GetCustomerBalanceResponse"]["GetCustomerBalanceResult"]["Balance"].to_f
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.basic_hash["soap:Envelope"]["soap:Body"]["GetInvoiceResponse"]["GetInvoiceResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetNominalCodesResponse"]["GetNominalCodesResult"]["NominalCode"].each do |code|
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.basic_hash["soap:Envelope"]["soap:Body"]["GetQuoteByIDResponse"]["GetQuoteByIDResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetReceiptResponse"]["GetReceiptResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetSupplierResponse"]["GetSupplierResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetSupplierByIDResponse"]["GetSupplierByIDResult"])
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.basic_hash["soap:Envelope"]["soap:Body"]["GetSuppliersResponse"]["GetSuppliersResult"]["Supplier"].each do |supplier|
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 }
@@ -1,3 +1,3 @@
1
1
  module KashflowApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
2
- # Require the gem
3
- require 'lib/kashflow_api'
1
+ require 'spec_helper'
4
2
 
5
3
  describe KashflowApi::CustomerBalance do
6
4
  before :each do
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
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.find_by_customer_id(test_data("customer_id")).should be_a 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
- prechange = KashflowApi::Customer.find(test_data("customer_code"))
52
- change_back_to = prechange.address2
53
- prechange.address2 = "rspec_tests"
54
- prechange.save
55
- postchange = KashflowApi::Customer.find(test_data("customer_code"))
56
- postchange.address2.should eq "rspec_tests"
57
- postchange.address2 = change_back_to
58
- postchange.save
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
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
2
- # Require the gem
3
- require 'lib/kashflow_api'
1
+ require 'spec_helper'
4
2
 
5
3
  describe KashflowApi::CustomerBalance do
6
4
  before :each do
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
2
- # Require the gem
3
- require 'lib/kashflow_api'
1
+ require 'spec_helper'
4
2
 
5
3
  describe KashflowApi::Quote do
6
4
  before :each do
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
2
- # Require the gem
3
- require 'lib/kashflow_api'
1
+ require 'spec_helper'
4
2
 
5
3
  describe KashflowApi do
6
4
  it "should raise an exception if username and password are not present" do
@@ -1,6 +1,4 @@
1
- require 'spec/spec_helper'
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.find_by_supplier_id(test_data("supplier_id")).should be_a 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
@@ -1,5 +1,8 @@
1
- require 'yaml'
1
+ require 'simplecov'
2
+ SimpleCov.start
2
3
 
4
+ require 'yaml'
5
+ require './lib/kashflow_api'
3
6
 
4
7
  def default_config
5
8
  KashflowApi.configure do |c|
@@ -0,0 +1,7 @@
1
+ username: foo
2
+ password: bar
3
+ customer_code: CUST01
4
+ customer_postcode: "FO0 84R"
5
+ customer_name: "Test Customer"
6
+ customer_email: api@testing.com
7
+ supplier_code: SUP01
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.2
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: 2012-10-08 00:00:00.000000000 Z
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: 0.9.2
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: 0.9.2
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
- homepage: ''
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: kashflow_api
101
- rubygems_version: 1.8.23
109
+ rubyforge_project:
110
+ rubygems_version: 2.0.0
102
111
  signing_key:
103
- specification_version: 3
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: