Class: AlogramPayRisk::CheckRequest

Inherits:
ApiModelBase show all
Defined in:
lib/alogram_payrisk/models/check_request.rb

Overview

Request for synchronous purchase risk check.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CheckRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/alogram_payrisk/models/check_request.rb', line 98

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

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

  if attributes.key?(:'event_type')
    self.event_type = attributes[:'event_type']
  else
    self.event_type = 'purchase'
  end

  if attributes.key?(:'payment_intent_id')
    self.payment_intent_id = attributes[:'payment_intent_id']
  end

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

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

  if attributes.key?(:'identity')
    self.identity = attributes[:'identity']
  end

  if attributes.key?(:'external_assessments')
    if (value = attributes[:'external_assessments']).is_a?(Array)
      self.external_assessments = value
    end
  end
end

Instance Attribute Details

#entitiesObject

Returns the value of attribute entities.



25
26
27
# File 'lib/alogram_payrisk/models/check_request.rb', line 25

def entities
  @entities
end

#event_typeObject

(optional) event being checked, this may expand later beyond ‘purchase’.



20
21
22
# File 'lib/alogram_payrisk/models/check_request.rb', line 20

def event_type
  @event_type
end

#external_assessmentsObject

Optional 3rd party risk assessments (e.g. Shopify, Stripe, Signifyd).



32
33
34
# File 'lib/alogram_payrisk/models/check_request.rb', line 32

def external_assessments
  @external_assessments
end

#identityObject

Returns the value of attribute identity.



29
30
31
# File 'lib/alogram_payrisk/models/check_request.rb', line 29

def identity
  @identity
end

#payment_intent_idObject

Server-minted unique payment identifier.



23
24
25
# File 'lib/alogram_payrisk/models/check_request.rb', line 23

def payment_intent_id
  @payment_intent_id
end

#purchaseObject

Returns the value of attribute purchase.



27
28
29
# File 'lib/alogram_payrisk/models/check_request.rb', line 27

def purchase
  @purchase
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



69
70
71
# File 'lib/alogram_payrisk/models/check_request.rb', line 69

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



74
75
76
# File 'lib/alogram_payrisk/models/check_request.rb', line 74

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



57
58
59
60
61
62
63
64
65
66
# File 'lib/alogram_payrisk/models/check_request.rb', line 57

def self.attribute_map
  {
    :'event_type' => :'eventType',
    :'payment_intent_id' => :'paymentIntentId',
    :'entities' => :'entities',
    :'purchase' => :'purchase',
    :'identity' => :'identity',
    :'external_assessments' => :'externalAssessments'
  }
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



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/alogram_payrisk/models/check_request.rb', line 265

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



91
92
93
94
# File 'lib/alogram_payrisk/models/check_request.rb', line 91

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

.openapi_typesObject

Attribute type mapping.



79
80
81
82
83
84
85
86
87
88
# File 'lib/alogram_payrisk/models/check_request.rb', line 79

def self.openapi_types
  {
    :'event_type' => :'String',
    :'payment_intent_id' => :'String',
    :'entities' => :'EntityIds',
    :'purchase' => :'Purchase',
    :'identity' => :'Identity',
    :'external_assessments' => :'Array<ExternalAssessment>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



239
240
241
242
243
244
245
246
247
248
# File 'lib/alogram_payrisk/models/check_request.rb', line 239

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      event_type == o.event_type &&
      payment_intent_id == o.payment_intent_id &&
      entities == o.entities &&
      purchase == o.purchase &&
      identity == o.identity &&
      external_assessments == o.external_assessments
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


252
253
254
# File 'lib/alogram_payrisk/models/check_request.rb', line 252

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



258
259
260
# File 'lib/alogram_payrisk/models/check_request.rb', line 258

def hash
  [event_type, payment_intent_id, entities, purchase, identity, external_assessments].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/alogram_payrisk/models/check_request.rb', line 147

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@payment_intent_id.nil? && @payment_intent_id.to_s.length > 35
    invalid_properties.push('invalid value for "payment_intent_id", the character length must be smaller than or equal to 35.')
  end

  if !@payment_intent_id.nil? && @payment_intent_id.to_s.length < 35
    invalid_properties.push('invalid value for "payment_intent_id", the character length must be greater than or equal to 35.')
  end

  pattern = Regexp.new(/^pi_[a-f0-9]{32}$/)
  if !@payment_intent_id.nil? && @payment_intent_id !~ pattern
    invalid_properties.push("invalid value for \"payment_intent_id\", must conform to the pattern #{pattern}.")
  end

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/alogram_payrisk/models/check_request.rb', line 287

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/alogram_payrisk/models/check_request.rb', line 176

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  event_type_validator = EnumAttributeValidator.new('String', ["purchase"])
  return false unless event_type_validator.valid?(@event_type)
  return false if !@payment_intent_id.nil? && @payment_intent_id.to_s.length > 35
  return false if !@payment_intent_id.nil? && @payment_intent_id.to_s.length < 35
  return false if !@payment_intent_id.nil? && @payment_intent_id !~ Regexp.new(/^pi_[a-f0-9]{32}$/)
  return false if @entities.nil?
  return false if @purchase.nil?
  true
end