Class: Courier::Tenants::TenantListResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/tenants/types/tenant_list_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(has_more:, items:, url:, type:, cursor: nil, next_url: nil, additional_properties: nil) ⇒ Tenants::TenantListResponse

Parameters:

  • cursor (String) (defaults to: nil)

    A pointer to the next page of results. Defined only when has_more is set to true.

  • has_more (Boolean)

    Set to true when there are more pages that can be retrieved.

  • items (Array<Tenants::Tenant>)

    An array of Tenants

  • next_url (String) (defaults to: nil)

    A url that may be used to generate fetch the next set of results. Defined only when has_more is set to true

  • url (String)

    A url that may be used to generate these results.

  • type (String)

    Always set to “list”. Represents the type of this object.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 20

def initialize(has_more:, items:, url:, type:, cursor: nil, next_url: nil, additional_properties: nil)
  # @type [String] A pointer to the next page of results. Defined only when has_more is set to true.
  @cursor = cursor
  # @type [Boolean] Set to true when there are more pages that can be retrieved.
  @has_more = has_more
  # @type [Array<Tenants::Tenant>] An array of Tenants
  @items = items
  # @type [String] A url that may be used to generate fetch the next set of results.
  #   Defined only when has_more is set to true
  @next_url = next_url
  # @type [String] A url that may be used to generate these results.
  @url = url
  # @type [String] Always set to "list". Represents the type of this object.
  @type = type
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def additional_properties
  @additional_properties
end

#cursorObject (readonly)

Returns the value of attribute cursor.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def cursor
  @cursor
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def has_more
  @has_more
end

#itemsObject (readonly)

Returns the value of attribute items.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def items
  @items
end

#next_urlObject (readonly)

Returns the value of attribute next_url.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def next_url
  @next_url
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 9

def url
  @url
end

Class Method Details

.from_json(json_object:) ⇒ Tenants::TenantListResponse

Deserialize a JSON object to an instance of TenantListResponse

Parameters:

  • json_object (JSON)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 42

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  cursor = struct.cursor
  has_more = struct.has_more
  items = parsed_json["items"]&.map do |v|
    v = v.to_json
    Tenants::Tenant.from_json(json_object: v)
  end
  next_url = struct.next_url
  url = struct.url
  type = struct.type
  new(cursor: cursor, has_more: has_more, items: items, next_url: next_url, url: url, type: type,
      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)


76
77
78
79
80
81
82
83
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 76

def self.validate_raw(obj:)
  obj.cursor&.is_a?(String) != false || raise("Passed value for field obj.cursor is not the expected type, validation failed.")
  obj.has_more.is_a?(Boolean) != false || raise("Passed value for field obj.has_more is not the expected type, validation failed.")
  obj.items.is_a?(Array) != false || raise("Passed value for field obj.items is not the expected type, validation failed.")
  obj.next_url&.is_a?(String) != false || raise("Passed value for field obj.next_url 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.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of TenantListResponse to a JSON object

Returns:

  • (JSON)


61
62
63
64
65
66
67
68
69
70
# File 'lib/trycourier/tenants/types/tenant_list_response.rb', line 61

def to_json(*_args)
  {
    "cursor": @cursor,
    "has_more": @has_more,
    "items": @items,
    "next_url": @next_url,
    "url": @url,
    "type": @type
  }.to_json
end