Class: UspsApi::PackageTransactionDetailsSubscription

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

Overview

The filters that should be applied to the subscription. The structure of this property will change dependent on the type of subscription a client is signing up for.

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(crid: SKIP, event_types: SKIP, additional_properties: nil) ⇒ PackageTransactionDetailsSubscription

Returns a new instance of PackageTransactionDetailsSubscription.



47
48
49
50
51
52
53
54
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 47

def initialize(crid: SKIP, event_types: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @crid = crid unless crid == SKIP
  @event_types = event_types unless event_types == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#cridString

Customer Registration ID used to identify the business location associated to a shipment.

Returns:

  • (String)


17
18
19
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 17

def crid
  @crid
end

#event_typesArray[EventType4]

Specify what package transaction detail events should be include in the subscription: </p> NON_LABEL_FEE - Package that does not have a label in manifest RETURN_LABEL - Package that has a return label

Returns:



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

def event_types
  @event_types
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  crid = hash.key?('CRID') ? hash['CRID'] : SKIP
  event_types = hash.key?('eventTypes') ? hash['eventTypes'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PackageTransactionDetailsSubscription.new(crid: crid,
                                            event_types: event_types,
                                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['crid'] = 'CRID'
  @_hash['event_types'] = 'eventTypes'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
40
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 35

def self.optionals
  %w[
    crid
    event_types
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 85

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

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
82
# File 'lib/usps_api/models/package_transaction_details_subscription.rb', line 78

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} crid: #{@crid}, event_types: #{@event_types}, additional_properties:"\
  " #{@additional_properties}>"
end