Class: Ittybit::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/ittybit/types/signature.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:, filename:, expiry:, method:, signature:, url:, folder: OMIT, additional_properties: nil) ⇒ Ittybit::Signature



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ittybit/types/signature.rb', line 39

def initialize(domain:, filename:, expiry:, method:, signature:, url:, folder: OMIT, additional_properties: nil)
  @domain = domain
  @filename = filename
  @folder = folder if folder != OMIT
  @expiry = expiry
  @method = method
  @signature = signature
  @url = url
  @additional_properties = additional_properties
  @_field_set = {
    "domain": domain,
    "filename": filename,
    "folder": folder,
    "expiry": expiry,
    "method": method,
    "signature": signature,
    "url": url
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



23
24
25
# File 'lib/ittybit/types/signature.rb', line 23

def additional_properties
  @additional_properties
end

#domainString (readonly)



9
10
11
# File 'lib/ittybit/types/signature.rb', line 9

def domain
  @domain
end

#expiryInteger (readonly)



15
16
17
# File 'lib/ittybit/types/signature.rb', line 15

def expiry
  @expiry
end

#filenameString (readonly)



11
12
13
# File 'lib/ittybit/types/signature.rb', line 11

def filename
  @filename
end

#folderString (readonly)



13
14
15
# File 'lib/ittybit/types/signature.rb', line 13

def folder
  @folder
end

#methodString (readonly)



17
18
19
# File 'lib/ittybit/types/signature.rb', line 17

def method
  @method
end

#signatureString (readonly)



19
20
21
# File 'lib/ittybit/types/signature.rb', line 19

def signature
  @signature
end

#urlString (readonly)



21
22
23
# File 'lib/ittybit/types/signature.rb', line 21

def url
  @url
end

Class Method Details

.from_json(json_object:) ⇒ Ittybit::Signature

Deserialize a JSON object to an instance of Signature



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ittybit/types/signature.rb', line 65

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  domain = parsed_json["domain"]
  filename = parsed_json["filename"]
  folder = parsed_json["folder"]
  expiry = parsed_json["expiry"]
  method = parsed_json["method"]
  signature = parsed_json["signature"]
  url = parsed_json["url"]
  new(
    domain: domain,
    filename: filename,
    folder: folder,
    expiry: expiry,
    method: method,
    signature: signature,
    url: url,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


100
101
102
103
104
105
106
107
108
# File 'lib/ittybit/types/signature.rb', line 100

def self.validate_raw(obj:)
  obj.domain.is_a?(String) != false || raise("Passed value for field obj.domain is not the expected type, validation failed.")
  obj.filename.is_a?(String) != false || raise("Passed value for field obj.filename is not the expected type, validation failed.")
  obj.folder&.is_a?(String) != false || raise("Passed value for field obj.folder is not the expected type, validation failed.")
  obj.expiry.is_a?(Integer) != false || raise("Passed value for field obj.expiry is not the expected type, validation failed.")
  obj.method.is_a?(String) != false || raise("Passed value for field obj.method is not the expected type, validation failed.")
  obj.signature.is_a?(String) != false || raise("Passed value for field obj.signature is not the expected type, validation failed.")
  obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Signature to a JSON object



90
91
92
# File 'lib/ittybit/types/signature.rb', line 90

def to_json(*_args)
  @_field_set&.to_json
end