Class: Courier::Audiences::AudienceMember

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/audiences/types/audience_member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(added_at:, audience_id:, audience_version:, member_id:, reason:, additional_properties: nil) ⇒ Audiences::AudienceMember

Parameters:

  • added_at (String)
  • audience_id (String)
  • audience_version (Integer)
  • member_id (String)
  • reason (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trycourier/audiences/types/audience_member.rb', line 17

def initialize(added_at:, audience_id:, audience_version:, member_id:, reason:, additional_properties: nil)
  # @type [String]
  @added_at = added_at
  # @type [String]
  @audience_id = audience_id
  # @type [Integer]
  @audience_version = audience_version
  # @type [String]
  @member_id = member_id
  # @type [String]
  @reason = reason
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#added_atObject (readonly)

Returns the value of attribute added_at.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def added_at
  @added_at
end

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def additional_properties
  @additional_properties
end

#audience_idObject (readonly)

Returns the value of attribute audience_id.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def audience_id
  @audience_id
end

#audience_versionObject (readonly)

Returns the value of attribute audience_version.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def audience_version
  @audience_version
end

#member_idObject (readonly)

Returns the value of attribute member_id.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def member_id
  @member_id
end

#reasonObject (readonly)

Returns the value of attribute reason.



8
9
10
# File 'lib/trycourier/audiences/types/audience_member.rb', line 8

def reason
  @reason
end

Class Method Details

.from_json(json_object:) ⇒ Audiences::AudienceMember

Deserialize a JSON object to an instance of AudienceMember

Parameters:

  • json_object (JSON)

Returns:



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/trycourier/audiences/types/audience_member.rb', line 36

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  added_at = struct.added_at
  audience_id = struct.audience_id
  audience_version = struct.audience_version
  member_id = struct.member_id
  reason = struct.reason
  new(added_at: added_at, audience_id: audience_id, audience_version: audience_version, member_id: member_id,
      reason: reason, 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)


65
66
67
68
69
70
71
# File 'lib/trycourier/audiences/types/audience_member.rb', line 65

def self.validate_raw(obj:)
  obj.added_at.is_a?(String) != false || raise("Passed value for field obj.added_at is not the expected type, validation failed.")
  obj.audience_id.is_a?(String) != false || raise("Passed value for field obj.audience_id is not the expected type, validation failed.")
  obj.audience_version.is_a?(Integer) != false || raise("Passed value for field obj.audience_version is not the expected type, validation failed.")
  obj.member_id.is_a?(String) != false || raise("Passed value for field obj.member_id is not the expected type, validation failed.")
  obj.reason.is_a?(String) != false || raise("Passed value for field obj.reason is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of AudienceMember to a JSON object

Returns:

  • (JSON)


51
52
53
54
55
56
57
58
59
# File 'lib/trycourier/audiences/types/audience_member.rb', line 51

def to_json(*_args)
  {
    "added_at": @added_at,
    "audience_id": @audience_id,
    "audience_version": @audience_version,
    "member_id": @member_id,
    "reason": @reason
  }.to_json
end