Sha256: 1db56283e44022a978ea40df50184a456fffd4e8d3932b66cdbfa951af9b4ee6
Contents?: true
Size: 940 Bytes
Versions: 1
Compression:
Stored size: 940 Bytes
Contents
module Correios module SRO class Tracker attr_accessor :user, :password attr_accessor :query_type, :result_mode attr_reader :object_numbers DEFAULT_OPTIONS = { query_type: :list, result_mode: :last }.freeze def initialize(options = {}) DEFAULT_OPTIONS.merge(options).each do |attr, value| self.send("#{attr}=", value) end yield self if block_given? @object_numbers = [] end def get(*object_numbers) @object_numbers = object_numbers response = web_service.request! objects = parser.objects(response) if @object_numbers.size == 1 objects.values.first else objects end end private def web_service @web_service ||= Correios::SRO::WebService.new(self) end def parser @parser ||= Correios::SRO::Parser.new end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
correios-sro-xml-0.2.0 | lib/correios/sro/tracker.rb |