Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for the claim status api
- Loading branch information
Tim Matheson
committed
Dec 7, 2009
1 parent
66276d6
commit cb2dd8d
Showing
15 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Shipsurance | ||
class ClaimResponse < Response | ||
attr_reader :claim_id, :claim_code | ||
|
||
def initialize(response) | ||
@response = parse(response) | ||
@code = @response[0] | ||
@reason_code = @response[1] | ||
@claim_id = @response[2] | ||
@claim_code = @response[3] | ||
self | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Shipsurance | ||
class ClaimStatus < Base | ||
|
||
def required | ||
super.push(:ext_claim_id, :person_last_name, :person_email) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Shipsurance | ||
class ClaimStatusResponse < Response | ||
def initialize(response) | ||
@response = response.body.split("|") | ||
@code = @response[0] | ||
@reason_code = @response[1] | ||
@claim_status_type = @response[2] | ||
@claim_status_type_description = @response[3] | ||
@claim_comments = @response[4] | ||
@last_updated = @response[5] | ||
self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Shipsurance | ||
class RecordShipmentResponse < Response | ||
attr_reader :recorded_shipment_id | ||
|
||
def initialize(response) | ||
@response = parse(response) | ||
@code = @response[0] | ||
@reason_code = @response[1] | ||
@recorded_shipment_id = @response[2] | ||
self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Shipsurance | ||
class ValidationResponse < Response | ||
|
||
attr_reader :validation_type, :response_reason, :response | ||
|
||
def initialize(response) | ||
@response = parse(response) | ||
@code = @response[0] | ||
@reason_code = @response[1] | ||
@validation_type = @response[2] | ||
@response = @response[4] | ||
self | ||
end | ||
|
||
def body | ||
@reason_code | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Shipsurance | ||
class VoidRecordShipmentResponse < Response | ||
|
||
def initialize(response) | ||
@response = parse(response) | ||
@code = @response[0] | ||
@reason_code = @response[1] | ||
self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.dirname(__FILE__) + "/../../spec_helper" | ||
|
||
describe Shipsurance::ClaimStatus do | ||
before(:each) do | ||
@claim_status = Shipsurance::ClaimStatus.new | ||
@claim = Shipsurance::Claim.new | ||
@shipment_id = Shipsurance::RecordShipment.new.commit(valid_record_shipment_params).recorded_shipment_id | ||
@claim_response = @claim.commit({:recorded_shipment_id => @shipment_id}.merge!(add_params(valid_record_shipment_params))) | ||
end | ||
|
||
it "should return success" do | ||
post = {} | ||
post[:person_last_name] = "Matheson" | ||
post[:person_email] = CREDENTIALS[:person_email] | ||
post[:ext_claim_id] = @claim_response.claim_code | ||
post[:claim_id] = @claim_response.claim_id | ||
response = @claim_status.commit(post) | ||
puts post.inspect | ||
response.reason_code.should == "foo" | ||
end | ||
|
||
private | ||
|
||
def add_params(post = {}) | ||
post[:person_source_identifier] = '1' | ||
post[:person_first_name] = 'Tim' | ||
post[:person_last_name] = 'Matheson' | ||
post[:ext_carrier_id] = '2' | ||
post[:consignee_full_name] = 'Tim Matheson' | ||
post[:claim_payment_full_name] = 'Bill Smith' | ||
post[:claim_payment_address_1] = '123 Test Address' | ||
post[:claim_payment_city] = 'RSM' | ||
post[:claim_payment_postal_code] = '92688' | ||
post[:claim_payment_country] = 'US' | ||
post[:claim_payment_phone] = '9492945624' | ||
post[:file_date] = Time.now.strftime("%m/%d/%Y") | ||
post[:loss_discovered_date] = Time.now.strftime("%m/%d/%Y") | ||
post[:ext_claim_type_id] = '1' | ||
post[:claim_description] = 'Test Description' | ||
post[:claim_amount] = '11.99' | ||
post[:certify_correct] = '1' | ||
post[:claim_shipment_date] = Time.now.strftime("%m/%d/%Y") | ||
post | ||
end | ||
|
||
|
||
def valid_record_shipment_params | ||
{ | ||
:ext_shipment_type_id => 1, | ||
:ext_carrier_id => 1, | ||
:carrier_service_name => "UPS", | ||
:declared_value => 50.00, | ||
:shipment_date => Time.now.strftime("%m/%d/%Y"), | ||
:person_email => CREDENTIALS[:person_email], | ||
:package_description => "Test Description #{rand(9999999)}" | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--exclude "spec/*,gems/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec/rake/spectask' | ||
|
||
namespace :spec do | ||
desc "Run all specs in spec directory with RCov (excluding plugin specs)" | ||
Spec::Rake::SpecTask.new(:rcov) do |t| | ||
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/../spec/spec.opts\""] | ||
t.spec_files = FileList['spec/**/*/*_spec.rb'] | ||
t.rcov = true | ||
t.rcov_opts = lambda do | ||
IO.readlines(File.dirname(__FILE__) + "/../spec/rcov.opts").map {|l| l.chomp.split " "}.flatten | ||
end | ||
end | ||
end |