Class: UspsApi::EnrollmentStatus

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

Overview

USPS Ship enrollment information for a single MID.

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(mid: SKIP, program: SKIP, start_date: SKIP) ⇒ EnrollmentStatus

Returns a new instance of EnrollmentStatus.



49
50
51
52
53
# File 'lib/usps_api/models/enrollment_status.rb', line 49

def initialize(mid: SKIP, program: SKIP, start_date: SKIP)
  @mid = mid unless mid == SKIP
  @program = program unless program == SKIP
  @start_date = start_date unless start_date == SKIP
end

Instance Attribute Details

#midString

The MID to which the information in this object applies.

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/enrollment_status.rb', line 14

def mid
  @mid
end

#programProgram

The program (Outbound or Returns) in which the MID is enrolled. If the MID is enrolled in both programs, two objects will be returned, one for each program.

Returns:



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

def program
  @program
end

#start_dateDate

The date on which the MID’s enrollment began.

Returns:

  • (Date)


24
25
26
# File 'lib/usps_api/models/enrollment_status.rb', line 24

def start_date
  @start_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/usps_api/models/enrollment_status.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mid = hash.key?('MID') ? hash['MID'] : SKIP
  program = hash.key?('program') ? hash['program'] : SKIP
  start_date = hash.key?('startDate') ? hash['startDate'] : SKIP

  # Create object from extracted values.
  EnrollmentStatus.new(mid: mid,
                       program: program,
                       start_date: start_date)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/usps_api/models/enrollment_status.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mid'] = 'MID'
  @_hash['program'] = 'program'
  @_hash['start_date'] = 'startDate'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/usps_api/models/enrollment_status.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
# File 'lib/usps_api/models/enrollment_status.rb', line 36

def self.optionals
  %w[
    mid
    program
    start_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
81
# File 'lib/usps_api/models/enrollment_status.rb', line 77

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} mid: #{@mid.inspect}, program: #{@program.inspect}, start_date:"\
  " #{@start_date.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} mid: #{@mid}, program: #{@program}, start_date: #{@start_date}>"
end