Sha256: 693013bf713ee9d75cd62aef47493e92a0cf991a4ee516192660a2d82be7634c
Contents?: true
Size: 982 Bytes
Versions: 1
Compression:
Stored size: 982 Bytes
Contents
# frozen_string_literal: true require 'go_puff/tax_service/response/base' module GoPuff module TaxService module Response class Get < Base attr_reader :products_taxes def initialize(*args) super parse_attributes! end def tax_for_product(product_id) @products_taxes[product_id] || @products_taxes[product_id.to_s] end %w[totalTaxCollected taxToAddToTotal taxBreakdown].each do |attribute| define_method(attribute.underscore.to_sym) { data[attribute.to_sym] } end private def parse_attributes! parse_products_taxes! end def parse_products_taxes! return unless data.try(:[], :products).is_a?(Array) @products_taxes = data[:products].each_with_object({}) do |product, products_hash| products_hash[product[:productId]] = product[:taxAmount] end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
go_puff-tax_service-1.5.0 | lib/go_puff/tax_service/response/get.rb |