# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default, :development)
require 'hashie'
require 'trebbianno'
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
end
def xml_string(type, body)
xml = ""
xml += ""
xml += xml_header_string(type)
xml += "<#{type} xmlns=\"SII\">"
xml += xml_user_string
xml += body
xml += "#{type}>"
end
def xml_header_string(type)
xml = "SII/ISIIService/#{type}"
xml += "urn:uuid:56b55a70-8bbc-471d-94bb-9ca060bcf99f"
xml += "http://www.w3.org/2005/08/addressing/anonymous"
xml += "https://www.trebbianno.us/webservices/SIIService.svc"
end
def xml_user_string
xml = ""
xml += "<![CDATA[the_username]]><![CDATA[the_password]]>"
end
def xml_address_string(type, address)
full_name = "#{address[:first_name]} #{address[:last_name]}"
xml = "<![CDATA[#{full_name}]]>"
xml += "<![CDATA[#{address[:address1]}]]>"
xml += "<![CDATA[#{address[:address2]}]]>"
xml += "<![CDATA[#{address[:address3]}]]>"
xml += "#{address[:city]}"
xml += "#{address[:country]}"
xml += "#{address[:state]}"
xml += "#{address[:zipcode]}"
xml += "#{address[:phone]}"
end
def xml_line_items_string(order)
xml = ""
order[:line_items].each do |line_item|
xml += ""
xml += "#{line_item[:price]}"
xml += "#{line_item[:quantity]}"
xml += "#{line_item[:size]}"
xml += "#{line_item[:sku]}"
xml += ""
end
xml += ""
end
def xml_order_request_string(order)
xml = ""
xml += "90"
xml += "<![CDATA[http://example.com/R123123123/invoice]]>"
xml += "FEDEX"
xml += ""
xml += "<![CDATA[Happy Birthday!]]>"
xml += "someone@somehwere.com"
xml += "R123123123"
xml += "OO"
xml += ""
xml += ""
xml += xml_address_string("CUSTOMER", order[:billing_address])
xml += xml_address_string("DELIVERY", order[:shipping_address])
xml += xml_line_items_string(order)
xml += ""
end
def order_hash
{
carrier: "FEDEX",
billing_address: {
first_name: "John",
last_name: "Smith",
address1: "123 Here Now",
address2: "2nd Floor",
address3: "",
city: "New York",
state: "New York",
country: "US",
zipcode: "10012",
phone: "123-123-1234"
},
shipping_address: {
first_name: "John",
last_name: "Smith",
address1: "123 Here Now",
address2: "2nd Floor",
address3: "",
city: "New York",
state: "New York",
country: "US",
zipcode: "10012",
phone: "123-123-1234"
},
gift_wrap: "true",
gift_message: "Happy Birthday!",
email: "someone@somehwere.com",
number: "R123123123",
type: "OO",
line_items: [
{
price: "127.23",
quantity: "1",
sku: "123332211",
size: "XS"
}
],
shipping_code: "90",
invoice_url: "http://example.com/R123123123/invoice"
}
end