Class: TrueLayerSigning::JwsBase

Inherits:
Object
  • Object
show all
Defined in:
lib/truelayer-signing/utils.rb

Direct Known Subclasses

Signer, Verifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_args = {}) ⇒ JwsBase

Returns a new instance of JwsBase.



62
63
64
65
# File 'lib/truelayer-signing/utils.rb', line 62

def initialize(_args = {})
  @method = "POST"
  @headers = {}
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



60
61
62
# File 'lib/truelayer-signing/utils.rb', line 60

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



60
61
62
# File 'lib/truelayer-signing/utils.rb', line 60

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



60
61
62
# File 'lib/truelayer-signing/utils.rb', line 60

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



60
61
62
# File 'lib/truelayer-signing/utils.rb', line 60

def path
  @path
end

Instance Method Details

#add_header(name, value) ⇒ Object



81
82
83
84
85
# File 'lib/truelayer-signing/utils.rb', line 81

def add_header(name, value)
  @headers[name.to_s] = value

  self
end

#set_body(body) ⇒ Object



93
94
95
96
97
# File 'lib/truelayer-signing/utils.rb', line 93

def set_body(body)
  @body = body

  self
end

#set_headers(headers) ⇒ Object



87
88
89
90
91
# File 'lib/truelayer-signing/utils.rb', line 87

def set_headers(headers)
  headers.each { |name, value| @headers[name.to_s] = value }

  self
end

#set_method(method) ⇒ Object



67
68
69
70
71
# File 'lib/truelayer-signing/utils.rb', line 67

def set_method(method)
  @method = method.to_s.upcase

  self
end

#set_path(path) ⇒ Object

Raises:



73
74
75
76
77
78
79
# File 'lib/truelayer-signing/utils.rb', line 73

def set_path(path)
  raise(Error, "Path must start with '/'") unless path.start_with?("/")

  @path = path

  self
end