Class: Pinnacle::Messaging

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/messaging.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt_in:, opt_out:, opt_out_keywords:, agent_use_case:, expected_agent_responses:, additional_properties: nil) ⇒ Pinnacle::Messaging

Parameters:

  • opt_in (String)

    Explain how users will opt in to receive messages.

  • opt_out (String)

    Explain how users will opt out of receiving messages.

  • opt_out_keywords (Array<String>)

    Please provide the unique keywords to opt out. Each keyword should not contain spaces.

  • agent_use_case (String)

    Please define what your agent will do.

  • expected_agent_responses (String)

    Please provide some example messages that your agent will send.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rcs/types/messaging.rb', line 35

def initialize(opt_in:, opt_out:, opt_out_keywords:, agent_use_case:, expected_agent_responses:,
               additional_properties: nil)
  @opt_in = opt_in
  @opt_out = opt_out
  @opt_out_keywords = opt_out_keywords
  @agent_use_case = agent_use_case
  @expected_agent_responses = expected_agent_responses
  @additional_properties = additional_properties
  @_field_set = {
    "optIn": opt_in,
    "optOut": opt_out,
    "optOutKeywords": opt_out_keywords,
    "agentUseCase": agent_use_case,
    "expectedAgentResponses": expected_agent_responses
  }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



20
21
22
# File 'lib/rcs/types/messaging.rb', line 20

def additional_properties
  @additional_properties
end

#agent_use_caseString (readonly)

Returns Please define what your agent will do.

Returns:

  • (String)

    Please define what your agent will do.



16
17
18
# File 'lib/rcs/types/messaging.rb', line 16

def agent_use_case
  @agent_use_case
end

#expected_agent_responsesString (readonly)

Returns Please provide some example messages that your agent will send.

Returns:

  • (String)

    Please provide some example messages that your agent will send.



18
19
20
# File 'lib/rcs/types/messaging.rb', line 18

def expected_agent_responses
  @expected_agent_responses
end

#opt_inString (readonly)

Returns Explain how users will opt in to receive messages.

Returns:

  • (String)

    Explain how users will opt in to receive messages.



9
10
11
# File 'lib/rcs/types/messaging.rb', line 9

def opt_in
  @opt_in
end

#opt_outString (readonly)

Returns Explain how users will opt out of receiving messages.

Returns:

  • (String)

    Explain how users will opt out of receiving messages.



11
12
13
# File 'lib/rcs/types/messaging.rb', line 11

def opt_out
  @opt_out
end

#opt_out_keywordsArray<String> (readonly)

Returns Please provide the unique keywords to opt out. Each keyword should not contain spaces.

Returns:

  • (Array<String>)

    Please provide the unique keywords to opt out. Each keyword should not contain spaces.



14
15
16
# File 'lib/rcs/types/messaging.rb', line 14

def opt_out_keywords
  @opt_out_keywords
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::Messaging

Deserialize a JSON object to an instance of Messaging

Parameters:

  • json_object (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rcs/types/messaging.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  opt_in = parsed_json["optIn"]
  opt_out = parsed_json["optOut"]
  opt_out_keywords = parsed_json["optOutKeywords"]
  agent_use_case = parsed_json["agentUseCase"]
  expected_agent_responses = parsed_json["expectedAgentResponses"]
  new(
    opt_in: opt_in,
    opt_out: opt_out,
    opt_out_keywords: opt_out_keywords,
    agent_use_case: agent_use_case,
    expected_agent_responses: expected_agent_responses,
    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)


87
88
89
90
91
92
93
# File 'lib/rcs/types/messaging.rb', line 87

def self.validate_raw(obj:)
  obj.opt_in.is_a?(String) != false || raise("Passed value for field obj.opt_in is not the expected type, validation failed.")
  obj.opt_out.is_a?(String) != false || raise("Passed value for field obj.opt_out is not the expected type, validation failed.")
  obj.opt_out_keywords.is_a?(Array) != false || raise("Passed value for field obj.opt_out_keywords is not the expected type, validation failed.")
  obj.agent_use_case.is_a?(String) != false || raise("Passed value for field obj.agent_use_case is not the expected type, validation failed.")
  obj.expected_agent_responses.is_a?(String) != false || raise("Passed value for field obj.expected_agent_responses is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Messaging to a JSON object

Returns:

  • (String)


77
78
79
# File 'lib/rcs/types/messaging.rb', line 77

def to_json(*_args)
  @_field_set&.to_json
end