Class: NewStoreApi::Request

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/request.rb

Overview

Request Model.

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(reason = SKIP, status = SKIP, tracking_code = SKIP, updated_at = SKIP, easypost_marker = SKIP) ⇒ Request

Returns a new instance of Request.



64
65
66
67
68
69
70
71
# File 'lib/new_store_api/models/request.rb', line 64

def initialize(reason = SKIP, status = SKIP, tracking_code = SKIP,
               updated_at = SKIP, easypost_marker = SKIP)
  @reason = reason unless reason == SKIP
  @status = status unless status == SKIP
  @tracking_code = tracking_code unless tracking_code == SKIP
  @updated_at = updated_at unless updated_at == SKIP
  @easypost_marker = easypost_marker unless easypost_marker == SKIP
end

Instance Attribute Details

#easypost_markerString

Set by carrier. It is the time at which the event has been recorded/generated by the carrier.

Returns:

  • (String)


33
34
35
# File 'lib/new_store_api/models/request.rb', line 33

def easypost_marker
  @easypost_marker
end

#reasonString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/new_store_api/models/request.rb', line 15

def reason
  @reason
end

#statusTrackingStatusEnum

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/new_store_api/models/request.rb', line 19

def status
  @status
end

#tracking_codeString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/request.rb', line 23

def tracking_code
  @tracking_code
end

#updated_atDateTime

Set by carrier. It is the time at which the event has been recorded/generated by the carrier.

Returns:

  • (DateTime)


28
29
30
# File 'lib/new_store_api/models/request.rb', line 28

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/new_store_api/models/request.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reason = hash.key?('reason') ? hash['reason'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  tracking_code = hash.key?('tracking_code') ? hash['tracking_code'] : SKIP
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end
  easypost_marker =
    hash.key?('easypost_marker') ? hash['easypost_marker'] : SKIP

  # Create object from extracted values.
  Request.new(reason,
              status,
              tracking_code,
              updated_at,
              easypost_marker)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/new_store_api/models/request.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reason'] = 'reason'
  @_hash['status'] = 'status'
  @_hash['tracking_code'] = 'tracking_code'
  @_hash['updated_at'] = 'updated_at'
  @_hash['easypost_marker'] = 'easypost_marker'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
61
62
# File 'lib/new_store_api/models/request.rb', line 58

def self.nullables
  %w[
    reason
  ]
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
54
55
# File 'lib/new_store_api/models/request.rb', line 47

def self.optionals
  %w[
    reason
    status
    tracking_code
    updated_at
    easypost_marker
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/new_store_api/models/request.rb', line 109

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} reason: #{@reason.inspect}, status: #{@status.inspect}, tracking_code:"\
  " #{@tracking_code.inspect}, updated_at: #{@updated_at.inspect}, easypost_marker:"\
  " #{@easypost_marker.inspect}>"
end

#to_custom_updated_atObject



97
98
99
# File 'lib/new_store_api/models/request.rb', line 97

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
# File 'lib/new_store_api/models/request.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} reason: #{@reason}, status: #{@status}, tracking_code: #{@tracking_code},"\
  " updated_at: #{@updated_at}, easypost_marker: #{@easypost_marker}>"
end