Class: CyberSource::Notificationsubscriptionsv1webhooksRetryPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb

Overview

Retry policy for the individual webhooks that are a part of your subscription. If a message fails to deliver, it will execute through this retry policy. Automatic suspend and resume: If you experience downtime and have ‘deactivateFlag = true` any new messages will be held in a "SUSPENDED" status. When your healthCheckUrl returns healthy again, the subscription will automatically be re-enabled and your messages will be sent. We will ping your healthCheckUrl routinely using a POST call with an empty payload to check availability. If your endpoint returns an unhealthy status of != 200, we will check the healthCheckUrl at a more frequent rate until it is healthy again. If you experience downtime and have `deactivateFlag = false` and your message exhausts all retry attempts the message will go to a "FAILED" status. Support will be notified and will reach out to suggest you execute the "REPLAY" endpoint at a later date when your server is healthy. Reference the below values for formulas and calculations related to the frequency of retries depending on algorithm and configuration.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Notificationsubscriptionsv1webhooksRetryPolicy

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



86
87
88
89
90
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
120
121
122
123
124
125
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 86

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'algorithm')
    self.algorithm = attributes[:'algorithm']
  end

  if attributes.has_key?(:'firstRetry')
    self.first_retry = attributes[:'firstRetry']
  end

  if attributes.has_key?(:'interval')
    self.interval = attributes[:'interval']
  end

  if attributes.has_key?(:'numberOfRetries')
    self.number_of_retries = attributes[:'numberOfRetries']
  end

  if attributes.has_key?(:'deactivateFlag')
    self.deactivate_flag = attributes[:'deactivateFlag']
  end

  if attributes.has_key?(:'repeatSequenceCount')
    self.repeat_sequence_count = attributes[:'repeatSequenceCount']
  end

  if attributes.has_key?(:'repeatSequenceWaitTime')
    self.repeat_sequence_wait_time = attributes[:'repeatSequenceWaitTime']
  end

  if attributes.has_key?(:'additionalAttributes')
    if (value = attributes[:'additionalAttributes']).is_a?(Array)
      self.additional_attributes = value
    end
  end
end

Instance Attribute Details

#additional_attributesObject

Additional data, if any.



40
41
42
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 40

def additional_attributes
  @additional_attributes
end

#algorithmObject

This is used to calculate the Retry Sequence. Sample calculations using firstRetry=10, interval=30, maxNumberOfRetries=3 Arithmetic = a+r(n-1) Retry 1 - 10 minutes Retry 2 - 10+30x1 = 40 minutes Retry 3 - 10+30x2 = 70 minutes Geometric = ar^(n-1) Retry 1 - 10 minutes Retry 2 - 10x30^1 = 300 minutes Retry 3 - 10x30^2 = 9,000 minutes



19
20
21
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 19

def algorithm
  @algorithm
end

#deactivate_flagObject

Deactivate the subscription if your retries fail to deliver. If this is set to ‘true`, the automatic suspend and resume feature will occur. This would prevent new webhooks from attempting to deliver and to queue up until your healthCheckUrl returns 200 again, then all messages will be sent. If this is set to `false`, new individual messages will continue to retry and exhaust all failures, but the subscription will stay active.



31
32
33
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 31

def deactivate_flag
  @deactivate_flag
end

#first_retryObject

When to initiate first retry, after the initial call failed. (in mins).



22
23
24
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 22

def first_retry
  @first_retry
end

#intervalObject

The interval between retries (in mins).



25
26
27
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 25

def interval
  @interval
end

#number_of_retriesObject

The number of retries per sequence.



28
29
30
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 28

def number_of_retries
  @number_of_retries
end

#repeat_sequence_countObject

The number of times to repeat the complete retry sequence. 0 => don’t repeat the retry sequence 1 => repeat the retry sequence once (R1, R2, R3)+ (R1, R2, R3) 2 => repeat the retry sequence twice (R1, R2, R3) + (R1, R2, R3) + (R1, R2, R3)



34
35
36
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 34

def repeat_sequence_count
  @repeat_sequence_count
end

#repeat_sequence_wait_timeObject

The time to wait to before repeating the complete retry sequence. Amount of time to wait between each sequence. Sample calculation using repeatSequenceWaitTime=10 (R1, R2, R3) + (10) + (R1, R2, R3) + (10) + (R1, R2, R3)



37
38
39
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 37

def repeat_sequence_wait_time
  @repeat_sequence_wait_time
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 43

def self.attribute_map
  {
    :'algorithm' => :'algorithm',
    :'first_retry' => :'firstRetry',
    :'interval' => :'interval',
    :'number_of_retries' => :'numberOfRetries',
    :'deactivate_flag' => :'deactivateFlag',
    :'repeat_sequence_count' => :'repeatSequenceCount',
    :'repeat_sequence_wait_time' => :'repeatSequenceWaitTime',
    :'additional_attributes' => :'additionalAttributes'
  }
end

.json_mapObject

Attribute mapping from JSON key to ruby-style variable name.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 57

def self.json_map
  {
    :'algorithm' => :'algorithm',
    :'first_retry' => :'first_retry',
    :'interval' => :'interval',
    :'number_of_retries' => :'number_of_retries',
    :'deactivate_flag' => :'deactivate_flag',
    :'repeat_sequence_count' => :'repeat_sequence_count',
    :'repeat_sequence_wait_time' => :'repeat_sequence_wait_time',
    :'additional_attributes' => :'additional_attributes'
  }
end

.swagger_typesObject

Attribute type mapping.



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 71

def self.swagger_types
  {
    :'algorithm' => :'String',
    :'first_retry' => :'Integer',
    :'interval' => :'Integer',
    :'number_of_retries' => :'Integer',
    :'deactivate_flag' => :'String',
    :'repeat_sequence_count' => :'Integer',
    :'repeat_sequence_wait_time' => :'Integer',
    :'additional_attributes' => :'Array<Hash<String, String>>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 142

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      algorithm == o.algorithm &&
      first_retry == o.first_retry &&
      interval == o.interval &&
      number_of_retries == o.number_of_retries &&
      deactivate_flag == o.deactivate_flag &&
      repeat_sequence_count == o.repeat_sequence_count &&
      repeat_sequence_wait_time == o.repeat_sequence_wait_time &&
      additional_attributes == o.additional_attributes
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 191

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = CyberSource.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 257

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 170

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{self.class.json_map[key]}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{self.class.json_map[key]}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


157
158
159
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 157

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



163
164
165
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 163

def hash
  [algorithm, first_retry, interval, number_of_retries, deactivate_flag, repeat_sequence_count, repeat_sequence_wait_time, additional_attributes].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



129
130
131
132
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 129

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



237
238
239
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 237

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



243
244
245
246
247
248
249
250
251
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 243

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



231
232
233
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 231

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



136
137
138
# File 'lib/cybersource_rest_client/models/notificationsubscriptionsv1webhooks_retry_policy.rb', line 136

def valid?
  true
end