taxamo 1.0.6.1 → 1.1.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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/lib/taxamo.rb +52 -10
  4. data/lib/taxamo/models/calculatesimpletaxout.rb +14 -2
  5. data/lib/taxamo/models/calculatetaxout.rb +14 -2
  6. data/lib/taxamo/models/confirmtransactionout.rb +14 -2
  7. data/lib/taxamo/models/country.rb +6 -1
  8. data/lib/taxamo/models/countryschema.rb +6 -1
  9. data/lib/taxamo/models/createtransactionout.rb +14 -2
  10. data/lib/taxamo/models/gettransactionout.rb +14 -2
  11. data/lib/taxamo/models/gettransactionsstatsbycountryout.rb +63 -0
  12. data/lib/taxamo/models/inputtransaction.rb +16 -1
  13. data/lib/taxamo/models/inputtransactionline.rb +6 -1
  14. data/lib/taxamo/models/inputtransactionupdate.rb +16 -1
  15. data/lib/taxamo/models/report.rb +28 -18
  16. data/lib/taxamo/models/storagerequiredfields.rb +62 -0
  17. data/lib/taxamo/models/summary.rb +11 -1
  18. data/lib/taxamo/models/taxdataschema.rb +62 -0
  19. data/lib/taxamo/models/taxrequiredfields.rb +62 -0
  20. data/lib/taxamo/models/transaction.rb +26 -1
  21. data/lib/taxamo/models/transactionlines.rb +6 -1
  22. data/lib/taxamo/models/transactions.rb +26 -1
  23. data/lib/taxamo/models/unconfirmtransactionout.rb +14 -2
  24. data/lib/taxamo/models/updatetransactionout.rb +14 -2
  25. data/lib/taxamo/models/ustaxexemptioncertificatedetailsschema.rb +138 -0
  26. data/lib/taxamo/models/ustaxexemptioncertificateschema.rb +67 -0
  27. data/lib/taxamo/models/ustaxexemptstate.rb +72 -0
  28. data/lib/taxamo/models/ustaxid.rb +72 -0
  29. data/lib/taxamo/version.rb +1 -1
  30. data/test/taxamo/tax_test.rb +14 -9
  31. data/test/taxamo/transactions_api_test.rb +37 -28
  32. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 218bdad1cb905732df5d17540353c2fd90fb5650
4
- data.tar.gz: bd01d12b8d931e5aa5a2364b46f11cf47fe6db8f
3
+ metadata.gz: fe35612dfa3bac00d6fde32a48b8e93e6c669a54
4
+ data.tar.gz: 97623bf070b917bda21e2caae333da045d78af1b
5
5
  SHA512:
6
- metadata.gz: a216f6396b08c907694795e9f8197b3a9cd44e0df36cc46d3cfed75d12a350dc8ef75f90713317de485c84cf919ba625c14069b4d4ad75bdafd922577a78823e
7
- data.tar.gz: c22232d06dd18bfd8e0a92827d459e15057449521f4ad987dc720dd6563a9fa1bf01a8dd09a98afb709d0facc10d8200d2e47d5fa3aed73c1437d6b7343ca576
6
+ metadata.gz: f22017ce6cbba4c20cd3e72b652bd20c1991cf1cca1cf4ff29eca710db8ecc673cd7add2c4f3fd989c7178b8ad6bb270519f8edceed2cc87e1ca284e87ed2f4c
7
+ data.tar.gz: 636fcaee290a0c636578310f6387b4298d1445571c77c37228232dfdc5194f2c0399b09200ee95bc29b0a503b5b6663b53d264a5bac534e21d1668266b8e05e1
data/README.md CHANGED
@@ -19,6 +19,10 @@ gem "taxamo", github: "taxamo/taxamo-ruby"
19
19
 
20
20
  ## Changes
21
21
 
22
+ 1.1.0 (2015-10-13):
23
+ * update API client with multiple region support. Please note that the following methods have their arity changed:
24
+ `list_transactions`, `calculate_simple_tax`, `get_refunds`, `get_settlement`, `get_settlement_summary`
25
+
22
26
  1.0.6.1 (2015-07-20):
23
27
  * fix for rubygems.org publishing issue
24
28
 
data/lib/taxamo.rb CHANGED
@@ -451,8 +451,8 @@ module Taxamo
451
451
 
452
452
  end
453
453
 
454
- def list_transactions (statuses,sort_reverse,tax_country_code,order_date_from,key_or_custom_id,offset,filter_text,format,invoice_number,order_date_to,currency_code,limit,opts={})
455
- query_param_keys = [:statuses,:sort_reverse,:tax_country_code,:order_date_from,:key_or_custom_id,:offset,:filter_text,:format,:invoice_number,:order_date_to,:currency_code,:limit]
454
+ def list_transactions (filter_text,offset,key_or_custom_id,currency_code,order_date_to,sort_reverse,limit,invoice_number,statuses,order_date_from,total_amount_greater_than,format,total_amount_less_than,tax_country_code,opts={})
455
+ query_param_keys = [:filter_text,:offset,:key_or_custom_id,:currency_code,:order_date_to,:sort_reverse,:limit,:invoice_number,:statuses,:order_date_from,:total_amount_greater_than,:format,:total_amount_less_than,:tax_country_code]
456
456
 
457
457
  # set default values and merge with input
458
458
  options = {
@@ -466,7 +466,9 @@ module Taxamo
466
466
  :invoice_number => invoice_number,
467
467
  :statuses => statuses,
468
468
  :order_date_from => order_date_from,
469
+ :total_amount_greater_than => total_amount_greater_than,
469
470
  :format => format,
471
+ :total_amount_less_than => total_amount_less_than,
470
472
  :tax_country_code => tax_country_code}.merge(opts)
471
473
 
472
474
  #resource path
@@ -530,16 +532,18 @@ module Taxamo
530
532
 
531
533
  end
532
534
 
533
- def calculate_simple_tax (buyer_credit_card_prefix,buyer_tax_number,product_type,force_country_code,quantity,unit_price,total_amount,tax_deducted,amount,billing_country_code,currency_code,order_date,opts={})
534
- query_param_keys = [:buyer_credit_card_prefix,:buyer_tax_number,:product_type,:force_country_code,:quantity,:unit_price,:total_amount,:tax_deducted,:amount,:billing_country_code,:currency_code,:order_date]
535
+ def calculate_simple_tax (product_type,invoice_address_city,buyer_credit_card_prefix,currency_code,invoice_address_region,unit_price,quantity,buyer_tax_number,force_country_code,order_date,amount,billing_country_code,invoice_address_postal_code,total_amount,tax_deducted,opts={})
536
+ query_param_keys = [:product_type,:invoice_address_city,:buyer_credit_card_prefix,:currency_code,:invoice_address_region,:unit_price,:quantity,:buyer_tax_number,:force_country_code,:order_date,:amount,:billing_country_code,:invoice_address_postal_code,:total_amount,:tax_deducted]
535
537
 
536
538
  # verify existence of params
537
539
  raise "currency_code is required" if currency_code.nil?
538
540
  # set default values and merge with input
539
541
  options = {
540
542
  :product_type => product_type,
543
+ :invoice_address_city => invoice_address_city,
541
544
  :buyer_credit_card_prefix => buyer_credit_card_prefix,
542
545
  :currency_code => currency_code,
546
+ :invoice_address_region => invoice_address_region,
543
547
  :unit_price => unit_price,
544
548
  :quantity => quantity,
545
549
  :buyer_tax_number => buyer_tax_number,
@@ -547,6 +551,7 @@ module Taxamo
547
551
  :order_date => order_date,
548
552
  :amount => amount,
549
553
  :billing_country_code => billing_country_code,
554
+ :invoice_address_postal_code => invoice_address_postal_code,
550
555
  :total_amount => total_amount,
551
556
  :tax_deducted => tax_deducted}.merge(opts)
552
557
 
@@ -664,6 +669,34 @@ module Taxamo
664
669
 
665
670
  end
666
671
 
672
+ def get_transactions_stats_by_country (global_currency_code,date_from,date_to,opts={})
673
+ query_param_keys = [:global_currency_code,:date_from,:date_to]
674
+
675
+ # verify existence of params
676
+ raise "date_from is required" if date_from.nil?
677
+ raise "date_to is required" if date_to.nil?
678
+ # set default values and merge with input
679
+ options = {
680
+ :global_currency_code => global_currency_code,
681
+ :date_from => date_from,
682
+ :date_to => date_to}.merge(opts)
683
+
684
+ #resource path
685
+ path = "/api/v1/stats/transactions/by_country".sub('{format}','json')
686
+
687
+
688
+ # pull querystring keys from options
689
+ queryopts = options.select do |key,value|
690
+ query_param_keys.include? key
691
+ end
692
+
693
+ headers = nil
694
+ post_body = nil
695
+ response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
696
+ GetTransactionsStatsByCountryOut.new(response)
697
+
698
+ end
699
+
667
700
  def get_transactions_stats (date_from,date_to,interval,opts={})
668
701
  query_param_keys = [:date_from,:date_to,:interval]
669
702
 
@@ -775,8 +808,8 @@ module Taxamo
775
808
 
776
809
  end
777
810
 
778
- def get_refunds (format,moss_country_code,date_from,opts={})
779
- query_param_keys = [:format,:moss_country_code,:date_from]
811
+ def get_refunds (format,moss_country_code,tax_region,date_from,opts={})
812
+ query_param_keys = [:format,:moss_country_code,:tax_region,:date_from]
780
813
 
781
814
  # verify existence of params
782
815
  raise "date_from is required" if date_from.nil?
@@ -784,6 +817,7 @@ module Taxamo
784
817
  options = {
785
818
  :format => format,
786
819
  :moss_country_code => moss_country_code,
820
+ :tax_region => tax_region,
787
821
  :date_from => date_from}.merge(opts)
788
822
 
789
823
  #resource path
@@ -802,8 +836,8 @@ module Taxamo
802
836
 
803
837
  end
804
838
 
805
- def get_settlement (format,moss_country_code,moss_tax_id,quarter,opts={})
806
- query_param_keys = [:format,:moss_country_code,:moss_tax_id]
839
+ def get_settlement (format,moss_country_code,tax_country_code,currency_code,moss_tax_id,tax_id,start_month,end_month,quarter,opts={})
840
+ query_param_keys = [:format,:moss_country_code,:tax_country_code,:currency_code,:moss_tax_id,:tax_id,:start_month,:end_month]
807
841
 
808
842
  # verify existence of params
809
843
  raise "quarter is required" if quarter.nil?
@@ -811,7 +845,12 @@ module Taxamo
811
845
  options = {
812
846
  :format => format,
813
847
  :moss_country_code => moss_country_code,
848
+ :tax_country_code => tax_country_code,
849
+ :currency_code => currency_code,
814
850
  :moss_tax_id => moss_tax_id,
851
+ :tax_id => tax_id,
852
+ :start_month => start_month,
853
+ :end_month => end_month,
815
854
  :quarter => quarter}.merge(opts)
816
855
 
817
856
  #resource path
@@ -830,14 +869,17 @@ module Taxamo
830
869
 
831
870
  end
832
871
 
833
- def get_settlement_summary (moss_country_code,quarter,opts={})
834
- query_param_keys = [:moss_country_code]
872
+ def get_settlement_summary (moss_country_code,tax_region,start_month,end_month,quarter,opts={})
873
+ query_param_keys = [:moss_country_code,:tax_region,:start_month,:end_month]
835
874
 
836
875
  # verify existence of params
837
876
  raise "quarter is required" if quarter.nil?
838
877
  # set default values and merge with input
839
878
  options = {
840
879
  :moss_country_code => moss_country_code,
880
+ :tax_region => tax_region,
881
+ :start_month => start_month,
882
+ :end_month => end_month,
841
883
  :quarter => quarter}.merge(opts)
842
884
 
843
885
  #resource path
@@ -11,12 +11,14 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class CalculateSimpleTaxOut
14
- attr_accessor :transaction
14
+ attr_accessor :transaction, :tax_required_fields, :storage_required_fields
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
18
18
  {
19
- :transaction => :transaction
19
+ :transaction => :transaction,
20
+ :tax_required_fields => :tax_required_fields,
21
+ :storage_required_fields => :storage_required_fields
20
22
 
21
23
  }
22
24
  end
@@ -28,6 +30,16 @@ class CalculateSimpleTaxOut
28
30
  @transaction = Transaction.new(attributes["transaction"])
29
31
 
30
32
  end
33
+ if attributes["tax_required_fields"]
34
+ if (value = attributes["tax_required_fields"]).is_a?(Array)
35
+ @tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
36
+ end
37
+ end
38
+ if attributes["storage_required_fields"]
39
+ if (value = attributes["storage_required_fields"]).is_a?(Array)
40
+ @storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
41
+ end
42
+ end
31
43
 
32
44
 
33
45
  end
@@ -11,12 +11,14 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class CalculateTaxOut
14
- attr_accessor :transaction
14
+ attr_accessor :transaction, :tax_required_fields, :storage_required_fields
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
18
18
  {
19
- :transaction => :transaction
19
+ :transaction => :transaction,
20
+ :tax_required_fields => :tax_required_fields,
21
+ :storage_required_fields => :storage_required_fields
20
22
 
21
23
  }
22
24
  end
@@ -28,6 +30,16 @@ class CalculateTaxOut
28
30
  @transaction = Transaction.new(attributes["transaction"])
29
31
 
30
32
  end
33
+ if attributes["tax_required_fields"]
34
+ if (value = attributes["tax_required_fields"]).is_a?(Array)
35
+ @tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
36
+ end
37
+ end
38
+ if attributes["storage_required_fields"]
39
+ if (value = attributes["storage_required_fields"]).is_a?(Array)
40
+ @storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
41
+ end
42
+ end
31
43
 
32
44
 
33
45
  end
@@ -11,12 +11,14 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class ConfirmTransactionOut
14
- attr_accessor :transaction
14
+ attr_accessor :transaction, :tax_required_fields, :storage_required_fields
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
18
18
  {
19
- :transaction => :transaction
19
+ :transaction => :transaction,
20
+ :tax_required_fields => :tax_required_fields,
21
+ :storage_required_fields => :storage_required_fields
20
22
 
21
23
  }
22
24
  end
@@ -28,6 +30,16 @@ class ConfirmTransactionOut
28
30
  @transaction = Transaction.new(attributes["transaction"])
29
31
 
30
32
  end
33
+ if attributes["tax_required_fields"]
34
+ if (value = attributes["tax_required_fields"]).is_a?(Array)
35
+ @tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
36
+ end
37
+ end
38
+ if attributes["storage_required_fields"]
39
+ if (value = attributes["storage_required_fields"]).is_a?(Array)
40
+ @storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
41
+ end
42
+ end
31
43
 
32
44
 
33
45
  end
@@ -11,7 +11,7 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class Country
14
- attr_accessor :code_long, :codenum, :currency, :tax_supported, :name, :ccn3, :cca3, :calling_code, :tax_number_country_code, :code, :cca2
14
+ attr_accessor :code_long, :codenum, :currency, :tax_supported, :name, :ccn3, :tax_region, :cca3, :calling_code, :tax_number_country_code, :code, :cca2
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
@@ -22,6 +22,7 @@ class Country
22
22
  :tax_supported => :tax_supported,
23
23
  :name => :name,
24
24
  :ccn3 => :ccn3,
25
+ :tax_region => :tax_region,
25
26
  :cca3 => :cca3,
26
27
  :calling_code => :callingCode,
27
28
  :tax_number_country_code => :tax_number_country_code,
@@ -58,6 +59,10 @@ class Country
58
59
  if attributes["ccn3"]
59
60
  @ccn3 = attributes["ccn3"]
60
61
 
62
+ end
63
+ if attributes["tax_region"]
64
+ @tax_region = attributes["tax_region"]
65
+
61
66
  end
62
67
  if attributes["cca3"]
63
68
  @cca3 = attributes["cca3"]
@@ -11,7 +11,7 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class CountrySchema
14
- attr_accessor :code_long, :codenum, :currency, :tax_supported, :name, :ccn3, :cca3, :calling_code, :tax_number_country_code, :code, :cca2
14
+ attr_accessor :code_long, :codenum, :currency, :tax_supported, :name, :ccn3, :tax_region, :cca3, :calling_code, :tax_number_country_code, :code, :cca2
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
@@ -22,6 +22,7 @@ class CountrySchema
22
22
  :tax_supported => :tax_supported,
23
23
  :name => :name,
24
24
  :ccn3 => :ccn3,
25
+ :tax_region => :tax_region,
25
26
  :cca3 => :cca3,
26
27
  :calling_code => :callingCode,
27
28
  :tax_number_country_code => :tax_number_country_code,
@@ -58,6 +59,10 @@ class CountrySchema
58
59
  if attributes["ccn3"]
59
60
  @ccn3 = attributes["ccn3"]
60
61
 
62
+ end
63
+ if attributes["tax_region"]
64
+ @tax_region = attributes["tax_region"]
65
+
61
66
  end
62
67
  if attributes["cca3"]
63
68
  @cca3 = attributes["cca3"]
@@ -11,12 +11,14 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class CreateTransactionOut
14
- attr_accessor :transaction
14
+ attr_accessor :transaction, :tax_required_fields, :storage_required_fields
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
18
18
  {
19
- :transaction => :transaction
19
+ :transaction => :transaction,
20
+ :tax_required_fields => :tax_required_fields,
21
+ :storage_required_fields => :storage_required_fields
20
22
 
21
23
  }
22
24
  end
@@ -28,6 +30,16 @@ class CreateTransactionOut
28
30
  @transaction = Transaction.new(attributes["transaction"])
29
31
 
30
32
  end
33
+ if attributes["tax_required_fields"]
34
+ if (value = attributes["tax_required_fields"]).is_a?(Array)
35
+ @tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
36
+ end
37
+ end
38
+ if attributes["storage_required_fields"]
39
+ if (value = attributes["storage_required_fields"]).is_a?(Array)
40
+ @storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
41
+ end
42
+ end
31
43
 
32
44
 
33
45
  end
@@ -11,12 +11,14 @@
11
11
  # limitations under the License.
12
12
 
13
13
  class GetTransactionOut
14
- attr_accessor :transaction
14
+ attr_accessor :transaction, :tax_required_fields, :storage_required_fields
15
15
 
16
16
  # :internal => :external
17
17
  def self.attribute_map
18
18
  {
19
- :transaction => :transaction
19
+ :transaction => :transaction,
20
+ :tax_required_fields => :tax_required_fields,
21
+ :storage_required_fields => :storage_required_fields
20
22
 
21
23
  }
22
24
  end
@@ -28,6 +30,16 @@ class GetTransactionOut
28
30
  @transaction = Transaction.new(attributes["transaction"])
29
31
 
30
32
  end
33
+ if attributes["tax_required_fields"]
34
+ if (value = attributes["tax_required_fields"]).is_a?(Array)
35
+ @tax_required_fields = value.map{ |v| TaxRequiredFields.new(v) }
36
+ end
37
+ end
38
+ if attributes["storage_required_fields"]
39
+ if (value = attributes["storage_required_fields"]).is_a?(Array)
40
+ @storage_required_fields = value.map{ |v| StorageRequiredFields.new(v) }
41
+ end
42
+ end
31
43
 
32
44
 
33
45
  end
@@ -0,0 +1,63 @@
1
+ # Copyright 2014-2015 Taxamo, Ltd.
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ class GetTransactionsStatsByCountryOut
14
+ attr_accessor :by_country
15
+
16
+ # :internal => :external
17
+ def self.attribute_map
18
+ {
19
+ :by_country => :by_country
20
+
21
+ }
22
+ end
23
+
24
+ def initialize(attributes = {})
25
+ return if attributes.empty?
26
+ # Morph attribute keys into undescored rubyish style
27
+ if attributes["by_country"]
28
+ if (value = attributes["by_country"]).is_a?(Array)
29
+ @by_country = value.map{ |v| ByCountry.new(v) }
30
+ end
31
+ end
32
+
33
+
34
+ end
35
+
36
+ def to_body
37
+ body = {}
38
+ self.class.attribute_map.each_pair do |key, value|
39
+ v = self.send(key)
40
+ unless v.nil?
41
+ if v.is_a?(Array)
42
+ array = Array.new
43
+ v.each do |item|
44
+ if item.respond_to?("to_body".to_sym)
45
+ array.push item.to_body
46
+ else
47
+ array.push item
48
+ end
49
+ end
50
+ body[value] = array
51
+ else
52
+ if v.respond_to?("to_body".to_sym)
53
+ body[value] = v.to_body
54
+ else
55
+ body[value] = v
56
+ end
57
+ end
58
+ end
59
+ end
60
+ body
61
+ end
62
+ end
63
+