Class: ThePlaidApi::JwkPublicKey

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/jwk_public_key.rb

Overview

A JSON Web Key (JWK) that can be used in conjunction with [JWT libraries](jwt.io/#libraries-io) to verify Plaid webhooks

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(alg:, crv:, kid:, kty:, use:, x:, y:, created_at:, expired_at:, additional_properties: nil) ⇒ JwkPublicKey

Returns a new instance of JwkPublicKey.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 85

def initialize(alg:, crv:, kid:, kty:, use:, x:, y:, created_at:,
               expired_at:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @alg = alg
  @crv = crv
  @kid = kid
  @kty = kty
  @use = use
  @x = x
  @y = y
  @created_at = created_at
  @expired_at = expired_at
  @additional_properties = additional_properties
end

Instance Attribute Details

#algString

The alg member identifies the cryptographic algorithm family used with the key.

Returns:

  • (String)


16
17
18
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 16

def alg
  @alg
end

#created_atInteger

The timestamp when the key was created, in Unix time.

Returns:

  • (Integer)


52
53
54
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 52

def created_at
  @created_at
end

#crvString

The crv member identifies the cryptographic curve used with the key.

Returns:

  • (String)


20
21
22
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 20

def crv
  @crv
end

#expired_atInteger

The timestamp when the key expired, in Unix time.

Returns:

  • (Integer)


56
57
58
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 56

def expired_at
  @expired_at
end

#kidString

The kid (Key ID) member can be used to match a specific key. This can be used, for instance, to choose among a set of keys within the JWK during key rollover.

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 26

def kid
  @kid
end

#ktyString

The kty (key type) parameter identifies the cryptographic algorithm family used with the key, such as RSA or EC.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 31

def kty
  @kty
end

#useString

The use (public key use) parameter identifies the intended use of the public key.

Returns:

  • (String)


36
37
38
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 36

def use
  @use
end

#xString

The x member contains the x coordinate for the elliptic curve point, provided as a base64url-encoded string of the coordinate’s big endian representation.

Returns:

  • (String)


42
43
44
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 42

def x
  @x
end

#yString

The y member contains the y coordinate for the elliptic curve point, provided as a base64url-encoded string of the coordinate’s big endian representation.

Returns:

  • (String)


48
49
50
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 48

def y
  @y
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 103

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  alg = hash.key?('alg') ? hash['alg'] : nil
  crv = hash.key?('crv') ? hash['crv'] : nil
  kid = hash.key?('kid') ? hash['kid'] : nil
  kty = hash.key?('kty') ? hash['kty'] : nil
  use = hash.key?('use') ? hash['use'] : nil
  x = hash.key?('x') ? hash['x'] : nil
  y = hash.key?('y') ? hash['y'] : nil
  created_at = hash.key?('created_at') ? hash['created_at'] : nil
  expired_at = hash.key?('expired_at') ? hash['expired_at'] : nil

  # 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.
  JwkPublicKey.new(alg: alg,
                   crv: crv,
                   kid: kid,
                   kty: kty,
                   use: use,
                   x: x,
                   y: y,
                   created_at: created_at,
                   expired_at: expired_at,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 59

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['alg'] = 'alg'
  @_hash['crv'] = 'crv'
  @_hash['kid'] = 'kid'
  @_hash['kty'] = 'kty'
  @_hash['use'] = 'use'
  @_hash['x'] = 'x'
  @_hash['y'] = 'y'
  @_hash['created_at'] = 'created_at'
  @_hash['expired_at'] = 'expired_at'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
82
83
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 79

def self.nullables
  %w[
    expired_at
  ]
end

.optionalsObject

An array for optional fields



74
75
76
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 74

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



146
147
148
149
150
151
152
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 146

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} alg: #{@alg.inspect}, crv: #{@crv.inspect}, kid: #{@kid.inspect}, kty:"\
  " #{@kty.inspect}, use: #{@use.inspect}, x: #{@x.inspect}, y: #{@y.inspect}, created_at:"\
  " #{@created_at.inspect}, expired_at: #{@expired_at.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



138
139
140
141
142
143
# File 'lib/the_plaid_api/models/jwk_public_key.rb', line 138

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} alg: #{@alg}, crv: #{@crv}, kid: #{@kid}, kty: #{@kty}, use: #{@use}, x:"\
  " #{@x}, y: #{@y}, created_at: #{@created_at}, expired_at: #{@expired_at},"\
  " additional_properties: #{@additional_properties}>"
end