Class: Hook0::Generated::SubscriptionPost

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

Overview

The SubscriptionPost the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id:, event_types:, is_enabled:, target:, dedicated_workers: nil, description: nil, label_key: nil, label_value: nil, labels: nil, metadata: nil) ⇒ SubscriptionPost

Returns a new instance of SubscriptionPost.

Parameters:

  • application_id (String)

    carries application_id.

  • event_types (Array<String>)

    carries event_types.

  • is_enabled (Boolean)

    carries is_enabled.

  • target (SubscriptionPostTarget)

    carries target.

  • dedicated_workers (Array<String>, nil) (defaults to: nil)

    carries dedicated_workers.

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

    carries description.

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

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

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

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

  • labels (Hash{String => String}, nil) (defaults to: nil)

    carries labels.

  • metadata (Hash{String => String}, nil) (defaults to: nil)

    carries metadata.



2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
# File 'lib/hook0/generated/models.rb', line 2889

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

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def application_id
  @application_id
end

#dedicated_workersObject (readonly)

Returns the value of attribute dedicated_workers.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def dedicated_workers
  @dedicated_workers
end

#descriptionObject (readonly)

Returns the value of attribute description.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def description
  @description
end

#event_typesObject (readonly)

Returns the value of attribute event_types.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def event_types
  @event_types
end

#is_enabledObject (readonly)

Returns the value of attribute is_enabled.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def is_enabled
  @is_enabled
end

#label_keyObject (readonly)

Returns the value of attribute label_key.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def label_key
  @label_key
end

#label_valueObject (readonly)

Returns the value of attribute label_value.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def label_value
  @label_value
end

#labelsObject (readonly)

Returns the value of attribute labels.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def labels
  @labels
end

#metadataObject (readonly)

Returns the value of attribute metadata.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def 
  @metadata
end

#targetObject (readonly)

Returns the value of attribute target.



2867
2868
2869
# File 'lib/hook0/generated/models.rb', line 2867

def target
  @target
end

Class Method Details

.from_json(value) ⇒ SubscriptionPost

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
# File 'lib/hook0/generated/models.rb', line 2918

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


2956
2957
2958
# File 'lib/hook0/generated/models.rb', line 2956

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

#hashInteger

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

Returns:

  • (Integer)


2964
2965
2966
# File 'lib/hook0/generated/models.rb', line 2964

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
# File 'lib/hook0/generated/models.rb', line 2937

def to_h
  out = {}
  out["application_id"] = @application_id
  out["event_types"] = @event_types
  out["is_enabled"] = @is_enabled
  out["target"] = @target.to_h
  out["dedicated_workers"] = @dedicated_workers unless @dedicated_workers.nil?
  out["description"] = @description unless @description.nil?
  out["label_key"] = @label_key unless @label_key.nil?
  out["label_value"] = @label_value unless @label_value.nil?
  out["labels"] = @labels unless @labels.nil?
  out["metadata"] = @metadata unless @metadata.nil?
  out
end