Class: Hook0::Generated::Organization

Inherits:
Object
  • Object
show all
Defined in:
lib/hook0/generated/models.rb

Overview

The Organization the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, organization_id:, role:, plan: nil) ⇒ Organization

Returns a new instance of Organization.

Parameters:

  • name (String)

    carries name.

  • organization_id (String)

    carries organization_id.

  • role (String)

    carries role.

  • plan (OrganizationPlan, nil) (defaults to: nil)

    carries plan.



1469
1470
1471
1472
1473
1474
1475
# File 'lib/hook0/generated/models.rb', line 1469

def initialize(name:, organization_id:, role:, plan: nil)
  @name = name
  @organization_id = organization_id
  @role = role
  @plan = plan
  freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1460
1461
1462
# File 'lib/hook0/generated/models.rb', line 1460

def name
  @name
end

#organization_idObject (readonly)

Returns the value of attribute organization_id.



1460
1461
1462
# File 'lib/hook0/generated/models.rb', line 1460

def organization_id
  @organization_id
end

#planObject (readonly)

Returns the value of attribute plan.



1460
1461
1462
# File 'lib/hook0/generated/models.rb', line 1460

def plan
  @plan
end

#roleObject (readonly)

Returns the value of attribute role.



1460
1461
1462
# File 'lib/hook0/generated/models.rb', line 1460

def role
  @role
end

Class Method Details

.from_json(value) ⇒ Organization

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



1481
1482
1483
1484
1485
1486
1487
1488
1489
# File 'lib/hook0/generated/models.rb', line 1481

def self.from_json(value)
  fields = Runtime.as_fields(value, "Organization")
  new(
    name: Runtime.read(fields, "name", Runtime::TEXT),
    organization_id: Runtime.read(fields, "organization_id", Runtime::UUID),
    role: Runtime.read(fields, "role", Runtime::TEXT),
    plan: Runtime.maybe(fields, "plan", OrganizationPlan.method(:from_json))
  )
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Whether that value carries the same members as this one.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


1507
1508
1509
# File 'lib/hook0/generated/models.rb', line 1507

def ==(other)
  other.is_a?(Organization) && to_h == other.to_h
end

#hashInteger

A value two equal instances share, so that either may key a hash.

Returns:

  • (Integer)


1515
1516
1517
# File 'lib/hook0/generated/models.rb', line 1515

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


1494
1495
1496
1497
1498
1499
1500
1501
# File 'lib/hook0/generated/models.rb', line 1494

def to_h
  out = {}
  out["name"] = @name
  out["organization_id"] = @organization_id
  out["role"] = @role
  out["plan"] = @plan.to_h unless @plan.nil?
  out
end