Class: DigitalFemsa::WebhookRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/digital_femsa/models/webhook_request.rb

Overview

Parameters used to create or update a webhook.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ WebhookRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/digital_femsa/models/webhook_request.rb', line 55

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `DigitalFemsa::WebhookRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `DigitalFemsa::WebhookRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'url')
    self.url = attributes[:'url']
  else
    self.url = nil
  end

  if attributes.key?(:'synchronous')
    self.synchronous = attributes[:'synchronous']
  else
    self.synchronous = false
  end
end

Instance Attribute Details

#synchronousObject

It is a value that allows to decide if the events will be synchronous or asynchronous. We recommend asynchronous = false



24
25
26
# File 'lib/digital_femsa/models/webhook_request.rb', line 24

def synchronous
  @synchronous
end

#urlObject

Here you must place the URL of your Webhook remember that you must program what you will do with the events received. Also do not forget to handle the HTTPS protocol for greater security.



21
22
23
# File 'lib/digital_femsa/models/webhook_request.rb', line 21

def url
  @url
end

Class Method Details

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



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/digital_femsa/models/webhook_request.rb', line 413

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.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
    # models (e.g. Pet) or oneOf
    klass = DigitalFemsa.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



35
36
37
# File 'lib/digital_femsa/models/webhook_request.rb', line 35

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



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

def self.attribute_map
  {
    :'url' => :'url',
    :'synchronous' => :'synchronous'
  }
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



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/digital_femsa/models/webhook_request.rb', line 389

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



48
49
50
51
# File 'lib/digital_femsa/models/webhook_request.rb', line 48

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



40
41
42
43
44
45
# File 'lib/digital_femsa/models/webhook_request.rb', line 40

def self.openapi_types
  {
    :'url' => :'String',
    :'synchronous' => :'Boolean'
  }
end

Instance Method Details

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/digital_femsa/models/webhook_request.rb', line 83

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @url.nil?
    invalid_properties.push('invalid value for "url", url cannot be nil.')
  end

  begin
    validate_url_safety(@url) if @url
  rescue ArgumentError => e
    invalid_properties.push(e.message)
  end

  if @synchronous.nil?
    invalid_properties.push('invalid value for "synchronous", synchronous cannot be nil.')
  end

  invalid_properties
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/digital_femsa/models/webhook_request.rb', line 105

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @url.nil?
  begin
    validate_url_safety(@url)
  rescue ArgumentError
    return false
  end
  return false if @synchronous.nil?
  true
end