Class: UspsApi::ServiceStandardsFilesHypermediaLink

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

Overview

ServiceStandardsFilesHypermediaLink 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(rel:, href:, title: SKIP, description: SKIP, method: SKIP, submission_media_type: SKIP, target_media_type: SKIP, publish_date: SKIP) ⇒ ServiceStandardsFilesHypermediaLink

Returns a new instance of ServiceStandardsFilesHypermediaLink.



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 77

def initialize(rel:, href:, title: SKIP, description: SKIP, method: SKIP,
               submission_media_type: SKIP, target_media_type: SKIP,
               publish_date: SKIP)
  @rel = rel
  @title = title unless title == SKIP
  @description = description unless description == SKIP
  @href = href
  @method = method unless method == SKIP
  @submission_media_type = submission_media_type unless submission_media_type == SKIP
  @target_media_type = target_media_type unless target_media_type == SKIP
  @publish_date = publish_date unless publish_date == SKIP
end

Instance Attribute Details

#descriptionString

A human-readable description of the link relationship.

Returns:

  • (String)


23
24
25
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 23

def description
  @description
end

#hrefString

The URL to a related resource.

Returns:

  • (String)


27
28
29
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 27

def href
  @href
end

#methodMethod

The HTTP method to use to access this link.

Returns:



31
32
33
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 31

def method
  @method
end

#publish_dateDateTime

The date and time the file was published. The date and time will be returned in UTC (Zulu) format.

Returns:

  • (DateTime)


44
45
46
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 44

def publish_date
  @publish_date
end

#relArray[String]

The short name(s) of the relationship corresponding to the link.

Returns:

  • (Array[String])


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

def rel
  @rel
end

#submission_media_typeString

The media type of the resource request.

Returns:

  • (String)


35
36
37
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 35

def submission_media_type
  @submission_media_type
end

#target_media_typeString

The media type of the resource response.

Returns:

  • (String)


39
40
41
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 39

def target_media_type
  @target_media_type
end

#titleString

A human-readable title of the link relationship.

Returns:

  • (String)


19
20
21
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 19

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  rel = hash.key?('rel') ? hash['rel'] : nil
  href = hash.key?('href') ? hash['href'] : nil
  title = hash.key?('title') ? hash['title'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  method = hash.key?('method') ? hash['method'] : SKIP
  submission_media_type =
    hash.key?('submissionMediaType') ? hash['submissionMediaType'] : SKIP
  target_media_type =
    hash.key?('targetMediaType') ? hash['targetMediaType'] : SKIP
  publish_date = if hash.key?('publishDate')
                   (DateTimeHelper.from_rfc3339(hash['publishDate']) if hash['publishDate'])
                 else
                   SKIP
                 end

  # Create object from extracted values.
  ServiceStandardsFilesHypermediaLink.new(rel: rel,
                                          href: href,
                                          title: title,
                                          description: description,
                                          method: method,
                                          submission_media_type: submission_media_type,
                                          target_media_type: target_media_type,
                                          publish_date: publish_date)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['rel'] = 'rel'
  @_hash['title'] = 'title'
  @_hash['description'] = 'description'
  @_hash['href'] = 'href'
  @_hash['method'] = 'method'
  @_hash['submission_media_type'] = 'submissionMediaType'
  @_hash['target_media_type'] = 'targetMediaType'
  @_hash['publish_date'] = 'publishDate'
  @_hash
end

.nullablesObject

An array for nullable fields



73
74
75
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 73

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    title
    description
    method
    submission_media_type
    target_media_type
    publish_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



134
135
136
137
138
139
140
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 134

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} rel: #{@rel.inspect}, title: #{@title.inspect}, description:"\
  " #{@description.inspect}, href: #{@href.inspect}, method: #{@method.inspect},"\
  " submission_media_type: #{@submission_media_type.inspect}, target_media_type:"\
  " #{@target_media_type.inspect}, publish_date: #{@publish_date.inspect}>"
end

#to_custom_publish_dateObject



121
122
123
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 121

def to_custom_publish_date
  DateTimeHelper.to_rfc3339(publish_date)
end

#to_sObject

Provides a human-readable string representation of the object.



126
127
128
129
130
131
# File 'lib/usps_api/models/service_standards_files_hypermedia_link.rb', line 126

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} rel: #{@rel}, title: #{@title}, description: #{@description}, href:"\
  " #{@href}, method: #{@method}, submission_media_type: #{@submission_media_type},"\
  " target_media_type: #{@target_media_type}, publish_date: #{@publish_date}>"
end