Class: UspsApi::UspsConnect8482Services

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/usps_connect8482_services.rb

Overview

Provides details on USPS Connect® services offered at the facility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(same_day_delivery: SKIP, same_day_pick_up: SKIP, next_day_pick_up: SKIP, sunday_delivery: SKIP, same_day_drop_off_cut_off_times: SKIP, same_day_carrier_pickup_cut_off_times: SKIP, next_day_drop_off_cut_off_times: SKIP) ⇒ UspsConnect8482Services

Returns a new instance of UspsConnect8482Services.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 76

def initialize(same_day_delivery: SKIP, same_day_pick_up: SKIP,
               next_day_pick_up: SKIP, sunday_delivery: SKIP,
               same_day_drop_off_cut_off_times: SKIP,
               same_day_carrier_pickup_cut_off_times: SKIP,
               next_day_drop_off_cut_off_times: SKIP)
  @same_day_delivery = same_day_delivery unless same_day_delivery == SKIP
  @same_day_pick_up = same_day_pick_up unless same_day_pick_up == SKIP
  @next_day_pick_up = next_day_pick_up unless next_day_pick_up == SKIP
  @sunday_delivery = sunday_delivery unless sunday_delivery == SKIP
  unless same_day_drop_off_cut_off_times == SKIP
    @same_day_drop_off_cut_off_times =
      same_day_drop_off_cut_off_times
  end
  unless same_day_carrier_pickup_cut_off_times == SKIP
    @same_day_carrier_pickup_cut_off_times =
      same_day_carrier_pickup_cut_off_times
  end
  unless next_day_drop_off_cut_off_times == SKIP
    @next_day_drop_off_cut_off_times =
      next_day_drop_off_cut_off_times
  end
end

Instance Attribute Details

#next_day_drop_off_cut_off_timesArray[CutOffTimesDropOff]

This field will be removed in Version 4.

Returns:



42
43
44
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 42

def next_day_drop_off_cut_off_times
  @next_day_drop_off_cut_off_times
end

#next_day_pick_upString

Indicates the latest time next day pick up can be scheduled for the given facility. If no time is given next day pick up service is not supported.

Returns:

  • (String)


25
26
27
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 25

def next_day_pick_up
  @next_day_pick_up
end

#same_day_carrier_pickup_cut_off_timesArray[CutOffTimesPickup]

This field will be removed in Version 4.

Returns:



38
39
40
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 38

def same_day_carrier_pickup_cut_off_times
  @same_day_carrier_pickup_cut_off_times
end

#same_day_deliveryTrueClass | FalseClass

Indicates whether same day delivery service is offered at the given facility.

Returns:

  • (TrueClass | FalseClass)


15
16
17
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 15

def same_day_delivery
  @same_day_delivery
end

#same_day_drop_off_cut_off_timesArray[CutOffTimesDropOff]

This field will be removed in Version 4.

Returns:



34
35
36
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 34

def same_day_drop_off_cut_off_times
  @same_day_drop_off_cut_off_times
end

#same_day_pick_upString

Indicates the latest time same day pick up can be scheduled for the given facility. If no time is given same day pick up service is not supported.

Returns:

  • (String)


20
21
22
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 20

def same_day_pick_up
  @same_day_pick_up
end

#sunday_deliveryTrueClass | FalseClass

Indicates whether sunday delivery service is offered at the given facility.

Returns:

  • (TrueClass | FalseClass)


30
31
32
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 30

def sunday_delivery
  @sunday_delivery
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 100

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  same_day_delivery =
    hash.key?('sameDayDelivery') ? hash['sameDayDelivery'] : SKIP
  same_day_pick_up =
    hash.key?('sameDayPickUp') ? hash['sameDayPickUp'] : SKIP
  next_day_pick_up =
    hash.key?('nextDayPickUp') ? hash['nextDayPickUp'] : SKIP
  sunday_delivery =
    hash.key?('SundayDelivery') ? hash['SundayDelivery'] : SKIP
  # Parameter is an array, so we need to iterate through it
  same_day_drop_off_cut_off_times = nil
  unless hash['sameDayDropOffCutOffTimes'].nil?
    same_day_drop_off_cut_off_times = []
    hash['sameDayDropOffCutOffTimes'].each do |structure|
      same_day_drop_off_cut_off_times << (CutOffTimesDropOff.from_hash(structure) if structure)
    end
  end

  same_day_drop_off_cut_off_times = SKIP unless hash.key?('sameDayDropOffCutOffTimes')
  # Parameter is an array, so we need to iterate through it
  same_day_carrier_pickup_cut_off_times = nil
  unless hash['sameDayCarrierPickupCutOffTimes'].nil?
    same_day_carrier_pickup_cut_off_times = []
    hash['sameDayCarrierPickupCutOffTimes'].each do |structure|
      same_day_carrier_pickup_cut_off_times << (CutOffTimesPickup.from_hash(structure) if structure)
    end
  end

  same_day_carrier_pickup_cut_off_times = SKIP unless hash.key?('sameDayCarrierPickupCutOffTimes')
  # Parameter is an array, so we need to iterate through it
  next_day_drop_off_cut_off_times = nil
  unless hash['nextDayDropOffCutOffTimes'].nil?
    next_day_drop_off_cut_off_times = []
    hash['nextDayDropOffCutOffTimes'].each do |structure|
      next_day_drop_off_cut_off_times << (CutOffTimesDropOff.from_hash(structure) if structure)
    end
  end

  next_day_drop_off_cut_off_times = SKIP unless hash.key?('nextDayDropOffCutOffTimes')

  # Create object from extracted values.
  UspsConnect8482Services.new(same_day_delivery: same_day_delivery,
                              same_day_pick_up: same_day_pick_up,
                              next_day_pick_up: next_day_pick_up,
                              sunday_delivery: sunday_delivery,
                              same_day_drop_off_cut_off_times: same_day_drop_off_cut_off_times,
                              same_day_carrier_pickup_cut_off_times: same_day_carrier_pickup_cut_off_times,
                              next_day_drop_off_cut_off_times: next_day_drop_off_cut_off_times)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['same_day_delivery'] = 'sameDayDelivery'
  @_hash['same_day_pick_up'] = 'sameDayPickUp'
  @_hash['next_day_pick_up'] = 'nextDayPickUp'
  @_hash['sunday_delivery'] = 'SundayDelivery'
  @_hash['same_day_drop_off_cut_off_times'] = 'sameDayDropOffCutOffTimes'
  @_hash['same_day_carrier_pickup_cut_off_times'] =
    'sameDayCarrierPickupCutOffTimes'
  @_hash['next_day_drop_off_cut_off_times'] = 'nextDayDropOffCutOffTimes'
  @_hash
end

.nullablesObject

An array for nullable fields



72
73
74
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 72

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 59

def self.optionals
  %w[
    same_day_delivery
    same_day_pick_up
    next_day_pick_up
    sunday_delivery
    same_day_drop_off_cut_off_times
    same_day_carrier_pickup_cut_off_times
    next_day_drop_off_cut_off_times
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



164
165
166
167
168
169
170
171
172
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 164

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} same_day_delivery: #{@same_day_delivery.inspect}, same_day_pick_up:"\
  " #{@same_day_pick_up.inspect}, next_day_pick_up: #{@next_day_pick_up.inspect},"\
  " sunday_delivery: #{@sunday_delivery.inspect}, same_day_drop_off_cut_off_times:"\
  " #{@same_day_drop_off_cut_off_times.inspect}, same_day_carrier_pickup_cut_off_times:"\
  " #{@same_day_carrier_pickup_cut_off_times.inspect}, next_day_drop_off_cut_off_times:"\
  " #{@next_day_drop_off_cut_off_times.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



154
155
156
157
158
159
160
161
# File 'lib/usps_api/models/usps_connect8482_services.rb', line 154

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} same_day_delivery: #{@same_day_delivery}, same_day_pick_up:"\
  " #{@same_day_pick_up}, next_day_pick_up: #{@next_day_pick_up}, sunday_delivery:"\
  " #{@sunday_delivery}, same_day_drop_off_cut_off_times: #{@same_day_drop_off_cut_off_times},"\
  " same_day_carrier_pickup_cut_off_times: #{@same_day_carrier_pickup_cut_off_times},"\
  " next_day_drop_off_cut_off_times: #{@next_day_drop_off_cut_off_times}>"
end