Class: Hook0::Generated::ServiceToken

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

Overview

The ServiceToken the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(biscuit:, created_at:, name:, token_id:) ⇒ ServiceToken

Returns a new instance of ServiceToken.

Parameters:

  • biscuit (String)

    carries biscuit.

  • created_at (Time)

    carries created_at.

  • name (String)

    carries name.

  • token_id (String)

    carries token_id.



2635
2636
2637
2638
2639
2640
2641
# File 'lib/hook0/generated/models.rb', line 2635

def initialize(biscuit:, created_at:, name:, token_id:)
  @biscuit = biscuit
  @created_at = created_at
  @name = name
  @token_id = token_id
  freeze
end

Instance Attribute Details

#biscuitObject (readonly)

Returns the value of attribute biscuit.



2626
2627
2628
# File 'lib/hook0/generated/models.rb', line 2626

def biscuit
  @biscuit
end

#created_atObject (readonly)

Returns the value of attribute created_at.



2626
2627
2628
# File 'lib/hook0/generated/models.rb', line 2626

def created_at
  @created_at
end

#nameObject (readonly)

Returns the value of attribute name.



2626
2627
2628
# File 'lib/hook0/generated/models.rb', line 2626

def name
  @name
end

#token_idObject (readonly)

Returns the value of attribute token_id.



2626
2627
2628
# File 'lib/hook0/generated/models.rb', line 2626

def token_id
  @token_id
end

Class Method Details

.from_json(value) ⇒ ServiceToken

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



2647
2648
2649
2650
2651
2652
2653
2654
2655
# File 'lib/hook0/generated/models.rb', line 2647

def self.from_json(value)
  fields = Runtime.as_fields(value, "ServiceToken")
  new(
    biscuit: Runtime.read(fields, "biscuit", Runtime::TEXT),
    created_at: Runtime.read(fields, "created_at", Runtime::DATE_TIME),
    name: Runtime.read(fields, "name", Runtime::TEXT),
    token_id: Runtime.read(fields, "token_id", Runtime::UUID)
  )
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)


2673
2674
2675
# File 'lib/hook0/generated/models.rb', line 2673

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

#hashInteger

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

Returns:

  • (Integer)


2681
2682
2683
# File 'lib/hook0/generated/models.rb', line 2681

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


2660
2661
2662
2663
2664
2665
2666
2667
# File 'lib/hook0/generated/models.rb', line 2660

def to_h
  out = {}
  out["biscuit"] = @biscuit
  out["created_at"] = Runtime.moment(@created_at)
  out["name"] = @name
  out["token_id"] = @token_id
  out
end