Class: SimpleShipping::Demo::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_shipping/demo/base.rb

Overview

Base class for UPS and FedEx demos.

Direct Known Subclasses

Fedex, Ups

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/simple_shipping/demo/base.rb', line 3

def options
  @options
end

Instance Method Details

#recipientSimpleShipping::Party

Build the recipient object.



65
66
67
68
69
70
# File 'lib/simple_shipping/demo/base.rb', line 65

def recipient
  @recipient ||= SimpleShipping::Party.new(
    :address        => recipient_address,
    :contact        => recipient_contact
)
end

#recipient_addressSimpleShipping::Address

Build the recipient address with random attributes.



42
43
44
45
46
47
48
49
50
# File 'lib/simple_shipping/demo/base.rb', line 42

def recipient_address
  @recipient_address ||= SimpleShipping::Address.new(
      :country_code => 'US',
      :state_code   => 'MN',
      :city         => 'Minneapolis',
      :street_line  => 'Nightmare Avenue 13',
      :postal_code  => '55411'
  )
end

#recipient_contactSimpleShipping::Contact

Build the recipient contact.



55
56
57
58
59
60
# File 'lib/simple_shipping/demo/base.rb', line 55

def recipient_contact
  @recipient_contact ||= SimpleShipping::Contact.new(
    :person_name  => "John Recipient Smith",
    :phone_number => "1234567890"
)
end

#shipperSimpleShipping::Party

Build the shipper object.



31
32
33
34
35
36
37
# File 'lib/simple_shipping/demo/base.rb', line 31

def shipper
  @shipper ||= SimpleShipping::Party.new(
      :address => shipper_address,
      :contact => shipper_contact,
      :account_number => options[:account_number]
  )
end

#shipper_addressSimpleShipping::Address

Build the shipper address with random attributes.



8
9
10
11
12
13
14
15
16
# File 'lib/simple_shipping/demo/base.rb', line 8

def shipper_address
  @shipper_address ||= SimpleShipping::Address.new(
      :country_code => 'US',
      :state_code   => 'TX',
      :city         => 'Texas',
      :street_line  => 'SN2000 Test Meter 8',
      :postal_code  => '73301'
  )
end

#shipper_contactSimpleShipping::Contact

Build the shipper contact object.



21
22
23
24
25
26
# File 'lib/simple_shipping/demo/base.rb', line 21

def shipper_contact
  @shipper_contact ||= SimpleShipping::Contact.new(
      :person_name  => 'Mister Someone',
      :phone_number => '1234567890'
  )
end