{': rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:$YARD::CodeObjects::ModuleObject;IC;[ o:#YARD::CodeObjects::ClassObject;IC;[ o:$YARD::CodeObjects::MethodObject: @scope: instance:@visibility: public: @pathI"&Trackerific::UPS#required_options:EF:@parameters[: @files[[I"lib/ups.rb;Ti:@current_file_has_commentsT: @name:required_options:@source_type: ruby: @tags[:@docstringIC:YARD::Docstring"WThe required options for tracking a UPS package are :key, :user_id, and :password. ;F: @object@ : @summary0:@hash_flagF:@ref_tags[;[o:YARD::Tags::Tag :@tag_nameI" return;F: @textI"5the required options for tracking a UPS package.;F;0: @types[I" Array;F;@ : @allI"The required options for tracking a UPS package are :key, :user_id, and :password. @return [Array] the required options for tracking a UPS package.;F:@line_rangeo: Range: exclF: begini:endi:@namespace@ : @sourceI";def required_options [:key, :user_id, :password] end;F:@signatureI"def required_options( );F:@explicitT:@docstring_extra0: @dynamicTo; ; ; ;;;I"#Trackerific::UPS#track_package;F;[["package_id0;[[@i;T;:track_package;;;[;IC;"[Tracks a UPS package. A Trackerific::Error is raised when a package cannot be tracked. ;F;@;0;F;[;[o; ;!I" return;F;"I"the tracking details;F;0;#[I"Trackerific::Details;F;@;$I"Tracks a UPS package. A Trackerific::Error is raised when a package cannot be tracked. @return [Trackerific::Details] the tracking details;F;%o;&;'F;(i;)i;*@ ;+I"def track_package(package_id) super # connect to UPS via HTTParty http_response = self.class.post('/Track', :body => build_xml_request) # throw any HTTP errors http_response.error! unless http_response.code == 200 # Check the response for errors, return a Trackerific::Error, or parse # the response from UPS and return a Trackerific::Details case http_response['TrackResponse']['Response']['ResponseStatusCode'] when "0" then raise Trackerific::Error, parse_error_response(http_response) when "1" then return parse_success_response(http_response) else raise Trackerific::Error, "Invalid response code returned from server." end end;F;,I""def track_package(package_id);F;-T;.0;/To; ; ; ;:protected;I",Trackerific::UPS#parse_success_response;F;[["http_response0;[[@i2;T;:parse_success_response;;;[;IC;"!Parses the response from UPS ;F;@3;0;F;[;[o; ;!I" return;F;"I";F;0;#[I"Trackerific::Details;F;@3;$I"@Parses the response from UPS @return [Trackerific::Details];F;%o;&;'F;(i0;)i1;*@ ;+I"def parse_success_response(http_response) # get the activity from the UPS response activity = http_response['TrackResponse']['Shipment']['Package']['Activity'] # if there's only one activity in the list, we need to put it in an array activity = [activity] if activity.is_a? Hash # UPS does not provide a summary, so we'll just use the last tracking status summary = activity.first['Status']['StatusType']['Description'].titleize details = [] activity.each do |a| # the time format from UPS is HHMMSS, which cannot be directly converted # to a Ruby time. hours = a['Time'][0..1] minutes = a['Time'][2..3] seconds = a['Time'][4..5] date = Date.parse(a['Date']) date = DateTime.parse("#{date} #{hours}:#{minutes}:#{seconds}") desc = a['Status']['StatusType']['Description'].titleize loc = a['ActivityLocation']['Address'].map {|k,v| v}.join(" ") details << Trackerific::Event.new(date, desc, loc) end Trackerific::Details.new( @package_id, summary, details ) end;F;,I".def parse_success_response(http_response);F;-T;.0;/To; ; ; ;;1;I"*Trackerific::UPS#parse_error_response;F;[["http_response0;[[@iP;T;:parse_error_response;;;[;IC;" xml) builder.AccessRequest do |ar| ar.AccessLicenseNumber @options[:key] ar.UserId @options[:user_id] ar.Password @options[:password] end builder.TrackRequest do |tr| tr.Request do |r| r.RequestAction 'Track' end tr.TrackingNumber @package_id end return xml end;F;,I"def build_xml_request( );F;-T;.0;/T: @owner@ :@class_mixinsIC;[;5@ :@instance_mixinsIC;[o:YARD::CodeObjects::Proxy : @imethod0:@origname0:@orignamespace0;: HTTParty;*@: @obj0;5@ :@attributesIC:SymbolHash{: classIC;?{:@symbolize_valueT; IC;?{;AT;AT: @aliases{: @groups[;[[@i ;T;:UPS;;;;;[;IC;"/Provides package tracking support for UPS. ;F;@ ;0;F;[;[;$I"/Provides package tracking support for UPS.;F;%o;&;'F;(i ;)i ;*@;I"Trackerific::UPS;F:@superclasso;8 ;90;:0;;0;: Base;*@;=o; ;IC;[o; ; ; ;;;I"!Trackerific::Base#initialize;F;[[" options"{};[[I"lib/trackerific.rb;Ti;F;:initialize;;;[;IC;" ;F;@|;0;F;[;[o; ;!I" return;F;"I"a new instance of Base;F;0;#[I" Base;F;@|;$I";F;*@;+I"=def initialize(options = {}) required = required_options required.each do |k| raise ArgumentError.new("Missing required parameter: #{k}") unless options.has_key?(k) end options.each do |k, v| raise ArgumentError.new("Invalid parameter: #{k}") unless required.include?(k) end @options = options end;F;,I"!def initialize(options = {});F;-T;/To; ; ; ;;;I"'Trackerific::Base#required_options;F;[;[[@i;T;;;;;[;IC;"@Override this method if your subclass has required options. ;F;@;0;F;[;[o; ;!I" return;F;"I"the required options;F;0;#[I" Array;F;@;$I"eOverride this method if your subclass has required options. @return [Array] the required options;F;%o;&;'F;(i;)i;*@;+I""def required_options [] end;F;,I"def required_options( );F;-T;.0;/To; ; ; ;;;I"$Trackerific::Base#track_package;F;[["package_id0;[[@i$;T;;0;;;[;IC;"KOverride this method in your subclass to implement tracking a package. ;F;@;0;F;[;[o; ;!I" return;F;"I"the tracking details;F;0;#[I" Hash;F;@;$I"oOverride this method in your subclass to implement tracking a package. @return [Hash] the tracking details;F;%o;&;'F;(i";)i#;*@;+I"Adef track_package(package_id) @package_id = package_id end;F;,I""def track_package(package_id);F;-T;.0;/T;5@;6IC;[;5@;7IC;[;5@;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@i;T;;F;;;;;[;IC;"2Base class for Trackerific tracking services. ;F;@;0;F;[;[;$I"2Base class for Trackerific tracking services.;F;%o;&;'F;(i;)i;*@;I"Trackerific::Base;F;Eo;8 ;90;:0;;0;: Object;*@;=0;.0;/T;.0;/To; ;IC;[ o; ; ; ;;;I"!Trackerific::USPS#initialize;F;[[" options"{};[[I"lib/usps.rb;Ti;F;;G;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"a new instance of USPS;F;0;#[I" USPS;F;@;$I";F;*@;+I"Bdef initialize(options = {}) super @options = options end;F;,I"!def initialize(options = {});F;-T;/To; ; ; ;;;I"'Trackerific::USPS#required_options;F;[;[[@i;T;;;;;[;IC;"?The required option for tracking a UPS package is :user_id ;F;@;0;F;[;[o; ;!I" return;F;"I"5the required options for tracking a UPS package.;F;0;#[I" Array;F;@;$I"|The required option for tracking a UPS package is :user_id @return [Array] the required options for tracking a UPS package.;F;%o;&;'F;(i;)i;*@;+I"*def required_options [:user_id] end;F;,I"def required_options( );F;-T;.0;/To; ; ; ;;;I"$Trackerific::USPS#track_package;F;[["package_id0;[[@i$;T;;0;;;[;IC;"\Tracks a USPS package. A Trackerific::Error is raised when a package cannot be tracked. ;F;@;0;F;[;[o; ;!I" return;F;"I"the tracking details;F;0;#[I"Trackerific::Details;F;@o; ;!I" raise;F;"I";F;0;#["Trackerific::Error;@;$I"Tracks a USPS package. A Trackerific::Error is raised when a package cannot be tracked. @return [Trackerific::Details] the tracking details;F;%o;&;'F;(i!;)i#;*@;+I"2def track_package(package_id) super response = self.class.get('/ShippingAPITest.dll', :query => {:API => 'TrackV2', :XML => build_xml_request}.to_query) response.error! unless response.code == 200 raise Trackerific::Error, response['Error']['Description'] unless response['Error'].nil? raise Trackerific::Error, "Tracking information not found in response from server." if response['TrackResponse'].nil? tracking_info = response['TrackResponse']['TrackInfo'] details = [] tracking_info['TrackDetail'].each do |d| # each tracking detail is a string in this format: # MM DD HH:MM am/pm DESCRIPTION CITY STATE ZIP. # unfortunately, it will not be possible to tell the difference between # the location, and the summary. So, for USPS, the location will be in # the summary d = d.split(" ") date = DateTime.parse(d[0..3].join(" ")) desc = d[4..d.length].join(" ") details << Trackerific::Event.new(date, desc, "") end Trackerific::Details.new( tracking_info['ID'], tracking_info['TrackSummary'], details ) end;F;,I""def track_package(package_id);F;-T;.0;/To; ; ; ;;1;I"(Trackerific::USPS#build_xml_request;F;[;[[@iB;T;;4;;;[;IC;"!Parses the response from UPS ;F;@ ;0;F;[;[o; ;!I" return;F;"I";F;0;#[I"Trackerific::Details;F;@ ;$I"@Parses the response from UPS @return [Trackerific::Details];F;%o;&;'F;(i@;)iA;*@;+I"def build_xml_request tracking_request = "" builder = ::Builder::XmlMarkup.new(:target => tracking_request) builder.TrackRequest(:USERID => @options[:user_id]) do |t| t.TrackID(:ID => @package_id) end return tracking_request end;F;,I"def build_xml_request( );F;-T;.0;/T;5@;6IC;[;5@;7IC;[o;8 ;90;:0;;0;;<;*@;=0;5@;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@i ;T;: USPS;;;;;[;IC;"0Provides package tracking support for USPS. ;F;@;0;F;[;[;$I"0Provides package tracking support for USPS.;F;%o;&;'F;(i ;)i ;*@;I"Trackerific::USPS;F;Eo;8 ;90;:0;;0;;F;*@;=@;.0;/To; ;IC;[o; ; ; ;;;I"(Trackerific::FedEx#required_options;F;[;[[I"lib/fedex.rb;Ti;T;;;;;[;IC;" ;F;@0;0;F;[;[o; ;!I" return;F;"I"Krequired options for tracking a FedEx package are :account and :meter.;F;0;#[I" Array;F;@0;$I"]@return [Array] required options for tracking a FedEx package are :account and :meter.;F;%o;&;'F;(i;)i;*@.;+I"2def required_options [:account, :meter] end;F;,I"def required_options( );F;-T;.0;/To; ; ; ;;;I"%Trackerific::FedEx#track_package;F;[["package_id0;[[@5i;T;;0;;;[;IC;"^Tracks a FedEx package. A Trackerific::Error is raised when a package cannot be tracked. ;F;@C;0;F;[;[o; ;!I" return;F;"I"the tracking details;F;0;#[I"Trackerific::Details;F;@Co; ;!I" raise;F;"I";F;0;#["Trackerific::Error;@C;$I"Tracks a FedEx package. A Trackerific::Error is raised when a package cannot be tracked. @return [Trackerific::Details] the tracking details;F;%o;&;'F;(i;)i;*@.;+I"def track_package(package_id) super http_response = self.class.post "/GatewayDC", :body => build_xml_request http_response.error! unless http_response.code == 200 track_reply = http_response["FDXTrack2Reply"] raise Trackerific::Error, track_reply["Error"]["Message"] unless track_reply["Error"].nil? details = track_reply["Package"] events = [] details["Event"].each do |e| date = Time.parse("#{e["Date"]} #{e["Time"]}") desc = e["Description"] addr = e["Address"] # Adds event in this format: # MM DD HH:MM am/pm Description City State Zip events << Trackerific::Event.new(date, desc, "#{addr["StateOrProvinceCode"]} #{addr["PostalCode"]}") end Details.new( details["TrackingNumber"], details["StatusDescription"], events ) end;F;,I""def track_package(package_id);F;-T;.0;/To; ; ; ;;1;I")Trackerific::FedEx#build_xml_request;F;[;[[@5i9;T;;4;;;[;IC;",Builds the XML request to send to FedEx ;F;@\;0;F;[;[o; ;!I" return;F;"I"a FDXTrack2Request XML;F;0;#[I" String;F;@\;$I"TBuilds the XML request to send to FedEx @return [String] a FDXTrack2Request XML;F;%o;&;'F;(i7;)i8;*@.;+I"def build_xml_request xml = "" xmlns_api = "http://www.fedex.com/fsmapi" xmlns_xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi_noNSL = "FDXTrack2Request.xsd" builder = ::Builder::XmlMarkup.new(:target => xml) builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8" builder.FDXTrack2Request "xmlns:api"=>xmlns_api, "xmlns:xsi"=>xmlns_xsi, "xsi:noNamespaceSchemaLocation" => xsi_noNSL do |r| r.RequestHeader do |rh| rh.AccountNumber @options[:account] rh.MeterNumber @options[:meter] end r.PackageIdentifier do |pi| pi.Value @package_id end r.DetailScans true end return xml end;F;,I"def build_xml_request( );F;-T;.0;/T;5@.;6IC;[;5@.;7IC;[o;8 ;90;:0;;0;;<;*@;=0;5@.;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@5i ;T;: FedEx;;;;;[;IC;"0Provides package tracking support for FedEx ;F;@.;0;F;[;[;$I"0Provides package tracking support for FedEx;F;%o;&;'F;(i ;)i ;*@;I"Trackerific::FedEx;F;Eo;8 ;90;:0;;0;;F;*@;=@;.0;/To; ;IC;[;5@;6IC;[;5@;7IC;[;5@;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@i ;T;: Error;;;;;[;IC;"ERaised if something other than tracking information is returned. ;F;@;0;F;[;[;$I"ERaised if something other than tracking information is returned.;F;%o;&;'F;(i ;)i ;*@;I"Trackerific::Error;F;Eo;8 ;90;:0;;0;:StandardError;*@;=0;.0;/T@o; ; ; ;;;I"!Trackerific#tracking_service;F;[["package_id0;[[@i3;T;:tracking_service;;;[;IC;"~Checks a string for a valid package identifier, and returns a Trackerific class that should be able to track the package. ;F;@;0;F;[;[o; ;!I" param;F;"I"package identifier.;F;I"the;F;#[I" String;F;@o; ;!I" return;F;"I"Uthe Trackerific class that can track the given package id, or nil if none found.;F;0;#[I"Trackerific::Base;F;@;$I"Checks a string for a valid package identifier, and returns a Trackerific class that should be able to track the package. @param [String] the package identifier. @return [Trackerific::Base] the Trackerific class that can track the given package id, or nil if none found.;F;%o;&;'F;(i-;)i2;*@;+I"3def tracking_service(package_id) case package_id when /^.Z/, /^[HK].{10}$/ then Trackerific::UPS when /^96.{20}$/ then Trackerific::FedEx else case package_id.length when 13, 20, 22, 30 then Trackerific::USPS when 12, 15, 19 then Trackerific::FedEx else nil end end end;F;,I"%def tracking_service(package_id);F;-T;.0;/To; ;IC;[ o; ; ; ;;;I""Trackerific::Event#initialize;F;[[" date0["description0[" location0;[[I"lib/trackerific_event.rb;Ti ;T;;G;;;[;IC;"%Provides a new instance of Event ;F;@;0;F;[;[ o; ;!I" param;F;"I"date / time of the event;F;I"the;F;#[I" Time;F;@o; ;!I" param;F;"I"event's description;F;I"the;F;#[I" String;F;@o; ;!I" param;F;"I"the event took place;F;I" where;F;#[I" String;F;@o; ;!I" return;F;"I"a new instance of Event;F;0;#[I" Event;F;@;$I"Provides a new instance of Event @param [Time] the date / time of the event @param [String] the event's description @param [String] where the event took place;F;%o;&;'F;(i ;)i ;*@;+I"wdef initialize(date, description, location) @date = date @description = description @location = location end;F;,I"0def initialize(date, description, location);F;-T;.0;/To; ; ; ;;;I"Trackerific::Event#date;F;[;[[@i;T;: date;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"!the date / time of the event;F;0;#[I" Time;F;@;$I"0@return [Time] the date / time of the event;F;%o;&;'F;(i;)i;*@;+I"def date @date end;F;,I"def date( );F;-T;.0;/To; ; ; ;;;I"#Trackerific::Event#description;F;[;[[@i;T;:description;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"the event's description.;F;0;#[I" String;F;@;$I".@return [String] the event's description.;F;%o;&;'F;(i;)i;*@;+I"'def description @description end;F;,I"def description( );F;-T;.0;/To; ; ; ;;;I" Trackerific::Event#location;F;[;[[@i;T;: location;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"Bwhere the event took place (usually in City State Zip format);F;0;#[I" String;F;@;$I"U@return [String] where the event took place (usually in City State Zip format);F;%o;&;'F;(i;)i;*@;+I"!def location @location end;F;,I"def location( );F;-T;.0;/To; ; ; ;;;I"Trackerific::Event#to_s;F;[;[[@i$;T;: to_s;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"%converts the event into a string;F;0;#[I" String;F;@;$I"6@return [String] converts the event into a string;F;%o;&;'F;(i#;)i#;*@;+I"def to_s dte = self.date.strftime('%b %d %I:%M %P') des = self.description loc = self.location "#{dte} #{des} #{loc}" end;F;,I"def to_s( );F;-T;.0;/T;5@;6IC;[;5@;7IC;[;5@;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@i;T;: Event;;;;;[;IC;"*Provides details for a tracking event ;F;@;0;F;[;[;$I"*Provides details for a tracking event;F;%o;&;'F;(i;)i;*@;I"Trackerific::Event;F;Eo;8 ;90;:0;;0;;H;*@;=0;.0;/To; ;IC;[ o; ; ; ;;;I"$Trackerific::Details#initialize;F;[["package_id0[" summary0[" events0;[[I"lib/trackerific_details.rb;Ti;T;;G;;;[;IC;"'Provides a new instance of Details ;F;@5;0;F;[;[ o; ;!I" param;F;"I"package identifier;F;I"the;F;#[I" String;F;@5o; ;!I" param;F;"I"#summary of the tracking status;F;I"a;F;#[I" String;F;@5o; ;!I" param;F;"I"tracking events;F;I"the;F;#[I" Array;FI"Trackerific::Event;F;@5o; ;!I" return;F;"I"a new instance of Details;F;0;#[I" Details;F;@5;$I"Provides a new instance of Details @param [String] the package identifier @param [String] a summary of the tracking status @param [Array, Trackerific::Event] the tracking events;F;%o;&;'F;(i ;)i ;*@3;+I"wdef initialize(package_id, summary, events) @package_id = package_id @summary = summary @events = events end;F;,I"0def initialize(package_id, summary, events);F;-T;.0;/To; ; ; ;;;I"$Trackerific::Details#package_id;F;[;[[@@i;T;:package_id;;;[;IC;" ;F;@a;0;F;[;[o; ;!I" return;F;"I"the package identifier;F;0;#[I" String;F;@a;$I",@return [String] the package identifier;F;%o;&;'F;(i;)i;*@3;+I"%def package_id @package_id end;F;,I"def package_id( );F;-T;.0;/To; ; ; ;;;I"!Trackerific::Details#summary;F;[;[[@@i;T;: summary;;;[;IC;" ;F;@s;0;F;[;[o; ;!I" return;F;"I"%a summary of the tracking status;F;0;#[I" String;F;@s;$I"6@return [String] a summary of the tracking status;F;%o;&;'F;(i;)i;*@3;+I"def summary @summary end;F;,I"def summary( );F;-T;.0;/To; ; ; ;;;I" Trackerific::Details#events;F;[;[[@@i;T;: events;;;[;IC;" ;F;@;0;F;[;[o; ;!I" return;F;"I"the tracking events;F;0;#[I" Array;FI"Trackerific::Event;F;@;$I"<@return [Array, Trackerific::Event] the tracking events;F;%o;&;'F;(i;)i;*@3;+I"def events @events end;F;,I"def events( );F;-T;.0;/T;5@3;6IC;[;5@3;7IC;[;5@3;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[[@@i ;T;: Details;;;;;[;IC;"hDetails returned when tracking a package. Stores the package identifier, a summary, and the events. ;F;@3;0;F;[;[;$I"hDetails returned when tracking a package. Stores the package identifier, a summary, and the events.;F;%o;&;'F;(i;)i;*@;I"Trackerific::Details;F;Eo;8 ;90;:0;;0;;H;*@;=0;.0;/T;5@;6IC;[;5@;7IC;[;5@;>IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[ [@i[@i[@i[@5i[@i[@@i;T;:Trackerific;;;;;[;IC;"IC;?{;@IC;?{;AT; IC;?{;AT;AT;B{;C[;[;F;;;;;;;[;IC;" ;F;@;0;F;[;[;$I";F;*0;I";F;W@:Trackerific::UPS@ :&Trackerific::UPS#required_options@ :#Trackerific::UPS#track_package@:,Trackerific::UPS#parse_success_response@3:*Trackerific::UPS#parse_error_response@G:'Trackerific::UPS#build_xml_request@[:Trackerific::USPS@:!Trackerific::USPS#initialize@:'Trackerific::USPS#required_options@:$Trackerific::USPS#track_package@:(Trackerific::USPS#build_xml_request@ :Trackerific::FedEx@.:(Trackerific::FedEx#required_options@0:%Trackerific::FedEx#track_package@C:)Trackerific::FedEx#build_xml_request@\:Trackerific::Error@:Trackerific::Base@:!Trackerific::Base#initialize@|:'Trackerific::Base#required_options@:$Trackerific::Base#track_package@:!Trackerific#tracking_service@:Trackerific::Event@:"Trackerific::Event#initialize@:Trackerific::Event#date@:#Trackerific::Event#description@: Trackerific::Event#location@:Trackerific::Event#to_s@:Trackerific::Details@3:$Trackerific::Details#initialize@5:$Trackerific::Details#package_id@a:!Trackerific::Details#summary@s: Trackerific::Details#events@