Class: NewDemoApiClient::CompanyResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/company_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, domain:, id:, group_id:, thumbnail: OMIT, created_at: OMIT, updated_at: OMIT, is_archived: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CompanyResponse

Parameters:

  • name (String)
  • domain (String)

    The domain of the company

  • thumbnail (String) (defaults to: OMIT)

    The thumbnail URL of the company

  • id (Integer)
  • created_at (DateTime) (defaults to: OMIT)
  • updated_at (DateTime) (defaults to: OMIT)
  • is_archived (Boolean) (defaults to: OMIT)
  • group_id (Integer)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/test_sdk/types/company_response.rb', line 43

def initialize(name:, domain:, id:, group_id:, thumbnail: OMIT, created_at: OMIT, updated_at: OMIT,
               is_archived: OMIT, additional_properties: nil)
  @name = name
  @domain = domain
  @thumbnail = thumbnail if thumbnail != OMIT
  @id = id
  @created_at = created_at if created_at != OMIT
  @updated_at = updated_at if updated_at != OMIT
  @is_archived = is_archived if is_archived != OMIT
  @group_id = group_id
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "domain": domain,
    "thumbnail": thumbnail,
    "id": id,
    "created_at": created_at,
    "updated_at": updated_at,
    "is_archived": is_archived,
    "group_id": group_id
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



26
27
28
# File 'lib/test_sdk/types/company_response.rb', line 26

def additional_properties
  @additional_properties
end

#created_atDateTime (readonly)

Returns:

  • (DateTime)


18
19
20
# File 'lib/test_sdk/types/company_response.rb', line 18

def created_at
  @created_at
end

#domainString (readonly)

Returns The domain of the company.

Returns:

  • (String)

    The domain of the company



12
13
14
# File 'lib/test_sdk/types/company_response.rb', line 12

def domain
  @domain
end

#group_idInteger (readonly)

Returns:

  • (Integer)


24
25
26
# File 'lib/test_sdk/types/company_response.rb', line 24

def group_id
  @group_id
end

#idInteger (readonly)

Returns:

  • (Integer)


16
17
18
# File 'lib/test_sdk/types/company_response.rb', line 16

def id
  @id
end

#is_archivedBoolean (readonly)

Returns:

  • (Boolean)


22
23
24
# File 'lib/test_sdk/types/company_response.rb', line 22

def is_archived
  @is_archived
end

#nameString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/test_sdk/types/company_response.rb', line 10

def name
  @name
end

#thumbnailString (readonly)

Returns The thumbnail URL of the company.

Returns:

  • (String)

    The thumbnail URL of the company



14
15
16
# File 'lib/test_sdk/types/company_response.rb', line 14

def thumbnail
  @thumbnail
end

#updated_atDateTime (readonly)

Returns:

  • (DateTime)


20
21
22
# File 'lib/test_sdk/types/company_response.rb', line 20

def updated_at
  @updated_at
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::CompanyResponse

Deserialize a JSON object to an instance of CompanyResponse

Parameters:

  • json_object (String)

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/test_sdk/types/company_response.rb', line 72

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  domain = parsed_json["domain"]
  thumbnail = parsed_json["thumbnail"]
  id = parsed_json["id"]
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  updated_at = (DateTime.parse(parsed_json["updated_at"]) unless parsed_json["updated_at"].nil?)
  is_archived = parsed_json["is_archived"]
  group_id = parsed_json["group_id"]
  new(
    name: name,
    domain: domain,
    thumbnail: thumbnail,
    id: id,
    created_at: created_at,
    updated_at: updated_at,
    is_archived: is_archived,
    group_id: group_id,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


109
110
111
112
113
114
115
116
117
118
# File 'lib/test_sdk/types/company_response.rb', line 109

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.domain.is_a?(String) != false || raise("Passed value for field obj.domain is not the expected type, validation failed.")
  obj.thumbnail&.is_a?(String) != false || raise("Passed value for field obj.thumbnail is not the expected type, validation failed.")
  obj.id.is_a?(Integer) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.")
  obj.is_archived&.is_a?(Boolean) != false || raise("Passed value for field obj.is_archived is not the expected type, validation failed.")
  obj.group_id.is_a?(Integer) != false || raise("Passed value for field obj.group_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CompanyResponse to a JSON object

Returns:

  • (String)


99
100
101
# File 'lib/test_sdk/types/company_response.rb', line 99

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