Class: UspsApi::HypermediaLink
- Defined in:
- lib/usps_api/models/hypermedia_link.rb
Overview
HypermediaLink Model.
Instance Attribute Summary collapse
-
#href ⇒ String
The URL to a related resource.
-
#method ⇒ Method
The HTTP method to use to access this link.
-
#rel ⇒ Array[String]
The short name(s) of the relationship corresponding to the link.
-
#submission_media_type ⇒ String
The media type of the resource request.
-
#target_media_type ⇒ String
The media type of the resource response.
-
#title ⇒ String
A human-readable description of the link relationship.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(rel:, href:, title: SKIP, method: SKIP, submission_media_type: SKIP, target_media_type: SKIP) ⇒ HypermediaLink
constructor
A new instance of HypermediaLink.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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) ⇒ HypermediaLink
Returns a new instance of HypermediaLink.
63 64 65 66 67 68 69 70 71 |
# File 'lib/usps_api/models/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
#href ⇒ String
The URL to a related resource.
22 23 24 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 22 def href @href end |
#method ⇒ Method
The HTTP method to use to access this link.
26 27 28 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 26 def method @method end |
#rel ⇒ Array[String]
The short name(s) of the relationship corresponding to the link.
14 15 16 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 14 def rel @rel end |
#submission_media_type ⇒ String
The media type of the resource request.
30 31 32 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 30 def submission_media_type @submission_media_type end |
#target_media_type ⇒ String
The media type of the resource response.
34 35 36 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 34 def target_media_type @target_media_type end |
#title ⇒ String
A human-readable description of the link relationship.
18 19 20 |
# File 'lib/usps_api/models/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/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. HypermediaLink.new(rel: rel, href: href, title: title, method: method, submission_media_type: submission_media_type, target_media_type: target_media_type) end |
.names ⇒ Object
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/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 |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 52 53 54 55 56 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 49 def self.optionals %w[ title method submission_media_type target_media_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
105 106 107 108 109 110 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 105 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_s ⇒ Object
Provides a human-readable string representation of the object.
97 98 99 100 101 102 |
# File 'lib/usps_api/models/hypermedia_link.rb', line 97 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 |