Class: Hook0::Generated::Subscription

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

Overview

The Subscription the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id:, created_at:, dedicated_workers:, event_types:, is_enabled:, label_key:, label_value:, labels:, metadata:, secret:, subscription_id:, target:, updated_at:, description: nil) ⇒ Subscription

Returns a new instance of Subscription.

Parameters:

  • application_id (String)

    carries application_id.

  • created_at (Time)

    carries created_at.

  • dedicated_workers (Array<String>)

    carries dedicated_workers.

  • event_types (Array<String>)

    carries event_types.

  • is_enabled (Boolean)

    carries is_enabled.

  • label_key (String)

    carries label_key: Kept for backward compatibility, you should use labels

  • label_value (String)

    carries label_value: Kept for backward compatibility, you should use labels

  • labels (Hash{String => String})

    carries labels.

  • metadata (Hash{String => String})

    carries metadata.

  • secret (String)

    carries secret.

  • subscription_id (String)

    carries subscription_id.

  • target (SubscriptionTarget)

    carries target.

  • updated_at (Time)

    carries updated_at.

  • description (String, nil) (defaults to: nil)

    carries description.



2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
# File 'lib/hook0/generated/models.rb', line 2769

def initialize(
  application_id:,
  created_at:,
  dedicated_workers:,
  event_types:,
  is_enabled:,
  label_key:,
  label_value:,
  labels:,
  metadata:,
  secret:,
  subscription_id:,
  target:,
  updated_at:,
  description: nil
)
  @application_id = application_id
  @created_at = created_at
  @dedicated_workers = dedicated_workers
  @event_types = event_types
  @is_enabled = is_enabled
  @label_key = label_key
  @label_value = label_value
  @labels = labels
  @metadata = 
  @secret = secret
  @subscription_id = subscription_id
  @target = target
  @updated_at = updated_at
  @description = description
  freeze
end

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def application_id
  @application_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def created_at
  @created_at
end

#dedicated_workersObject (readonly)

Returns the value of attribute dedicated_workers.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def dedicated_workers
  @dedicated_workers
end

#descriptionObject (readonly)

Returns the value of attribute description.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def description
  @description
end

#event_typesObject (readonly)

Returns the value of attribute event_types.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def event_types
  @event_types
end

#is_enabledObject (readonly)

Returns the value of attribute is_enabled.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def is_enabled
  @is_enabled
end

#label_keyObject (readonly)

Returns the value of attribute label_key.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def label_key
  @label_key
end

#label_valueObject (readonly)

Returns the value of attribute label_value.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def label_value
  @label_value
end

#labelsObject (readonly)

Returns the value of attribute labels.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def labels
  @labels
end

#metadataObject (readonly)

Returns the value of attribute metadata.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def 
  @metadata
end

#secretObject (readonly)

Returns the value of attribute secret.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def secret
  @secret
end

#subscription_idObject (readonly)

Returns the value of attribute subscription_id.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def subscription_id
  @subscription_id
end

#targetObject (readonly)

Returns the value of attribute target.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def target
  @target
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



2740
2741
2742
# File 'lib/hook0/generated/models.rb', line 2740

def updated_at
  @updated_at
end

Class Method Details

.from_json(value) ⇒ Subscription

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
# File 'lib/hook0/generated/models.rb', line 2806

def self.from_json(value)
  fields = Runtime.as_fields(value, "Subscription")
  new(
    application_id: Runtime.read(fields, "application_id", Runtime::UUID),
    created_at: Runtime.read(fields, "created_at", Runtime::DATE_TIME),
    dedicated_workers: Runtime.read(fields, "dedicated_workers", Runtime.list(Runtime::TEXT)),
    event_types: Runtime.read(fields, "event_types", Runtime.list(Runtime::TEXT)),
    is_enabled: Runtime.read(fields, "is_enabled", Runtime::BOOLEAN),
    label_key: Runtime.read(fields, "label_key", Runtime::TEXT),
    label_value: Runtime.read(fields, "label_value", Runtime::TEXT),
    labels: Runtime.read(fields, "labels", Runtime.map(Runtime::TEXT)),
    metadata: Runtime.read(fields, "metadata", Runtime.map(Runtime::TEXT)),
    secret: Runtime.read(fields, "secret", Runtime::UUID),
    subscription_id: Runtime.read(fields, "subscription_id", Runtime::UUID),
    target: Runtime.read(fields, "target", SubscriptionTarget.method(:from_json)),
    updated_at: Runtime.read(fields, "updated_at", Runtime::DATE_TIME),
    description: Runtime.maybe(fields, "description", Runtime::TEXT)
  )
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)


2852
2853
2854
# File 'lib/hook0/generated/models.rb', line 2852

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

#hashInteger

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

Returns:

  • (Integer)


2860
2861
2862
# File 'lib/hook0/generated/models.rb', line 2860

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
# File 'lib/hook0/generated/models.rb', line 2829

def to_h
  out = {}
  out["application_id"] = @application_id
  out["created_at"] = Runtime.moment(@created_at)
  out["dedicated_workers"] = @dedicated_workers
  out["event_types"] = @event_types
  out["is_enabled"] = @is_enabled
  out["label_key"] = @label_key
  out["label_value"] = @label_value
  out["labels"] = @labels
  out["metadata"] = @metadata
  out["secret"] = @secret
  out["subscription_id"] = @subscription_id
  out["target"] = @target.to_h
  out["updated_at"] = Runtime.moment(@updated_at)
  out["description"] = @description unless @description.nil?
  out
end