Class: Plaid::JwkPublicKey

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/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.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/plaid/models/jwk_public_key.rb', line 81

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/plaid/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)


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

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/plaid/models/jwk_public_key.rb', line 20

def crv
  @crv
end

#expired_atInteger

The timestamp when the key expired, in Unix time.

Returns:

  • (Integer)


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

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/plaid/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/plaid/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/plaid/models/jwk_public_key.rb', line 36

def use
  @use
end

#xString

The x member contains the x coordinate for the elliptic curve point.

Returns:

  • (String)


40
41
42
# File 'lib/plaid/models/jwk_public_key.rb', line 40

def x
  @x
end

#yString

The y member contains the y coordinate for the elliptic curve point.

Returns:

  • (String)


44
45
46
# File 'lib/plaid/models/jwk_public_key.rb', line 44

def y
  @y
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/plaid/models/jwk_public_key.rb', line 55

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



75
76
77
78
79
# File 'lib/plaid/models/jwk_public_key.rb', line 75

def self.nullables
  %w[
    expired_at
  ]
end

.optionalsObject

An array for optional fields



70
71
72
# File 'lib/plaid/models/jwk_public_key.rb', line 70

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
147
148
# File 'lib/plaid/models/jwk_public_key.rb', line 142

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.



134
135
136
137
138
139
# File 'lib/plaid/models/jwk_public_key.rb', line 134

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