Class: FdxV660Api::NotificationSubscriptionEntity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/notification_subscription_entity.rb

Overview

Provides the fields of a notification subscription

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(type:, category:, callback_url:, subscriber:, effective_date: SKIP, subscription_id: SKIP, additional_properties: nil) ⇒ NotificationSubscriptionEntity

Returns a new instance of NotificationSubscriptionEntity.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 61

def initialize(type:, category:, callback_url:, subscriber:,
               effective_date: SKIP, subscription_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type
  @category = category
  @callback_url = callback_url
  @subscriber = subscriber
  @effective_date = effective_date unless effective_date == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#callback_urlString

Callback URL. Previous callback URL will be updated with latest.

Returns:

  • (String)


22
23
24
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 22

def callback_url
  @callback_url
end

#categoryNotificationCategory1

Category of notification



18
19
20
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 18

def category
  @category
end

#effective_dateDate

Effective date of notification

Returns:

  • (Date)


30
31
32
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 30

def effective_date
  @effective_date
end

#subscriberPartyEntity3

The Party who is subscribing to the notification

Returns:



26
27
28
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 26

def subscriber
  @subscriber
end

#subscription_idString

Subscription id of notification

Returns:

  • (String)


34
35
36
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 34

def subscription_id
  @subscription_id
end

#typeEventType1

Type of notification

Returns:



14
15
16
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 14

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : nil
  category = hash.key?('category') ? hash['category'] : nil
  callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : nil
  subscriber = PartyEntity3.from_hash(hash['subscriber']) if hash['subscriber']
  effective_date = hash.key?('effectiveDate') ? hash['effectiveDate'] : SKIP
  subscription_id =
    hash.key?('subscriptionId') ? hash['subscriptionId'] : 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.
  NotificationSubscriptionEntity.new(type: type,
                                     category: category,
                                     callback_url: callback_url,
                                     subscriber: subscriber,
                                     effective_date: effective_date,
                                     subscription_id: subscription_id,
                                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['category'] = 'category'
  @_hash['callback_url'] = 'callbackUrl'
  @_hash['subscriber'] = 'subscriber'
  @_hash['effective_date'] = 'effectiveDate'
  @_hash['subscription_id'] = 'subscriptionId'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 49

def self.optionals
  %w[
    effective_date
    subscription_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



115
116
117
118
119
120
121
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 115

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, category: #{@category.inspect}, callback_url:"\
  " #{@callback_url.inspect}, subscriber: #{@subscriber.inspect}, effective_date:"\
  " #{@effective_date.inspect}, subscription_id: #{@subscription_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



107
108
109
110
111
112
# File 'lib/fdx_v660_api/models/notification_subscription_entity.rb', line 107

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, category: #{@category}, callback_url: #{@callback_url},"\
  " subscriber: #{@subscriber}, effective_date: #{@effective_date}, subscription_id:"\
  " #{@subscription_id}, additional_properties: #{@additional_properties}>"
end