vertex_client 0.6.2 → 0.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82c674e8ad961329ee8e150e93f1125a734dfece4f8a3e7bf0486c9bf9d03af5
4
- data.tar.gz: 58e3660e3770a41fd5a45c72ad797c3160745da6109f6ef37731b574ff441e26
3
+ metadata.gz: b2bc8e8c69324495ed95b5e9fd9ff02f2a6cc3ac959a799fe03abf2617f8aab2
4
+ data.tar.gz: 0c246581ec77e3743b2ba05a2957dc6dbbdcb765c6c6883df13268b8a3772138
5
5
  SHA512:
6
- metadata.gz: dc170bf34f37a52629163e9e573a89a2ee318b6091a0f88690ef6e5f74319cdd3220edc6acc5f70f5dcf776b0c4ba450d0af138c44ed2becfed445d52f420405
7
- data.tar.gz: 21efd5e2acb6f453d1e34f75de7b56879bb0bf1947be34f853e72a0847a21ffd85df6f8b7b4cadc07bd75d1a23726c9f01971c71a7e7c1a7cfc25651f82f5fe4
6
+ metadata.gz: 4bdf87b6784d5a0dc968bfedba89f532e55be49ff46a58816bbe3687b36af68af67a751f86c27a479d7815a23cc23c49f9e45a532fd9bb918f837ac1faf25b86
7
+ data.tar.gz: c86f016775c33bdb129827452ba71fb50d8dd63dd59920cee1966c71456fc8538b2d6fb29c8f849f0010560f8ab8998c8654436c679b59493a21998d677af266
data/bin/console CHANGED
@@ -3,6 +3,8 @@
3
3
  require "bundler/setup"
4
4
  require "dotenv/load"
5
5
  require "vertex_client"
6
+ require 'byebug'
7
+ require 'awesome_print'
6
8
 
7
9
  # You can add fixtures and/or initialization code here to make experimenting
8
10
  # with your gem easier. You can also use a different console, if you like.
@@ -1,5 +1,5 @@
1
1
  # Uncomment the next line if you want to use circuitbox with VertexClient.
2
- # require "circuitbox"
2
+ # require 'circuitbox'
3
3
  VertexClient.configure do |config|
4
4
  config.trusted_id = ENV.fetch('VERTEX_TRUSTED_ID')
5
5
  config.soap_api = ENV.fetch('VERTEX_SOAP_API')
data/lib/vertex_client.rb CHANGED
@@ -35,6 +35,7 @@ module VertexClient
35
35
  autoload :DistributeTax, 'vertex_client/responses/distribute_tax'
36
36
  autoload :Invoice, 'vertex_client/responses/invoice'
37
37
  autoload :LineItem, 'vertex_client/responses/line_item'
38
+ autoload :LineItemProduct, 'vertex_client/responses/line_item_product'
38
39
  autoload :Quotation, 'vertex_client/responses/quotation'
39
40
  autoload :QuotationFallback, 'vertex_client/responses/quotation_fallback'
40
41
  autoload :TaxArea, 'vertex_client/responses/tax_area'
@@ -1,7 +1,7 @@
1
1
  module VertexClient
2
2
  class Connection
3
3
 
4
- VERTEX_NAMESPACE = "urn:vertexinc:o-series:tps:7:0".freeze
4
+ VERTEX_NAMESPACE = 'urn:vertexinc:o-series:tps:7:0'.freeze
5
5
  ERROR_MESSAGE = 'The Vertex API returned an error or is unavailable'.freeze
6
6
 
7
7
  def initialize(endpoint)
@@ -0,0 +1,13 @@
1
+ module VertexClient
2
+ module Response
3
+ class LineItemProduct
4
+
5
+ attr_reader :product_code, :product_class
6
+
7
+ def initialize(params)
8
+ @product_code = params[:product_code]
9
+ @product_class = params[:product_class]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -17,7 +17,7 @@ module VertexClient
17
17
  def line_items
18
18
  @line_items ||= @body[:line_item].flatten.map do |line_item|
19
19
  LineItem.new(
20
- product: product_for_line_item(line_item),
20
+ product: product_for_line_item(line_item[:product]),
21
21
  quantity: line_item[:quantity],
22
22
  price: line_item[:extended_price],
23
23
  total_tax: tax_for_line_item(line_item)
@@ -27,12 +27,22 @@ module VertexClient
27
27
 
28
28
  private
29
29
 
30
- def tax_for_line_item(line_item)
31
- line_item[:total_tax]
30
+ def product_for_line_item(product)
31
+ if(product).is_a?(Nori::StringWithAttributes)
32
+ LineItemProduct.new(
33
+ product_code: product.to_s,
34
+ product_class: product.attributes['productClass'],
35
+ )
36
+ else
37
+ LineItemProduct.new(
38
+ product_code: product['@product_code'],
39
+ product_class: product['@product_class'],
40
+ )
41
+ end
32
42
  end
33
43
 
34
- def product_for_line_item(line_item)
35
- line_item[:product]
44
+ def tax_for_line_item(line_item)
45
+ line_item[:total_tax]
36
46
  end
37
47
  end
38
48
  end
@@ -20,11 +20,18 @@ module VertexClient
20
20
 
21
21
  private
22
22
 
23
+ def product_for_line_item(product)
24
+ LineItemProduct.new(
25
+ product_code: product[:content!],
26
+ product_class: product[:@productClass],
27
+ )
28
+ end
29
+
23
30
  def tax_amount(price, state)
24
31
  if RATES.has_key?(state)
25
32
  price * BigDecimal.new(RATES[state])
26
33
  else
27
- BigDecimal.new("0.0")
34
+ BigDecimal.new('0.0')
28
35
  end
29
36
  end
30
37
 
@@ -33,10 +40,6 @@ module VertexClient
33
40
  state = line_item[:customer][:destination][:main_division]
34
41
  tax_amount(price, state)
35
42
  end
36
-
37
- def product_for_line_item(line_item)
38
- line_item[:product][:content!]
39
- end
40
43
  end
41
44
  end
42
45
  end
@@ -1,3 +1,3 @@
1
1
  module VertexClient
2
- VERSION = "0.6.2"
2
+ VERSION = '0.6.4'
3
3
  end
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.add_dependency "activesupport"
40
40
  spec.add_dependency "savon", ">= 2.11"
41
+ spec.add_development_dependency "awesome_print"
41
42
  spec.add_development_dependency "circuitbox"
42
43
  spec.add_development_dependency "bundler"
43
44
  spec.add_development_dependency "byebug"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vertex_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Custom Ink
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: circuitbox
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -250,6 +264,7 @@ files:
250
264
  - lib/vertex_client/responses/distribute_tax.rb
251
265
  - lib/vertex_client/responses/invoice.rb
252
266
  - lib/vertex_client/responses/line_item.rb
267
+ - lib/vertex_client/responses/line_item_product.rb
253
268
  - lib/vertex_client/responses/quotation.rb
254
269
  - lib/vertex_client/responses/quotation_fallback.rb
255
270
  - lib/vertex_client/responses/tax_area.rb