Class: UspsApi::AdjustmentsHypermediaLink

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

Overview

AdjustmentsHypermediaLink 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, method: SKIP, submission_media_type: SKIP, target_media_type: SKIP) ⇒ AdjustmentsHypermediaLink

Returns a new instance of AdjustmentsHypermediaLink.



63
64
65
66
67
68
69
70
71
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 63

def initialize(rel:, href:, title: SKIP, method: SKIP,
               submission_media_type: SKIP, target_media_type: SKIP)
  @rel = rel
  @title = title unless title == 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
end

Instance Attribute Details

#hrefString

The URL to a related resource.

Returns:

  • (String)


22
23
24
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 22

def href
  @href
end

#methodMethod

The HTTP method to use to access this link.

Returns:



26
27
28
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 26

def method
  @method
end

#relArray[String]

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

Returns:

  • (Array[String])


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

def rel
  @rel
end

#submission_media_typeString

The media type of the resource request.

Returns:

  • (String)


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

def submission_media_type
  @submission_media_type
end

#target_media_typeString

The media type of the resource response.

Returns:

  • (String)


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

def target_media_type
  @target_media_type
end

#titleString

A human-readable description of the link relationship.

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 18

def title
  @title
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
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 74

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
  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

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

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 37

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

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 49

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 98

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.rel,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.href,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['rel'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['href'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_sObject

Provides a human-readable string representation of the object.



119
120
121
122
123
124
# File 'lib/usps_api/models/adjustments_hypermedia_link.rb', line 119

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